[lld] [lld][ICF] Prevent merging two sections when they point to non-globals (PR #136641)
James Y Knight via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 29 18:39:16 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;
----------------
jyknight wrote:
I think the definition of "non-trivial" here should be "all relocation types which have a side-effect based on the symbol's identity".
And I think we should be able to avoid adding new target-specific code for this by using the existing TargetInfo::getRelExpr virtual function, and then switching on the returned RelExpr enum.
https://github.com/llvm/llvm-project/pull/136641
More information about the llvm-commits
mailing list