diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 2b375c20a1d71..0ee00dbe1e919 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -719,7 +719,6 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym, return nullptr; } -template static void reportUndefinedSymbol(const UndefinedDiag &undef, bool correctSpelling) { Undefined &sym = *undef.sym; @@ -737,7 +736,23 @@ static void reportUndefinedSymbol(const UndefinedDiag &undef, } }; - std::string msg = maybeReportDiscarded(sym); + std::string msg; + switch (config->ekind) { + case ELF32LEKind: + msg = maybeReportDiscarded(sym); + break; + case ELF32BEKind: + msg = maybeReportDiscarded(sym); + break; + case ELF64LEKind: + msg = maybeReportDiscarded(sym); + break; + case ELF64BEKind: + msg = maybeReportDiscarded(sym); + break; + default: + llvm_unreachable(""); + } if (msg.empty()) msg = "undefined " + visibility() + "symbol: " + toString(sym); @@ -788,7 +803,7 @@ static void reportUndefinedSymbol(const UndefinedDiag &undef, error(msg, ErrorTag::SymbolNotFound, {sym.getName()}); } -template void elf::reportUndefinedSymbols() { +void elf::reportUndefinedSymbols() { // Find the first "undefined symbol" diagnostic for each diagnostic, and // collect all "referenced from" lines at the first diagnostic. DenseMap firstRef; @@ -804,7 +819,7 @@ template void elf::reportUndefinedSymbols() { // Enable spell corrector for the first 2 diagnostics. for (auto it : enumerate(undefs)) if (!it.value().locs.empty()) - reportUndefinedSymbol(it.value(), it.index() < 2); + reportUndefinedSymbol(it.value(), it.index() < 2); undefs.clear(); } @@ -2221,7 +2236,3 @@ template void elf::scanRelocations(InputSectionBase &); template void elf::scanRelocations(InputSectionBase &); template void elf::scanRelocations(InputSectionBase &); template void elf::scanRelocations(InputSectionBase &); -template void elf::reportUndefinedSymbols(); -template void elf::reportUndefinedSymbols(); -template void elf::reportUndefinedSymbols(); -template void elf::reportUndefinedSymbols(); diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h index 73f6970b80f13..3eecc02764a3a 100644 --- a/lld/ELF/Relocations.h +++ b/lld/ELF/Relocations.h @@ -127,10 +127,9 @@ struct JumpInstrMod { // Call reportUndefinedSymbols() after calling scanRelocations() to emit // the diagnostics. template void scanRelocations(InputSectionBase &); +void reportUndefinedSymbols(); void postScanRelocations(); -template void reportUndefinedSymbols(); - void hexagonTLSSymbolUpdate(ArrayRef outputSections); bool hexagonNeedsTLSSymbol(ArrayRef outputSections); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 4042ca1a631c4..23a310a60b480 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1911,7 +1911,7 @@ template void Writer::finalizeSections() { scanRelocations(*sec); } - reportUndefinedSymbols(); + reportUndefinedSymbols(); postScanRelocations(); } }