Page MenuHomeFreeBSD

rtld: do not rely on a prepopulated GOT on amd64
ClosedPublic

Authored by emaste on Jan 14 2017, 5:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 9:08 AM
Unknown Object (File)
Mar 1 2024, 1:33 AM
Unknown Object (File)
Jan 9 2024, 7:15 AM
Unknown Object (File)
Jan 3 2024, 6:40 PM
Unknown Object (File)
Dec 21 2023, 7:25 AM
Unknown Object (File)
Dec 14 2023, 4:56 PM
Unknown Object (File)
Oct 25 2023, 6:14 AM
Unknown Object (File)
Sep 26 2023, 12:38 AM
Subscribers

Details

Summary

Previously rtld required that amd64 GOT entries were populated with unrelocated offsets, in order to find rtld's own _DYNAMIC symbol. Both GNU BFD ld and gold have this behaviour but there's no expectation of this in the ABI (AFAIK). Use a technique similar to sparc64 and add an rtld_dynamic_addr() that returns the address of _DYNAMIC directly.

PR: 214927

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste retitled this revision from to rtld: do not rely on a prepopulated GOT on amd64.
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added reviewers: kib, kan.

Right now rtld amd64 binary all relocations are of type R_X86_64_RELATIVE, including the GOT locations. This is the natural consequence of the fact that rtld does not have undefined references, and that all symbol's visibility attribute is hidden. From the description of the change, is sounds as if rtld is linked in a mode where different relocation types appear for it, which would be IMO, regression even if that relocation types are handled. In particular, no symbols should appear in the rtld symbol table except explicitely listed in the version map.

That said, I do not object against the change, but I suspect it is an indicator of the other problems.

What about i386 ? There, we also have only R_386_RELATIVE relocations for ld-elf.so.1 right now.

The referenced PR is about gdb upgrade to 7.12.

Oops, correct PR is 214972. I also submitted an LLD PR which has a more detailed description in https://llvm.org/bugs/show_bug.cgi?id=31221#c0.

The problem isn't the relocation type; LLD produces a .rela.dyn that's identical to BFD ld or gold, perhaps other than order.

Also, I think we should use a similar approach on all architectures and expect to take a look at others later. My initial goal is to make sure that it's possible to build all of the FreeBSD/amd64 base system with LLD once 4.0.0 releases.

kib edited edge metadata.

I do not have objections against the code change itself.

This revision is now accepted and ready to land.Jan 15 2017, 8:02 PM
This revision was automatically updated to reflect the committed changes.