[PATCH v2] static-pie: Skip the empty PT_LOAD segment at offset 0 [BZ #32763]

Sam James sam@gentoo.org
Wed Mar 5 22:48:21 GMT 2025


"H.J. Lu" <hjl.tools@gmail.com> writes:

> On Wed, Mar 5, 2025 at 11:02 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> As shown in
>>
>> https://sourceware.org/bugzilla/show_bug.cgi?id=32761
>>
>> linker may generate more than one PT_LOAD segments at offset 0
>>
>
> This is intentional.  Here is the v2 patch:
>
> As shown in
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=25237
>
> linker may generate an empty PT_LOAD segments at offset 0:
>
> Elf file type is EXEC (Executable file)
> Entry point 0x4000e8
> There are 3 program headers, starting at offset 64
>
> Program Headers:
>   Type           Offset             VirtAddr           PhysAddr
>                  FileSiz            MemSiz              Flags  Align
>   LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
>                  0x00000000000000f0 0x00000000000000f0  R E    0x1000
>   LOAD           0x0000000000000000 0x0000000000410000 0x0000000000410000
>                  0x0000000000000000 0x0000000000b5dce8  RW     0x10000
>   GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
>                  0x0000000000000000 0x0000000000000000  RW     0x10
>
>  Section to Segment mapping:
>   Segment Sections...
>    00     .text
>    01     .bss
>    02
>
> Skip the empty PT_LOAD segment at offset 0 to support such binaries.
> This fixes BZ #32763.

Thanks. It looks good to me after reviewing the other linker bugs and
Alan's linker change.


More information about the Libc-alpha mailing list