[lld] [ELF] Support R_RISCV_SET_ULEB128/R_RISCV_SUB_ULEB128 in SHF_ALLOC sections (PR #77261)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 8 20:23:40 PST 2024
================
@@ -515,6 +517,46 @@ void RISCV::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
}
}
+void RISCV::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
+ uint64_t secAddr = sec.getOutputSection()->addr;
+ if (auto *s = dyn_cast<InputSection>(&sec))
+ secAddr += s->outSecOff;
+ else if (auto *ehIn = dyn_cast<EhInputSection>(&sec))
+ secAddr += ehIn->getParent()->outSecOff;
+ for (size_t i = 0, size = sec.relocs().size(); i != size; ++i) {
+ const Relocation &rel = sec.relocs()[i];
+ uint8_t *loc = buf + rel.offset;
+ const uint64_t val =
+ sec.getRelocTargetVA(sec.file, rel.type, rel.addend,
+ secAddr + rel.offset, *rel.sym, rel.expr);
+
+ switch (rel.expr) {
+ case R_RELAX_HINT:
+ break;
+ case R_RISCV_LEB128:
----------------
MaskRay wrote:
I'll merge this soon. `relocateAlloc` is needed for TLSDESC relaxation as well.
https://github.com/llvm/llvm-project/pull/77261
More information about the llvm-commits
mailing list