Fix bugs with attribute weak emission
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9678 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index e32987c..0fd3046 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -653,6 +653,7 @@
if ((I->hasInternalLinkage() || !MangledGlobals.count(I)) &&
!I->getIntrinsicID()) {
printFunctionSignature(I, true);
+ if (I->hasWeakLinkage()) Out << " __attribute__((weak))";
Out << ";\n";
}
}
@@ -671,7 +672,11 @@
if (!I->isExternal()) {
Out << "extern ";
printType(Out, I->getType()->getElementType(), Mang->getValueName(I));
-
+
+ if (I->hasLinkOnceLinkage())
+ Out << " __attribute__((common))";
+ else if (I->hasWeakLinkage())
+ Out << " __attribute__((weak))";
Out << ";\n";
}
}
@@ -903,8 +908,6 @@
FunctionInnards << ")";
// Print out the return type and the entire signature for that matter
printType(Out, F->getReturnType(), FunctionInnards.str());
-
- if (F->hasWeakLinkage()) Out << " __attribute((weak))";
}
void CWriter::printFunction(Function *F) {