Unknown = 0, ///< Custom section
Text, ///< Text section
Data, ///< Data section
+ DataRel, ///< Contains data that has relocations
+ DataRelLocal, ///< Contains data that has only local relocations
BSS, ///< BSS section
ROData, ///< Readonly data section
+ DataRelRO, ///< Contains data that is otherwise readonly
+ DataRelROLocal, ///< Contains r/o data with only local relocations
RODataMergeStr, ///< Readonly data section (mergeable strings)
RODataMergeConst, ///< Readonly data section (mergeable constants)
SmallData, ///< Small data section
TLSBSSSection = getNamedSection("\t.tbss",
SectionFlags::Writeable | SectionFlags::TLS | SectionFlags::BSS);
+ DataRelSection = getNamedSection("\t.data.rel", SectionFlags::Writeable);
+ DataRelLocalSection = getNamedSection("\t.data.rel.local",
+ SectionFlags::Writeable);
+ DataRelROSection = getNamedSection("\t.data.rel.ro",
+ SectionFlags::Writeable);
+ DataRelROLocalSection = getNamedSection("\t.data.rel.ro.local",
+ SectionFlags::Writeable);
}
const Section*
case SectionKind::Data:
case SectionKind::SmallData:
return DataSection;
+ case SectionKind::DataRel:
+ return DataRelSection;
+ case SectionKind::DataRelLocal:
+ return DataRelLocalSection;
+ case SectionKind::DataRelRO:
+ return DataRelROSection;
+ case SectionKind::DataRelROLocal:
+ return DataRelROLocalSection;
case SectionKind::BSS:
case SectionKind::SmallBSS:
// ELF targets usually have BSS sections
DataSection = getUnnamedSection("\t.data", SectionFlags::Writeable);
}
-TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm)
+TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm)
: TM(tm) {
fillDefaultValues();
}
unsigned Reloc = RelocBehaviour();
// We already did a query for 'all' relocs, thus - early exits.
- if (Reloc == Reloc::LocalOrGlobal)
- return SectionKind::Data;
- else if (Reloc == Reloc::None)
+ if (Reloc == Reloc::LocalOrGlobal) {
+ return (C->ContainsRelocations(Reloc::Local) ?
+ SectionKind::DataRelROLocal : SectionKind::DataRelRO);
+ } else if (Reloc == Reloc::None)
return SectionKind::ROData;
else {
// Ok, target wants something funny. Honour it.
- return (C->ContainsRelocations(Reloc) ?
- SectionKind::Data : SectionKind::ROData);
+ if (C->ContainsRelocations(Reloc)) {
+ return (Reloc == Reloc::Local ?
+ SectionKind::DataRelROLocal : SectionKind::DataRelRO);
+ } else
+ return SectionKind::ROData;
}
} else {
// Check, if initializer is a null-terminated string
}
}
- // Variable is not constant or thread-local - emit to generic data section.
- return (isThreadLocal ? SectionKind::ThreadData : SectionKind::Data);
+ // Variable either is not constant or thread-local - output to data section.
+ if (isThreadLocal)
+ return SectionKind::ThreadData;
+
+ if (GVar->hasInitializer()) {
+ Constant *C = GVar->getInitializer();
+ unsigned Reloc = RelocBehaviour();
+ if (Reloc != Reloc::None && C->ContainsRelocations(Reloc))
+ return (C->ContainsRelocations(Reloc::Local) ?
+ SectionKind::DataRelLocal : SectionKind::DataRel);
+ }
+
+ return SectionKind::Data;
}
unsigned
Flags |= SectionFlags::TLS;
// FALLS THROUGH
case SectionKind::Data:
+ case SectionKind::DataRel:
+ case SectionKind::DataRelLocal:
+ case SectionKind::DataRelRO:
+ case SectionKind::DataRelROLocal:
case SectionKind::BSS:
Flags |= SectionFlags::Writeable;
break;
return ".gnu.linkonce.t." + GV->getName();
case SectionKind::Data:
return ".gnu.linkonce.d." + GV->getName();
+ case SectionKind::DataRel:
+ return ".gnu.linkonce.d.rel" + GV->getName();
+ case SectionKind::DataRelLocal:
+ return ".gnu.linkonce.d.rel.local" + GV->getName();
+ case SectionKind::DataRelRO:
+ return ".gnu.linkonce.d.rel.ro" + GV->getName();
+ case SectionKind::DataRelROLocal:
+ return ".gnu.linkonce.d.rel.ro.local" + GV->getName();
case SectionKind::SmallData:
return ".gnu.linkonce.s." + GV->getName();
case SectionKind::BSS:
switch (kind) {
case SectionKind::Text:
return ".text$linkonce" + GV->getName();
- case SectionKind::Data:
- case SectionKind::BSS:
- case SectionKind::ThreadData:
- case SectionKind::ThreadBSS:
- return ".data$linkonce" + GV->getName();
case SectionKind::ROData:
case SectionKind::RODataMergeConst:
case SectionKind::RODataMergeStr:
return ".rdata$linkonce" + GV->getName();
default:
- assert(0 && "Unknown section kind");
+ return ".data$linkonce" + GV->getName();
}
return NULL;
}