Port-m68k archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: More toolchain issues



On Mon, 28 Sep 2009 02:48:40 +0200
Michael van Elst <mlelstv%serpens.de@localhost> wrote:

> > jemalloc uses mmap() to allocate memory. When I test an equivalent
> > mmap() it succeeds but a ktruss reports an ENOMEM error and the
> > pointer returned by mmap() causes a segfault when accessed.
> 
> Ok. That's a bug in libc. See port-m68k/37631 for some history.
> The fix finally introduced end of 2007 is broken.
> 
> Here is the system call stub:
> 
> _SYSCALL(__mmap,mmap)
> #ifdef  __SVR4_ABI__
>         movl    %d0,%a0
> #endif
>         rts
> 
> When mmap sets errno the _SYSCALL macro will return through
> a private CERROR exit which knows nothing about returning
> pointer values in %a0. Even worse, CERROR junks the %a0 contents.

Indeed. What can we do about that? Probably it would be best to make sure
that CERROR always returns its result in d0 *and* a0?
Performance considerations should have low priority in case of an error.

I must say that I'm a bit confused by the current implementation:
_ENTRY(CERROR)
#ifdef  _REENTRANT
        movl    %d0,%sp@-
#if defined(PIC) && !defined(__ELF__)
        movl    #_C_LABEL(_GLOBAL_OFFSET_TABLE_),%a0
        lea     %pc@(0,%a0:l),%a0
        movl    %a0@(_C_LABEL(__errno):l),%a0
        jsr     %a0@
#else
        jbsr    PIC_PLT(_C_LABEL(__errno))
#endif
#ifndef __SVR4_ABI__
        movl    %d0,%a0
#endif
        movl    %sp@+,%a0@
#else
[...]

Seems it would only copy d0 to a0 when V4-ABI (AKA ELF) is *not* defined?
And in the next line it would write the saved error code (which probably
is the same as d0) to (a0) in case of non-ELF? Doesn't look good to me...

(I'm crossposting this to port-m68k now.)

-- 
Frank Wille


Home | Main Index | Thread Index | Old Index