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

H.J. Lu hjl.tools@gmail.com
Wed Mar 5 04:23:36 GMT 2025


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.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-static-pie-Skip-the-empty-PT_LOAD-segment-at-offs.patch
Type: text/x-patch
Size: 5133 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250305/6f4e2461/attachment-0001.bin>


More information about the Libc-alpha mailing list