From: Chris Lattner Date: Tue, 17 Feb 2004 21:56:04 +0000 (+0000) Subject: Fix PR245: Linking weak and strong global variables is dependent on link order X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=57cb9883aa4c82357594d4186858f175135be3b1;p=oota-llvm.git Fix PR245: Linking weak and strong global variables is dependent on link order git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11565 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index aa7720ece35..529fb771489 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -566,7 +566,6 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src, GlobalVariable *DGV = cast(ValueMap[SGV]); if (DGV->hasInitializer()) { - assert(SGV->getLinkage() == DGV->getLinkage()); if (SGV->hasExternalLinkage()) { if (DGV->getInitializer() != SInit) return Error(Err, "Global Variable Collision on '" + @@ -575,6 +574,9 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src, } else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage()) { // Nothing is required, mapped values will take the new global // automatically. + } else if (SGV->hasLinkOnceLinkage() || SGV->hasWeakLinkage()) { + // Nothing is required, mapped values will take the new global + // automatically. } else if (DGV->hasAppendingLinkage()) { assert(0 && "Appending linkage unimplemented!"); } else { diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp index aa7720ece35..529fb771489 100644 --- a/lib/Transforms/Utils/Linker.cpp +++ b/lib/Transforms/Utils/Linker.cpp @@ -566,7 +566,6 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src, GlobalVariable *DGV = cast(ValueMap[SGV]); if (DGV->hasInitializer()) { - assert(SGV->getLinkage() == DGV->getLinkage()); if (SGV->hasExternalLinkage()) { if (DGV->getInitializer() != SInit) return Error(Err, "Global Variable Collision on '" + @@ -575,6 +574,9 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src, } else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage()) { // Nothing is required, mapped values will take the new global // automatically. + } else if (SGV->hasLinkOnceLinkage() || SGV->hasWeakLinkage()) { + // Nothing is required, mapped values will take the new global + // automatically. } else if (DGV->hasAppendingLinkage()) { assert(0 && "Appending linkage unimplemented!"); } else { diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp index aa7720ece35..529fb771489 100644 --- a/lib/VMCore/Linker.cpp +++ b/lib/VMCore/Linker.cpp @@ -566,7 +566,6 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src, GlobalVariable *DGV = cast(ValueMap[SGV]); if (DGV->hasInitializer()) { - assert(SGV->getLinkage() == DGV->getLinkage()); if (SGV->hasExternalLinkage()) { if (DGV->getInitializer() != SInit) return Error(Err, "Global Variable Collision on '" + @@ -575,6 +574,9 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src, } else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage()) { // Nothing is required, mapped values will take the new global // automatically. + } else if (SGV->hasLinkOnceLinkage() || SGV->hasWeakLinkage()) { + // Nothing is required, mapped values will take the new global + // automatically. } else if (DGV->hasAppendingLinkage()) { assert(0 && "Appending linkage unimplemented!"); } else {