diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/DarwinTargetAsmInfo.cpp | 18 | ||||
-rw-r--r-- | lib/Target/ELFTargetAsmInfo.cpp | 65 | ||||
-rw-r--r-- | lib/Target/TargetAsmInfo.cpp | 26 | ||||
-rw-r--r-- | lib/Target/X86/X86TargetAsmInfo.cpp | 2 |
4 files changed, 57 insertions, 54 deletions
diff --git a/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp index 1356f671e0..7321b187dd 100644 --- a/lib/Target/DarwinTargetAsmInfo.cpp +++ b/lib/Target/DarwinTargetAsmInfo.cpp @@ -127,12 +127,12 @@ bool DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV, const Section* DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind) const { - assert(!Kind.isTLS() && "Darwin doesn't support TLS"); + assert(!Kind.isThreadLocal() && "Darwin doesn't support TLS"); // FIXME: Use sectionflags:linkonce instead of isWeakForLinker() here. bool isWeak = GV->isWeakForLinker(); - if (Kind.isCode()) + if (Kind.isText()) return isWeak ? TextCoalSection : TextSection; // If this is weak/linkonce, put this in a coalescable section, either in text @@ -144,24 +144,24 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV, } // FIXME: Alignment check should be handled by section classifier. - if (Kind.isMergableString()) + if (Kind.isMergableCString()) return MergeableStringSection(cast<GlobalVariable>(GV)); - if (Kind.isMergableConstant()) { + if (Kind.isMergableConst()) { const Type *Ty = cast<GlobalVariable>(GV)->getInitializer()->getType(); const TargetData *TD = TM.getTargetData(); return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0); } - - // If this is marked const, put it into a const section. But if the dynamic - // linker needs to write to it, put it in the data segment. - if (Kind.isReadOnlyWithDynamicInit()) - return ConstDataSection; // FIXME: ROData -> const in -static mode that is relocatable but they happen // by the static linker. Why not mergable? if (Kind.isReadOnly()) return getReadOnlySection(); + + // If this is marked const, put it into a const section. But if the dynamic + // linker needs to write to it, put it in the data segment. + if (Kind.isReadOnlyWithRel()) + return ConstDataSection; // Otherwise, just drop the variable in the normal data section. return DataSection; diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp index 880dfbc0a9..c4011098b8 100644 --- a/lib/Target/ELFTargetAsmInfo.cpp +++ b/lib/Target/ELFTargetAsmInfo.cpp @@ -49,28 +49,30 @@ ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM) const Section* ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind) const { - switch (Kind.getKind()) { - default: llvm_unreachable("Unknown section kind"); - case SectionKind::Text: return TextSection; - case SectionKind::BSS: return getBSSSection_(); - case SectionKind::Data: return DataSection; - case SectionKind::DataRel: return DataRelSection; - case SectionKind::DataRelLocal: return DataRelLocalSection; - case SectionKind::DataRelRO: return DataRelROSection; - case SectionKind::DataRelROLocal: return DataRelROLocalSection; - case SectionKind::ROData: return getReadOnlySection(); - case SectionKind::RODataMergeStr: + if (Kind.isText()) return TextSection; + if (Kind.isMergableCString()) return MergeableStringSection(cast<GlobalVariable>(GV)); - case SectionKind::RODataMergeConst: { + if (Kind.isMergableConst()) { const Type *Ty = cast<GlobalVariable>(GV)->getInitializer()->getType(); const TargetData *TD = TM.getTargetData(); return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0); } - case SectionKind::ThreadData: - return TLSDataSection; - case SectionKind::ThreadBSS: - return TLSBSSSection; - } + if (Kind.isReadOnly()) return getReadOnlySection(); + + + if (Kind.isThreadData()) return TLSDataSection; + if (Kind.isThreadBSS()) return TLSBSSSection; + + if (Kind.isBSS()) return getBSSSection_(); + + + if (Kind.isDataNoRel()) return DataSection; + if (Kind.isDataRelLocal()) return DataRelLocalSection; + if (Kind.isDataRel()) return DataRelSection; + if (Kind.isReadOnlyWithRelLocal()) return DataRelROLocalSection; + + assert(Kind.isReadOnlyWithRel() && "Unknown section kind"); + return DataRelROSection; } /// getSectionForMergableConstant - Given a mergable constant with the @@ -129,21 +131,20 @@ unsigned ELFTargetAsmInfo::getFlagsForNamedSection(const char *Name) const { const char * ELFTargetAsmInfo::getSectionPrefixForUniqueGlobal(SectionKind Kind) const{ - switch (Kind.getKind()) { - default: llvm_unreachable("Unknown section kind"); - case SectionKind::Text: return ".gnu.linkonce.t."; - case SectionKind::Data: return ".gnu.linkonce.d."; - case SectionKind::DataRel: return ".gnu.linkonce.d.rel."; - case SectionKind::DataRelLocal: return ".gnu.linkonce.d.rel.local."; - case SectionKind::DataRelRO: return ".gnu.linkonce.d.rel.ro."; - case SectionKind::DataRelROLocal: return ".gnu.linkonce.d.rel.ro.local."; - case SectionKind::BSS: return ".gnu.linkonce.b."; - case SectionKind::ROData: - case SectionKind::RODataMergeConst: - case SectionKind::RODataMergeStr: return ".gnu.linkonce.r."; - case SectionKind::ThreadData: return ".gnu.linkonce.td."; - case SectionKind::ThreadBSS: return ".gnu.linkonce.tb."; - } + if (Kind.isText()) return ".gnu.linkonce.t."; + if (Kind.isReadOnly()) return ".gnu.linkonce.r."; + + if (Kind.isThreadData()) return ".gnu.linkonce.td."; + if (Kind.isThreadBSS()) return ".gnu.linkonce.tb."; + + if (Kind.isBSS()) return ".gnu.linkonce.b."; + if (Kind.isDataNoRel()) return ".gnu.linkonce.d."; + if (Kind.isDataRelLocal()) return ".gnu.linkonce.d.rel.local."; + if (Kind.isDataRel()) return ".gnu.linkonce.d.rel."; + if (Kind.isReadOnlyWithRelLocal()) return ".gnu.linkonce.d.rel.ro.local."; + + assert(Kind.isReadOnlyWithRel() && "Unknown section kind"); + return ".gnu.linkonce.d.rel.ro."; } diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp index c3fb942865..02e01be5df 100644 --- a/lib/Target/TargetAsmInfo.cpp +++ b/lib/Target/TargetAsmInfo.cpp @@ -204,11 +204,11 @@ static unsigned SectionFlagsForGlobal(const GlobalValue *GV, unsigned Flags = SectionFlags::None; if (GV->isWeakForLinker()) Flags |= SectionFlags::Linkonce; - if (Kind.isBSS()) + if (Kind.isBSS() || Kind.isThreadBSS()) Flags |= SectionFlags::BSS; - if (Kind.isTLS()) + if (Kind.isThreadLocal()) Flags |= SectionFlags::TLS; - if (Kind.isCode()) + if (Kind.isText()) Flags |= SectionFlags::Code; if (Kind.isWritable()) Flags |= SectionFlags::Writable; @@ -247,32 +247,32 @@ static SectionKind SectionKindForGlobal(const GlobalValue *GV, // If initializer is a null-terminated string, put it in a "cstring" // section if the target has it. if (isConstantString(C)) - return SectionKind::getRODataMergeStr(); + return SectionKind::getMergableCString(); // Otherwise, just drop it into a mergable constant section. - return SectionKind::getRODataMergeConst(); + return SectionKind::getMergableConst(); case Constant::LocalRelocation: // In static relocation model, the linker will resolve all addresses, so // the relocation entries will actually be constants by the time the app // starts up. if (ReloModel == Reloc::Static) - return SectionKind::getROData(); + return SectionKind::getReadOnly(); // Otherwise, the dynamic linker needs to fix it up, put it in the // writable data.rel.local section. - return SectionKind::getDataRelROLocal(); + return SectionKind::getReadOnlyWithRelLocal(); case Constant::GlobalRelocations: // In static relocation model, the linker will resolve all addresses, so // the relocation entries will actually be constants by the time the app // starts up. if (ReloModel == Reloc::Static) - return SectionKind::getROData(); + return SectionKind::getReadOnly(); // Otherwise, the dynamic linker needs to fix it up, put it in the // writable data.rel section. - return SectionKind::getDataRelRO(); + return SectionKind::getReadOnlyWithRel(); } } @@ -282,11 +282,11 @@ static SectionKind SectionKindForGlobal(const GlobalValue *GV, // globals together onto fewer pages, improving the locality of the dynamic // linker. if (ReloModel == Reloc::Static) - return SectionKind::getData(); + return SectionKind::getDataNoRel(); switch (C->getRelocationInfo()) { default: llvm_unreachable("unknown relocation info kind"); - case Constant::NoRelocation: return SectionKind::getData(); + case Constant::NoRelocation: return SectionKind::getDataNoRel(); case Constant::LocalRelocation: return SectionKind::getDataRelLocal(); case Constant::GlobalRelocations: return SectionKind::getDataRel(); } @@ -342,7 +342,9 @@ const Section *TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const { const Section* TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind) const { - if (Kind.isCode()) + assert(!Kind.isThreadLocal() && "Doesn't support TLS"); + + if (Kind.isText()) return getTextSection(); if (Kind.isBSS()) diff --git a/lib/Target/X86/X86TargetAsmInfo.cpp b/lib/Target/X86/X86TargetAsmInfo.cpp index 39dfb00230..9e7973aaa0 100644 --- a/lib/Target/X86/X86TargetAsmInfo.cpp +++ b/lib/Target/X86/X86TargetAsmInfo.cpp @@ -267,7 +267,7 @@ X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason, const char *X86COFFTargetAsmInfo:: getSectionPrefixForUniqueGlobal(SectionKind Kind) const { - if (Kind.isCode()) + if (Kind.isText()) return ".text$linkonce"; if (Kind.isWritable()) return ".data$linkonce"; |