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);
+}
+
+SectionKind::Kind
+ELFTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
+ SectionKind::Kind Kind = TargetAsmInfo::SectionKindForGlobal(GV);
+
+ if (Kind != SectionKind::Data)
+ return Kind;
+
+ // Decide, whether we need data.rel stuff
+ const GlobalVariable* GVar = dyn_cast<GlobalVariable>(GV);
+ if (GVar->hasInitializer()) {
+ Constant *C = GVar->getInitializer();
+ bool isConstant = GVar->isConstant();
+ unsigned Reloc = RelocBehaviour();
+ if (Reloc != Reloc::None && C->ContainsRelocations(Reloc))
+ return (C->ContainsRelocations(Reloc::Global) ?
+ (isConstant ?
+ SectionKind::DataRelRO : SectionKind::DataRel) :
+ (isConstant ?
+ SectionKind::DataRelROLocal : SectionKind::DataRelLocal));
+ }
+
+ return Kind;
}
const Section*
case Function::DLLExportLinkage:
case Function::ExternalLinkage:
return TextSection;
- case Function::WeakLinkage:
- case Function::LinkOnceLinkage:
+ case Function::WeakAnyLinkage:
+ case Function::WeakODRLinkage:
+ case Function::LinkOnceAnyLinkage:
+ case Function::LinkOnceODRLinkage:
std::string Name = UniqueSectionForGlobal(GV, Kind);
unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str());
return getNamedSection(Name.c_str(), Flags);
}
} else if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV)) {
- if (GVar->mayBeOverridden()) {
+ if (GVar->isWeakForLinker()) {
std::string Name = UniqueSectionForGlobal(GVar, Kind);
unsigned Flags = SectionFlagsForGlobal(GVar, Name.c_str());
return getNamedSection(Name.c_str(), Flags);
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
// FIXME: string here is temporary, until stuff will fully land in.
// We cannot use {Four,Eight,Sixteen}ByteConstantSection here, since it's
// currently directly used by asmprinter.
- unsigned Size = TD->getTypePaddedSize(Ty);
+ unsigned Size = TD->getTypeAllocSize(Ty);
if (Size == 4 || Size == 8 || Size == 16) {
std::string Name = ".rodata.cst" + utostr(Size);
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
const Type *Ty = cast<ArrayType>(C->getType())->getElementType();
- unsigned Size = TD->getTypePaddedSize(Ty);
+ unsigned Size = TD->getTypeAllocSize(Ty);
if (Size <= 16) {
assert(getCStringSection() && "Should have string section prefix");