HomeFreeBSD

MFC r312288: rtld: do not rely on a populated GOT on amd64

Description

MFC r312288: rtld: do not rely on a populated GOT on amd64

On rela architectures GNU BFD ld and gold store the relocation addend
in GOT entries (in addition to the relocation's r_addend field).
rtld previously relied on this to access its own _DYNAMIC symbol in
order to apply its own relocations.

However, recording addends in the GOT is not specified by the ABI,
and some versions of LLVM's LLD linker leave the GOT uninitialized on
rela architectures.

BFD ld does not populate the GOT on sparc64, and sparc64 rtld has a
machine-dependent rtld_dynamic_addr() function that returns the
_DYNAMIC address. Use the same approach on amd64, obtaining the %rip-
relative _DYNAMIC address following a suggestion from Rafael EspĂ­ndola.

Architectures other than amd64 should be addressed in future work.

Details

Provenance
emasteAuthored on
Parents
rS312788: Enable LLD (as ld.lld) on i386 and arm
Branches
Unknown
Tags
Unknown