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

Evan Cheng evan.cheng at apple.com
Mon Oct 30 17:27:09 PST 2006



Changes in directory llvm/lib/Target/X86:

X86AsmPrinter.cpp updated: 1.208 -> 1.209
---
Log message:

Apply Aton's LLVM patch for PR973: http://llvm.org/PR973 : Linux ctors / dtors support.

---
Diffs of the changes:  (+22 -4)

 X86AsmPrinter.cpp |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.208 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.209
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.208	Mon Oct 30 16:32:30 2006
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp	Mon Oct 30 19:26:55 2006
@@ -145,10 +145,11 @@
     unsigned Align = TD->getPreferredAlignmentLog(I);
 
     if (C->isNullValue() && /* FIXME: Verify correct */
+        !I->hasSection() &&
         (I->hasInternalLinkage() || I->hasWeakLinkage() ||
          I->hasLinkOnceLinkage() ||
          (Subtarget->isTargetDarwin() && 
-          I->hasExternalLinkage() && !I->hasSection()))) {
+          I->hasExternalLinkage()))) {
       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
       if (I->hasExternalLinkage()) {
           O << "\t.globl\t" << name << "\n";
@@ -185,14 +186,14 @@
         } else if (Subtarget->isTargetCygwin()) {
           std::string SectionName(".section\t.data$linkonce." +
                                   name +
-                                  ",\"aw\"\n");
+                                  ",\"aw\"");
           SwitchToDataSection(SectionName.c_str(), I);
           O << "\t.globl " << name << "\n"
             << "\t.linkonce same_size\n";
         } else {
           std::string SectionName("\t.section\t.llvm.linkonce.d." +
                                   name +
-                                  ",\"aw\", at progbits\n");
+                                  ",\"aw\", at progbits");
           SwitchToDataSection(SectionName.c_str(), I);
           O << "\t.weak " << name << "\n";
         }
@@ -215,7 +216,24 @@
             break;
           }
         }
-        SwitchToDataSection(TAI->getDataSection(), I);
+        // FIXME: special handling for ".ctors" & ".dtors" sections
+        if (I->hasSection() &&
+            (I->getSection() == ".ctors" ||
+             I->getSection() == ".dtors")) {
+          std::string SectionName = ".section " + I->getSection();
+          
+          if (Subtarget->isTargetCygwin()) {
+            SectionName += ",\"aw\"";
+          } else {
+            assert(!Subtarget->isTargetDarwin());
+            SectionName += ",\"aw\", at progbits";
+          }
+
+          SwitchToDataSection(SectionName.c_str());
+        } else {
+          SwitchToDataSection(TAI->getDataSection(), I);
+        }
+        
         break;
       }
       default:






More information about the llvm-commits mailing list