Newer
Older
Chris Lattner
committed
const MCSectionCOFF *&Entry = Map[Name];
if (Entry) return Entry;
Chris Lattner
committed
return Entry = MCSectionCOFF::Create(Name, isDirective, Kind, getContext());
}
void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,
const TargetMachine &TM) {
Benjamin Kramer
committed
if (UniquingMap != 0)
((COFFUniqueMapTy*)UniquingMap)->clear();
TargetLoweringObjectFile::Initialize(Ctx, TM);
TextSection = getCOFFSection("\t.text", true, SectionKind::getText());
DataSection = getCOFFSection("\t.data", true, SectionKind::getDataRel());
StaticCtorSection =
getCOFFSection(".ctors", false, SectionKind::getDataRel());
StaticDtorSection =
getCOFFSection(".dtors", false, SectionKind::getDataRel());
// FIXME: We're emitting LSDA info into a readonly section on COFF, even
// though it contains relocatable pointers. In PIC mode, this is probably a
// big runtime hit for C++ apps. Either the contents of the LSDA need to be
// adjusted or this should be a data section.
LSDASection =
getCOFFSection(".gcc_except_table", false, SectionKind::getReadOnly());
EHFrameSection =
getCOFFSection(".eh_frame", false, SectionKind::getDataRel());
// Debug info.
// FIXME: Don't use 'directive' mode here.
getCOFFSection("\t.section\t.debug_abbrev,\"dr\"",
true, SectionKind::getMetadata());
getCOFFSection("\t.section\t.debug_info,\"dr\"",
true, SectionKind::getMetadata());
getCOFFSection("\t.section\t.debug_line,\"dr\"",
true, SectionKind::getMetadata());
getCOFFSection("\t.section\t.debug_frame,\"dr\"",
true, SectionKind::getMetadata());
DwarfPubNamesSection =
getCOFFSection("\t.section\t.debug_pubnames,\"dr\"",
true, SectionKind::getMetadata());
DwarfPubTypesSection =
getCOFFSection("\t.section\t.debug_pubtypes,\"dr\"",
true, SectionKind::getMetadata());
getCOFFSection("\t.section\t.debug_str,\"dr\"",
true, SectionKind::getMetadata());
getCOFFSection("\t.section\t.debug_loc,\"dr\"",
true, SectionKind::getMetadata());
getCOFFSection("\t.section\t.debug_aranges,\"dr\"",
true, SectionKind::getMetadata());
getCOFFSection("\t.section\t.debug_ranges,\"dr\"",
true, SectionKind::getMetadata());
getCOFFSection("\t.section\t.debug_macinfo,\"dr\"",
true, SectionKind::getMetadata());
}
const MCSection *TargetLoweringObjectFileCOFF::
getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const {
return getCOFFSection(GV->getSection().c_str(), false, Kind);
static const char *getCOFFSectionPrefixForUniqueGlobal(SectionKind Kind) {
if (Kind.isText())
return ".text$linkonce";
if (Kind.isWriteable())
return ".data$linkonce";
return ".rdata$linkonce";
}
const MCSection *TargetLoweringObjectFileCOFF::
Chris Lattner
committed
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const {
Chris Lattner
committed
assert(!Kind.isThreadLocal() && "Doesn't support TLS");
// If this global is linkonce/weak and the target handles this by emitting it
// into a 'uniqued' section name, create and return the section now.
Chris Lattner
committed
const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Kind);
SmallString<128> Name(Prefix, Prefix+strlen(Prefix));
Mang->getNameWithPrefix(Name, GV, false);
return getCOFFSection(Name.str(), false, Kind);
}
Chris Lattner
committed
if (Kind.isText())
return getTextSection();
return getDataSection();
}