@@ -97,8 +97,8 @@ static std::string getLocation(Ctx &ctx, InputSectionBase &s, const Symbol &sym,
9797 return msg + s.getObjMsg (off);
9898}
9999
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) {
102102 ErrorPlace errPlace = getErrorPlace (ctx, loc);
103103 std::string hint;
104104 if (rel.sym ) {
@@ -285,7 +285,7 @@ template <class ELFT> static bool isReadOnly(SharedSymbol &ss) {
285285// them are copied by a copy relocation, all of them need to be copied.
286286// Otherwise, they would refer to different places at runtime.
287287template <class ELFT >
288- static SmallSet<SharedSymbol *, 4 > getSymbolsAt (SharedSymbol &ss) {
288+ static SmallSet<SharedSymbol *, 4 > getSymbolsAt (Ctx &ctx, SharedSymbol &ss) {
289289 using Elf_Sym = typename ELFT::Sym;
290290
291291 const auto &file = cast<SharedFile>(*ss.file );
@@ -372,7 +372,7 @@ static void replaceWithDefined(Symbol &sym, SectionBase &sec, uint64_t value,
372372// to the variable in .bss. This kind of issue is sometimes very hard to
373373// debug. What's a solution? Instead of exporting a variable V from a DSO,
374374// define an accessor getV().
375- template <class ELFT > static void addCopyRelSymbol (SharedSymbol &ss) {
375+ template <class ELFT > static void addCopyRelSymbol (Ctx &ctx, SharedSymbol &ss) {
376376 // Copy relocation against zero-sized symbol doesn't make sense.
377377 uint64_t symSize = ss.getSize ();
378378 if (symSize == 0 || ss.alignment == 0 )
@@ -397,7 +397,7 @@ template <class ELFT> static void addCopyRelSymbol(SharedSymbol &ss) {
397397 // Look through the DSO's dynamic symbol table for aliases and create a
398398 // dynamic symbol for each one. This causes the copy relocation to correctly
399399 // interpose any aliases.
400- for (SharedSymbol *sym : getSymbolsAt<ELFT>(ss))
400+ for (SharedSymbol *sym : getSymbolsAt<ELFT>(ctx, ss))
401401 replaceWithDefined (*sym, *sec, 0 , sym->size );
402402
403403 ctx.mainPart ->relaDyn ->addSymbolReloc (ctx.target ->copyRel , *sec, 0 , ss);
@@ -526,7 +526,7 @@ int64_t RelocationScanner::computeMipsAddend(const RelTy &rel, RelExpr expr,
526526
527527// Custom error message if Sym is defined in a discarded section.
528528template <class ELFT >
529- static std::string maybeReportDiscarded (Undefined &sym) {
529+ static std::string maybeReportDiscarded (Ctx &ctx, Undefined &sym) {
530530 auto *file = dyn_cast_or_null<ObjFile<ELFT>>(sym.file );
531531 if (!file || !sym.discardedSecIdx )
532532 return " " ;
@@ -714,7 +714,7 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
714714 return nullptr ;
715715}
716716
717- static void reportUndefinedSymbol (const UndefinedDiag &undef,
717+ static void reportUndefinedSymbol (Ctx &ctx, const UndefinedDiag &undef,
718718 bool correctSpelling) {
719719 Undefined &sym = *undef.sym ;
720720
@@ -734,16 +734,16 @@ static void reportUndefinedSymbol(const UndefinedDiag &undef,
734734 std::string msg;
735735 switch (ctx.arg .ekind ) {
736736 case ELF32LEKind:
737- msg = maybeReportDiscarded<ELF32LE>(sym);
737+ msg = maybeReportDiscarded<ELF32LE>(ctx, sym);
738738 break ;
739739 case ELF32BEKind:
740- msg = maybeReportDiscarded<ELF32BE>(sym);
740+ msg = maybeReportDiscarded<ELF32BE>(ctx, sym);
741741 break ;
742742 case ELF64LEKind:
743- msg = maybeReportDiscarded<ELF64LE>(sym);
743+ msg = maybeReportDiscarded<ELF64LE>(ctx, sym);
744744 break ;
745745 case ELF64BEKind:
746- msg = maybeReportDiscarded<ELF64BE>(sym);
746+ msg = maybeReportDiscarded<ELF64BE>(ctx, sym);
747747 break ;
748748 default :
749749 llvm_unreachable (" " );
@@ -801,7 +801,7 @@ static void reportUndefinedSymbol(const UndefinedDiag &undef,
801801 error (msg, ErrorTag::SymbolNotFound, {sym.getName ()});
802802}
803803
804- void elf::reportUndefinedSymbols () {
804+ void elf::reportUndefinedSymbols (Ctx &ctx ) {
805805 // Find the first "undefined symbol" diagnostic for each diagnostic, and
806806 // collect all "referenced from" lines at the first diagnostic.
807807 DenseMap<Symbol *, UndefinedDiag *> firstRef;
@@ -817,14 +817,14 @@ void elf::reportUndefinedSymbols() {
817817 // Enable spell corrector for the first 2 diagnostics.
818818 for (const auto &[i, undef] : llvm::enumerate (undefs))
819819 if (!undef.locs .empty ())
820- reportUndefinedSymbol (undef, i < 2 );
820+ reportUndefinedSymbol (ctx, undef, i < 2 );
821821 undefs.clear ();
822822}
823823
824824// Report an undefined symbol if necessary.
825825// 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) {
828828 std::lock_guard<std::mutex> lock (relocMutex);
829829 // If versioned, issue an error (even if the symbol is weak) because we don't
830830 // know the defining filename which is required to construct a Verneed entry.
@@ -947,7 +947,7 @@ void elf::addGotEntry(Ctx &ctx, Symbol &sym) {
947947 addRelativeReloc (*ctx.in .got , off, sym, 0 , R_ABS, ctx.target ->symbolicRel );
948948}
949949
950- static void addTpOffsetGotEntry (Symbol &sym) {
950+ static void addTpOffsetGotEntry (Ctx &ctx, Symbol &sym) {
951951 ctx.in .got ->addEntry (sym);
952952 uint64_t off = sym.getGotOffset ();
953953 if (!sym.isPreemptible && !ctx.arg .shared ) {
@@ -1277,7 +1277,7 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
12771277// pollute other `handleTlsRelocation` by MIPS `ifs` statements.
12781278// Mips has a custom MipsGotSection that handles the writing of GOT entries
12791279// without dynamic relocations.
1280- static unsigned handleMipsTlsRelocation (RelType type, Symbol &sym,
1280+ static unsigned handleMipsTlsRelocation (Ctx &ctx, RelType type, Symbol &sym,
12811281 InputSectionBase &c, uint64_t offset,
12821282 int64_t addend, RelExpr expr) {
12831283 if (expr == R_MIPS_TLSLD) {
@@ -1314,7 +1314,7 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
13141314 }
13151315
13161316 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);
13181318
13191319 // LoongArch does not yet implement transition from TLSDESC to LE/IE, so
13201320 // generate TLSDESC dynamic relocation for the dynamic linker to handle.
@@ -1488,7 +1488,7 @@ void RelocationScanner::scanOne(typename Relocs<RelTy>::const_iterator &i) {
14881488 // Error if the target symbol is undefined. Symbol index 0 may be used by
14891489 // marker relocations, e.g. R_*_NONE and R_ARM_V4BX. Don't error on them.
14901490 if (sym.isUndefined () && symIndex != 0 &&
1491- maybeReportUndefined (cast<Undefined>(sym), *sec, offset))
1491+ maybeReportUndefined (ctx, cast<Undefined>(sym), *sec, offset))
14921492 return ;
14931493
14941494 if (ctx.arg .emachine == EM_PPC64) {
@@ -1799,7 +1799,7 @@ void elf::postScanRelocations(Ctx &ctx) {
17991799 ctx.target ->pltRel , sym);
18001800 if (flags & NEEDS_COPY) {
18011801 if (sym.isObject ()) {
1802- invokeELFT (addCopyRelSymbol, cast<SharedSymbol>(sym));
1802+ invokeELFT (addCopyRelSymbol, ctx, cast<SharedSymbol>(sym));
18031803 // NEEDS_COPY is cleared for sym and its aliases so that in
18041804 // later iterations aliases won't cause redundant copies.
18051805 assert (!sym.hasFlag (NEEDS_COPY));
@@ -1863,7 +1863,7 @@ void elf::postScanRelocations(Ctx &ctx) {
18631863 }
18641864
18651865 if ((flags & NEEDS_TLSIE) && !(flags & NEEDS_TLSGD_TO_IE))
1866- addTpOffsetGotEntry (sym);
1866+ addTpOffsetGotEntry (ctx, sym);
18671867 };
18681868
18691869 GotSection *got = ctx.in .got .get ();
0 commit comments