OSDN Git Service

Whee. What a most entertaining bug.
authorDavid McCullough <davidm@snapgear.com>
Mon, 3 Apr 2006 00:06:38 +0000 (00:06 +0000)
committerDavid McCullough <davidm@snapgear.com>
Mon, 3 Apr 2006 00:06:38 +0000 (00:06 +0000)
commit22effd1ea2b2ce421721f6fdf2129ecce94bc08b
tree258b43c3c41f00826ff79e22f70a4a8491a3a836
parentbfb08d44f34f9dda67b303fd68f1441bc0edc85e
Whee.  What a most entertaining bug.

For some (unfathomable) reason, the flat loader in the kernel likes to
use network (big endian) byte order, but only sometimes.  In particular,
its assumptions about relocation byte order depend on whether the
executable uses ID shared libraries or not.

It took me most of today to figure out why the kernel was trying to
relocate something at address 0x94160000, until I noticed that that's
the byteswapped version of 0x1694, and further noticed that it was
omitting a byteswap due to the flag Has-PIC-GOT in the flat header.

So, why is that flag set?  After all, opreport wasn't compiled with
-mid-shared-library or anything.

It turns out that elf2flt sets that flag if grepping the executable for
GLOBAL_OFFSET_TABLE succeeds.  That's a reasonable thing to do, except
when we link an executable against libbfd.a - which contains
GLOBAL_OFFSET_TABLE not as a symbol, but as a string, as it needs to
produce the symbol in linker output files.

Changing elf2flt to grep nm output, rather than the executable directly,
fixes the problem.  So, in the end it turns out this wasn't related to
the 20030928 failure at all...

Bernd Schmidt <bernds_cb1@t-online.de>
ld-elf2flt.in