[lld] [lld][ICF] Prevent merging two sections when they point to non-globals (PR #136641)
Pranav Kant via llvm-commits
llvm-commits at lists.llvm.org
Tue May 13 14:39:36 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;
----------------
pranavk wrote:
It's unfortunately not completely target-neutral. See https://github.com/llvm/llvm-project/blob/faa11ed33f123e30f26116ff1c968fb249d72416/lld/ELF/Relocations.h#L89-L94
So we will still end up with target specific stuff if we use this function.
https://github.com/llvm/llvm-project/pull/136641
More information about the llvm-commits
mailing list