Subject: Re: Non executable mappings and compatibility options bugs
To: Emmanuel Dreyfus <manu@NetBSD.org>
From: Charles M. Hannum <abuse@spamalicious.com>
List: tech-kern
Date: 06/21/2004 07:21:37
On Sunday 20 June 2004 13:15, Emmanuel Dreyfus wrote:
> Hi
>
> Wiz reported me a bug in COMPAT_LINUX/powerpc that might be an unwanted
> consequence of non executable mappings: Linux's ldconfig will randomly
> crash with either SIGSEGV or SIGILL.
>
> Tracking down the problem with GDB, it occurs always at the same place,
> in a function called __DTOR_END__:
>
> Program received signal SIGILL, Illegal instruction.
> 0x1007ff84 in __DTOR_END__ ()
> (gdb) x/1i $pc
> 0x1007ff84 <__DTOR_END__+4>:    blrl
>
> The instruction is perfectly legal, I assume the problem is just that
> the memory is mapped as non executable.
>
> This function comes from the .dtors ELF section:
>
>  12 .dtors        00000008  1007ff4c  1007ff4c  0006ff4c  2**2
>                   CONTENTS, ALLOC, LOAD, DATA

No, actually, it doesn't occur there.  If you add the size and VMA for .dtors, 
you'll find that the address you're looking at is beyond that.  It occurs at 
the beginning of the GOT, and is standard on PowerPC.  The .got section, and 
the program header that contains it, are marked executable for this reason.