/// section with the section name and this suffix printed.
const char *SectionEndDirectiveSuffix;// Defaults to null.
- /// JumpTableDataSection - This is the section that we SwitchToSection right
- /// before emitting the jump tables for a function when the relocation model
- /// is not PIC.
- const char *JumpTableDataSection; // Defaults to "\t.section .rodata"
-
/// JumpTableDirective - if non-null, the directive to emit before a jump
/// table.
const char *JumpTableDirective;
const char *getSectionEndDirectiveSuffix() const {
return SectionEndDirectiveSuffix;
}
- const char *getJumpTableDataSection() const {
- return JumpTableDataSection;
- }
const char *getStaticCtorsSection() const {
return StaticCtorsSection;
}
const MCSection *BSSSection;
/// ReadOnlySection - Section that is readonly and can contain arbitrary
- /// initialized data.
+ /// initialized data. Targets are not required to have a readonly section.
+ /// If they don't, various bits of code will fall back to using the data
+ /// section for constants.
const MCSection *ReadOnlySection;
public:
return GV != 0;
}
- /// getSectionForMergeableConstant - Given a mergeable constant with the
- /// specified size and relocation information, return a section that it
- /// should be placed in.
- virtual const MCSection *
- getSectionForMergeableConstant(SectionKind Kind) const;
+ /// getSectionForConstant - Given a constant with the SectionKind, return a
+ /// section that it should be placed in.
+ virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
/// getKindForNamedSection - If this target wants to be able to override
/// section flags based on the name of the section specified for a global
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
- /// getSectionForMergeableConstant - Given a mergeable constant with the
- /// specified size and relocation information, return a section that it
- /// should be placed in.
- virtual const MCSection *
- getSectionForMergeableConstant(SectionKind Kind) const;
+ /// getSectionForConstant - Given a constant with the SectionKind, return a
+ /// section that it should be placed in.
+ virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
virtual SectionKind getKindForNamedSection(const char *Section,
SectionKind K) const;
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const;
- virtual const MCSection *
- getSectionForMergeableConstant(SectionKind Kind) const;
+ virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
/// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
/// decide not to emit the UsedDirective for some symbols in llvm.used.
}
}
- const MCSection *S =
- getObjFileLowering().getSectionForMergeableConstant(Kind);
+ const MCSection *S = getObjFileLowering().getSectionForConstant(Kind);
// The number of sections are small, just do a linear search from the
// last section to the first.
// the appropriate section.
TargetLowering *LoweringInfo = TM.getTargetLowering();
- const char *JumpTableDataSection = TAI->getJumpTableDataSection();
const Function *F = MF.getFunction();
-
- const MCSection *FuncSection =
- getObjFileLowering().SectionForGlobal(F, Mang, TM);
-
bool JTInDiffSection = false;
- if ((IsPic && !LoweringInfo->usesGlobalOffsetTable()) ||
- !JumpTableDataSection || F->isWeakForLinker()) {
+ if (F->isWeakForLinker() ||
+ (IsPic && !LoweringInfo->usesGlobalOffsetTable())) {
// In PIC mode, we need to emit the jump table to the same section as the
// function body itself, otherwise the label differences won't make sense.
// We should also do if the section name is NULL or function is declared in
// discardable section.
- SwitchToSection(FuncSection);
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
} else {
- SwitchToDataSection(JumpTableDataSection);
+ // Otherwise, drop it in the readonly section.
+ const MCSection *ReadOnlySection =
+ getObjFileLowering().getSectionForConstant(
+ SectionKind::get(SectionKind::ReadOnly));
+ SwitchToSection(ReadOnlySection);
JTInDiffSection = true;
}
// Get jump table section on the section name returned by TAI
ELFSection &ELFWriter::getJumpTableSection() {
unsigned Align = TM.getTargetData()->getPointerABIAlignment();
- return getSection(TAI->getJumpTableDataSection(),
+
+ const TargetLoweringObjectFile &TLOF =
+ TM.getTargetLowering()->getObjFileLowering();
+
+ return getSection(TLOF.getSectionForConstant(
+ SectionKind::get(SectionKind::ReadOnly))
+ ->getName(),
ELFSection::SHT_PROGBITS,
ELFSection::SHF_ALLOC, Align);
}
const TargetLoweringObjectFile &TLOF =
TM.getTargetLowering()->getObjFileLowering();
- return getSection(TLOF.getSectionForMergeableConstant(Kind)->getName(),
+ return getSection(TLOF.getSectionForConstant(Kind)->getName(),
ELFSection::SHT_PROGBITS,
ELFSection::SHF_MERGE | ELFSection::SHF_ALLOC,
CPE.getAlignment());
HiddenDirective = "\t.private_extern ";
// Sections:
- JumpTableDataSection = "\t.const";
-
if (TM.getRelocationModel() == Reloc::Static) {
StaticCtorsSection = ".constructor";
StaticDtorsSection = ".destructor";
TextSectionStartSuffix = "";
DataSectionStartSuffix = "";
SectionEndDirectiveSuffix = 0;
- JumpTableDataSection = "\t.section .rodata";
JumpTableDirective = 0;
// FIXME: Flags are ELFish - replace with normal section stuff.
StaticCtorsSection = "\t.section .ctors,\"aw\",@progbits";
return getDataSection();
}
-/// getSectionForMergableConstant - Given a mergable constant with the
+/// getSectionForConstant - Given a mergable constant with the
/// specified size and relocation information, return a section that it
/// should be placed in.
const MCSection *
-TargetLoweringObjectFile::
-getSectionForMergeableConstant(SectionKind Kind) const {
+TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const {
if (Kind.isReadOnly() && ReadOnlySection != 0)
return ReadOnlySection;
return DataRelROSection;
}
-/// getSectionForMergeableConstant - Given a mergeable constant with the
+/// getSectionForConstant - Given a mergeable constant with the
/// specified size and relocation information, return a section that it
/// should be placed in.
const MCSection *TargetLoweringObjectFileELF::
-getSectionForMergeableConstant(SectionKind Kind) const {
+getSectionForConstant(SectionKind Kind) const {
if (Kind.isMergeableConst4())
return MergeableConst4Section;
if (Kind.isMergeableConst8())
}
const MCSection *
-TargetLoweringObjectFileMachO::
-getSectionForMergeableConstant(SectionKind Kind) const {
+TargetLoweringObjectFileMachO::getSectionForConstant(SectionKind Kind) const {
// If this constant requires a relocation, we have to put it in the data
// segment, not in the text segment.
if (Kind.isDataRel())
AlignmentIsInBytes = true;
- JumpTableDataSection = NULL;
SwitchToSectionDirective = "";
TextSectionStartSuffix = "\tSEGMENT PARA 'CODE'";
DataSectionStartSuffix = "\tSEGMENT PARA 'DATA'";
Data64bitsDirective = 0;
ZeroDirective = "\t.space\t";
CommentString = "#";
- JumpTableDataSection = "\t.section\t.dp.data,\"awd\",@progbits";
+
PrivateGlobalPrefix = ".L";
AscizDirective = ".asciiz";
WeakDefDirective = "\t.weak\t";