diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index 416084adce2..12039672439 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -908,6 +908,10 @@ bool ARMAsmPrinter::doFinalization(Module &M) { std::string SectionName = ".section " + I->getSection(); SectionName += ",\"aw\",%progbits"; SwitchToDataSection(SectionName.c_str()); + } else if (I->hasSection() && Subtarget->isTargetDarwin()) { + // Honor all section names on Darwin; ObjC uses this + std::string SectionName = ".section " + I->getSection(); + SwitchToDataSection(SectionName.c_str()); } else { if (C->isNullValue() && !NoZerosInBSS && TAI->getBSSSection()) SwitchToDataSection(I->isThreadLocal() ? TAI->getTLSBSSSection() : diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index d5367dca350..bab1af3491a 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -958,8 +958,11 @@ bool DarwinAsmPrinter::doFinalization(Module &M) { break; } } - - if (!I->isConstant()) + if (I->hasSection()) { + // Honor all section names on Darwin; ObjC uses this + std::string SectionName = ".section " + I->getSection(); + SwitchToDataSection(SectionName.c_str()); + } else if (!I->isConstant()) SwitchToDataSection(TAI->getDataSection(), I); else { // Read-only data. diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index ef8cbea590d..0b8c31cc7f6 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -275,7 +275,10 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { assert(!Subtarget->isTargetDarwin()); SectionName += ",\"aw\",@progbits"; } - + SwitchToDataSection(SectionName.c_str()); + } else if (I->hasSection() && Subtarget->isTargetDarwin()) { + // Honor all section names on Darwin; ObjC uses this + std::string SectionName = ".section " + I->getSection(); SwitchToDataSection(SectionName.c_str()); } else { if (C->isNullValue() && !NoZerosInBSS && TAI->getBSSSection())