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> &);
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();
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.
(!_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");
}
}
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);
}
}