bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/31795] ld.bfd makes ELFs of type ET_EXEC for static PIEs when lo


From: mintsuki at protonmail dot com
Subject: [Bug ld/31795] ld.bfd makes ELFs of type ET_EXEC for static PIEs when load address is non-0
Date: Sun, 26 May 2024 14:47:07 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=31795

--- Comment #30 from mintsuki <mintsuki at protonmail dot com> ---
(In reply to H.J. Lu from comment #29)
> (In reply to mintsuki from comment #27)
> > This is the aforementioned other kernel's readelf -d output:
> > 
> > 
> > Dynamic section at offset 0x46b70 contains 13 entries:
> >   Tag        Type                         Name/Value
> >  0x0000000000000004 (HASH)               0xffffffff8003c140
> >  0x000000006ffffef5 (GNU_HASH)           0xffffffff8003c150
> >  0x0000000000000005 (STRTAB)             0xffffffff8003c138
> >  0x0000000000000006 (SYMTAB)             0xffffffff8003c120
> >  0x000000000000000a (STRSZ)              1 (bytes)
> >  0x000000000000000b (SYMENT)             24 (bytes)
> >  0x0000000000000015 (DEBUG)              0x0
> >  0x0000000000000007 (RELA)               0xffffffff8003c170
> >  0x0000000000000008 (RELASZ)             27264 (bytes)
> >  0x0000000000000009 (RELAENT)            24 (bytes)
> >  0x000000006ffffffb (FLAGS_1)            Flags: PIE
> >  0x000000006ffffff9 (RELACOUNT)          1136
> >  0x0000000000000000 (NULL)               0x0
> > 
> 
> Your kernel contains the relocated addresses in dynamic section since its
> load address != 0.  Try load address == 0, these addresses will be different.
> You need to decide how to handle addresses like
> 
>   0x0000000000000007 (RELA)               0xffffffff8003c170
> 
> Should you add load address to them or not?

Well, the way Limine has always dealt with this issue is:
https://github.com/limine-bootloader/limine/blob/c204af454fc9c11b8ef3633664b6e03817c33ff1/common/lib/elf.c#L223

Basically, it tries to find a PHDR which contains the RELA section, and if it
find it, it subtracts the PHDR's virtual address and adds its offset in order
to find the offset of the RELA section inside the ELF file itself.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]