[lld] [ELF] -r --compress-debug-sections: update addends for .debug_* sections relocated by REL (PR #66804)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 22:03:27 PDT 2023


================
@@ -463,7 +463,10 @@ void InputSection::copyRelocations(uint8_t *buf,
 
       if (RelTy::IsRela)
         p->r_addend = sym.getVA(addend) - section->getOutputSection()->addr;
-      else if (config->relocatable && type != target.noneRel)
+      // See the comment in writeSections. For SHF_ALLOC sections relocated by
+      // REL relocations, utilize the non-REL/RELA loop.
+      else if (config->relocatable && (sec->flags & SHF_ALLOC) &&
+               type != target.noneRel)
         sec->addReloc({R_ABS, type, rel.offset, addend, &sym});
----------------
arichardson wrote:

Would it make sense to move the `(sec->flags & SHF_ALLOC)` check inside this if? That would ensure that we don't end up hitting later branches if we add some in the future?
```suggestion
        if ((sec->flags & SHF_ALLOC) == 0)
          sec->addReloc({R_ABS, type, rel.offset, addend, &sym});
```

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


More information about the llvm-commits mailing list