Move code only used by codegen out of MC. NFC.
MC itself never needs to know about these sections. llvm-svn: 279965
This commit is contained in:
@@ -446,13 +446,20 @@ const MCExpr *TargetLoweringObjectFileELF::lowerRelativeReference(
|
||||
void
|
||||
TargetLoweringObjectFileELF::InitializeELF(bool UseInitArray_) {
|
||||
UseInitArray = UseInitArray_;
|
||||
if (!UseInitArray)
|
||||
return;
|
||||
MCContext &Ctx = getContext();
|
||||
if (!UseInitArray) {
|
||||
StaticCtorSection = Ctx.getELFSection(".ctors", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_WRITE);
|
||||
|
||||
StaticCtorSection = getContext().getELFSection(
|
||||
".init_array", ELF::SHT_INIT_ARRAY, ELF::SHF_WRITE | ELF::SHF_ALLOC);
|
||||
StaticDtorSection = getContext().getELFSection(
|
||||
".fini_array", ELF::SHT_FINI_ARRAY, ELF::SHF_WRITE | ELF::SHF_ALLOC);
|
||||
StaticDtorSection = Ctx.getELFSection(".dtors", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_WRITE);
|
||||
return;
|
||||
}
|
||||
|
||||
StaticCtorSection = Ctx.getELFSection(".init_array", ELF::SHT_INIT_ARRAY,
|
||||
ELF::SHF_WRITE | ELF::SHF_ALLOC);
|
||||
StaticDtorSection = Ctx.getELFSection(".fini_array", ELF::SHT_FINI_ARRAY,
|
||||
ELF::SHF_WRITE | ELF::SHF_ALLOC);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -464,6 +471,24 @@ TargetLoweringObjectFileMachO::TargetLoweringObjectFileMachO()
|
||||
SupportIndirectSymViaGOTPCRel = true;
|
||||
}
|
||||
|
||||
void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx,
|
||||
const TargetMachine &TM) {
|
||||
TargetLoweringObjectFile::Initialize(Ctx, TM);
|
||||
if (!TM.isPositionIndependent()) {
|
||||
StaticCtorSection = Ctx.getMachOSection("__TEXT", "__constructor", 0,
|
||||
SectionKind::getData());
|
||||
StaticDtorSection = Ctx.getMachOSection("__TEXT", "__destructor", 0,
|
||||
SectionKind::getData());
|
||||
} else {
|
||||
StaticCtorSection = Ctx.getMachOSection("__DATA", "__mod_init_func",
|
||||
MachO::S_MOD_INIT_FUNC_POINTERS,
|
||||
SectionKind::getData());
|
||||
StaticDtorSection = Ctx.getMachOSection("__DATA", "__mod_term_func",
|
||||
MachO::S_MOD_TERM_FUNC_POINTERS,
|
||||
SectionKind::getData());
|
||||
}
|
||||
}
|
||||
|
||||
/// emitModuleFlags - Perform code emission for module flags.
|
||||
void TargetLoweringObjectFileMachO::
|
||||
emitModuleFlags(MCStreamer &Streamer,
|
||||
@@ -1052,6 +1077,31 @@ emitModuleFlags(MCStreamer &Streamer,
|
||||
}
|
||||
}
|
||||
|
||||
void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,
|
||||
const TargetMachine &TM) {
|
||||
TargetLoweringObjectFile::Initialize(Ctx, TM);
|
||||
const Triple &T = TM.getTargetTriple();
|
||||
if (T.isKnownWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) {
|
||||
StaticCtorSection =
|
||||
Ctx.getCOFFSection(".CRT$XCU", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
||||
COFF::IMAGE_SCN_MEM_READ,
|
||||
SectionKind::getReadOnly());
|
||||
StaticDtorSection =
|
||||
Ctx.getCOFFSection(".CRT$XTX", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
||||
COFF::IMAGE_SCN_MEM_READ,
|
||||
SectionKind::getReadOnly());
|
||||
} else {
|
||||
StaticCtorSection = Ctx.getCOFFSection(
|
||||
".ctors", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
||||
COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
|
||||
SectionKind::getData());
|
||||
StaticDtorSection = Ctx.getCOFFSection(
|
||||
".dtors", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
||||
COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
|
||||
SectionKind::getData());
|
||||
}
|
||||
}
|
||||
|
||||
MCSection *TargetLoweringObjectFileCOFF::getStaticCtorSection(
|
||||
unsigned Priority, const MCSymbol *KeySym) const {
|
||||
return getContext().getAssociativeCOFFSection(
|
||||
|
||||
Reference in New Issue
Block a user