diff options
author | Dale Johannesen <dalej@apple.com> | 2008-05-14 20:12:51 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2008-05-14 20:12:51 +0000 |
commit | aafce77b17d340aace52bcd49d1944109d82f14a (patch) | |
tree | e7d1caf5f9d6c359802174c4a01644b9aa326202 /lib/Linker/LinkModules.cpp | |
parent | 50871247216dfef8386a112766e972a1792b0b56 (diff) |
Add CommonLinkage; currently tentative definitions
are represented as "weak", but there are subtle differences
in some cases on Darwin, so we need both. The intent
is that "common" will behave identically to "weak" unless
somebody changes their target to do something else.
No functional change as yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51118 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker/LinkModules.cpp')
-rw-r--r-- | lib/Linker/LinkModules.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 3db5b0927c..cf4ceaac50 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -410,10 +410,12 @@ static bool GetLinkageResult(GlobalValue *Dest, const GlobalValue *Src, "': can only link appending global with another appending global!"); LinkFromSrc = true; // Special cased. LT = Src->getLinkage(); - } else if (Src->hasWeakLinkage() || Src->hasLinkOnceLinkage()) { - // At this point we know that Dest has LinkOnce, External*, Weak, or - // DLL* linkage. - if ((Dest->hasLinkOnceLinkage() && Src->hasWeakLinkage()) || + } else if (Src->hasWeakLinkage() || Src->hasLinkOnceLinkage() || + Src->hasCommonLinkage()) { + // At this point we know that Dest has LinkOnce, External*, Weak, Common, + // or DLL* linkage. + if ((Dest->hasLinkOnceLinkage() && + (Src->hasWeakLinkage() || Src->hasCommonLinkage())) || Dest->hasExternalWeakLinkage()) { LinkFromSrc = true; LT = Src->getLinkage(); @@ -421,7 +423,8 @@ static bool GetLinkageResult(GlobalValue *Dest, const GlobalValue *Src, LinkFromSrc = false; LT = Dest->getLinkage(); } - } else if (Dest->hasWeakLinkage() || Dest->hasLinkOnceLinkage()) { + } else if (Dest->hasWeakLinkage() || Dest->hasLinkOnceLinkage() || + Dest->hasCommonLinkage()) { // At this point we know that Src has External* or DLL* linkage. if (Src->hasExternalWeakLinkage()) { LinkFromSrc = false; @@ -792,10 +795,12 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src, if (DGV->getInitializer() != SInit) return Error(Err, "Global Variable Collision on '" + SGV->getName() + "': global variables have different initializers"); - } else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage()) { + } else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage() || + DGV->hasCommonLinkage()) { // Nothing is required, mapped values will take the new global // automatically. - } else if (SGV->hasLinkOnceLinkage() || SGV->hasWeakLinkage()) { + } else if (SGV->hasLinkOnceLinkage() || SGV->hasWeakLinkage() || + SGV->hasCommonLinkage()) { // Nothing is required, mapped values will take the new global // automatically. } else if (DGV->hasAppendingLinkage()) { @@ -916,16 +921,19 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src, DF->setLinkage(SF->getLinkage()); // Visibility of prototype is overridden by vis of definition. DF->setVisibility(SF->getVisibility()); - } else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage()) { + } else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage() || + SF->hasCommonLinkage()) { // At this point we know that DF has LinkOnce, Weak, or External* linkage. ValueMap[SF] = DF; // Linkonce+Weak = Weak // *+External Weak = * - if ((DF->hasLinkOnceLinkage() && SF->hasWeakLinkage()) || + if ((DF->hasLinkOnceLinkage() && + (SF->hasWeakLinkage() || SF->hasCommonLinkage())) || DF->hasExternalWeakLinkage()) DF->setLinkage(SF->getLinkage()); - } else if (DF->hasWeakLinkage() || DF->hasLinkOnceLinkage()) { + } else if (DF->hasWeakLinkage() || DF->hasLinkOnceLinkage() || + DF->hasCommonLinkage()) { // At this point we know that SF has LinkOnce or External* linkage. ValueMap[SF] = DF; if (!SF->hasLinkOnceLinkage() && !SF->hasExternalWeakLinkage()) |