if (K.isThreadLocal())
Flags |= ELF::SHF_TLS;
+ // FIXME: There is nothing in ELF preventing an SHF_MERGE from being
+ // in a comdat. We just avoid it for now because we don't print
+ // those .sections correctly.
if (!InCOMDAT && (K.isMergeableCString() || K.isMergeableConst()))
Flags |= ELF::SHF_MERGE;
/*EntrySize=*/0, Group);
}
-/// getSectionPrefixForGlobal - Return the section prefix name used by options
-/// FunctionsSections and DataSections.
+/// Return the section prefix name used by options FunctionsSections and
+/// DataSections.
static StringRef getSectionPrefixForGlobal(SectionKind Kind) {
- if (Kind.isText()) return ".text.";
- if (Kind.isReadOnly()) return ".rodata.";
- if (Kind.isBSS()) return ".bss.";
-
- if (Kind.isThreadData()) return ".tdata.";
- if (Kind.isThreadBSS()) return ".tbss.";
-
- if (Kind.isDataNoRel()) return ".data.";
- if (Kind.isDataRelLocal()) return ".data.rel.local.";
- if (Kind.isDataRel()) return ".data.rel.";
- if (Kind.isReadOnlyWithRelLocal()) return ".data.rel.ro.local.";
-
+ if (Kind.isText())
+ return ".text.";
+ if (Kind.isReadOnly())
+ return ".rodata.";
+ if (Kind.isBSS())
+ return ".bss.";
+ if (Kind.isThreadData())
+ return ".tdata.";
+ if (Kind.isThreadBSS())
+ return ".tbss.";
+ if (Kind.isDataNoRel())
+ return ".data.";
+ if (Kind.isDataRelLocal())
+ return ".data.rel.local.";
+ if (Kind.isDataRel())
+ return ".data.rel.";
+ if (Kind.isReadOnlyWithRelLocal())
+ return ".data.rel.ro.local.";
assert(Kind.isReadOnlyWithRel() && "Unknown section kind");
return ".data.rel.ro.";
}
return DataRelROSection;
}
+const MCSection *TargetLoweringObjectFileELF::getSectionForJumpTable(
+ const Function &F, Mangler &Mang, const TargetMachine &TM) const {
+ // If the function can be removed, produce a unique section so that
+ // the table doesn't prevent the removal.
+ const Comdat *C = F.getComdat();
+ bool EmitUniqueSection = TM.getFunctionSections() || C;
+ if (!EmitUniqueSection)
+ return ReadOnlySection;
+
+ SmallString<128> Name(".rodata.");
+ TM.getNameWithPrefix(Name, &F, Mang, true);
+
+ unsigned Flags = ELF::SHF_ALLOC;
+ StringRef Group = "";
+ if (C) {
+ Flags |= ELF::SHF_GROUP;
+ Group = C->getName();
+ }
+
+ return getContext().getELFSection(Name, ELF::SHT_PROGBITS, Flags, 0, Group);
+}
+
+bool TargetLoweringObjectFileELF::shouldPutJumpTableInFunctionSection(
+ bool UsesLabelDifference, const Function &F) const {
+ // We can always create relative relocations, so use another section
+ // that can be marked non-executable.
+ return false;
+}
+
/// getSectionForConstant - Given a mergeable constant with the
/// specified size and relocation information, return a section that it
/// should be placed in.