SuccessChanges

Summary

  1. [ELF][PPC32] Support canonical PLT (details)
Commit 837e8a9c0cd097034e023dfba146d17ce132998c by i
[ELF][PPC32] Support canonical PLT
-fno-pie produces a pair of non-GOT-non-PLT relocations
R_PPC_ADDR16_{HA,LO} (R_ABS) referencing external functions.
``` lis 3, func@ha la 3, func@l(3)
```
In a -no-pie/-pie link, if func is not defined in the executable, a
canonical PLT entry (st_value>0, st_shndx=0) will be needed. References
to func in shared objects will be resolved to this address.
-fno-pie -pie should fail with "can't create dynamic relocation ...
against ...", so we just need to think about -no-pie.
On x86, the PLT entry passes the JMP_SLOT offset to the rtld PLT
resolver. On x86-64: the PLT entry passes the JUMP_SLOT index to the
rtld PLT resolver. On ARM/AArch64: the PLT entry passes &.got.plt[n].
The PLT header passes &.got.plt[fixed-index]. The rtld PLT resolver can
compute the JUMP_SLOT index from the two addresses.
For these targets, the canonical PLT entry can just reuse the regular
PLT entry (in PltSection).
On PPC32: PltSection (.glink) consists of `b PLTresolve` instructions
and `PLTresolve`. The rtld PLT resolver depends on r11 having been set
up to the .plt (GotPltSection) entry. On PPC64 ELFv2: PltSection
(.glink) consists of `__glink_PLTresolve` and `bl __glink_PLTresolve`.
The rtld PLT resolver depends on r12 having been set up to the .plt
(GotPltSection) entry.
We cannot reuse a `b PLTresolve`/`bl __glink_PLTresolve` in PltSection
as a canonical PLT entry. PPC64 ELFv2 avoids the problem by using TOC
for any external reference, even in non-pic code, so the canonical PLT
entry scenario should not happen in the first place. For PPC32, we have
to create a PLT call stub as the canonical PLT entry. The code sequence
sets up r11.
Reviewed By: Bdragon28
Differential Revision: https://reviews.llvm.org/D73399
The file was modifiedlld/ELF/Relocations.cpp
The file was addedlld/test/ELF/ppc32-canonical-plt.s
The file was modifiedlld/ELF/SyntheticSections.cpp
The file was modifiedlld/ELF/SyntheticSections.h
The file was modifiedlld/ELF/Arch/PPC.cpp