[lld] [lld][ICF] Prevent merging two sections when they point to non-globals (PR #136641)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 03:20:26 PDT 2025
================
@@ -356,6 +357,22 @@ static SmallVector<Symbol *> getRelocTargetSyms(const InputSection *sec) {
return getReloc(sec, rel.relas);
}
+// Checks if relocation has semantics beyond just the offset. We identify
+// such relocations to prevent ICF to preserve correctness.
+static bool isTrivialRelocationType(uint16_t emachine, RelType type) {
+ if (emachine == EM_AARCH64) {
+ switch (type) {
+ case R_AARCH64_GOT_LD_PREL19:
+ case R_AARCH64_LD64_GOTOFF_LO15:
+ case R_AARCH64_ADR_GOT_PAGE:
+ case R_AARCH64_LD64_GOT_LO12_NC:
+ case R_AARCH64_LD64_GOTPAGE_LO15:
+ return false;
----------------
smithp35 wrote:
I'd expect it to break in GNU ld as that assumes that the sequence is emitted exactly. I've recently written that into the ABI in https://github.com/ARM-software/abi-aa/pull/311 (not merged yet).
Putting it here, would be more a philosophical "this is a non trivial relocation" rather than something that would make a practical difference.
https://github.com/llvm/llvm-project/pull/136641
More information about the llvm-commits
mailing list