aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/CBackend
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-16 18:29:00 +0000
committerChris Lattner <sabre@nondot.org>2003-10-16 18:29:00 +0000
commit72ac148d4964fbff950fe11a0eeeda73973b849b (patch)
treefde7ca11baf974328570db3b0d678d98e576fb30 /lib/Target/CBackend
parent6b25242a4ba80e8c3a8a2664eefeba9c69814012 (diff)
downloadexternal_llvm-72ac148d4964fbff950fe11a0eeeda73973b849b.zip
external_llvm-72ac148d4964fbff950fe11a0eeeda73973b849b.tar.gz
external_llvm-72ac148d4964fbff950fe11a0eeeda73973b849b.tar.bz2
Add support for 'weak' linkage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9171 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/CBackend')
-rw-r--r--lib/Target/CBackend/CBackend.cpp4
-rw-r--r--lib/Target/CBackend/Writer.cpp4
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index af33e4b..a34f3f7 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -684,6 +684,8 @@ void CWriter::printModule(Module *M) {
printType(Out, I->getType()->getElementType(), Mang->getValueName(I));
if (I->hasLinkOnceLinkage())
Out << " __attribute__((common))";
+ else if (I->hasWeakLinkage())
+ Out << " __attribute__((weak))";
if (!I->getInitializer()->isNullValue()) {
Out << " = " ;
writeOperand(I->getInitializer());
@@ -893,6 +895,8 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
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) {
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index af33e4b..a34f3f7 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -684,6 +684,8 @@ void CWriter::printModule(Module *M) {
printType(Out, I->getType()->getElementType(), Mang->getValueName(I));
if (I->hasLinkOnceLinkage())
Out << " __attribute__((common))";
+ else if (I->hasWeakLinkage())
+ Out << " __attribute__((weak))";
if (!I->getInitializer()->isNullValue()) {
Out << " = " ;
writeOperand(I->getInitializer());
@@ -893,6 +895,8 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
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) {