diff --git a/docs/LangRef.html b/docs/LangRef.html
index 33fc7d4ff6c..52ec97888d1 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -552,19 +552,22 @@ define i32 @main() { ; i32()*
translation unit that uses it. Unreferenced linkonce globals are
allowed to be discarded.
- common:
- "common" linkage is exactly the same as linkonce
- linkage, except that unreferenced common globals may not be
- discarded. This is used for globals that may be emitted in multiple
- translation units, but that are not guaranteed to be emitted into every
- translation unit that uses them. One example of this is tentative
- definitions in C, such as "int X;" at global scope.
-
weak:
- "weak" linkage is the same as common linkage, except
- that some targets may choose to emit different assembly sequences for them
- for target-dependent reasons. This is used for globals that are declared
- "weak" in C source code.
+ "weak" linkage has the same merging semantics as
+ linkonce linkage, except that unreferenced globals with
+ weak linkage may not be discarded. This is used for globals that
+ are declared "weak" in C source code.
+
+ common:
+ "common" linkage is most similar to "weak" linkage, but
+ they are used for tentative definitions in C, such as "int X;" at
+ global scope.
+ Symbols with "common" linkage are merged in the same way as
+ weak symbols, and they may not be deleted if unreferenced.
+ Further, common symbols may not have an explicit section, and
+ must have a zero initializer. Functions and aliases may not have common
+ linkage.
+
appending:
"appending" linkage may only be applied to global variables of
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index 2f56c2a9559..d5279ef4e33 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
@@ -782,8 +782,13 @@ void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (Subtarget->isTargetELF())
O << "\t.type\t" << name << ",@object\n";
+
+ SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM);
+
+
+
const MCSection *TheSection =
- getObjFileLowering().SectionForGlobal(GVar, Mang, TM);
+ getObjFileLowering().SectionForGlobal(GVar, GVKind, Mang, TM);
SwitchToSection(TheSection);
// FIXME: get this stuff from section kind flags.
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 2b832983f5c..f50299bdc0c 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -378,6 +378,12 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) {
"Global variable initializer type does not match global "
"variable type!", &GV);
+ // If the global has common linkage, it must have a zero initializer.
+ if (GV.hasCommonLinkage())
+ Assert1(GV.getInitializer()->isNullValue(),
+ "'common' global must have a zero initializer!", &GV);
+
+
// Verify that any metadata used in a global initializer points only to
// other globals.
if (MDNode *FirstNode = dyn_cast(GV.getInitializer())) {
@@ -544,6 +550,7 @@ void Verifier::visitFunction(Function &F) {
const FunctionType *FT = F.getFunctionType();
unsigned NumArgs = F.arg_size();
+ Assert1(!F.hasCommonLinkage(), "Functions may not have common linkage", &F);
Assert2(FT->getNumParams() == NumArgs,
"# formal arguments must match # of arguments for function type!",
&F, FT);