diff options
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 5859937..941e6a2 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1889,11 +1889,24 @@ static MCSectionCOFF *getCOFFStaticStructorSection(MCContext &Ctx, // string that sorts between .CRT$XCA and .CRT$XCU. In the general case, we // make a name like ".CRT$XCT12345", since that runs before .CRT$XCU. Really // low priorities need to sort before 'L', since the CRT uses that - // internally, so we use ".CRT$XCA00001" for them. + // internally, so we use ".CRT$XCA00001" for them. We have a contract with + // the frontend that "init_seg(compiler)" corresponds to priority 200 and + // "init_seg(lib)" corresponds to priority 400, and those respectively use + // 'C' and 'L' without the priority suffix. Priorities between 200 and 400 + // use 'C' with the priority as a suffix. SmallString<24> Name; + char LastLetter = 'T'; + bool AddPrioritySuffix = Priority != 200 && Priority != 400; + if (Priority < 200) + LastLetter = 'A'; + else if (Priority < 400) + LastLetter = 'C'; + else if (Priority == 400) + LastLetter = 'L'; raw_svector_ostream OS(Name); - OS << ".CRT$X" << (IsCtor ? "C" : "T") << - (Priority < 200 ? 'A' : 'T') << format("%05u", Priority); + OS << ".CRT$X" << (IsCtor ? "C" : "T") << LastLetter; + if (AddPrioritySuffix) + OS << format("%05u", Priority); MCSectionCOFF *Sec = Ctx.getCOFFSection( Name, COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ, SectionKind::getReadOnly()); |