[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 23:03:10 GMT 2025
On Thu, Mar 6, 2025 at 6:48 AM Sam James <sam@gentoo.org> wrote:
>
> "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.
Here is the v3 patch I am checking in. The main addition is
@@ -2082,6 +2086,7 @@ $(objpfx)tst-array5-static-cmp.out: tst-array5-static.exp
\
CFLAGS-tst-pie1.c += $(pie-ccflag)
CFLAGS-tst-pie2.c += $(pie-ccflag)
+CFLAGS-tst-pie-bss.c += $(pie-ccflag)
CFLAGS-tst-pie-address.c += $(pie-ccflag)
$(objpfx)tst-piemod1.so: $(libsupport)
for glibc configured with --disable-default-pie
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v3-0001-static-pie-Skip-the-empty-PT_LOAD-segment-at-offs.patch
Type: text/x-patch
Size: 5413 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250306/69ec19ac/attachment.bin>
More information about the Libc-alpha
mailing list