Properly populate lists of defined/undefined symbols in presence of aliases

llvm-svn: 47900
This commit is contained in:
Anton Korobeynikov 2008-03-04 20:16:11 +00:00
parent d72ade3b3b
commit 28179f764c
1 changed files with 11 additions and 1 deletions

View File

@ -56,6 +56,7 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
DefinedSymbols.insert(I->getName()); DefinedSymbols.insert(I->getName());
} }
} }
for (Module::global_iterator I = M->global_begin(), E = M->global_end(); for (Module::global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I) I != E; ++I)
if (I->hasName()) { if (I->hasName()) {
@ -68,6 +69,16 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
} }
} }
for (Module::alias_iterator I = M->alias_begin(), E = M->alias_end();
I != E; ++I)
if (I->hasName()) {
const GlobalValue *Aliased = I->getAliasedGlobal();
if (Aliased->isDeclaration())
UndefinedSymbols.insert(I->getName());
else
DefinedSymbols.insert(I->getName());
}
// Prune out any defined symbols from the undefined symbols set... // Prune out any defined symbols from the undefined symbols set...
for (std::set<std::string>::iterator I = UndefinedSymbols.begin(); for (std::set<std::string>::iterator I = UndefinedSymbols.begin();
I != UndefinedSymbols.end(); ) I != UndefinedSymbols.end(); )
@ -88,7 +99,6 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
/// FALSE - No errors. /// FALSE - No errors.
bool bool
Linker::LinkInArchive(const sys::Path &Filename, bool &is_native) { Linker::LinkInArchive(const sys::Path &Filename, bool &is_native) {
// Make sure this is an archive file we're dealing with // Make sure this is an archive file we're dealing with
if (!Filename.isArchive()) if (!Filename.isArchive())
return error("File '" + Filename.toString() + "' is not an archive."); return error("File '" + Filename.toString() + "' is not an archive.");