From e018f550d0c40bd99294cdd943c23bbec3804ace Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 10 Oct 2024 22:22:25 -0700 Subject: [PATCH] [ELF] Pass Ctx & --- lld/ELF/ARMErrataFix.cpp | 2 +- lld/ELF/Arch/Mips.cpp | 4 ++-- lld/ELF/DWARF.cpp | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lld/ELF/ARMErrataFix.cpp b/lld/ELF/ARMErrataFix.cpp index 839ab2b074bd..5818772bf19d 100644 --- a/lld/ELF/ARMErrataFix.cpp +++ b/lld/ELF/ARMErrataFix.cpp @@ -417,7 +417,7 @@ void ARMErr657417Patcher::insertPatches( // isec so the branch we are patching always goes forwards. static void implementPatch(ScanResult sr, InputSection *isec, std::vector &patches) { - + Ctx &ctx = isec->getCtx(); log("detected cortex-a8-657419 erratum sequence starting at " + utohexstr(isec->getVA(sr.off)) + " in unpatched output."); Patch657417Section *psec; diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp index 975fa9ead762..6313ac8ca4fb 100644 --- a/lld/ELF/Arch/Mips.cpp +++ b/lld/ELF/Arch/Mips.cpp @@ -480,7 +480,7 @@ int64_t MIPS::getImplicitAddend(const uint8_t *buf, RelType type) const { } static std::pair -calculateMipsRelChain(uint8_t *loc, RelType type, uint64_t val) { +calculateMipsRelChain(Ctx &ctx, uint8_t *loc, RelType type, uint64_t val) { // MIPS N64 ABI packs multiple relocations into the single relocation // record. In general, all up to three relocations can have arbitrary // types. In fact, Clang and GCC uses only a few combinations. For now, @@ -572,7 +572,7 @@ void MIPS::relocate(uint8_t *loc, const Relocation &rel, RelType type = rel.type; if (ELFT::Is64Bits || ctx.arg.mipsN32Abi) - std::tie(type, val) = calculateMipsRelChain(loc, type, val); + std::tie(type, val) = calculateMipsRelChain(ctx, loc, type, val); // Detect cross-mode jump/branch and fix instruction. val = fixupCrossModeJump(loc, type, val); diff --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp index 133e66baabe2..8e4740919a48 100644 --- a/lld/ELF/DWARF.cpp +++ b/lld/ELF/DWARF.cpp @@ -112,6 +112,7 @@ LLDDwarfObj::findAux(const InputSectionBase &sec, uint64_t pos, const RelTy &rel = *it; const ObjFile *file = sec.getFile(); + Ctx &ctx = sec.getCtx(); uint32_t symIndex = rel.getSymbol(ctx.arg.isMips64EL); const typename ELFT::Sym &sym = file->template getELFSyms()[symIndex]; uint32_t secIndex = file->getSectionIndex(sym);