From 6e61a44470e3cd3076b137ba709e4e177779ab4d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 29 Aug 2016 12:47:22 +0000 Subject: [PATCH] Use the correct ctor/dtor section for dynamic-no-pic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279967 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 2 +- test/CodeGen/ARM/ctor_order.ll | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index fdd8dca5b9f..3bbf9469a89 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -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, diff --git a/test/CodeGen/ARM/ctor_order.ll b/test/CodeGen/ARM/ctor_order.ll index 6419292280f..7fcc8cba0c8 100644 --- a/test/CodeGen/ARM/ctor_order.ll +++ b/test/CodeGen/ARM/ctor_order.ll @@ -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 -- 2.11.0