@@ -214,10 +214,9 @@ struct UndefinedDiag {
214214 std::vector<File> files;
215215};
216216
217- static void reportUndefinedSymbol (COFFLinkerContext &ctx,
218- const UndefinedDiag &undefDiag) {
217+ void SymbolTable::reportUndefinedSymbol (const UndefinedDiag &undefDiag) {
219218 auto diag = errorOrWarn (ctx);
220- diag << " undefined symbol: " << undefDiag.sym ;
219+ diag << " undefined symbol: " << printSymbol ( undefDiag.sym ) ;
221220
222221 const size_t maxUndefReferences = 3 ;
223222 size_t numDisplayedRefs = 0 , numRefs = 0 ;
@@ -363,12 +362,12 @@ void SymbolTable::reportProblemSymbols(
363362
364363 for (Symbol *b : ctx.config .gcroot ) {
365364 if (undefs.count (b))
366- errorOrWarn (ctx) << " <root>: undefined symbol: " << b ;
365+ errorOrWarn (ctx) << " <root>: undefined symbol: " << printSymbol (b) ;
367366 if (localImports)
368367 if (Symbol *imp = localImports->lookup (b))
369- Warn (ctx) << " <root>: locally defined symbol imported: " << imp
370- << " (defined in " << toString (imp-> getFile ())
371- << " ) [LNK4217]" ;
368+ Warn (ctx) << " <root>: locally defined symbol imported: "
369+ << printSymbol (imp) << " (defined in "
370+ << toString (imp-> getFile ()) << " ) [LNK4217]" ;
372371 }
373372
374373 std::vector<UndefinedDiag> undefDiags;
@@ -389,7 +388,8 @@ void SymbolTable::reportProblemSymbols(
389388 }
390389 if (localImports)
391390 if (Symbol *imp = localImports->lookup (sym))
392- Warn (ctx) << file << " : locally defined symbol imported: " << imp
391+ Warn (ctx) << file
392+ << " : locally defined symbol imported: " << printSymbol (imp)
393393 << " (defined in " << imp->getFile () << " ) [LNK4217]" ;
394394 }
395395 };
@@ -402,7 +402,7 @@ void SymbolTable::reportProblemSymbols(
402402 processFile (file, file->getSymbols ());
403403
404404 for (const UndefinedDiag &undefDiag : undefDiags)
405- reportUndefinedSymbol (ctx, undefDiag);
405+ reportUndefinedSymbol (undefDiag);
406406}
407407
408408void SymbolTable::reportUnresolvable () {
@@ -822,7 +822,7 @@ void SymbolTable::reportDuplicate(Symbol *existing, InputFile *newFile,
822822 uint32_t newSectionOffset) {
823823 COFFSyncStream diag (ctx, ctx.config .forceMultiple ? DiagLevel::Warn
824824 : DiagLevel::Err);
825- diag << " duplicate symbol: " << existing;
825+ diag << " duplicate symbol: " << printSymbol ( existing) ;
826826
827827 DefinedRegular *d = dyn_cast<DefinedRegular>(existing);
828828 if (d && isa<ObjFile>(d->getFile ())) {
@@ -1350,6 +1350,13 @@ Symbol *SymbolTable::addUndefined(StringRef name) {
13501350 return addUndefined (name, nullptr , false );
13511351}
13521352
1353+ std::string SymbolTable::printSymbol (Symbol *sym) const {
1354+ std::string name = maybeDemangleSymbol (ctx, sym->getName ());
1355+ if (ctx.hybridSymtab )
1356+ return name + (isEC () ? " (EC symbol)" : " (native symbol)" );
1357+ return name;
1358+ }
1359+
13531360void SymbolTable::compileBitcodeFiles () {
13541361 if (bitcodeFileInstances.empty ())
13551362 return ;
0 commit comments