Many -no-pie/-shared/-pie applications linked against glibc or musl
should work with this patch. This also helps FreeBSD rtld (PR40888).
* Fix default image base and max page size.
* Support more relocation types.new-style Secure PLT (see below). Old-style BSS PLT is not
* Support secure PLT (see below). implemented, musl supports only secure PLTso it is not suitable for FreeBSD rtld now because it doesn't
* S support .got2 for position independent codeSecure PLT yet.
* Add a new thunk: PPC32PltCallStub.* Support more relocation types: R_PPC_REL16*, R_PPC_LOCAL24PC, Similar to PPC64PltCallStubR_PPC_PLTREL24, it isand R_PPC_GOT16
used by R_PPC_REL24 andThe addend of R_PPC_PLTREL24.
On ppc32, a PLT stub used in -pie/-shared loads an address relative to is special: it decides call stub PLT types
.got2+0x8000. Two object files have 2 .got2 with different addressesbut it should be ignored for the computation of target symbol VA.
Thus a PLT stub can't be shared by two object files.* Support .glink used for lazy PLT resolution in glibc
To handle this incompatibility,* Add a new thunk: PPC32PltCallStub that is similar to PPC64PltCallStub. make Thunk::isCompatibleWith acceptIt is
another parameter `const InputSecused by R_PPC_REL24 and R_PPC_PLTREL24.
A PLT stub used in -fPIE/-fPIC usually loads an address relative to
.got2+0x8000 (-fpie/-fpic code uses _GLOBAL_OFFSET_TABLE_ relative
addresses).
2 .got2 sections in two object files have different addresses, thus a PLT stub
can't be shared by two object files. To handle this incompatibility,
change the parameters of Thunk::isCompatibleWith to `const InputSection
&` + `const Relocation &`.
PowerPC psABI specified an old-style .plt (BSS PLT) (.plt is NOBITS and
written by the dynamic loader) that is both writable and executable.
Linkers don't make separate RW- and RWE segments, which causes all
initially writable memory (think .data) executable. This is a big
security concern so a new PLT scheme (secure PLT) was developed to
address the security issue.
This helps PR40888. Actually,TLS is not implemented but I believe PPC.cpp can just reuse some TLS code
from PPC64.cpp. with this patchFor tests, I think manyI create ppc32-* instead of ppc-* because I plan to
-shared/-static/-pie applications linked against musl will workuse ppc-* for tests shareable on ppc32 and ppc64.
A hello world program linked against glibc doesn't runglibc older than ~2012 can not handle the DT_RELA+DT_RELASZ == DT_JMPREL
case correctly. TLS is notA hack (not included in this patch) in LinkerScript.cpp
addOrphanSections() is required:
if (Config->EMachine == EM_PPC) {
// Older glibc assumes .rela.dyn includes .rela.plt
Add(In.RelaDyn);
implemented but I believe PPC.cpp can just reuse TLS code from if (In.RelaPlt->isLive() && !In.RelaPlt->Parent)
PPC64.cpp. I create ppc32-* instead of ppc-* for tests as I plan to use In.RelaDyn->getParent()->addSection(In.RelaPlt);
ppc-* for tests shareable on ppc32 and ppc64. }