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

Evan Cheng evan.cheng at apple.com
Tue Jan 30 00:05:14 PST 2007



Changes in directory llvm/lib/Target/X86:

X86AsmPrinter.cpp updated: 1.233 -> 1.234
X86TargetAsmInfo.cpp updated: 1.30 -> 1.31
---
Log message:

Darwin -static should codegen static ctors / dtors to .constructor / .destructor sections.

---
Diffs of the changes:  (+16 -3)

 X86AsmPrinter.cpp    |   10 +++++++++-
 X86TargetAsmInfo.cpp |    9 +++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.233 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.234
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.233	Sun Jan 28 07:31:35 2007
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp	Tue Jan 30 02:04:53 2007
@@ -134,8 +134,16 @@
       continue;   // External global require no code
     
     // Check to see if this is a special global used by LLVM, if so, emit it.
-    if (EmitSpecialLLVMGlobal(I))
+    if (EmitSpecialLLVMGlobal(I)) {
+      if (Subtarget->isTargetDarwin() &&
+          TM.getRelocationModel() == Reloc::Static) {
+        if (I->getName() == "llvm.global_ctors")
+          O << ".reference .constructors_used\n";
+        else if (I->getName() == "llvm.global_dtors")
+          O << ".reference .destructors_used\n";
+      }
       continue;
+    }
     
     std::string name = Mang->getValueName(I);
     Constant *C = I->getInitializer();


Index: llvm/lib/Target/X86/X86TargetAsmInfo.cpp
diff -u llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.30 llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.31
--- llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.30	Wed Jan 17 19:15:58 2007
+++ llvm/lib/Target/X86/X86TargetAsmInfo.cpp	Tue Jan 30 02:04:53 2007
@@ -59,8 +59,13 @@
     LCOMMDirective = "\t.lcomm\t";
     COMMDirectiveTakesAlignment = false;
     HasDotTypeDotSizeDirective = false;
-    StaticCtorsSection = ".mod_init_func";
-    StaticDtorsSection = ".mod_term_func";
+    if (TM.getRelocationModel() == Reloc::Static) {
+      StaticCtorsSection = ".constructor";
+      StaticDtorsSection = ".destructor";
+    } else {
+      StaticCtorsSection = ".mod_init_func";
+      StaticDtorsSection = ".mod_term_func";
+    }
     InlineAsmStart = "# InlineAsm Start";
     InlineAsmEnd = "# InlineAsm End";
     SetDirective = "\t.set";






More information about the llvm-commits mailing list