@@ -560,24 +560,6 @@ static std::string maybeReportDiscarded(Ctx &ctx, Undefined &sym) {
560
560
return msg;
561
561
}
562
562
563
- namespace {
564
- // Undefined diagnostics are collected in a vector and emitted once all of
565
- // them are known, so that some postprocessing on the list of undefined symbols
566
- // can happen before lld emits diagnostics.
567
- struct UndefinedDiag {
568
- Undefined *sym;
569
- struct Loc {
570
- InputSectionBase *sec;
571
- uint64_t offset;
572
- };
573
- std::vector<Loc> locs;
574
- bool isWarning;
575
- };
576
-
577
- std::vector<UndefinedDiag> undefs;
578
- std::mutex relocMutex;
579
- }
580
-
581
563
// Check whether the definition name def is a mangled function name that matches
582
564
// the reference name ref.
583
565
static bool canSuggestExternCForCXX (StringRef ref, StringRef def) {
@@ -802,7 +784,7 @@ void elf::reportUndefinedSymbols(Ctx &ctx) {
802
784
// Find the first "undefined symbol" diagnostic for each diagnostic, and
803
785
// collect all "referenced from" lines at the first diagnostic.
804
786
DenseMap<Symbol *, UndefinedDiag *> firstRef;
805
- for (UndefinedDiag &undef : undefs ) {
787
+ for (UndefinedDiag &undef : ctx. undefErrs ) {
806
788
assert (undef.locs .size () == 1 );
807
789
if (UndefinedDiag *canon = firstRef.lookup (undef.sym )) {
808
790
canon->locs .push_back (undef.locs [0 ]);
@@ -812,21 +794,20 @@ void elf::reportUndefinedSymbols(Ctx &ctx) {
812
794
}
813
795
814
796
// Enable spell corrector for the first 2 diagnostics.
815
- for (const auto & [i, undef] : llvm::enumerate (undefs ))
797
+ for (auto [i, undef] : llvm::enumerate (ctx. undefErrs ))
816
798
if (!undef.locs .empty ())
817
799
reportUndefinedSymbol (ctx, undef, i < 2 );
818
- undefs.clear ();
819
800
}
820
801
821
802
// Report an undefined symbol if necessary.
822
803
// Returns true if the undefined symbol will produce an error message.
823
804
static bool maybeReportUndefined (Ctx &ctx, Undefined &sym,
824
805
InputSectionBase &sec, uint64_t offset) {
825
- std::lock_guard<std::mutex> lock (relocMutex);
806
+ std::lock_guard<std::mutex> lock (ctx. relocMutex );
826
807
// If versioned, issue an error (even if the symbol is weak) because we don't
827
808
// know the defining filename which is required to construct a Verneed entry.
828
809
if (sym.hasVersionSuffix ) {
829
- undefs .push_back ({&sym, {{&sec, offset}}, false });
810
+ ctx. undefErrs .push_back ({&sym, {{&sec, offset}}, false });
830
811
return true ;
831
812
}
832
813
if (sym.isWeak ())
@@ -851,7 +832,7 @@ static bool maybeReportUndefined(Ctx &ctx, Undefined &sym,
851
832
bool isWarning =
852
833
(ctx.arg .unresolvedSymbols == UnresolvedPolicy::Warn && canBeExternal) ||
853
834
ctx.arg .noinhibitExec ;
854
- undefs .push_back ({&sym, {{&sec, offset}}, isWarning});
835
+ ctx. undefErrs .push_back ({&sym, {{&sec, offset}}, isWarning});
855
836
return !isWarning;
856
837
}
857
838
@@ -878,7 +859,7 @@ static void addRelativeReloc(Ctx &ctx, InputSectionBase &isec,
878
859
Partition &part = isec.getPartition (ctx);
879
860
880
861
if (sym.isTagged ()) {
881
- std::lock_guard<std::mutex> lock (relocMutex);
862
+ std::lock_guard<std::mutex> lock (ctx. relocMutex );
882
863
part.relaDyn ->addRelativeReloc (ctx.target ->relativeRel , isec, offsetInSec,
883
864
sym, addend, type, expr);
884
865
// With MTE globals, we always want to derive the address tag by `ldg`-ing
@@ -1089,7 +1070,7 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
1089
1070
// We were asked not to generate PLT entries for ifuncs. Instead, pass the
1090
1071
// direct relocation on through.
1091
1072
if (LLVM_UNLIKELY (isIfunc) && ctx.arg .zIfuncNoplt ) {
1092
- std::lock_guard<std::mutex> lock (relocMutex);
1073
+ std::lock_guard<std::mutex> lock (ctx. relocMutex );
1093
1074
sym.exportDynamic = true ;
1094
1075
ctx.mainPart ->relaDyn ->addSymbolReloc (type, *sec, offset, sym, addend,
1095
1076
type);
@@ -1156,7 +1137,7 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
1156
1137
if (rel != 0 ) {
1157
1138
if (ctx.arg .emachine == EM_MIPS && rel == ctx.target ->symbolicRel )
1158
1139
rel = ctx.target ->relativeRel ;
1159
- std::lock_guard<std::mutex> lock (relocMutex);
1140
+ std::lock_guard<std::mutex> lock (ctx. relocMutex );
1160
1141
Partition &part = sec->getPartition (ctx);
1161
1142
if (ctx.arg .emachine == EM_AARCH64 && type == R_AARCH64_AUTH_ABS64) {
1162
1143
// For a preemptible symbol, we can't use a relative relocation. For an
0 commit comments