Subject: Re: weird elf header issues, is it binutils or my linker script?

From: Chris Friesen <[email-masked]>
Date: Mon, 01 Apr 2013 09:02:24 -0600

On 03/29/2013 06:01 AM, Segher Boessenkool wrote:
>> PHDRS
>> {
>> headers PT_PHDR PHDRS ;
>> interp PT_INTERP ;
>> <snip>
>> }
>>
>> SECTIONS
>> {
>> /* Read-only sections, merged into text segment: */
>> PROVIDE (__executable_start = 0xf2000000); . = 0xf2000000 +
>> SIZEOF_HEADERS;
>> .interp : { *(.interp) } :text :interp
>> <snip>
>> }
>>
>> So I'm wondering...is this something wrong with our linker script,
>> or is there a bug in our binutils? I'm no linker expert, but the
>> interpreter sections in the script seem to match the binutils
>> documentation that I found and I don't see anything that would be
>> messing with the length.
>>
>> Any suggestions on where to look?
>
> It looks like your .interp input section lacks the required
> zero-termination.

That's the weird thing....the actual interpreter string "/lib/ld.so.1" 
is in fact null-terminated, but the length in the elf headers is 
incorrect (0x30 instead of 0xd) and so when the kernel checks the last 
character in the array it sees a nonzero value.

What I don't understand is where the "/lib/ld.so.1" string is coming 
from and how the length gets set to the invalid value.

Chris