diff options
| author | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-01-31 22:56:13 +0000 |
|---|---|---|
| committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-01-31 22:56:13 +0000 |
| commit | 280dadbbaf398b8172db71de15c753a2c803db8a (patch) | |
| tree | fdcb18912207b06576939c2fd3faeb2f209d8f8e | |
| parent | e1137a2058ec3ea105323bbd9b99b5dc034c93d6 (diff) | |
| download | bcm5719-llvm-280dadbbaf398b8172db71de15c753a2c803db8a.tar.gz bcm5719-llvm-280dadbbaf398b8172db71de15c753a2c803db8a.zip | |
[Core] Only complain about undefined symbols if they are marked as canBeNullNever.
llvm-svn: 174107
| -rw-r--r-- | lld/include/lld/Core/SymbolTable.h | 2 | ||||
| -rw-r--r-- | lld/lib/Core/Resolver.cpp | 16 | ||||
| -rw-r--r-- | lld/lib/Core/SymbolTable.cpp | 6 |
3 files changed, 14 insertions, 10 deletions
diff --git a/lld/include/lld/Core/SymbolTable.h b/lld/include/lld/Core/SymbolTable.h index b78cce45bca..f1d25e5b828 100644 --- a/lld/include/lld/Core/SymbolTable.h +++ b/lld/include/lld/Core/SymbolTable.h @@ -59,7 +59,7 @@ public: const Atom *findByName(StringRef sym); /// @brief returns vector of remaining UndefinedAtoms - void undefines(std::vector<const Atom *>&); + void undefines(std::vector<const UndefinedAtom *>&); /// returns vector of tentative definitions void tentativeDefinitions(std::vector<StringRef> &); diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index b80a2214173..d0dd41fb5b4 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -191,7 +191,7 @@ void Resolver::resolveUndefines() { unsigned int undefineGenCount = 0xFFFFFFFF; while (undefineGenCount != _symbolTable.size()) { undefineGenCount = _symbolTable.size(); - std::vector<const Atom *> undefines; + std::vector<const UndefinedAtom *> undefines; _symbolTable.undefines(undefines); for ( const Atom *undefAtom : undefines ) { StringRef undefName = undefAtom->name(); @@ -301,7 +301,7 @@ void Resolver::checkUndefines(bool final) { return; // build vector of remaining undefined symbols - std::vector<const Atom *> undefinedAtoms; + std::vector<const UndefinedAtom *> undefinedAtoms; _symbolTable.undefines(undefinedAtoms); if (_targetInfo.getLinkerOptions()._deadStrip) { // When dead code stripping, we don't care if dead atoms are undefined. @@ -315,11 +315,15 @@ void Resolver::checkUndefines(bool final) { (!_targetInfo.getLinkerOptions()._noInhibitExec || _targetInfo.getLinkerOptions()._outputKind == OutputKind::Relocatable)) { // FIXME: need diagonstics interface for writing error messages - llvm::errs() << "Undefined symbols:\n"; - for ( const Atom *undefAtom : undefinedAtoms ) { - llvm::errs() << " " << undefAtom->name() << "\n"; + bool isError = false; + for (const UndefinedAtom *undefAtom : undefinedAtoms) { + if (undefAtom->canBeNull() == UndefinedAtom::canBeNullNever) { + llvm::errs() << "Undefined Symbol: " << undefAtom->name() << "\n"; + isError = true; + } } - llvm::report_fatal_error("symbol(s) not found"); + if (isError) + llvm::report_fatal_error("symbol(s) not found"); } } diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp index 7a35ed90144..29e58796022 100644 --- a/lld/lib/Core/SymbolTable.cpp +++ b/lld/lib/Core/SymbolTable.cpp @@ -332,13 +332,13 @@ unsigned int SymbolTable::size() { return _nameTable.size(); } -void SymbolTable::undefines(std::vector<const Atom *> &undefs) { +void SymbolTable::undefines(std::vector<const UndefinedAtom *> &undefs) { for (NameToAtom::iterator it = _nameTable.begin(), end = _nameTable.end(); it != end; ++it) { const Atom *atom = it->second; assert(atom != nullptr); - if (atom->definition() == Atom::definitionUndefined) - undefs.push_back(atom); + if (const auto undef = dyn_cast<const UndefinedAtom>(atom)) + undefs.push_back(undef); } } |

