[ELF][PPC32] Make R_PPC32_PLTREL retain .got
authorGeorge Koehler <kernigh@gmail.com>
Thu, 2 Dec 2021 23:28:37 +0000 (15:28 -0800)
committerFangrui Song <i@maskray.me>
Thu, 2 Dec 2021 23:28:37 +0000 (15:28 -0800)
commit885fb9a257faa14ec33ad972df81801483c85da2
treed35de28597401f1fb22e9b74dea59539c81bd8ac
parent0eebe2e36c69654fe93a54f02ce06552527b0dfa
[ELF][PPC32] Make R_PPC32_PLTREL retain .got

PLT usage needs the first 12 bytes of the .got section. We need to keep .got and
DT_GOT_PPC even if .got/_GLOBAL_OFFSET_TABLE_ are not referenced (large PIC code
may only reference .got2), which is the case in OpenBSD's ld.so, leading
to a misleading error, "unsupported insecure BSS PLT object".

Fix this by adding R_PPC32_PLTREL to the list of hasGotOffRel.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D114982
lld/ELF/Relocations.cpp
lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s
lld/test/ELF/ppc32-reloc-pltrel.s [new file with mode: 0644]
lld/test/ELF/ppc32-reloc-rel.s