llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lld @llvm/pr-subscribers-lld-elf Author: Jessica Clarke (jrtc27) <details> <summary>Changes</summary> This allows R_AARCH64_AUTH_ABS64 to follow R_AARCH64_ABS64's flow rather than being implemented in the side in the place that is normally for symbolic relocations. Note that this has one implementation change: the RelExpr passed to relaDyn is now RE_AARCH64_AUTH rather than R_ABS, but the two are handled identically by InputSectionbase::getRelocTargetVA, and it was inconsistent with relrAuthDyn which was passed RE_AARCH64_AUTH. --- Full diff: https://github.com/llvm/llvm-project/pull/171180.diff 1 Files Affected: - (modified) lld/ELF/Relocations.cpp (+20-24) ``````````diff diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index ce7ed5a413beb..e3bb2e8b6e805 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -704,8 +704,10 @@ static void addRelativeReloc(Ctx &ctx, InputSectionBase &isec, uint64_t offsetInSec, Symbol &sym, int64_t addend, RelExpr expr, RelType type) { Partition &part = isec.getPartition(ctx); + bool isAArch64Auth = + ctx.arg.emachine == EM_AARCH64 && type == R_AARCH64_AUTH_ABS64; - if (sym.isTagged()) { + if (sym.isTagged() && !isAArch64Auth) { part.relaDyn->addRelativeReloc<shard>(ctx.target->relativeRel, isec, offsetInSec, sym, addend, type, expr); // With MTE globals, we always want to derive the address tag by `ldg`-ing @@ -727,13 +729,22 @@ static void addRelativeReloc(Ctx &ctx, InputSectionBase &isec, // relrDyn sections don't support odd offsets. Also, relrDyn sections // don't store the addend values, so we must write it to the relocated // address. - if (part.relrDyn && isec.addralign >= 2 && offsetInSec % 2 == 0) { - part.relrDyn->addRelativeReloc<shard>(isec, offsetInSec, sym, addend, type, - expr); + // + // When symbol values are determined in finalizeAddressDependentContent, + // some .relr.auth.dyn relocations may be moved to .rela.dyn. + RelrBaseSection *relrDyn = part.relrDyn.get(); + if (isAArch64Auth) + relrDyn = part.relrAuthDyn.get(); + if (relrDyn && isec.addralign >= 2 && offsetInSec % 2 == 0) { + relrDyn->addRelativeReloc<shard>(isec, offsetInSec, sym, addend, type, + expr); return; } - part.relaDyn->addRelativeReloc<shard>(ctx.target->relativeRel, isec, - offsetInSec, sym, addend, type, expr); + RelType relativeType = ctx.target->relativeRel; + if (isAArch64Auth) + relativeType = R_AARCH64_AUTH_RELATIVE; + part.relaDyn->addRelativeReloc<shard>(relativeType, isec, offsetInSec, sym, + addend, type, expr); } template <class PltSection, class GotPltSection> @@ -992,7 +1003,9 @@ void RelocScan::process(RelExpr expr, RelType type, uint64_t offset, if (canWrite) { RelType rel = ctx.target->getDynRel(type); if (oneof<R_GOT, RE_LOONGARCH_GOT>(expr) || - (rel == ctx.target->symbolicRel && !sym.isPreemptible)) { + ((rel == ctx.target->symbolicRel || + (ctx.arg.emachine == EM_AARCH64 && type == R_AARCH64_AUTH_ABS64)) && + !sym.isPreemptible)) { addRelativeReloc<true>(ctx, *sec, offset, sym, addend, expr, type); return; } @@ -1001,23 +1014,6 @@ void RelocScan::process(RelExpr expr, RelType type, uint64_t offset, rel = ctx.target->relativeRel; std::lock_guard<std::mutex> lock(ctx.relocMutex); Partition &part = sec->getPartition(ctx); - // For a preemptible symbol, we can't use a relative relocation. For an - // undefined symbol, we can't compute offset at link-time and use a - // relative relocation. Use a symbolic relocation instead. - if (ctx.arg.emachine == EM_AARCH64 && type == R_AARCH64_AUTH_ABS64 && - !sym.isPreemptible) { - if (part.relrAuthDyn && sec->addralign >= 2 && offset % 2 == 0) { - // When symbol values are determined in - // finalizeAddressDependentContent, some .relr.auth.dyn relocations - // may be moved to .rela.dyn. - part.relrAuthDyn->addRelativeReloc(*sec, offset, sym, addend, type, - expr); - } else { - part.relaDyn->addReloc({R_AARCH64_AUTH_RELATIVE, sec, offset, false, - sym, addend, R_ABS}); - } - return; - } if (LLVM_UNLIKELY(type == ctx.target->iRelSymbolicRel)) { if (sym.isPreemptible) { auto diag = Err(ctx); `````````` </details> https://github.com/llvm/llvm-project/pull/171180 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
