const MCSectionELF *&Entry = Map[Section];
if (Entry) return Entry;
- return Entry = MCSectionELF::Create(Section, Type, Flags, Kind, HasCrazyBSS,
- IsExplicit, getContext());
+ return Entry = MCSectionELF::Create(Section, Type, Flags, Kind, IsExplicit,
+ getContext());
}
void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
const TargetMachine &TM) {
+ if (UniquingMap != 0)
+ ((ELFUniqueMapTy*)UniquingMap)->clear();
TargetLoweringObjectFile::Initialize(Ctx, TM);
BSSSection =
MCSectionELF::SHF_ALLOC, SectionKind::getReadOnly());
EHFrameSection =
getELFSection(".eh_frame", MCSectionELF::SHT_PROGBITS,
- MCSectionELF::SHF_ALLOC, SectionKind::getDataRel());
+ MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE,
+ SectionKind::getDataRel());
// Debug Info Sections.
DwarfAbbrevSection =
static unsigned
getELFSectionType(const char *Name, SectionKind K) {
- if (strncmp(Name, ".init_array", 11) == 0)
+ if (strcmp(Name, ".init_array") == 0)
return MCSectionELF::SHT_INIT_ARRAY;
- if (strncmp(Name, ".fini_array", 11) == 0)
+ if (strcmp(Name, ".fini_array") == 0)
return MCSectionELF::SHT_FINI_ARRAY;
- if (strncmp(Name, ".preinit_array", 14) == 0)
+ if (strcmp(Name, ".preinit_array") == 0)
return MCSectionELF::SHT_PREINIT_ARRAY;
if (K.isBSS() || K.isThreadBSS())
if (!K.isMetadata())
Flags |= MCSectionELF::SHF_ALLOC;
+ if (K.isText())
+ Flags |= MCSectionELF::SHF_EXECINSTR;
+
if (K.isWriteable())
Flags |= MCSectionELF::SHF_WRITE;
}
if (Kind.isMergeableConst()) {
- if (Kind.isMergeableConst4())
+ if (Kind.isMergeableConst4() && MergeableConst4Section)
return MergeableConst4Section;
- if (Kind.isMergeableConst8())
+ if (Kind.isMergeableConst8() && MergeableConst8Section)
return MergeableConst8Section;
- if (Kind.isMergeableConst16())
+ if (Kind.isMergeableConst16() && MergeableConst16Section)
return MergeableConst16Section;
return ReadOnlySection; // .const
}
/// should be placed in.
const MCSection *TargetLoweringObjectFileELF::
getSectionForConstant(SectionKind Kind) const {
- if (Kind.isMergeableConst4())
+ if (Kind.isMergeableConst4() && MergeableConst4Section)
return MergeableConst4Section;
- if (Kind.isMergeableConst8())
+ if (Kind.isMergeableConst8() && MergeableConst8Section)
return MergeableConst8Section;
- if (Kind.isMergeableConst16())
+ if (Kind.isMergeableConst16() && MergeableConst16Section)
return MergeableConst16Section;
if (Kind.isReadOnly())
return ReadOnlySection;
// Form the name to look up.
SmallString<64> Name;
- Name.append(Segment.begin(), Segment.end());
+ Name += Segment;
Name.push_back(',');
- Name.append(Section.begin(), Section.end());
+ Name += Section;
// Do the lookup, if we have a hit, return it.
- const MCSectionMachO *&Entry = Map[StringRef(Name.data(), Name.size())];
+ const MCSectionMachO *&Entry = Map[Name.str()];
if (Entry) return Entry;
// Otherwise, return a new section.
void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx,
const TargetMachine &TM) {
+ if (UniquingMap != 0)
+ ((MachOUniqueMapTy*)UniquingMap)->clear();
TargetLoweringObjectFile::Initialize(Ctx, TM);
TextSection // .text
void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,
const TargetMachine &TM) {
+ if (UniquingMap != 0)
+ ((COFFUniqueMapTy*)UniquingMap)->clear();
TargetLoweringObjectFile::Initialize(Ctx, TM);
TextSection = getCOFFSection("\t.text", true, SectionKind::getText());
DataSection = getCOFFSection("\t.data", true, 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.