Record weak external linkage in a case where we were
authorDale Johannesen <dalej@apple.com>
Fri, 16 May 2008 20:09:25 +0000 (20:09 +0000)
committerDale Johannesen <dalej@apple.com>
Fri, 16 May 2008 20:09:25 +0000 (20:09 +0000)
missing it. gcc.dg/darwin-weakimport-2.c.
Handle common and weak differently for darwin ppc32.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51201 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCAsmPrinter.cpp

index 96e1ae8a04a9a47ac1ea30e99fa397fbb81e67b6..bd4975c42f7078b620bdaa7461c78c88cb47c3e5 100644 (file)
@@ -393,6 +393,8 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
             GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) {
         GVStubs.insert(Name);
         O << "L" << Name << "$non_lazy_ptr";
+        if (GV->hasExternalWeakLinkage())
+          ExtWeakSymbols.insert(GV);
         return;
       }
     }
@@ -948,6 +950,16 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
       } else if (I->hasInternalLinkage()) {
         SwitchToDataSection("\t.data", I);
         O << TAI->getLCOMMDirective() << name << "," << Size << "," << Align;
+      } else if (!I->hasCommonLinkage()) {
+        O << "\t.globl " << name << "\n"
+          << TAI->getWeakDefDirective() << name << "\n";
+        SwitchToDataSection("\t.section __DATA,__datacoal_nt,coalesced", I);
+        EmitAlignment(Align, I);
+        O << name << ":\t\t\t\t" << TAI->getCommentString() << " ";
+        PrintUnmangledNameSafely(I, O);
+        O << "\n";
+        EmitGlobalConstant(C);
+        continue;
       } else {
         SwitchToDataSection("\t.data", I);
         O << ".comm " << name << "," << Size;