Skip to content

Commit d0837a6

Browse files
committed
Merge pull request #2889 from compnerd/explicit-section-name-mapping
2 parents 3334a82 + c05815a commit d0837a6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,6 @@ swift::createSwiftModuleObjectFile(SILModule &SILMod, StringRef Buffer,
912912
auto targetMachine = irgen.createTargetMachine();
913913
if (!targetMachine) return;
914914

915-
const llvm::Triple &Triple = Ctx.LangOpts.Target;
916915
IRGenModule IGM(irgen, std::move(targetMachine), nullptr, VMContext,
917916
OutputPath, Opts.getSingleOutputFilename());
918917
initLLVMModule(IGM);
@@ -924,13 +923,19 @@ swift::createSwiftModuleObjectFile(SILModule &SILMod, StringRef Buffer,
924923
llvm::GlobalVariable::InternalLinkage,
925924
Data, "__Swift_AST");
926925
std::string Section;
927-
if (Triple.isOSBinFormatMachO())
928-
Section = std::string(MachOASTSegmentName) + "," + MachOASTSectionName;
929-
else if (Triple.isOSBinFormatCOFF())
926+
switch (IGM.TargetInfo.OutputObjectFormat) {
927+
case llvm::Triple::UnknownObjectFormat:
928+
llvm_unreachable("unknown object format");
929+
case llvm::Triple::COFF:
930930
Section = COFFASTSectionName;
931-
else
931+
break;
932+
case llvm::Triple::ELF:
932933
Section = ELFASTSectionName;
933-
934+
break;
935+
case llvm::Triple::MachO:
936+
Section = std::string(MachOASTSegmentName) + "," + MachOASTSectionName;
937+
break;
938+
}
934939
ASTSym->setSection(Section);
935940
ASTSym->setAlignment(8);
936941
::performLLVM(Opts, Ctx.Diags, nullptr, nullptr, IGM.getModule(),

0 commit comments

Comments
 (0)