File tree 3 files changed +16
-3
lines changed
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -2601,7 +2601,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2601
2601
createECExportThunks ();
2602
2602
2603
2603
// Resolve remaining undefined symbols and warn about imported locals.
2604
- ctx.symtab .resolveRemainingUndefines ();
2604
+ if (ctx.symtab .resolveRemainingUndefines ()) {
2605
+ run ();
2606
+ ctx.symtab .resolveRemainingUndefines ();
2607
+ }
2605
2608
if (errorCount ())
2606
2609
return ;
2607
2610
Original file line number Diff line number Diff line change @@ -479,10 +479,11 @@ void SymbolTable::reportUnresolvable() {
479
479
/* localImports */ nullptr , true );
480
480
}
481
481
482
- void SymbolTable::resolveRemainingUndefines () {
482
+ bool SymbolTable::resolveRemainingUndefines () {
483
483
llvm::TimeTraceScope timeScope (" Resolve remaining undefined symbols" );
484
484
SmallPtrSet<Symbol *, 8 > undefs;
485
485
DenseMap<Symbol *, Symbol *> localImports;
486
+ bool foundLazy = false ;
486
487
487
488
for (auto &i : symMap) {
488
489
Symbol *sym = i.second ;
@@ -502,6 +503,11 @@ void SymbolTable::resolveRemainingUndefines() {
502
503
// This odd rule is for compatibility with MSVC linker.
503
504
if (name.starts_with (" __imp_" )) {
504
505
Symbol *imp = find (name.substr (strlen (" __imp_" )));
506
+ if (imp && imp->isLazy ()) {
507
+ forceLazy (imp);
508
+ foundLazy = true ;
509
+ continue ;
510
+ }
505
511
if (imp && isa<Defined>(imp)) {
506
512
auto *d = cast<Defined>(imp);
507
513
replaceSymbol<DefinedLocalImport>(sym, ctx, name, d);
@@ -529,6 +535,7 @@ void SymbolTable::resolveRemainingUndefines() {
529
535
reportProblemSymbols (
530
536
ctx, undefs,
531
537
ctx.config .warnLocallyDefinedImported ? &localImports : nullptr , false );
538
+ return foundLazy;
532
539
}
533
540
534
541
std::pair<Symbol *, bool > SymbolTable::insert (StringRef name) {
Original file line number Diff line number Diff line change @@ -57,7 +57,10 @@ class SymbolTable {
57
57
// Try to resolve any undefined symbols and update the symbol table
58
58
// accordingly, then print an error message for any remaining undefined
59
59
// symbols and warn about imported local symbols.
60
- void resolveRemainingUndefines ();
60
+ // Returns whether more files might need to be linked in to resolve lazy
61
+ // symbols, in which case the caller is expected to call the function again
62
+ // after linking those files.
63
+ bool resolveRemainingUndefines ();
61
64
62
65
// Load lazy objects that are needed for MinGW automatic import and for
63
66
// doing stdcall fixups.
You can’t perform that action at this time.
0 commit comments