Properly populate lists of defined/undefined symbols in presence of aliases
authorAnton Korobeynikov <asl@math.spbu.ru>
Tue, 4 Mar 2008 20:16:11 +0000 (20:16 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Tue, 4 Mar 2008 20:16:11 +0000 (20:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47900 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkArchives.cpp

index 974ad26e372922871a03a16e3dbaccded65abbe5..308a775acd2c590826abfb340b4889c1a6ad96a0 100644 (file)
@@ -56,6 +56,7 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
         DefinedSymbols.insert(I->getName());
       }      
     }
+
   for (Module::global_iterator I = M->global_begin(), E = M->global_end();
        I != E; ++I)
     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...
   for (std::set<std::string>::iterator I = UndefinedSymbols.begin();
        I != UndefinedSymbols.end(); )
@@ -88,7 +99,6 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
 ///  FALSE - No errors.
 bool
 Linker::LinkInArchive(const sys::Path &Filename, bool &is_native) {
-
   // Make sure this is an archive file we're dealing with
   if (!Filename.isArchive())
     return error("File '" + Filename.toString() + "' is not an archive.");