Skip to content

Commit 87d199f

Browse files
committed
[ELF] Pass Ctx & to Relocations
1 parent c574180 commit 87d199f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lld/ELF/Relocations.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static std::string getLocation(Ctx &ctx, InputSectionBase &s, const Symbol &sym,
9797
return msg + s.getObjMsg(off);
9898
}
9999

100-
void elf::reportRangeError(Ctx &, uint8_t *loc, const Relocation &rel,
100+
void elf::reportRangeError(Ctx &ctx, uint8_t *loc, const Relocation &rel,
101101
const Twine &v, int64_t min, uint64_t max) {
102102
ErrorPlace errPlace = getErrorPlace(ctx, loc);
103103
std::string hint;
@@ -600,7 +600,7 @@ static bool canSuggestExternCForCXX(StringRef ref, StringRef def) {
600600
// Suggest an alternative spelling of an "undefined symbol" diagnostic. Returns
601601
// the suggested symbol, which is either in the symbol table, or in the same
602602
// file of sym.
603-
static const Symbol *getAlternativeSpelling(const Undefined &sym,
603+
static const Symbol *getAlternativeSpelling(Ctx &ctx, const Undefined &sym,
604604
std::string &pre_hint,
605605
std::string &post_hint) {
606606
DenseMap<StringRef, const Symbol *> map;
@@ -777,7 +777,7 @@ static void reportUndefinedSymbol(Ctx &ctx, const UndefinedDiag &undef,
777777
if (correctSpelling) {
778778
std::string pre_hint = ": ", post_hint;
779779
if (const Symbol *corrected =
780-
getAlternativeSpelling(sym, pre_hint, post_hint)) {
780+
getAlternativeSpelling(ctx, sym, pre_hint, post_hint)) {
781781
msg += "\n>>> did you mean" + pre_hint + toString(*corrected) + post_hint;
782782
if (corrected->file)
783783
msg += "\n>>> defined in: " + toString(corrected->file);
@@ -875,9 +875,9 @@ RelType RelocationScanner::getMipsN32RelType(RelTy *&rel) const {
875875
}
876876

877877
template <bool shard = false>
878-
static void addRelativeReloc(InputSectionBase &isec, uint64_t offsetInSec,
879-
Symbol &sym, int64_t addend, RelExpr expr,
880-
RelType type) {
878+
static void addRelativeReloc(Ctx &ctx, InputSectionBase &isec,
879+
uint64_t offsetInSec, Symbol &sym, int64_t addend,
880+
RelExpr expr, RelType type) {
881881
Partition &part = isec.getPartition();
882882

883883
if (sym.isTagged()) {
@@ -944,7 +944,8 @@ void elf::addGotEntry(Ctx &ctx, Symbol &sym) {
944944
if (!ctx.arg.isPic || isAbsolute(sym))
945945
ctx.in.got->addConstant({R_ABS, ctx.target->symbolicRel, off, 0, &sym});
946946
else
947-
addRelativeReloc(*ctx.in.got, off, sym, 0, R_ABS, ctx.target->symbolicRel);
947+
addRelativeReloc(ctx, *ctx.in.got, off, sym, 0, R_ABS,
948+
ctx.target->symbolicRel);
948949
}
949950

950951
static void addTpOffsetGotEntry(Ctx &ctx, Symbol &sym) {
@@ -1151,7 +1152,7 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
11511152
RelType rel = ctx.target->getDynRel(type);
11521153
if (oneof<R_GOT, R_LOONGARCH_GOT>(expr) ||
11531154
(rel == ctx.target->symbolicRel && !sym.isPreemptible)) {
1154-
addRelativeReloc<true>(*sec, offset, sym, addend, expr, type);
1155+
addRelativeReloc<true>(ctx, *sec, offset, sym, addend, expr, type);
11551156
return;
11561157
}
11571158
if (rel != 0) {
@@ -1437,7 +1438,7 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
14371438
// R_GOT needs a relative relocation for PIC on i386 and Hexagon.
14381439
if (expr == R_GOT && ctx.arg.isPic &&
14391440
!ctx.target->usesOnlyLowPageBits(type))
1440-
addRelativeReloc<true>(*sec, offset, sym, addend, expr, type);
1441+
addRelativeReloc<true>(ctx, *sec, offset, sym, addend, expr, type);
14411442
else
14421443
sec->addReloc({expr, type, offset, addend, &sym});
14431444
}

0 commit comments

Comments
 (0)