[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp PPCTargetAsmInfo.cpp

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



Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.230 -> 1.231
PPCTargetAsmInfo.cpp updated: 1.15 -> 1.16
---
Log message:

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

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

 PPCAsmPrinter.cpp    |    9 ++++++++-
 PPCTargetAsmInfo.cpp |    9 +++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.230 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.231
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.230	Fri Jan 26 15:22:28 2007
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp	Tue Jan 30 02:04:53 2007
@@ -855,8 +855,15 @@
     if (!I->hasInitializer()) 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 (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);
     


Index: llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.15 llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.16
--- llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.15	Mon Jan 29 12:51:14 2007
+++ llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp	Tue Jan 30 02:04:53 2007
@@ -53,8 +53,13 @@
   JumpTableDataSection = ".const";
   GlobalDirective = "\t.globl\t";
   CStringSection = "\t.cstring";
-  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";
+  }
   UsedDirective = "\t.no_dead_strip\t";
   WeakRefDirective = "\t.weak_reference\t";
   HiddenDirective = "\t.private_extern\t";






More information about the llvm-commits mailing list