From: Rafael Espindola Date: Thu, 29 Jan 2015 17:33:21 +0000 (+0000) Subject: Compute the ELF SectionKind from the flags. X-Git-Tag: llvmorg-3.7.0-rc1~13705 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba31e27f0adb88edffeacd8c18fc760ce7e0a640;p=platform%2Fupstream%2Fllvm.git Compute the ELF SectionKind from the flags. Any code creating an MCSectionELF knows ELF and already provides the flags. SectionKind is an abstraction used by common code that uses a plain MCSection. Use the flags to compute the SectionKind. This removes a lot of guessing and boilerplate from the MCSectionELF construction. llvm-svn: 227476 --- diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h index e3163a7..44ee424 100644 --- a/llvm/include/llvm/MC/MCContext.h +++ b/llvm/include/llvm/MC/MCContext.h @@ -271,11 +271,11 @@ namespace llvm { } const MCSectionELF *getELFSection(StringRef Section, unsigned Type, - unsigned Flags, SectionKind Kind); + unsigned Flags); const MCSectionELF *getELFSection(StringRef Section, unsigned Type, - unsigned Flags, SectionKind Kind, - unsigned EntrySize, StringRef Group); + unsigned Flags, unsigned EntrySize, + StringRef Group); void renameELFSection(const MCSectionELF *Section, StringRef Name); diff --git a/llvm/include/llvm/MC/MCSectionELF.h b/llvm/include/llvm/MC/MCSectionELF.h index 5ec23f1..0500c30 100644 --- a/llvm/include/llvm/MC/MCSectionELF.h +++ b/llvm/include/llvm/MC/MCSectionELF.h @@ -92,10 +92,6 @@ public: static bool classof(const MCSection *S) { return S->getVariant() == SV_ELF; } - - // Return the entry size for sections with fixed-width data. - static unsigned DetermineEntrySize(SectionKind Kind); - }; } // end namespace llvm diff --git a/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp index 569ecc5..97a3234 100644 --- a/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp @@ -52,8 +52,8 @@ void ErlangGCPrinter::finishAssembly(Module &M, GCModuleInfo &Info, // Put this in a custom .note section. AP.OutStreamer.SwitchSection( - AP.getObjFileLowering().getContext().getELFSection( - ".note.gc", ELF::SHT_PROGBITS, 0, SectionKind::getDataRel())); + AP.getObjFileLowering().getContext().getELFSection(".note.gc", + ELF::SHT_PROGBITS, 0)); // For each function... for (GCModuleInfo::FuncInfoVec::iterator FI = Info.funcinfo_begin(), diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 5e5f8e4..0cbd775 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -71,7 +71,6 @@ void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer, const MCSection *Sec = getContext().getELFSection(NameData, ELF::SHT_PROGBITS, Flags, - SectionKind::getDataRel(), 0, Label->getName()); unsigned Size = TM.getDataLayout()->getPointerSize(); Streamer.SwitchSection(Sec); @@ -219,7 +218,7 @@ const MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal( } return getContext().getELFSection(SectionName, getELFSectionType(SectionName, Kind), Flags, - Kind, /*EntrySize=*/0, Group); + /*EntrySize=*/0, Group); } /// getSectionPrefixForGlobal - Return the section prefix name used by options @@ -268,9 +267,8 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Group = C->getName(); } - return getContext().getELFSection(Name.str(), - getELFSectionType(Name.str(), Kind), - Flags, Kind, 0, Group); + return getContext().getELFSection( + Name.str(), getELFSectionType(Name.str(), Kind), Flags, 0, Group); } if (Kind.isText()) return TextSection; @@ -283,21 +281,19 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, unsigned Align = TM.getDataLayout()->getPreferredAlignment(cast(GV)); - const char *SizeSpec = ".rodata.str1."; + unsigned EntrySize = 1; if (Kind.isMergeable2ByteCString()) - SizeSpec = ".rodata.str2."; + EntrySize = 2; else if (Kind.isMergeable4ByteCString()) - SizeSpec = ".rodata.str4."; + EntrySize = 4; else assert(Kind.isMergeable1ByteCString() && "unknown string width"); - + std::string SizeSpec = ".rodata.str" + utostr(EntrySize) + "."; std::string Name = SizeSpec + utostr(Align); - return getContext().getELFSection(Name, ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | - ELF::SHF_MERGE | - ELF::SHF_STRINGS, - Kind); + return getContext().getELFSection( + Name, ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::SHF_STRINGS, EntrySize, ""); } if (Kind.isMergeableConst()) { @@ -357,7 +353,6 @@ static const MCSectionELF *getStaticStructorSection(MCContext &Ctx, std::string Name; unsigned Type; unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE; - SectionKind Kind = SectionKind::getDataRel(); StringRef COMDAT = KeySym ? KeySym->getName() : ""; if (KeySym) @@ -389,7 +384,7 @@ static const MCSectionELF *getStaticStructorSection(MCContext &Ctx, Type = ELF::SHT_PROGBITS; } - return Ctx.getELFSection(Name, Type, Flags, Kind, 0, COMDAT); + return Ctx.getELFSection(Name, Type, Flags, 0, COMDAT); } const MCSection *TargetLoweringObjectFileELF::getStaticCtorSection( @@ -410,16 +405,10 @@ TargetLoweringObjectFileELF::InitializeELF(bool UseInitArray_) { if (!UseInitArray) return; - StaticCtorSection = - getContext().getELFSection(".init_array", ELF::SHT_INIT_ARRAY, - ELF::SHF_WRITE | - ELF::SHF_ALLOC, - SectionKind::getDataRel()); - StaticDtorSection = - getContext().getELFSection(".fini_array", ELF::SHT_FINI_ARRAY, - ELF::SHF_WRITE | - ELF::SHF_ALLOC, - SectionKind::getDataRel()); + StaticCtorSection = getContext().getELFSection( + ".init_array", ELF::SHT_INIT_ARRAY, ELF::SHF_WRITE | ELF::SHF_ALLOC); + StaticDtorSection = getContext().getELFSection( + ".fini_array", ELF::SHT_FINI_ARRAY, ELF::SHF_WRITE | ELF::SHF_ALLOC); } //===----------------------------------------------------------------------===// diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index d82dad8..aecdb65 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -325,8 +325,7 @@ void SymbolTableWriter::createSymtabShndx() { MCContext &Ctx = Asm.getContext(); const MCSectionELF *SymtabShndxSection = - Ctx.getELFSection(".symtab_shndxr", ELF::SHT_SYMTAB_SHNDX, 0, - SectionKind::getReadOnly(), 4, ""); + Ctx.getELFSection(".symtab_shndxr", ELF::SHT_SYMTAB_SHNDX, 0, 4, ""); MCSectionData *SymtabShndxSD = &Asm.getOrCreateSectionData(*SymtabShndxSection); SymtabShndxSD->setAlignment(4); @@ -1151,7 +1150,6 @@ void ELFObjectWriter::CreateRelocationSections(MCAssembler &Asm, const MCSectionELF *RelaSection = Ctx.getELFSection(RelaSectionName, hasRelocationAddend() ? ELF::SHT_RELA : ELF::SHT_REL, Flags, - SectionKind::getReadOnly(), EntrySize, Group); RelMap[&Section] = RelaSection; Asm.getOrCreateSectionData(*RelaSection); @@ -1410,21 +1408,18 @@ void ELFObjectWriter::CreateMetadataSections(MCAssembler &Asm, // We construct .shstrtab, .symtab and .strtab in this order to match gnu as. const MCSectionELF *ShstrtabSection = - Ctx.getELFSection(".shstrtab", ELF::SHT_STRTAB, 0, - SectionKind::getReadOnly()); + Ctx.getELFSection(".shstrtab", ELF::SHT_STRTAB, 0); MCSectionData &ShstrtabSD = Asm.getOrCreateSectionData(*ShstrtabSection); ShstrtabSD.setAlignment(1); const MCSectionELF *SymtabSection = Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0, - SectionKind::getReadOnly(), EntrySize, ""); MCSectionData &SymtabSD = Asm.getOrCreateSectionData(*SymtabSection); SymtabSD.setAlignment(is64Bit() ? 8 : 4); const MCSectionELF *StrtabSection; - StrtabSection = Ctx.getELFSection(".strtab", ELF::SHT_STRTAB, 0, - SectionKind::getReadOnly()); + StrtabSection = Ctx.getELFSection(".strtab", ELF::SHT_STRTAB, 0); MCSectionData &StrtabSD = Asm.getOrCreateSectionData(*StrtabSection); StrtabSD.setAlignment(1); @@ -1521,9 +1516,8 @@ void ELFObjectWriter::WriteSection(MCAssembler &Asm, case ELF::SHT_RELA: { const MCSectionELF *SymtabSection; const MCSectionELF *InfoSection; - SymtabSection = Asm.getContext().getELFSection(".symtab", ELF::SHT_SYMTAB, - 0, - SectionKind::getReadOnly()); + SymtabSection = + Asm.getContext().getELFSection(".symtab", ELF::SHT_SYMTAB, 0); sh_link = SectionIndexMap.lookup(SymtabSection); assert(sh_link && ".symtab not found"); @@ -1534,8 +1528,7 @@ void ELFObjectWriter::WriteSection(MCAssembler &Asm, Section.getGroup() ? Section.getGroup()->getName() : ""; InfoSection = Asm.getContext().getELFSection(SectionName, ELF::SHT_PROGBITS, - 0, SectionKind::getReadOnly(), - 0, GroupName); + 0, 0, GroupName); sh_info = SectionIndexMap.lookup(InfoSection); break; } @@ -1579,18 +1572,14 @@ void ELFObjectWriter::WriteSection(MCAssembler &Asm, Section.getType() == ELF::SHT_ARM_EXIDX) { StringRef SecName(Section.getSectionName()); if (SecName == ".ARM.exidx") { - sh_link = SectionIndexMap.lookup( - Asm.getContext().getELFSection(".text", - ELF::SHT_PROGBITS, - ELF::SHF_EXECINSTR | ELF::SHF_ALLOC, - SectionKind::getText())); + sh_link = SectionIndexMap.lookup(Asm.getContext().getELFSection( + ".text", ELF::SHT_PROGBITS, ELF::SHF_EXECINSTR | ELF::SHF_ALLOC)); } else if (SecName.startswith(".ARM.exidx")) { StringRef GroupName = Section.getGroup() ? Section.getGroup()->getName() : ""; sh_link = SectionIndexMap.lookup(Asm.getContext().getELFSection( SecName.substr(sizeof(".ARM.exidx") - 1), ELF::SHT_PROGBITS, - ELF::SHF_EXECINSTR | ELF::SHF_ALLOC, SectionKind::getText(), 0, - GroupName)); + ELF::SHF_EXECINSTR | ELF::SHF_ALLOC, 0, GroupName)); } } diff --git a/llvm/lib/MC/MCAsmInfoELF.cpp b/llvm/lib/MC/MCAsmInfoELF.cpp index 2fe626e..cd61a43 100644 --- a/llvm/lib/MC/MCAsmInfoELF.cpp +++ b/llvm/lib/MC/MCAsmInfoELF.cpp @@ -22,8 +22,7 @@ void MCAsmInfoELF::anchor() { } const MCSection * MCAsmInfoELF::getNonexecutableStackSection(MCContext &Ctx) const { - return Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS, - 0, SectionKind::getMetadata()); + return Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS, 0); } MCAsmInfoELF::MCAsmInfoELF() { diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index b41e6d8..3560989 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -252,10 +252,9 @@ getMachOSection(StringRef Segment, StringRef Section, Reserved2, Kind); } -const MCSectionELF *MCContext:: -getELFSection(StringRef Section, unsigned Type, unsigned Flags, - SectionKind Kind) { - return getELFSection(Section, Type, Flags, Kind, 0, ""); +const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, + unsigned Flags) { + return getELFSection(Section, Type, Flags, 0, ""); } void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) { @@ -271,25 +270,27 @@ void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) { const_cast(Section)->setSectionName(CachedName); } -const MCSectionELF *MCContext:: -getELFSection(StringRef Section, unsigned Type, unsigned Flags, - SectionKind Kind, unsigned EntrySize, StringRef Group) { +const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, + unsigned Flags, unsigned EntrySize, + StringRef Group) { // Do the lookup, if we have a hit, return it. auto IterBool = ELFUniquingMap.insert( std::make_pair(SectionGroupPair(Section, Group), nullptr)); auto &Entry = *IterBool.first; if (!IterBool.second) return Entry.second; - // Possibly refine the entry size first. - if (!EntrySize) { - EntrySize = MCSectionELF::DetermineEntrySize(Kind); - } - MCSymbol *GroupSym = nullptr; if (!Group.empty()) GroupSym = GetOrCreateSymbol(Group); StringRef CachedName = Entry.first.first; + + SectionKind Kind; + if (Flags & ELF::SHF_EXECINSTR) + Kind = SectionKind::getText(); + else + Kind = SectionKind::getReadOnly(); + MCSectionELF *Result = new (*this) MCSectionELF(CachedName, Type, Flags, Kind, EntrySize, GroupSym); Entry.second = Result; diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp index 5cfcfe5..199825e 100644 --- a/llvm/lib/MC/MCELFStreamer.cpp +++ b/llvm/lib/MC/MCELFStreamer.cpp @@ -259,11 +259,8 @@ void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, MCELF::SetType(SD, ELF::STT_OBJECT); if (MCELF::GetBinding(SD) == ELF_STB_Local) { - const MCSection *Section = getAssembler().getContext().getELFSection(".bss", - ELF::SHT_NOBITS, - ELF::SHF_WRITE | - ELF::SHF_ALLOC, - SectionKind::getBSS()); + const MCSection *Section = getAssembler().getContext().getELFSection( + ".bss", ELF::SHT_NOBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); AssignSection(Symbol, Section); @@ -318,8 +315,7 @@ void MCELFStreamer::EmitFileDirective(StringRef Filename) { void MCELFStreamer::EmitIdent(StringRef IdentString) { const MCSection *Comment = getAssembler().getContext().getELFSection( - ".comment", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS, - SectionKind::getReadOnly(), 1, ""); + ".comment", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); PushSection(); SwitchSection(Comment); if (!SeenIdent) { diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 858181d..2a3f5fe 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -416,83 +416,54 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) { // ELF - BSSSection = - Ctx->getELFSection(".bss", ELF::SHT_NOBITS, - ELF::SHF_WRITE | ELF::SHF_ALLOC, - SectionKind::getBSS()); + BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS, + ELF::SHF_WRITE | ELF::SHF_ALLOC); - TextSection = - Ctx->getELFSection(".text", ELF::SHT_PROGBITS, - ELF::SHF_EXECINSTR | - ELF::SHF_ALLOC, - SectionKind::getText()); + TextSection = Ctx->getELFSection(".text", ELF::SHT_PROGBITS, + ELF::SHF_EXECINSTR | ELF::SHF_ALLOC); - DataSection = - Ctx->getELFSection(".data", ELF::SHT_PROGBITS, - ELF::SHF_WRITE |ELF::SHF_ALLOC, - SectionKind::getDataRel()); + DataSection = Ctx->getELFSection(".data", ELF::SHT_PROGBITS, + ELF::SHF_WRITE | ELF::SHF_ALLOC); ReadOnlySection = - Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC, - SectionKind::getReadOnly()); + Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, ELF::SHF_ALLOC); TLSDataSection = - Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHF_TLS | - ELF::SHF_WRITE, - SectionKind::getThreadData()); - - TLSBSSSection = - Ctx->getELFSection(".tbss", ELF::SHT_NOBITS, - ELF::SHF_ALLOC | ELF::SHF_TLS | - ELF::SHF_WRITE, - SectionKind::getThreadBSS()); - - DataRelSection = - Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC |ELF::SHF_WRITE, - SectionKind::getDataRel()); - - DataRelLocalSection = - Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC |ELF::SHF_WRITE, - SectionKind::getDataRelLocal()); - - DataRelROSection = - Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC |ELF::SHF_WRITE, - SectionKind::getReadOnlyWithRel()); - - DataRelROLocalSection = - Ctx->getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC |ELF::SHF_WRITE, - SectionKind::getReadOnlyWithRelLocal()); + Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE); + + TLSBSSSection = Ctx->getELFSection( + ".tbss", ELF::SHT_NOBITS, ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE); + + DataRelSection = Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE); + + DataRelLocalSection = Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE); + + DataRelROSection = Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE); + + DataRelROLocalSection = Ctx->getELFSection( + ".data.rel.ro.local", ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHF_WRITE); MergeableConst4Section = - Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC |ELF::SHF_MERGE, - SectionKind::getMergeableConst4()); + Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_MERGE, 4, ""); MergeableConst8Section = - Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC |ELF::SHF_MERGE, - SectionKind::getMergeableConst8()); + Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_MERGE, 8, ""); MergeableConst16Section = - Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC |ELF::SHF_MERGE, - SectionKind::getMergeableConst16()); + Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_MERGE, 16, ""); - StaticCtorSection = - Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC |ELF::SHF_WRITE, - SectionKind::getDataRel()); + StaticCtorSection = Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE); - StaticDtorSection = - Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC |ELF::SHF_WRITE, - SectionKind::getDataRel()); + StaticDtorSection = Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE); // Exception Handling Sections. @@ -500,103 +471,68 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) { // it contains relocatable pointers. In PIC mode, this is probably a big // runtime hit for C++ apps. Either the contents of the LSDA need to be // adjusted or this should be a data section. - LSDASection = - Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC, - SectionKind::getReadOnly()); + LSDASection = Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC); COFFDebugSymbolsSection = nullptr; // Debug Info Sections. DwarfAbbrevSection = - Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfInfoSection = - Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfLineSection = - Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfFrameSection = - Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0); + DwarfInfoSection = Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0); + DwarfLineSection = Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0); + DwarfFrameSection = Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0); DwarfPubNamesSection = - Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0); DwarfPubTypesSection = - Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0); DwarfGnuPubNamesSection = - Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0); DwarfGnuPubTypesSection = - Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0); DwarfStrSection = - Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS, - ELF::SHF_MERGE | ELF::SHF_STRINGS, - SectionKind::getMergeable1ByteCString()); - DwarfLocSection = - Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS, + ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); + DwarfLocSection = Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0); DwarfARangesSection = - Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0); DwarfRangesSection = - Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0); DwarfMacroInfoSection = - Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0); // DWARF5 Experimental Debug Info // Accelerator Tables DwarfAccelNamesSection = - Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0); DwarfAccelObjCSection = - Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0); DwarfAccelNamespaceSection = - Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0); DwarfAccelTypesSection = - Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0); // Fission Sections DwarfInfoDWOSection = - Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0); DwarfTypesDWOSection = - Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS, 0); DwarfAbbrevDWOSection = - Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0); DwarfStrDWOSection = - Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS, - ELF::SHF_MERGE | ELF::SHF_STRINGS, - SectionKind::getMergeable1ByteCString()); + Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS, + ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); DwarfLineDWOSection = - Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0); DwarfLocDWOSection = - Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0); DwarfStrOffDWOSection = - Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfAddrSection = - Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); + Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0); + DwarfAddrSection = Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0); StackMapSection = - Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC, - SectionKind::getMetadata()); - + Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC); } @@ -884,7 +820,7 @@ void MCObjectFileInfo::InitMCObjectFileInfo(StringRef T, Reloc::Model relocm, const MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const { return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP, - SectionKind::getMetadata(), 0, utostr(Hash)); + 0, utostr(Hash)); } void MCObjectFileInfo::InitEHFrameSection() { @@ -898,9 +834,7 @@ void MCObjectFileInfo::InitEHFrameSection() { SectionKind::getReadOnly()); else if (Env == IsELF) EHFrameSection = - Ctx->getELFSection(".eh_frame", EHSectionType, - EHSectionFlags, - SectionKind::getDataRel()); + Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags); else EHFrameSection = Ctx->getCOFFSection(".eh_frame", diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index e302004..21c65ce 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -199,8 +199,7 @@ bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type, return true; } - getStreamer().SwitchSection(getContext().getELFSection( - Section, Type, Flags, Kind), + getStreamer().SwitchSection(getContext().getELFSection(Section, Type, Flags), Subsection); return false; @@ -269,40 +268,6 @@ bool ELFAsmParser::ParseSectionName(StringRef &SectionName) { return false; } -static SectionKind computeSectionKind(unsigned Flags, unsigned ElemSize) { - if (Flags & ELF::SHF_EXECINSTR) - return SectionKind::getText(); - if (Flags & ELF::SHF_TLS) - return SectionKind::getThreadData(); - if (Flags & ELF::SHF_MERGE) { - if (Flags & ELF::SHF_STRINGS) { - switch (ElemSize) { - default: - break; - case 1: - return SectionKind::getMergeable1ByteCString(); - case 2: - return SectionKind::getMergeable2ByteCString(); - case 4: - return SectionKind::getMergeable4ByteCString(); - } - } else { - switch (ElemSize) { - default: - break; - case 4: - return SectionKind::getMergeableConst4(); - case 8: - return SectionKind::getMergeableConst8(); - case 16: - return SectionKind::getMergeableConst16(); - } - } - } - - return SectionKind::getDataRel(); -} - static unsigned parseSectionFlags(StringRef flagsStr, bool *UseLastGroup) { unsigned flags = 0; @@ -544,9 +509,8 @@ EndStmt: } } - SectionKind Kind = computeSectionKind(Flags, Size); - const MCSection *ELFSection = getContext().getELFSection( - SectionName, Type, Flags, Kind, Size, GroupName); + const MCSection *ELFSection = + getContext().getELFSection(SectionName, Type, Flags, Size, GroupName); getStreamer().SwitchSection(ELFSection, Subsection); if (getContext().getGenDwarfForAssembly()) { @@ -697,9 +661,7 @@ bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) { Lex(); - const MCSection *Note = - getContext().getELFSection(".note", ELF::SHT_NOTE, 0, - SectionKind::getReadOnly()); + const MCSection *Note = getContext().getELFSection(".note", ELF::SHT_NOTE, 0); getStreamer().PushSection(); getStreamer().SwitchSection(Note); diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp index a29bb97..fb364c8 100644 --- a/llvm/lib/MC/MCSectionELF.cpp +++ b/llvm/lib/MC/MCSectionELF.cpp @@ -157,13 +157,3 @@ bool MCSectionELF::UseCodeAlign() const { bool MCSectionELF::isVirtualSection() const { return getType() == ELF::SHT_NOBITS; } - -unsigned MCSectionELF::DetermineEntrySize(SectionKind Kind) { - if (Kind.isMergeable1ByteCString()) return 1; - if (Kind.isMergeable2ByteCString()) return 2; - if (Kind.isMergeable4ByteCString()) return 4; - if (Kind.isMergeableConst4()) return 4; - if (Kind.isMergeableConst8()) return 8; - if (Kind.isMergeableConst16()) return 16; - return 0; -} diff --git a/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp b/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp index 48238bf..1dd15b7 100644 --- a/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp +++ b/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp @@ -36,10 +36,7 @@ void ARMElfTargetObjectFile::Initialize(MCContext &Ctx, } AttributesSection = - getContext().getELFSection(".ARM.attributes", - ELF::SHT_ARM_ATTRIBUTES, - 0, - SectionKind::getMetadata()); + getContext().getELFSection(".ARM.attributes", ELF::SHT_ARM_ATTRIBUTES, 0); } const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference( diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp index 99b5c62..d698fea 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -958,11 +958,8 @@ void ARMTargetELFStreamer::finishAttributeSection() { if (AttributeSection) { Streamer.SwitchSection(AttributeSection); } else { - AttributeSection = - Streamer.getContext().getELFSection(".ARM.attributes", - ELF::SHT_ARM_ATTRIBUTES, - 0, - SectionKind::getMetadata()); + AttributeSection = Streamer.getContext().getELFSection( + ".ARM.attributes", ELF::SHT_ARM_ATTRIBUTES, 0); Streamer.SwitchSection(AttributeSection); // Format version @@ -1069,11 +1066,11 @@ inline void ARMELFStreamer::SwitchToEHSection(const char *Prefix, // Get .ARM.extab or .ARM.exidx section const MCSectionELF *EHSection = nullptr; if (const MCSymbol *Group = FnSection.getGroup()) { - EHSection = getContext().getELFSection( - EHSecName, Type, Flags | ELF::SHF_GROUP, Kind, - FnSection.getEntrySize(), Group->getName()); + EHSection = + getContext().getELFSection(EHSecName, Type, Flags | ELF::SHF_GROUP, + FnSection.getEntrySize(), Group->getName()); } else { - EHSection = getContext().getELFSection(EHSecName, Type, Flags, Kind); + EHSection = getContext().getELFSection(EHSecName, Type, Flags); } assert(EHSection && "Failed to get the required EH section"); diff --git a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp index 69202e6..d8660d3 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp @@ -33,14 +33,10 @@ void HexagonTargetObjectFile::Initialize(MCContext &Ctx, TargetLoweringObjectFileELF::Initialize(Ctx, TM); InitializeELF(TM.Options.UseInitArray); - SmallDataSection = - getContext().getELFSection(".sdata", ELF::SHT_PROGBITS, - ELF::SHF_WRITE | ELF::SHF_ALLOC, - SectionKind::getDataRel()); - SmallBSSSection = - getContext().getELFSection(".sbss", ELF::SHT_NOBITS, - ELF::SHF_WRITE | ELF::SHF_ALLOC, - SectionKind::getBSS()); + SmallDataSection = getContext().getELFSection( + ".sdata", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); + SmallBSSSection = getContext().getELFSection(".sbss", ELF::SHT_NOBITS, + ELF::SHF_WRITE | ELF::SHF_ALLOC); } // sdata/sbss support taken largely from the MIPS Backend. diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp index 666e883..07d3a5f 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp @@ -30,8 +30,7 @@ void MipsRegInfoRecord::EmitMipsOptionRecord() { // 1-byte long nor fixed length but it matches the value GAS emits. const MCSectionELF *Sec = Context.getELFSection(".MIPS.options", ELF::SHT_MIPS_OPTIONS, - ELF::SHF_ALLOC | ELF::SHF_MIPS_NOSTRIP, - SectionKind::getMetadata(), 1, ""); + ELF::SHF_ALLOC | ELF::SHF_MIPS_NOSTRIP, 1, ""); MCA.getOrCreateSectionData(*Sec).setAlignment(8); Streamer->SwitchSection(Sec); @@ -47,9 +46,8 @@ void MipsRegInfoRecord::EmitMipsOptionRecord() { Streamer->EmitIntValue(ri_cprmask[3], 4); Streamer->EmitIntValue(ri_gp_value, 8); } else { - const MCSectionELF *Sec = - Context.getELFSection(".reginfo", ELF::SHT_MIPS_REGINFO, ELF::SHF_ALLOC, - SectionKind::getMetadata(), 24, ""); + const MCSectionELF *Sec = Context.getELFSection( + ".reginfo", ELF::SHT_MIPS_REGINFO, ELF::SHF_ALLOC, 24, ""); MCA.getOrCreateSectionData(*Sec) .setAlignment(MTS->getABI().IsN32() ? 8 : 4); Streamer->SwitchSection(Sec); diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index f6db379..f3a3fce 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -515,9 +515,8 @@ void MipsTargetELFStreamer::emitDirectiveEnd(StringRef Name) { MCContext &Context = MCA.getContext(); MCStreamer &OS = getStreamer(); - const MCSectionELF *Sec = Context.getELFSection(".pdr", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHT_REL, - SectionKind::getMetadata()); + const MCSectionELF *Sec = Context.getELFSection( + ".pdr", ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHT_REL); const MCSymbolRefExpr *ExprRef = MCSymbolRefExpr::Create(Name, MCSymbolRefExpr::VK_None, Context); @@ -731,9 +730,8 @@ void MipsTargetELFStreamer::emitMipsAbiFlags() { MCAssembler &MCA = getStreamer().getAssembler(); MCContext &Context = MCA.getContext(); MCStreamer &OS = getStreamer(); - const MCSectionELF *Sec = - Context.getELFSection(".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, - ELF::SHF_ALLOC, SectionKind::getMetadata(), 24, ""); + const MCSectionELF *Sec = Context.getELFSection( + ".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, ELF::SHF_ALLOC, 24, ""); MCSectionData &ABIShndxSD = MCA.getOrCreateSectionData(*Sec); ABIShndxSD.setAlignment(8); OS.SwitchSection(Sec); diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp index 7008f15..4f3729c 100644 --- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp @@ -704,8 +704,8 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) { // Tell the assembler which ABI we are using std::string SectionName = std::string(".mdebug.") + getCurrentABIString(); - OutStreamer.SwitchSection(OutContext.getELFSection( - SectionName, ELF::SHT_PROGBITS, 0, SectionKind::getDataRel())); + OutStreamer.SwitchSection( + OutContext.getELFSection(SectionName, ELF::SHT_PROGBITS, 0)); // NaN: At the moment we only support: // 1. .nan legacy (default) @@ -717,13 +717,11 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) { if (Subtarget->isABI_EABI()) { if (Subtarget->isGP32bit()) - OutStreamer.SwitchSection( - OutContext.getELFSection(".gcc_compiled_long32", ELF::SHT_PROGBITS, 0, - SectionKind::getDataRel())); + OutStreamer.SwitchSection(OutContext.getELFSection(".gcc_compiled_long32", + ELF::SHT_PROGBITS, 0)); else - OutStreamer.SwitchSection( - OutContext.getELFSection(".gcc_compiled_long64", ELF::SHT_PROGBITS, 0, - SectionKind::getDataRel())); + OutStreamer.SwitchSection(OutContext.getELFSection(".gcc_compiled_long64", + ELF::SHT_PROGBITS, 0)); } getTargetStreamer().updateABIInfo(*Subtarget); @@ -945,7 +943,7 @@ void MipsAsmPrinter::EmitFPCallStub( // const MCSectionELF *M = OutContext.getELFSection( ".mips16.call.fp." + std::string(Symbol), ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHF_EXECINSTR, SectionKind::getText()); + ELF::SHF_ALLOC | ELF::SHF_EXECINSTR); OutStreamer.SwitchSection(M, nullptr); // // .align 2 diff --git a/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp b/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp index 06379ef..c07693e 100644 --- a/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp +++ b/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp @@ -39,15 +39,11 @@ void MipsTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM){ TargetLoweringObjectFileELF::Initialize(Ctx, TM); InitializeELF(TM.Options.UseInitArray); - SmallDataSection = - getContext().getELFSection(".sdata", ELF::SHT_PROGBITS, - ELF::SHF_WRITE |ELF::SHF_ALLOC, - SectionKind::getDataRel()); - - SmallBSSSection = - getContext().getELFSection(".sbss", ELF::SHT_NOBITS, - ELF::SHF_WRITE |ELF::SHF_ALLOC, - SectionKind::getBSS()); + SmallDataSection = getContext().getELFSection( + ".sdata", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); + + SmallBSSSection = getContext().getELFSection(".sbss", ELF::SHT_NOBITS, + ELF::SHF_WRITE | ELF::SHF_ALLOC); this->TM = &TM; } diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index 925f0b6..55da913 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -953,9 +953,8 @@ void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) { if (M.getPICLevel() == PICLevel::Small) return AsmPrinter::EmitStartOfAsmFile(M); - OutStreamer.SwitchSection(OutContext.getELFSection(".got2", - ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC, - SectionKind::getReadOnly())); + OutStreamer.SwitchSection(OutContext.getELFSection( + ".got2", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC)); MCSymbol *TOCSym = OutContext.GetOrCreateSymbol(Twine(".LTOC")); MCSymbol *CurrentPos = OutContext.CreateTempSymbol(); @@ -1007,9 +1006,8 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() { // Emit an official procedure descriptor. MCSectionSubPair Current = OutStreamer.getCurrentSection(); - const MCSectionELF *Section = OutStreamer.getContext().getELFSection(".opd", - ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC, - SectionKind::getReadOnly()); + const MCSectionELF *Section = OutStreamer.getContext().getELFSection( + ".opd", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); OutStreamer.SwitchSection(Section); OutStreamer.EmitLabel(CurrentFnSym); OutStreamer.EmitValueToAlignment(8); @@ -1047,13 +1045,11 @@ bool PPCLinuxAsmPrinter::doFinalization(Module &M) { const MCSectionELF *Section; if (isPPC64) - Section = OutStreamer.getContext().getELFSection(".toc", - ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC, - SectionKind::getReadOnly()); - else - Section = OutStreamer.getContext().getELFSection(".got2", - ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC, - SectionKind::getReadOnly()); + Section = OutStreamer.getContext().getELFSection( + ".toc", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); + else + Section = OutStreamer.getContext().getELFSection( + ".got2", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); OutStreamer.SwitchSection(Section); for (MapVector::iterator I = TOC.begin(), diff --git a/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp index 8f35f58..4721a44 100644 --- a/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp +++ b/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp @@ -110,9 +110,8 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) { EmitFunctionHeader(); MCContext &Context = getObjFileLowering().getContext(); - const MCSectionELF *ConfigSection = Context.getELFSection(".AMDGPU.config", - ELF::SHT_PROGBITS, 0, - SectionKind::getReadOnly()); + const MCSectionELF *ConfigSection = + Context.getELFSection(".AMDGPU.config", ELF::SHT_PROGBITS, 0); OutStreamer.SwitchSection(ConfigSection); const AMDGPUSubtarget &STM = TM.getSubtarget(); @@ -136,10 +135,8 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) { EmitFunctionBody(); if (isVerbose()) { - const MCSectionELF *CommentSection - = Context.getELFSection(".AMDGPU.csdata", - ELF::SHT_PROGBITS, 0, - SectionKind::getReadOnly()); + const MCSectionELF *CommentSection = + Context.getELFSection(".AMDGPU.csdata", ELF::SHT_PROGBITS, 0); OutStreamer.SwitchSection(CommentSection); if (STM.getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS) { @@ -165,9 +162,8 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) { if (STM.dumpCode() && DisasmEnabled) { - OutStreamer.SwitchSection(Context.getELFSection(".AMDGPU.disasm", - ELF::SHT_NOTE, 0, - SectionKind::getReadOnly())); + OutStreamer.SwitchSection( + Context.getELFSection(".AMDGPU.disasm", ELF::SHT_NOTE, 0)); for (size_t i = 0; i < DisasmLines.size(); ++i) { std::string Comment(DisasmLineMaxLen - DisasmLines[i].size(), ' '); @@ -510,8 +506,8 @@ void AMDGPUAsmPrinter::EmitAmdKernelCodeT(const MachineFunction &MF, header.wavefront_size = STM.getWavefrontSize(); - const MCSectionELF *VersionSection = OutContext.getELFSection(".hsa.version", - ELF::SHT_PROGBITS, 0, SectionKind::getReadOnly()); + const MCSectionELF *VersionSection = + OutContext.getELFSection(".hsa.version", ELF::SHT_PROGBITS, 0); OutStreamer.SwitchSection(VersionSection); OutStreamer.EmitBytes(Twine("HSA Code Unit:" + Twine(header.hsail_version_major) + "." + diff --git a/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp b/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp index 53723d8..c435b36 100644 --- a/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp +++ b/llvm/lib/Target/XCore/XCoreTargetObjectFile.cpp @@ -21,66 +21,43 @@ using namespace llvm; void XCoreTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM){ TargetLoweringObjectFileELF::Initialize(Ctx, TM); - BSSSection = - Ctx.getELFSection(".dp.bss", ELF::SHT_NOBITS, - ELF::SHF_ALLOC | ELF::SHF_WRITE | - ELF::XCORE_SHF_DP_SECTION, - SectionKind::getBSS()); - BSSSectionLarge = - Ctx.getELFSection(".dp.bss.large", ELF::SHT_NOBITS, - ELF::SHF_ALLOC | ELF::SHF_WRITE | - ELF::XCORE_SHF_DP_SECTION, - SectionKind::getBSS()); - DataSection = - Ctx.getELFSection(".dp.data", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHF_WRITE | - ELF::XCORE_SHF_DP_SECTION, - SectionKind::getDataRel()); - DataSectionLarge = - Ctx.getELFSection(".dp.data.large", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHF_WRITE | - ELF::XCORE_SHF_DP_SECTION, - SectionKind::getDataRel()); - DataRelROSection = - Ctx.getELFSection(".dp.rodata", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHF_WRITE | - ELF::XCORE_SHF_DP_SECTION, - SectionKind::getReadOnlyWithRel()); - DataRelROSectionLarge = - Ctx.getELFSection(".dp.rodata.large", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHF_WRITE | - ELF::XCORE_SHF_DP_SECTION, - SectionKind::getReadOnlyWithRel()); + BSSSection = Ctx.getELFSection(".dp.bss", ELF::SHT_NOBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE | + ELF::XCORE_SHF_DP_SECTION); + BSSSectionLarge = Ctx.getELFSection(".dp.bss.large", ELF::SHT_NOBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE | + ELF::XCORE_SHF_DP_SECTION); + DataSection = Ctx.getELFSection(".dp.data", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE | + ELF::XCORE_SHF_DP_SECTION); + DataSectionLarge = Ctx.getELFSection(".dp.data.large", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE | + ELF::XCORE_SHF_DP_SECTION); + DataRelROSection = Ctx.getELFSection(".dp.rodata", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE | + ELF::XCORE_SHF_DP_SECTION); + DataRelROSectionLarge = Ctx.getELFSection( + ".dp.rodata.large", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::XCORE_SHF_DP_SECTION); ReadOnlySection = - Ctx.getELFSection(".cp.rodata", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | - ELF::XCORE_SHF_CP_SECTION, - SectionKind::getReadOnlyWithRel()); + Ctx.getELFSection(".cp.rodata", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::XCORE_SHF_CP_SECTION); ReadOnlySectionLarge = - Ctx.getELFSection(".cp.rodata.large", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | - ELF::XCORE_SHF_CP_SECTION, - SectionKind::getReadOnlyWithRel()); - MergeableConst4Section = - Ctx.getELFSection(".cp.rodata.cst4", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHF_MERGE | - ELF::XCORE_SHF_CP_SECTION, - SectionKind::getMergeableConst4()); - MergeableConst8Section = - Ctx.getELFSection(".cp.rodata.cst8", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHF_MERGE | - ELF::XCORE_SHF_CP_SECTION, - SectionKind::getMergeableConst8()); - MergeableConst16Section = - Ctx.getELFSection(".cp.rodata.cst16", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHF_MERGE | - ELF::XCORE_SHF_CP_SECTION, - SectionKind::getMergeableConst16()); + Ctx.getELFSection(".cp.rodata.large", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::XCORE_SHF_CP_SECTION); + MergeableConst4Section = Ctx.getELFSection( + ".cp.rodata.cst4", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::XCORE_SHF_CP_SECTION, 4, ""); + MergeableConst8Section = Ctx.getELFSection( + ".cp.rodata.cst8", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::XCORE_SHF_CP_SECTION, 8, ""); + MergeableConst16Section = Ctx.getELFSection( + ".cp.rodata.cst16", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::XCORE_SHF_CP_SECTION, 16, ""); CStringSection = - Ctx.getELFSection(".cp.rodata.string", ELF::SHT_PROGBITS, - ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::SHF_STRINGS | - ELF::XCORE_SHF_CP_SECTION, - SectionKind::getReadOnlyWithRel()); + Ctx.getELFSection(".cp.rodata.string", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::SHF_STRINGS | + ELF::XCORE_SHF_CP_SECTION); // TextSection - see MObjectFileInfo.cpp // StaticCtorSection - see MObjectFileInfo.cpp // StaticDtorSection - see MObjectFileInfo.cpp @@ -128,7 +105,7 @@ XCoreTargetObjectFile::getExplicitSectionGlobal(const GlobalValue *GV, if (IsCPRel && !Kind.isReadOnly()) report_fatal_error("Using .cp. section for writeable object."); return getContext().getELFSection(SectionName, getXCoreSectionType(Kind), - getXCoreSectionFlags(Kind, IsCPRel), Kind); + getXCoreSectionFlags(Kind, IsCPRel)); } const MCSection *XCoreTargetObjectFile::