extern_weak linkage. fixes PR1038
authorAndrew Lenharth <andrewl@lenharth.org>
Fri, 15 Dec 2006 17:35:32 +0000 (17:35 +0000)
committerAndrew Lenharth <andrewl@lenharth.org>
Fri, 15 Dec 2006 17:35:32 +0000 (17:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32603 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkModules.cpp

index 433dfa682d60d02c0d7472620243b029856da663..9346c118240e6d358df8650c43a3aa7d2d73fdc2 100644 (file)
@@ -365,6 +365,10 @@ static bool GetLinkageResult(GlobalValue *Dest, GlobalValue *Src,
         LinkFromSrc = true;
         LT = Src->getLinkage();
       }      
         LinkFromSrc = true;
         LT = Src->getLinkage();
       }      
+    } else if (Dest->hasExternalWeakLinkage()) {
+      //If the Dest is weak, use the source linkage
+      LinkFromSrc = true;
+      LT = Src->getLinkage();
     } else {
       LinkFromSrc = false;
       LT = Dest->getLinkage();
     } else {
       LinkFromSrc = false;
       LT = Dest->getLinkage();
@@ -446,7 +450,7 @@ static bool LinkGlobals(Module *Dest, Module *Src,
     if (DGV && DGV->hasInternalLinkage())
       DGV = 0;
 
     if (DGV && DGV->hasInternalLinkage())
       DGV = 0;
 
-    assert(SGV->hasInitializer() ||
+    assert(SGV->hasInitializer() || SGV->hasExternalWeakLinkage() ||
            SGV->hasExternalLinkage() || SGV->hasDLLImportLinkage() &&
            "Global must either be external or have an initializer!");
 
            SGV->hasExternalLinkage() || SGV->hasDLLImportLinkage() &&
            "Global must either be external or have an initializer!");