diff options
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/CBackend/CBackend.cpp | 4 | ||||
-rw-r--r-- | lib/Target/CBackend/Writer.cpp | 4 | ||||
-rw-r--r-- | lib/Target/X86/Printer.cpp | 4 | ||||
-rw-r--r-- | lib/Target/X86/X86AsmPrinter.cpp | 4 |
4 files changed, 14 insertions, 2 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index af33e4b85f..a34f3f7712 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 af33e4b85f..a34f3f7712 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) { diff --git a/lib/Target/X86/Printer.cpp b/lib/Target/X86/Printer.cpp index fbc6b6e1af..f8c006cfd1 100644 --- a/lib/Target/X86/Printer.cpp +++ b/lib/Target/X86/Printer.cpp @@ -948,7 +948,8 @@ bool Printer::doFinalization(Module &M) { unsigned Align = TD.getTypeAlignment(C->getType()); if (C->isNullValue() && - (I->hasLinkOnceLinkage() || I->hasInternalLinkage())) { + (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || + I->hasWeakLinkage() /* FIXME: Verify correct */)) { SwitchSection(O, CurSection, ".data"); if (I->hasInternalLinkage()) O << "\t.local " << name << "\n"; @@ -961,6 +962,7 @@ bool Printer::doFinalization(Module &M) { } else { switch (I->getLinkage()) { case GlobalValue::LinkOnceLinkage: + case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak O << "\t.weak " << name << "\n"; SwitchSection(O, CurSection, ""); diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index fbc6b6e1af..f8c006cfd1 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -948,7 +948,8 @@ bool Printer::doFinalization(Module &M) { unsigned Align = TD.getTypeAlignment(C->getType()); if (C->isNullValue() && - (I->hasLinkOnceLinkage() || I->hasInternalLinkage())) { + (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || + I->hasWeakLinkage() /* FIXME: Verify correct */)) { SwitchSection(O, CurSection, ".data"); if (I->hasInternalLinkage()) O << "\t.local " << name << "\n"; @@ -961,6 +962,7 @@ bool Printer::doFinalization(Module &M) { } else { switch (I->getLinkage()) { case GlobalValue::LinkOnceLinkage: + case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak O << "\t.weak " << name << "\n"; SwitchSection(O, CurSection, ""); |