[llvm-commits] CVS: llvm/lib/Target/ARM/ARMAsmPrinter.cpp ARMTargetAsmInfo.cpp

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



Changes in directory llvm/lib/Target/ARM:

ARMAsmPrinter.cpp updated: 1.52 -> 1.53
ARMTargetAsmInfo.cpp updated: 1.9 -> 1.10
---
Log message:

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

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

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


Index: llvm/lib/Target/ARM/ARMAsmPrinter.cpp
diff -u llvm/lib/Target/ARM/ARMAsmPrinter.cpp:1.52 llvm/lib/Target/ARM/ARMAsmPrinter.cpp:1.53
--- llvm/lib/Target/ARM/ARMAsmPrinter.cpp:1.52	Mon Jan 29 20:35:32 2007
+++ llvm/lib/Target/ARM/ARMAsmPrinter.cpp	Tue Jan 30 02:04:53 2007
@@ -714,8 +714,16 @@
     if (!I->hasInitializer())   // External global require no code
       continue;
 
-    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/ARM/ARMTargetAsmInfo.cpp
diff -u llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.9 llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.10
--- llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.9	Fri Jan 26 17:24:43 2007
+++ llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp	Tue Jan 30 02:04:53 2007
@@ -28,8 +28,13 @@
     JumpTableDataSection = ".const";
     CStringSection = "\t.cstring";
     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";
+    }
     
     // In non-PIC modes, emit a special label before jump tables so that the
     // linker can perform more accurate dead code stripping.






More information about the llvm-commits mailing list