[lld] 87d199f - [ELF] Pass Ctx & to Relocations
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 5 09:37:32 PDT 2024
Author: Fangrui Song
Date: 2024-10-05T09:37:27-07:00
New Revision: 87d199ff243ff25b06d68a529815519901e8294f
URL: https://github.com/llvm/llvm-project/commit/87d199ff243ff25b06d68a529815519901e8294f
DIFF: https://github.com/llvm/llvm-project/commit/87d199ff243ff25b06d68a529815519901e8294f.diff
LOG: [ELF] Pass Ctx & to Relocations
Added:
Modified:
lld/ELF/Relocations.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 7bb657822ee192..12c4b69bee57e4 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -97,7 +97,7 @@ static std::string getLocation(Ctx &ctx, InputSectionBase &s, const Symbol &sym,
return msg + s.getObjMsg(off);
}
-void elf::reportRangeError(Ctx &, uint8_t *loc, const Relocation &rel,
+void elf::reportRangeError(Ctx &ctx, uint8_t *loc, const Relocation &rel,
const Twine &v, int64_t min, uint64_t max) {
ErrorPlace errPlace = getErrorPlace(ctx, loc);
std::string hint;
@@ -600,7 +600,7 @@ static bool canSuggestExternCForCXX(StringRef ref, StringRef def) {
// Suggest an alternative spelling of an "undefined symbol" diagnostic. Returns
// the suggested symbol, which is either in the symbol table, or in the same
// file of sym.
-static const Symbol *getAlternativeSpelling(const Undefined &sym,
+static const Symbol *getAlternativeSpelling(Ctx &ctx, const Undefined &sym,
std::string &pre_hint,
std::string &post_hint) {
DenseMap<StringRef, const Symbol *> map;
@@ -777,7 +777,7 @@ static void reportUndefinedSymbol(Ctx &ctx, const UndefinedDiag &undef,
if (correctSpelling) {
std::string pre_hint = ": ", post_hint;
if (const Symbol *corrected =
- getAlternativeSpelling(sym, pre_hint, post_hint)) {
+ getAlternativeSpelling(ctx, sym, pre_hint, post_hint)) {
msg += "\n>>> did you mean" + pre_hint + toString(*corrected) + post_hint;
if (corrected->file)
msg += "\n>>> defined in: " + toString(corrected->file);
@@ -875,9 +875,9 @@ RelType RelocationScanner::getMipsN32RelType(RelTy *&rel) const {
}
template <bool shard = false>
-static void addRelativeReloc(InputSectionBase &isec, uint64_t offsetInSec,
- Symbol &sym, int64_t addend, RelExpr expr,
- RelType type) {
+static void addRelativeReloc(Ctx &ctx, InputSectionBase &isec,
+ uint64_t offsetInSec, Symbol &sym, int64_t addend,
+ RelExpr expr, RelType type) {
Partition &part = isec.getPartition();
if (sym.isTagged()) {
@@ -944,7 +944,8 @@ void elf::addGotEntry(Ctx &ctx, Symbol &sym) {
if (!ctx.arg.isPic || isAbsolute(sym))
ctx.in.got->addConstant({R_ABS, ctx.target->symbolicRel, off, 0, &sym});
else
- addRelativeReloc(*ctx.in.got, off, sym, 0, R_ABS, ctx.target->symbolicRel);
+ addRelativeReloc(ctx, *ctx.in.got, off, sym, 0, R_ABS,
+ ctx.target->symbolicRel);
}
static void addTpOffsetGotEntry(Ctx &ctx, Symbol &sym) {
@@ -1151,7 +1152,7 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
RelType rel = ctx.target->getDynRel(type);
if (oneof<R_GOT, R_LOONGARCH_GOT>(expr) ||
(rel == ctx.target->symbolicRel && !sym.isPreemptible)) {
- addRelativeReloc<true>(*sec, offset, sym, addend, expr, type);
+ addRelativeReloc<true>(ctx, *sec, offset, sym, addend, expr, type);
return;
}
if (rel != 0) {
@@ -1437,7 +1438,7 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
// R_GOT needs a relative relocation for PIC on i386 and Hexagon.
if (expr == R_GOT && ctx.arg.isPic &&
!ctx.target->usesOnlyLowPageBits(type))
- addRelativeReloc<true>(*sec, offset, sym, addend, expr, type);
+ addRelativeReloc<true>(ctx, *sec, offset, sym, addend, expr, type);
else
sec->addReloc({expr, type, offset, addend, &sym});
}
More information about the llvm-commits
mailing list