[llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp

Anton Korobeynikov asl at math.spbu.ru
Wed Oct 18 02:12:43 PDT 2006



Changes in directory llvm/lib/Target/X86:

X86ATTAsmPrinter.cpp updated: 1.68 -> 1.69
X86AsmPrinter.cpp updated: 1.202 -> 1.203
---
Log message:

Fixed mingw\cygwin linkonce linkage once again.
Added workaround for linker bug with linkonce sections.
Changed sections prefix to allow linker merge them 
(PE loader doesn't like too much long-named sections :) )
All of this unbreaks libstdc++ on mingw32 allowing (small)
programs to be compiled, linked and run.


---
Diffs of the changes:  (+9 -27)

 X86ATTAsmPrinter.cpp |   20 +++++++-------------
 X86AsmPrinter.cpp    |   16 ++--------------
 2 files changed, 9 insertions(+), 27 deletions(-)


Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.68 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.69
--- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.68	Tue Oct 17 15:29:49 2006
+++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp	Wed Oct 18 04:12:29 2006
@@ -40,7 +40,7 @@
     if (Subtarget->isTargetDarwin()) {
       return ".section __TEXT,__textcoal_nt,coalesced,pure_instructions";
     } else if (Subtarget->isTargetCygwin()) {
-      return "\t.section\t.llvm.linkonce.t." + CurrentFnName + ",\"ax\"\n";
+      return "\t.section\t.text$linkonce." + CurrentFnName + ",\"ax\"\n";
     } else {
       return "\t.section\t.llvm.linkonce.t." + CurrentFnName +
              ",\"ax\", at progbits\n";
@@ -90,6 +90,7 @@
     O << "\t.globl\t" << CurrentFnName << "\n";    
     break;
   case Function::LinkOnceLinkage:
+  case Function::WeakLinkage:
     if (Subtarget->isTargetDarwin()) {
       O << "\t.globl\t" << CurrentFnName << "\n";
       O << "\t.weak_definition\t" << CurrentFnName << "\n";
@@ -102,20 +103,13 @@
       O << "\t.weak " << CurrentFnName << "\n";
     }
     break;
-  case Function::WeakLinkage:
-    if (Subtarget->isTargetDarwin()) {
-      O << "\t.globl\t" << CurrentFnName << "\n";
-      O << "\t.weak_definition\t" << CurrentFnName << "\n";
-    } else if (Subtarget->isTargetCygwin()) {
-      EmitAlignment(4, F);     // FIXME: This should be parameterized somewhere.
-      O << "\t.weak " << CurrentFnName << "\n";
-    } else {
-      EmitAlignment(4, F);     // FIXME: This should be parameterized somewhere.
-      O << "\t.weak " << CurrentFnName << "\n";
-    }
-    break;
   }
   O << CurrentFnName << ":\n";
+  // Add some workaround for linkonce linkage on Cygwin\MinGW
+  if (Subtarget->isTargetCygwin() &&
+      (F->getLinkage() == Function::LinkOnceLinkage ||
+       F->getLinkage() == Function::WeakLinkage))
+    O << "_llvm$workaround$fake$stub_" << CurrentFnName << ":\n";
 
   if (Subtarget->isTargetDarwin()) {
     // Emit pre-function debug information.


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.202 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.203
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.202	Tue Oct 17 15:29:49 2006
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp	Wed Oct 18 04:12:29 2006
@@ -174,12 +174,13 @@
     } else {
       switch (I->getLinkage()) {
       case GlobalValue::LinkOnceLinkage:
+      case GlobalValue::WeakLinkage:
         if (Subtarget->isTargetDarwin()) {
           O << "\t.globl " << name << "\n"
             << "\t.weak_definition " << name << "\n";
           SwitchToDataSection(".section __DATA,__const_coal,coalesced", I);
         } else if (Subtarget->isTargetCygwin()) {
-          O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\"\n"
+          O << "\t.section\t.data$linkonce." << name << ",\"aw\"\n"
             << "\t.globl " << name << "\n"
             << "\t.linkonce same_size\n";
         } else {
@@ -187,19 +188,6 @@
             << "\t.weak " << name << "\n";
         }
         break;
-      case GlobalValue::WeakLinkage:
-        if (Subtarget->isTargetDarwin()) {
-          O << "\t.globl " << name << "\n"
-            << "\t.weak_definition " << name << "\n";
-          SwitchToDataSection(".section __DATA,__const_coal,coalesced", I);
-        } else if (Subtarget->isTargetCygwin()) {
-          O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\"\n"
-            << "\t.weak " << name << "\n";
-        } else {
-          O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\", at progbits\n"
-            << "\t.weak " << name << "\n";
-        }
-        break;
       case GlobalValue::AppendingLinkage:
         // FIXME: appending linkage variables should go into a section of
         // their name or something.  For now, just emit them as external.






More information about the llvm-commits mailing list