+ } else if (SGV->hasWeakLinkage() || SGV->hasLinkOnceLinkage()) {
+ // At this point we know that DGV has LinkOnce, Appending, Weak, or
+ // External linkage. If DGV is Appending, this is an error.
+ if (DGV->hasAppendingLinkage())
+ return Error(Err, "Linking globals named '" + SGV->getName() +
+ " ' with 'weak' and 'appending' linkage is not allowed!");
+
+ if (SGV->isConstant() != DGV->isConstant())
+ return Error(Err, "Global Variable Collision on '" +
+ SGV->getType()->getDescription() + " %" + SGV->getName() +
+ "' - Global variables differ in const'ness");
+
+ // Otherwise, just perform the link.
+ ValueMap.insert(std::make_pair(SGV, DGV));
+
+ // Linkonce+Weak = Weak
+ if (DGV->hasLinkOnceLinkage() && SGV->hasWeakLinkage())
+ DGV->setLinkage(SGV->getLinkage());
+
+ } else if (DGV->hasWeakLinkage() || DGV->hasLinkOnceLinkage()) {
+ // At this point we know that SGV has LinkOnce, Appending, or External
+ // linkage. If SGV is Appending, this is an error.
+ if (SGV->hasAppendingLinkage())
+ return Error(Err, "Linking globals named '" + SGV->getName() +
+ " ' with 'weak' and 'appending' linkage is not allowed!");
+
+ if (SGV->isConstant() != DGV->isConstant())
+ return Error(Err, "Global Variable Collision on '" +
+ SGV->getType()->getDescription() + " %" + SGV->getName() +
+ "' - Global variables differ in const'ness");
+
+ if (!SGV->hasLinkOnceLinkage())
+ DGV->setLinkage(SGV->getLinkage()); // Inherit linkage!
+ ValueMap.insert(std::make_pair(SGV, DGV));
+