@@ -97,8 +97,8 @@ static std::string getLocation(Ctx &ctx, InputSectionBase &s, const Symbol &sym,
97
97
return msg + s.getObjMsg (off);
98
98
}
99
99
100
- void elf::reportRangeError (uint8_t *loc, const Relocation &rel, const Twine &v ,
101
- int64_t min, uint64_t max) {
100
+ void elf::reportRangeError (Ctx &, uint8_t *loc, const Relocation &rel,
101
+ const Twine &v, int64_t min, uint64_t max) {
102
102
ErrorPlace errPlace = getErrorPlace (ctx, loc);
103
103
std::string hint;
104
104
if (rel.sym ) {
@@ -285,7 +285,7 @@ template <class ELFT> static bool isReadOnly(SharedSymbol &ss) {
285
285
// them are copied by a copy relocation, all of them need to be copied.
286
286
// Otherwise, they would refer to different places at runtime.
287
287
template <class ELFT >
288
- static SmallSet<SharedSymbol *, 4 > getSymbolsAt (SharedSymbol &ss) {
288
+ static SmallSet<SharedSymbol *, 4 > getSymbolsAt (Ctx &ctx, SharedSymbol &ss) {
289
289
using Elf_Sym = typename ELFT::Sym;
290
290
291
291
const auto &file = cast<SharedFile>(*ss.file );
@@ -372,7 +372,7 @@ static void replaceWithDefined(Symbol &sym, SectionBase &sec, uint64_t value,
372
372
// to the variable in .bss. This kind of issue is sometimes very hard to
373
373
// debug. What's a solution? Instead of exporting a variable V from a DSO,
374
374
// define an accessor getV().
375
- template <class ELFT > static void addCopyRelSymbol (SharedSymbol &ss) {
375
+ template <class ELFT > static void addCopyRelSymbol (Ctx &ctx, SharedSymbol &ss) {
376
376
// Copy relocation against zero-sized symbol doesn't make sense.
377
377
uint64_t symSize = ss.getSize ();
378
378
if (symSize == 0 || ss.alignment == 0 )
@@ -397,7 +397,7 @@ template <class ELFT> static void addCopyRelSymbol(SharedSymbol &ss) {
397
397
// Look through the DSO's dynamic symbol table for aliases and create a
398
398
// dynamic symbol for each one. This causes the copy relocation to correctly
399
399
// interpose any aliases.
400
- for (SharedSymbol *sym : getSymbolsAt<ELFT>(ss))
400
+ for (SharedSymbol *sym : getSymbolsAt<ELFT>(ctx, ss))
401
401
replaceWithDefined (*sym, *sec, 0 , sym->size );
402
402
403
403
ctx.mainPart ->relaDyn ->addSymbolReloc (ctx.target ->copyRel , *sec, 0 , ss);
@@ -526,7 +526,7 @@ int64_t RelocationScanner::computeMipsAddend(const RelTy &rel, RelExpr expr,
526
526
527
527
// Custom error message if Sym is defined in a discarded section.
528
528
template <class ELFT >
529
- static std::string maybeReportDiscarded (Undefined &sym) {
529
+ static std::string maybeReportDiscarded (Ctx &ctx, Undefined &sym) {
530
530
auto *file = dyn_cast_or_null<ObjFile<ELFT>>(sym.file );
531
531
if (!file || !sym.discardedSecIdx )
532
532
return " " ;
@@ -714,7 +714,7 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
714
714
return nullptr ;
715
715
}
716
716
717
- static void reportUndefinedSymbol (const UndefinedDiag &undef,
717
+ static void reportUndefinedSymbol (Ctx &ctx, const UndefinedDiag &undef,
718
718
bool correctSpelling) {
719
719
Undefined &sym = *undef.sym ;
720
720
@@ -734,16 +734,16 @@ static void reportUndefinedSymbol(const UndefinedDiag &undef,
734
734
std::string msg;
735
735
switch (ctx.arg .ekind ) {
736
736
case ELF32LEKind:
737
- msg = maybeReportDiscarded<ELF32LE>(sym);
737
+ msg = maybeReportDiscarded<ELF32LE>(ctx, sym);
738
738
break ;
739
739
case ELF32BEKind:
740
- msg = maybeReportDiscarded<ELF32BE>(sym);
740
+ msg = maybeReportDiscarded<ELF32BE>(ctx, sym);
741
741
break ;
742
742
case ELF64LEKind:
743
- msg = maybeReportDiscarded<ELF64LE>(sym);
743
+ msg = maybeReportDiscarded<ELF64LE>(ctx, sym);
744
744
break ;
745
745
case ELF64BEKind:
746
- msg = maybeReportDiscarded<ELF64BE>(sym);
746
+ msg = maybeReportDiscarded<ELF64BE>(ctx, sym);
747
747
break ;
748
748
default :
749
749
llvm_unreachable (" " );
@@ -801,7 +801,7 @@ static void reportUndefinedSymbol(const UndefinedDiag &undef,
801
801
error (msg, ErrorTag::SymbolNotFound, {sym.getName ()});
802
802
}
803
803
804
- void elf::reportUndefinedSymbols () {
804
+ void elf::reportUndefinedSymbols (Ctx &ctx ) {
805
805
// Find the first "undefined symbol" diagnostic for each diagnostic, and
806
806
// collect all "referenced from" lines at the first diagnostic.
807
807
DenseMap<Symbol *, UndefinedDiag *> firstRef;
@@ -817,14 +817,14 @@ void elf::reportUndefinedSymbols() {
817
817
// Enable spell corrector for the first 2 diagnostics.
818
818
for (const auto &[i, undef] : llvm::enumerate (undefs))
819
819
if (!undef.locs .empty ())
820
- reportUndefinedSymbol (undef, i < 2 );
820
+ reportUndefinedSymbol (ctx, undef, i < 2 );
821
821
undefs.clear ();
822
822
}
823
823
824
824
// Report an undefined symbol if necessary.
825
825
// Returns true if the undefined symbol will produce an error message.
826
- static bool maybeReportUndefined (Undefined &sym, InputSectionBase &sec ,
827
- uint64_t offset) {
826
+ static bool maybeReportUndefined (Ctx &ctx, Undefined &sym ,
827
+ InputSectionBase &sec, uint64_t offset) {
828
828
std::lock_guard<std::mutex> lock (relocMutex);
829
829
// If versioned, issue an error (even if the symbol is weak) because we don't
830
830
// know the defining filename which is required to construct a Verneed entry.
@@ -947,7 +947,7 @@ void elf::addGotEntry(Ctx &ctx, Symbol &sym) {
947
947
addRelativeReloc (*ctx.in .got , off, sym, 0 , R_ABS, ctx.target ->symbolicRel );
948
948
}
949
949
950
- static void addTpOffsetGotEntry (Symbol &sym) {
950
+ static void addTpOffsetGotEntry (Ctx &ctx, Symbol &sym) {
951
951
ctx.in .got ->addEntry (sym);
952
952
uint64_t off = sym.getGotOffset ();
953
953
if (!sym.isPreemptible && !ctx.arg .shared ) {
@@ -1277,7 +1277,7 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
1277
1277
// pollute other `handleTlsRelocation` by MIPS `ifs` statements.
1278
1278
// Mips has a custom MipsGotSection that handles the writing of GOT entries
1279
1279
// without dynamic relocations.
1280
- static unsigned handleMipsTlsRelocation (RelType type, Symbol &sym,
1280
+ static unsigned handleMipsTlsRelocation (Ctx &ctx, RelType type, Symbol &sym,
1281
1281
InputSectionBase &c, uint64_t offset,
1282
1282
int64_t addend, RelExpr expr) {
1283
1283
if (expr == R_MIPS_TLSLD) {
@@ -1314,7 +1314,7 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
1314
1314
}
1315
1315
1316
1316
if (ctx.arg .emachine == EM_MIPS)
1317
- return handleMipsTlsRelocation (type, sym, *sec, offset, addend, expr);
1317
+ return handleMipsTlsRelocation (ctx, type, sym, *sec, offset, addend, expr);
1318
1318
1319
1319
// LoongArch does not yet implement transition from TLSDESC to LE/IE, so
1320
1320
// generate TLSDESC dynamic relocation for the dynamic linker to handle.
@@ -1488,7 +1488,7 @@ void RelocationScanner::scanOne(typename Relocs<RelTy>::const_iterator &i) {
1488
1488
// Error if the target symbol is undefined. Symbol index 0 may be used by
1489
1489
// marker relocations, e.g. R_*_NONE and R_ARM_V4BX. Don't error on them.
1490
1490
if (sym.isUndefined () && symIndex != 0 &&
1491
- maybeReportUndefined (cast<Undefined>(sym), *sec, offset))
1491
+ maybeReportUndefined (ctx, cast<Undefined>(sym), *sec, offset))
1492
1492
return ;
1493
1493
1494
1494
if (ctx.arg .emachine == EM_PPC64) {
@@ -1799,7 +1799,7 @@ void elf::postScanRelocations(Ctx &ctx) {
1799
1799
ctx.target ->pltRel , sym);
1800
1800
if (flags & NEEDS_COPY) {
1801
1801
if (sym.isObject ()) {
1802
- invokeELFT (addCopyRelSymbol, cast<SharedSymbol>(sym));
1802
+ invokeELFT (addCopyRelSymbol, ctx, cast<SharedSymbol>(sym));
1803
1803
// NEEDS_COPY is cleared for sym and its aliases so that in
1804
1804
// later iterations aliases won't cause redundant copies.
1805
1805
assert (!sym.hasFlag (NEEDS_COPY));
@@ -1863,7 +1863,7 @@ void elf::postScanRelocations(Ctx &ctx) {
1863
1863
}
1864
1864
1865
1865
if ((flags & NEEDS_TLSIE) && !(flags & NEEDS_TLSGD_TO_IE))
1866
- addTpOffsetGotEntry (sym);
1866
+ addTpOffsetGotEntry (ctx, sym);
1867
1867
};
1868
1868
1869
1869
GotSection *got = ctx.in .got .get ();
0 commit comments