[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 15:32: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;
----------------
pranavk wrote:

Looking more into it, perhaps something is possible if I factor out some of functionality in Relocations.cpp (functionality that check if GOT or TLS needs to be handled). That would likely be a bigger diff than I was hoping but would do the job. 

https://github.com/llvm/llvm-project/pull/136641


More information about the llvm-commits mailing list