diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index a00e361eb53..3e797123498 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -317,10 +317,17 @@ bool ARMAsmPrinter::doFinalization(Module &M) { break; } - if (C->isNullValue()) - SwitchToDataSection(".bss", I); - else - SwitchToDataSection(".data", I); + if (I->hasSection() && + (I->getSection() == ".ctors" || + I->getSection() == ".dtors")) { + std::string SectionName = ".section " + I->getSection(); + + SectionName += ",\"aw\",@progbits"; + + SwitchToDataSection(SectionName.c_str()); + } else { + SwitchToDataSection(TAI->getDataSection(), I); + } EmitAlignment(Align, I); O << "\t.type " << name << ", %object\n"; diff --git a/test/CodeGen/ARM/section.ll b/test/CodeGen/ARM/section.ll index cd33c12f410..ecda87b05bf 100644 --- a/test/CodeGen/ARM/section.ll +++ b/test/CodeGen/ARM/section.ll @@ -1,4 +1,5 @@ ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm && ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep "__DTOR_END__:" +; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep ".section .dtors,\"aw\",@progbits" %__DTOR_END__ = internal global [1 x int] zeroinitializer, section ".dtors"