diff options
| -rw-r--r-- | lld/include/lld/Core/SymbolTable.h | 4 | ||||
| -rw-r--r-- | lld/lib/Core/Resolver.cpp | 12 | ||||
| -rw-r--r-- | lld/lib/Core/SymbolTable.cpp | 13 |
3 files changed, 15 insertions, 14 deletions
diff --git a/lld/include/lld/Core/SymbolTable.h b/lld/include/lld/Core/SymbolTable.h index 588ac137635..26bdf820104 100644 --- a/lld/include/lld/Core/SymbolTable.h +++ b/lld/include/lld/Core/SymbolTable.h @@ -58,10 +58,10 @@ public: const Atom *findByName(StringRef sym); /// @brief returns vector of remaining UndefinedAtoms - void undefines(std::vector<const UndefinedAtom *>&); + std::vector<const UndefinedAtom *> undefines(); /// returns vector of tentative definitions - void tentativeDefinitions(std::vector<StringRef> &); + std::vector<StringRef> tentativeDefinitions(); /// @brief count of by-name entries in symbol table unsigned int size(); diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 1b40bd37dcc..768c05a32fc 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -74,19 +74,16 @@ void Resolver::forEachUndefines(UndefCallback callback, int64_t undefineGenCount = 0; do { undefineGenCount = _symbolTable.size(); - std::vector<const UndefinedAtom *> undefines; - _symbolTable.undefines(undefines); - for (const UndefinedAtom *undefAtom : undefines) { + for (const UndefinedAtom *undefAtom : _symbolTable.undefines()) { StringRef undefName = undefAtom->name(); // load for previous undefine may also have loaded this undefine if (!_symbolTable.isDefined(undefName)) callback(undefName, false); } + // search libraries for overrides of common symbols if (searchForOverrides) { - std::vector<StringRef> tentDefNames; - _symbolTable.tentativeDefinitions(tentDefNames); - for (StringRef tentDefName : tentDefNames) { + for (StringRef tentDefName : _symbolTable.tentativeDefinitions()) { // Load for previous tentative may also have loaded // something that overrode this tentative, so always check. const Atom *curAtom = _symbolTable.findByName(tentDefName); @@ -359,8 +356,7 @@ void Resolver::deadStripOptimize() { // error out if some undefines remain bool Resolver::checkUndefines() { // build vector of remaining undefined symbols - std::vector<const UndefinedAtom *> undefinedAtoms; - _symbolTable.undefines(undefinedAtoms); + std::vector<const UndefinedAtom *> undefinedAtoms = _symbolTable.undefines(); if (_context.deadStrip()) { // When dead code stripping, we don't care if dead atoms are undefined. undefinedAtoms.erase( diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp index 2ad1d80927a..97181f70468 100644 --- a/lld/lib/Core/SymbolTable.cpp +++ b/lld/lib/Core/SymbolTable.cpp @@ -392,7 +392,8 @@ unsigned int SymbolTable::size() { return _nameTable.size(); } -void SymbolTable::undefines(std::vector<const UndefinedAtom *> &undefs) { +std::vector<const UndefinedAtom *> SymbolTable::undefines() { + std::vector<const UndefinedAtom *> ret; for (auto it : _nameTable) { const Atom *atom = it.second; assert(atom != nullptr); @@ -400,19 +401,23 @@ void SymbolTable::undefines(std::vector<const UndefinedAtom *> &undefs) { AtomToAtom::iterator pos = _replacedAtoms.find(undef); if (pos != _replacedAtoms.end()) continue; - undefs.push_back(undef); + ret.push_back(undef); } } + return ret; } -void SymbolTable::tentativeDefinitions(std::vector<StringRef> &names) { +std::vector<StringRef> SymbolTable::tentativeDefinitions() { + std::vector<StringRef> ret; for (auto entry : _nameTable) { const Atom *atom = entry.second; StringRef name = entry.first; assert(atom != nullptr); if (const DefinedAtom *defAtom = dyn_cast<DefinedAtom>(atom)) if (defAtom->merge() == DefinedAtom::mergeAsTentative) - names.push_back(name); + ret.push_back(name); } + return ret; } + } // namespace lld |

