[lld] r174107 - [Core] Only complain about undefined symbols if they are marked as canBeNullNever.
Michael J. Spencer
bigcheesegs at gmail.com
Thu Jan 31 14:56:13 PST 2013
Author: mspencer
Date: Thu Jan 31 16:56:13 2013
New Revision: 174107
URL: http://llvm.org/viewvc/llvm-project?rev=174107&view=rev
Log:
[Core] Only complain about undefined symbols if they are marked as canBeNullNever.
Modified:
lld/trunk/include/lld/Core/SymbolTable.h
lld/trunk/lib/Core/Resolver.cpp
lld/trunk/lib/Core/SymbolTable.cpp
Modified: lld/trunk/include/lld/Core/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/SymbolTable.h?rev=174107&r1=174106&r2=174107&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/SymbolTable.h (original)
+++ lld/trunk/include/lld/Core/SymbolTable.h Thu Jan 31 16:56:13 2013
@@ -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> &);
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=174107&r1=174106&r2=174107&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Jan 31 16:56:13 2013
@@ -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");
}
}
Modified: lld/trunk/lib/Core/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=174107&r1=174106&r2=174107&view=diff
==============================================================================
--- lld/trunk/lib/Core/SymbolTable.cpp (original)
+++ lld/trunk/lib/Core/SymbolTable.cpp Thu Jan 31 16:56:13 2013
@@ -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);
}
}
More information about the llvm-commits
mailing list