Use the correct ctor/dtor section for dynamic-no-pic.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 29 Aug 2016 12:47:22 +0000 (12:47 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 29 Aug 2016 12:47:22 +0000 (12:47 +0000)
llvm-svn: 279967

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/test/CodeGen/ARM/ctor_order.ll

index fdd8dca..3bbf946 100644 (file)
@@ -474,7 +474,7 @@ TargetLoweringObjectFileMachO::TargetLoweringObjectFileMachO()
 void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx,
                                                const TargetMachine &TM) {
   TargetLoweringObjectFile::Initialize(Ctx, TM);
-  if (!TM.isPositionIndependent()) {
+  if (TM.getRelocationModel() == Reloc::Static) {
     StaticCtorSection = Ctx.getMachOSection("__TEXT", "__constructor", 0,
                                             SectionKind::getData());
     StaticDtorSection = Ctx.getMachOSection("__TEXT", "__destructor", 0,
index 6419292..7fcc8cb 100644 (file)
@@ -1,4 +1,6 @@
 ; RUN: llc < %s -mtriple=arm-apple-darwin  | FileCheck %s -check-prefix=DARWIN
+; RUN: llc < %s -mtriple=arm-apple-darwin -relocation-model=dynamic-no-pic  | FileCheck %s --check-prefix=DARWIN
+; RUN: llc < %s -mtriple=arm-apple-darwin -relocation-model=static  | FileCheck %s -check-prefix=DARWIN-STATIC
 ; RUN: llc < %s -mtriple=arm-linux-gnu     | FileCheck %s -check-prefix=ELF
 ; RUN: llc < %s -mtriple=arm-linux-gnueabi | FileCheck %s -check-prefix=GNUEABI
 
@@ -6,6 +8,8 @@
 ; DARWIN:      .long _f151
 ; DARWIN-NEXT: .long _f152
 
+; DARWIN-STATIC: .section __TEXT,__constructor
+
 ; ELF:      .section .ctors.65384,"aw",%progbits
 ; ELF:      .long    f151
 ; ELF:      .section .ctors.65383,"aw",%progbits