Fix MIPS non-NOBITS after NOBITS in segment error

Mark Hatle mark.hatle@windriver.com
Wed Jan 11 19:08:00 GMT 2012


With recent compilers and linkers it is typical for a MIPS binary to
be built with the sections such as:

       [23] .got              PROGBITS        004aafb0 09afb0 00055c 04 WAp  0  $
       [24] .sdata            PROGBITS        004ab50c 09b50c 000004 00 WAp  0  $
       [25] .sbss             NOBITS          004ab510 09b510 00003d 00 WAp  0  $
       [26] .bss              NOBITS          004ab550 09b510 0021cc 00  WA  0  $
       [27] .dynstr           STRTAB          004bb510 09b510 000b99 00   A  0  $
       [28] .gnu.attributes   LOOS+ffffff5    00000000 09c0a9 000010 00      0  $
       [29] .mdebug.abi32     PROGBITS        004ad71c 09c0b9 000000 00      0  $
       [30] .gnu_debuglink    PROGBITS        00000000 09c0b9 00000c 00      0  $
       [31] .gnu.prelink_undo PROGBITS        00000000 09c0c8 0005bc 01      0  $

When determining if a section is within a segment, simply checking
that it fits within the boundaries of that segment is not enough.  In
the above example, the .mdebug.abi32 fits within the boundaries of the
third segment.  However with a size of 0 there is nothing for the
prelinker to do.  The validation that non-NOBITS sections can't come
after a PROGBITS fails, because it incorrectly assumes that it is
part of the same section as .sbss, and .bss.

Using elfutils readelf as a guide, a check was missing in the mapping
function that the section had a size > 0.  Binutils has a similar
check, but it is a bit more specific that the address of a section
can not start at the end of a segment.  The size > 0 was an easier
and more obvious check, which is why it was used.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: prelink_sectoseg.patch
URL: <http://sourceware.org/pipermail/prelink/attachments/20120111/7d7d0a46/attachment.ksh>


More information about the Prelink mailing list