diff options
Diffstat (limited to 'lld/COFF')
-rw-r--r-- | lld/COFF/Driver.cpp | 20 | ||||
-rw-r--r-- | lld/COFF/SymbolTable.cpp | 17 | ||||
-rw-r--r-- | lld/COFF/SymbolTable.h | 6 |
3 files changed, 28 insertions, 15 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 6db8f01f30d2..8c51030a7d55 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -526,15 +526,11 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) { OwningMBs.push_back(std::move(MB)); // take ownership } - // Parse all input files and put all symbols to the symbol table. - // The symbol table will take care of name resolution. + // Read all input files given via the command line. Note that step() + // doesn't read files that are specified by directive sections. for (MemoryBufferRef MB : Inputs) Symtab.addFile(createFile(MB)); - if (auto EC = Symtab.readObjects()) { - llvm::errs() << EC.message() << "\n"; - return false; - } - if (auto EC = Symtab.run()) { + if (auto EC = Symtab.step()) { llvm::errs() << EC.message() << "\n"; return false; } @@ -548,9 +544,17 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) { return false; } Config->Entry = addUndefined(S); + if (Config->Verbose) + llvm::outs() << "Entry name inferred: " << S << "\n"; + } + + // Read as much files as we can. + if (auto EC = Symtab.run()) { + llvm::errs() << EC.message() << "\n"; + return false; } - // Resolve auxiliary symbols until converge. + // Resolve auxiliary symbols until we get a convergence. // (Trying to resolve a symbol may trigger a Lazy symbol to load a new file. // A new file may contain a directive section to add new command line options. // That's why we have to repeat until converge.) diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp index 627c9a22f55e..ca4c6fa835bf 100644 --- a/lld/COFF/SymbolTable.cpp +++ b/lld/COFF/SymbolTable.cpp @@ -44,13 +44,20 @@ void SymbolTable::addFile(std::unique_ptr<InputFile> FileP) { } } +std::error_code SymbolTable::step() { + if (queueEmpty()) + return std::error_code(); + if (auto EC = readObjects()) + return EC; + if (auto EC = readArchives()) + return EC; + return std::error_code(); +} + std::error_code SymbolTable::run() { - while (!queueEmpty()) { - if (auto EC = readArchives()) + while (!queueEmpty()) + if (auto EC = step()) return EC; - if (auto EC = readObjects()) - return EC; - } return std::error_code(); } diff --git a/lld/COFF/SymbolTable.h b/lld/COFF/SymbolTable.h index 37075bdf57b7..188b2382fb4b 100644 --- a/lld/COFF/SymbolTable.h +++ b/lld/COFF/SymbolTable.h @@ -43,9 +43,8 @@ class SymbolTable { public: SymbolTable(); void addFile(std::unique_ptr<InputFile> File); + std::error_code step(); std::error_code run(); - std::error_code readArchives(); - std::error_code readObjects(); bool queueEmpty(); // Print an error message on undefined symbols. @@ -89,6 +88,9 @@ public: std::vector<Chunk *> LocalImportChunks; private: + std::error_code readArchives(); + std::error_code readObjects(); + std::error_code addSymbol(SymbolBody *New); void addLazy(Lazy *New, std::vector<Symbol *> *Accum); |