Use init_array/fini_array sections for static contructors/destructors when the ABI...
authorLauro Ramos Venancio <lauro.venancio@gmail.com>
Mon, 5 Mar 2007 17:59:58 +0000 (17:59 +0000)
committerLauro Ramos Venancio <lauro.venancio@gmail.com>
Mon, 5 Mar 2007 17:59:58 +0000 (17:59 +0000)
Fix SingleSource/Regression/C/ConstructorDestructorAttributes test on arm-linux-gnueabi.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34931 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMTargetAsmInfo.cpp
test/CodeGen/ARM/ctors_dtors.ll

index b4948c5b5b5a7a28696d828ea592b027c63bbfb4..ff6de2eee407c99f56b053df96f60dd2cad62bcc 100644 (file)
@@ -58,8 +58,13 @@ ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) {
   } else {
     PrivateGlobalPrefix = ".L";
     WeakRefDirective = "\t.weak\t";
-    StaticCtorsSection = "\t.section .ctors,\"aw\",%progbits";
-    StaticDtorsSection = "\t.section .dtors,\"aw\",%progbits";
+    if (Subtarget->isAAPCS_ABI()) {
+      StaticCtorsSection = "\t.section .init_array,\"aw\",%init_array";
+      StaticDtorsSection = "\t.section .fini_array,\"aw\",%fini_array";
+    } else {
+      StaticCtorsSection = "\t.section .ctors,\"aw\",%progbits";
+      StaticDtorsSection = "\t.section .dtors,\"aw\",%progbits";
+    }
   }
 
   ZeroDirective = "\t.space\t";
index b4cdf27b3cccda206750343481a289f8fced0c3b..709fb2bb3230c02dc73daab06891ebdf73cc4dc7 100644 (file)
@@ -1,8 +1,10 @@
 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm &&
 ; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-apple-darwin | grep '\.mod_init_func' &&
 ; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-apple-darwin | grep '\.mod_term_func' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux | grep '\.section \.ctors,"aw",.progbits' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux | grep '\.section \.dtors,"aw",.progbits'
+; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux-gnu | grep '\.section \.ctors,"aw",.progbits' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux-gnu | grep '\.section \.dtors,"aw",.progbits' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux-gnueabi | grep '\.section \.init_array,"aw",.init_array' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux-gnueabi  | grep '\.section \.fini_array,"aw",.fini_array'
 
 %llvm.global_ctors = appending global [1 x { int, void ()* }] [ { int, void ()* } { int 65535, void ()* %__mf_init } ]         ; <[1 x { int, void ()* }]*> [#uses=0]
 %llvm.global_dtors = appending global [1 x { int, void ()* }] [ { int, void ()* } { int 65535, void ()* %__mf_fini } ]         ; <[1 x { int, void ()* }]*> [#uses=0]