[lld] r296313 - De-template SyntheticSection.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 12:08:45 PST 2017


Thanks!

Rui Ueyama via llvm-commits <llvm-commits at lists.llvm.org> writes:

> Author: ruiu
> Date: Sun Feb 26 20:56:02 2017
> New Revision: 296313
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296313&view=rev
> Log:
> De-template SyntheticSection.
>
> This class didn't use ELFT.
>
> Modified:
>     lld/trunk/ELF/InputSection.cpp
>     lld/trunk/ELF/LinkerScript.cpp
>     lld/trunk/ELF/OutputSections.cpp
>     lld/trunk/ELF/SyntheticSections.cpp
>     lld/trunk/ELF/SyntheticSections.h
>     lld/trunk/ELF/Writer.cpp
>
> Modified: lld/trunk/ELF/InputSection.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=296313&r1=296312&r2=296313&view=diff
> ==============================================================================
> --- lld/trunk/ELF/InputSection.cpp (original)
> +++ lld/trunk/ELF/InputSection.cpp Sun Feb 26 20:56:02 2017
> @@ -88,7 +88,7 @@ InputSectionBase::InputSectionBase(elf::
>  }
>  
>  template <class ELFT> size_t InputSectionBase::getSize() const {
> -  if (auto *S = dyn_cast<SyntheticSection<ELFT>>(this))
> +  if (auto *S = dyn_cast<SyntheticSection>(this))
>      return S->getSize();
>  
>    return Data.size();
> @@ -545,7 +545,7 @@ template <class ELFT> void InputSection:
>    if (this->Type == SHT_NOBITS)
>      return;
>  
> -  if (auto *S = dyn_cast<SyntheticSection<ELFT>>(this)) {
> +  if (auto *S = dyn_cast<SyntheticSection>(this)) {
>      S->writeTo(Buf + OutSecOff);
>      return;
>    }
>
> Modified: lld/trunk/ELF/LinkerScript.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=296313&r1=296312&r2=296313&view=diff
> ==============================================================================
> --- lld/trunk/ELF/LinkerScript.cpp (original)
> +++ lld/trunk/ELF/LinkerScript.cpp Sun Feb 26 20:56:02 2017
> @@ -490,7 +490,7 @@ template <class ELFT> void LinkerScript<
>      // empty ones afterwards (because there is no way to know whether they were
>      // going be empty or not other than actually running linker scripts.)
>      // We need to ignore remains of empty sections.
> -    if (auto *Sec = dyn_cast<SyntheticSection<ELFT>>(ID))
> +    if (auto *Sec = dyn_cast<SyntheticSection>(ID))
>        if (Sec->empty())
>          continue;
>  
>
> Modified: lld/trunk/ELF/OutputSections.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=296313&r1=296312&r2=296313&view=diff
> ==============================================================================
> --- lld/trunk/ELF/OutputSections.cpp (original)
> +++ lld/trunk/ELF/OutputSections.cpp Sun Feb 26 20:56:02 2017
> @@ -137,7 +137,7 @@ template <class ELFT> void OutputSection
>      return;
>  
>    InputSection *First = Sections[0];
> -  if (isa<SyntheticSection<ELFT>>(First))
> +  if (isa<SyntheticSection>(First))
>      return;
>  
>    this->Link = In<ELFT>::SymTab->OutSec->SectionIndex;
>
> Modified: lld/trunk/ELF/SyntheticSections.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=296313&r1=296312&r2=296313&view=diff
> ==============================================================================
> --- lld/trunk/ELF/SyntheticSections.cpp (original)
> +++ lld/trunk/ELF/SyntheticSections.cpp Sun Feb 26 20:56:02 2017
> @@ -45,6 +45,12 @@ using namespace llvm::support::endian;
>  using namespace lld;
>  using namespace lld::elf;
>  
> +uint64_t SyntheticSection::getVA() const {
> +  if (this->OutSec)
> +    return this->OutSec->Addr + this->OutSecOff;
> +  return 0;
> +}
> +
>  template <class ELFT> static std::vector<DefinedCommon *> getCommonSymbols() {
>    std::vector<DefinedCommon *> V;
>    for (Symbol *S : Symtab<ELFT>::X->getSymbols())
> @@ -118,7 +124,7 @@ template <class ELFT> MergeInputSection<
>  // .MIPS.abiflags section.
>  template <class ELFT>
>  MipsAbiFlagsSection<ELFT>::MipsAbiFlagsSection(Elf_Mips_ABIFlags Flags)
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_MIPS_ABIFLAGS, 8, ".MIPS.abiflags"),
> +    : SyntheticSection(SHF_ALLOC, SHT_MIPS_ABIFLAGS, 8, ".MIPS.abiflags"),
>        Flags(Flags) {}
>  
>  template <class ELFT> void MipsAbiFlagsSection<ELFT>::writeTo(uint8_t *Buf) {
> @@ -175,7 +181,7 @@ MipsAbiFlagsSection<ELFT> *MipsAbiFlagsS
>  // .MIPS.options section.
>  template <class ELFT>
>  MipsOptionsSection<ELFT>::MipsOptionsSection(Elf_Mips_RegInfo Reginfo)
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_MIPS_OPTIONS, 8, ".MIPS.options"),
> +    : SyntheticSection(SHF_ALLOC, SHT_MIPS_OPTIONS, 8, ".MIPS.options"),
>        Reginfo(Reginfo) {}
>  
>  template <class ELFT> void MipsOptionsSection<ELFT>::writeTo(uint8_t *Buf) {
> @@ -235,7 +241,7 @@ MipsOptionsSection<ELFT> *MipsOptionsSec
>  // MIPS .reginfo section.
>  template <class ELFT>
>  MipsReginfoSection<ELFT>::MipsReginfoSection(Elf_Mips_RegInfo Reginfo)
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_MIPS_REGINFO, 4, ".reginfo"),
> +    : SyntheticSection(SHF_ALLOC, SHT_MIPS_REGINFO, 4, ".reginfo"),
>        Reginfo(Reginfo) {}
>  
>  template <class ELFT> void MipsReginfoSection<ELFT>::writeTo(uint8_t *Buf) {
> @@ -317,7 +323,7 @@ static size_t getHashSize() {
>  
>  template <class ELFT>
>  BuildIdSection<ELFT>::BuildIdSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_NOTE, 1, ".note.gnu.build-id"),
> +    : SyntheticSection(SHF_ALLOC, SHT_NOTE, 1, ".note.gnu.build-id"),
>        HashSize(getHashSize()) {}
>  
>  template <class ELFT> void BuildIdSection<ELFT>::writeTo(uint8_t *Buf) {
> @@ -363,8 +369,8 @@ void BuildIdSection<ELFT>::computeHash(
>  
>  template <class ELFT>
>  CopyRelSection<ELFT>::CopyRelSection(bool ReadOnly, uintX_t AddrAlign, size_t S)
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_NOBITS, AddrAlign,
> -                             ReadOnly ? ".bss.rel.ro" : ".bss"),
> +    : SyntheticSection(SHF_ALLOC, SHT_NOBITS, AddrAlign,
> +                       ReadOnly ? ".bss.rel.ro" : ".bss"),
>        Size(S) {
>    if (!ReadOnly)
>      this->Flags |= SHF_WRITE;
> @@ -402,7 +408,7 @@ void BuildIdSection<ELFT>::writeBuildId(
>  
>  template <class ELFT>
>  EhFrameSection<ELFT>::EhFrameSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_PROGBITS, 1, ".eh_frame") {}
> +    : SyntheticSection(SHF_ALLOC, SHT_PROGBITS, 1, ".eh_frame") {}
>  
>  // Search for an existing CIE record or create a new one.
>  // CIE records from input object files are uniquified by their contents
> @@ -606,8 +612,8 @@ template <class ELFT> void EhFrameSectio
>  
>  template <class ELFT>
>  GotSection<ELFT>::GotSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
> -                             Target->GotEntrySize, ".got") {}
> +    : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
> +                       Target->GotEntrySize, ".got") {}
>  
>  template <class ELFT> void GotSection<ELFT>::addEntry(SymbolBody &Sym) {
>    Sym.GotIndex = NumEntries;
> @@ -661,8 +667,8 @@ template <class ELFT> void GotSection<EL
>  
>  template <class ELFT>
>  MipsGotSection<ELFT>::MipsGotSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL,
> -                             SHT_PROGBITS, 16, ".got") {}
> +    : SyntheticSection(SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL, SHT_PROGBITS, 16,
> +                       ".got") {}
>  
>  template <class ELFT>
>  void MipsGotSection<ELFT>::addEntry(SymbolBody &Sym, int64_t Addend,
> @@ -922,8 +928,8 @@ template <class ELFT> void MipsGotSectio
>  
>  template <class ELFT>
>  GotPltSection<ELFT>::GotPltSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
> -                             Target->GotPltEntrySize, ".got.plt") {}
> +    : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
> +                       Target->GotPltEntrySize, ".got.plt") {}
>  
>  template <class ELFT> void GotPltSection<ELFT>::addEntry(SymbolBody &Sym) {
>    Sym.GotPltIndex = Target->GotPltHeaderEntriesNum + Entries.size();
> @@ -948,10 +954,9 @@ template <class ELFT> void GotPltSection
>  // part of the .got.plt
>  template <class ELFT>
>  IgotPltSection<ELFT>::IgotPltSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
> -                             Target->GotPltEntrySize,
> -                             Config->EMachine == EM_ARM ? ".got" : ".got.plt") {
> -}
> +    : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
> +                       Target->GotPltEntrySize,
> +                       Config->EMachine == EM_ARM ? ".got" : ".got.plt") {}
>  
>  template <class ELFT> void IgotPltSection<ELFT>::addEntry(SymbolBody &Sym) {
>    Sym.IsInIgot = true;
> @@ -972,8 +977,7 @@ template <class ELFT> void IgotPltSectio
>  
>  template <class ELFT>
>  StringTableSection<ELFT>::StringTableSection(StringRef Name, bool Dynamic)
> -    : SyntheticSection<ELFT>(Dynamic ? (uintX_t)SHF_ALLOC : 0, SHT_STRTAB, 1,
> -                             Name),
> +    : SyntheticSection(Dynamic ? (uintX_t)SHF_ALLOC : 0, SHT_STRTAB, 1, Name),
>        Dynamic(Dynamic) {
>    // ELF string tables start with a NUL byte.
>    addString("");
> @@ -1010,8 +1014,8 @@ static unsigned getVerDefNum() { return
>  
>  template <class ELFT>
>  DynamicSection<ELFT>::DynamicSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC | SHF_WRITE, SHT_DYNAMIC,
> -                             sizeof(uintX_t), ".dynamic") {
> +    : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_DYNAMIC, sizeof(uintX_t),
> +                       ".dynamic") {
>    this->Entsize = ELFT::Is64Bits ? 16 : 8;
>    // .dynamic section is not writable on MIPS.
>    // See "Special Section" in Chapter 4 in the following document:
> @@ -1199,8 +1203,8 @@ template <class ELFT> uint32_t DynamicRe
>  
>  template <class ELFT>
>  RelocationSection<ELFT>::RelocationSection(StringRef Name, bool Sort)
> -    : SyntheticSection<ELFT>(SHF_ALLOC, Config->Rela ? SHT_RELA : SHT_REL,
> -                             sizeof(uintX_t), Name),
> +    : SyntheticSection(SHF_ALLOC, Config->Rela ? SHT_RELA : SHT_REL,
> +                       sizeof(uintX_t), Name),
>        Sort(Sort) {
>    this->Entsize = Config->Rela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);
>  }
> @@ -1266,10 +1270,10 @@ template <class ELFT> void RelocationSec
>  template <class ELFT>
>  SymbolTableSection<ELFT>::SymbolTableSection(
>      StringTableSection<ELFT> &StrTabSec)
> -    : SyntheticSection<ELFT>(StrTabSec.isDynamic() ? (uintX_t)SHF_ALLOC : 0,
> -                             StrTabSec.isDynamic() ? SHT_DYNSYM : SHT_SYMTAB,
> -                             sizeof(uintX_t),
> -                             StrTabSec.isDynamic() ? ".dynsym" : ".symtab"),
> +    : SyntheticSection(StrTabSec.isDynamic() ? (uintX_t)SHF_ALLOC : 0,
> +                       StrTabSec.isDynamic() ? SHT_DYNSYM : SHT_SYMTAB,
> +                       sizeof(uintX_t),
> +                       StrTabSec.isDynamic() ? ".dynsym" : ".symtab"),
>        StrTabSec(StrTabSec) {
>    this->Entsize = sizeof(Elf_Sym);
>  }
> @@ -1470,8 +1474,7 @@ SymbolTableSection<ELFT>::getOutputSecti
>  
>  template <class ELFT>
>  GnuHashTableSection<ELFT>::GnuHashTableSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_GNU_HASH, sizeof(uintX_t),
> -                             ".gnu.hash") {
> +    : SyntheticSection(SHF_ALLOC, SHT_GNU_HASH, sizeof(uintX_t), ".gnu.hash") {
>    this->Entsize = ELFT::Is64Bits ? 0 : 4;
>  }
>  
> @@ -1618,7 +1621,7 @@ void GnuHashTableSection<ELFT>::addSymbo
>  
>  template <class ELFT>
>  HashTableSection<ELFT>::HashTableSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_HASH, sizeof(Elf_Word), ".hash") {
> +    : SyntheticSection(SHF_ALLOC, SHT_HASH, sizeof(Elf_Word), ".hash") {
>    this->Entsize = sizeof(Elf_Word);
>  }
>  
> @@ -1657,8 +1660,7 @@ template <class ELFT> void HashTableSect
>  
>  template <class ELFT>
>  PltSection<ELFT>::PltSection(size_t S)
> -    : SyntheticSection<ELFT>(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 16,
> -                             ".plt"),
> +    : SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 16, ".plt"),
>        HeaderSize(S) {}
>  
>  template <class ELFT> void PltSection<ELFT>::writeTo(uint8_t *Buf) {
> @@ -1714,7 +1716,7 @@ template <class ELFT> unsigned PltSectio
>  
>  template <class ELFT>
>  GdbIndexSection<ELFT>::GdbIndexSection()
> -    : SyntheticSection<ELFT>(0, SHT_PROGBITS, 1, ".gdb_index"),
> +    : SyntheticSection(0, SHT_PROGBITS, 1, ".gdb_index"),
>        StringPool(llvm::StringTableBuilder::ELF) {}
>  
>  template <class ELFT> void GdbIndexSection<ELFT>::parseDebugSections() {
> @@ -1858,7 +1860,7 @@ template <class ELFT> bool GdbIndexSecti
>  
>  template <class ELFT>
>  EhFrameHeader<ELFT>::EhFrameHeader()
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_PROGBITS, 1, ".eh_frame_hdr") {}
> +    : SyntheticSection(SHF_ALLOC, SHT_PROGBITS, 1, ".eh_frame_hdr") {}
>  
>  // .eh_frame_hdr contains a binary search table of pointers to FDEs.
>  // Each entry of the search table consists of two values,
> @@ -1907,8 +1909,8 @@ template <class ELFT> bool EhFrameHeader
>  
>  template <class ELFT>
>  VersionDefinitionSection<ELFT>::VersionDefinitionSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_GNU_verdef, sizeof(uint32_t),
> -                             ".gnu.version_d") {}
> +    : SyntheticSection(SHF_ALLOC, SHT_GNU_verdef, sizeof(uint32_t),
> +                       ".gnu.version_d") {}
>  
>  static StringRef getFileDefName() {
>    if (!Config->SoName.empty())
> @@ -1966,8 +1968,8 @@ template <class ELFT> size_t VersionDefi
>  
>  template <class ELFT>
>  VersionTableSection<ELFT>::VersionTableSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_GNU_versym, sizeof(uint16_t),
> -                             ".gnu.version") {}
> +    : SyntheticSection(SHF_ALLOC, SHT_GNU_versym, sizeof(uint16_t),
> +                       ".gnu.version") {}
>  
>  template <class ELFT> void VersionTableSection<ELFT>::finalize() {
>    this->OutSec->Entsize = this->Entsize = sizeof(Elf_Versym);
> @@ -1994,8 +1996,8 @@ template <class ELFT> bool VersionTableS
>  
>  template <class ELFT>
>  VersionNeedSection<ELFT>::VersionNeedSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC, SHT_GNU_verneed, sizeof(uint32_t),
> -                             ".gnu.version_r") {
> +    : SyntheticSection(SHF_ALLOC, SHT_GNU_verneed, sizeof(uint32_t),
> +                       ".gnu.version_r") {
>    // Identifiers in verneed section start at 2 because 0 and 1 are reserved
>    // for VER_NDX_LOCAL and VER_NDX_GLOBAL.
>    // First identifiers are reserved by verdef section if it exist.
> @@ -2084,7 +2086,7 @@ template <class ELFT>
>  MergeSyntheticSection<ELFT>::MergeSyntheticSection(StringRef Name,
>                                                     uint32_t Type, uintX_t Flags,
>                                                     uintX_t Alignment)
> -    : SyntheticSection<ELFT>(Flags, Type, Alignment, Name),
> +    : SyntheticSection(Flags, Type, Alignment, Name),
>        Builder(StringTableBuilder::RAW, Alignment) {}
>  
>  template <class ELFT>
> @@ -2154,8 +2156,8 @@ template <class ELFT> size_t MergeSynthe
>  
>  template <class ELFT>
>  MipsRldMapSection<ELFT>::MipsRldMapSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
> -                             sizeof(typename ELFT::uint), ".rld_map") {}
> +    : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
> +                       sizeof(typename ELFT::uint), ".rld_map") {}
>  
>  template <class ELFT> void MipsRldMapSection<ELFT>::writeTo(uint8_t *Buf) {
>    // Apply filler from linker script.
> @@ -2166,8 +2168,8 @@ template <class ELFT> void MipsRldMapSec
>  
>  template <class ELFT>
>  ARMExidxSentinelSection<ELFT>::ARMExidxSentinelSection()
> -    : SyntheticSection<ELFT>(SHF_ALLOC | SHF_LINK_ORDER, SHT_ARM_EXIDX,
> -                             sizeof(typename ELFT::uint), ".ARM.exidx") {}
> +    : SyntheticSection(SHF_ALLOC | SHF_LINK_ORDER, SHT_ARM_EXIDX,
> +                       sizeof(typename ELFT::uint), ".ARM.exidx") {}
>  
>  // Write a terminating sentinel entry to the end of the .ARM.exidx table.
>  // This section will have been sorted last in the .ARM.exidx table.
> @@ -2188,8 +2190,8 @@ void ARMExidxSentinelSection<ELFT>::writ
>  
>  template <class ELFT>
>  ThunkSection<ELFT>::ThunkSection(OutputSection *OS, uint64_t Off)
> -    : SyntheticSection<ELFT>(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS,
> -                             sizeof(typename ELFT::uint), ".text.thunk") {
> +    : SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS,
> +                       sizeof(typename ELFT::uint), ".text.thunk") {
>    this->OutSec = OS;
>    this->OutSecOff = Off;
>  }
>
> Modified: lld/trunk/ELF/SyntheticSections.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=296313&r1=296312&r2=296313&view=diff
> ==============================================================================
> --- lld/trunk/ELF/SyntheticSections.h (original)
> +++ lld/trunk/ELF/SyntheticSections.h Sun Feb 26 20:56:02 2017
> @@ -30,11 +30,9 @@
>  namespace lld {
>  namespace elf {
>  
> -template <class ELFT> class SyntheticSection : public InputSection {
> -  typedef typename ELFT::uint uintX_t;
> -
> +class SyntheticSection : public InputSection {
>  public:
> -  SyntheticSection(uintX_t Flags, uint32_t Type, uintX_t Addralign,
> +  SyntheticSection(uint64_t Flags, uint32_t Type, uint64_t Addralign,
>                     StringRef Name)
>        : InputSection(Flags, Type, Addralign, {}, Name,
>                       InputSectionBase::Synthetic) {
> @@ -46,10 +44,7 @@ public:
>    virtual size_t getSize() const = 0;
>    virtual void finalize() {}
>    virtual bool empty() const { return false; }
> -
> -  uintX_t getVA() const {
> -    return this->OutSec ? this->OutSec->Addr + this->OutSecOff : 0;
> -  }
> +  uint64_t getVA() const;
>  
>    static bool classof(const InputSectionBase *D) {
>      return D->kind() == InputSectionBase::Synthetic;
> @@ -62,8 +57,7 @@ struct CieRecord {
>  };
>  
>  // Section for .eh_frame.
> -template <class ELFT>
> -class EhFrameSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class EhFrameSection final : public SyntheticSection {
>    typedef typename ELFT::uint uintX_t;
>    typedef typename ELFT::Shdr Elf_Shdr;
>    typedef typename ELFT::Rel Elf_Rel;
> @@ -105,7 +99,7 @@ private:
>    llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
>  };
>  
> -template <class ELFT> class GotSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class GotSection final : public SyntheticSection {
>    typedef typename ELFT::uint uintX_t;
>  
>  public:
> @@ -135,7 +129,7 @@ private:
>  };
>  
>  // .note.gnu.build-id section.
> -template <class ELFT> class BuildIdSection : public SyntheticSection<ELFT> {
> +template <class ELFT> class BuildIdSection : public SyntheticSection {
>    // First 16 bytes are a header.
>    static const unsigned HeaderSize = 16;
>  
> @@ -155,8 +149,7 @@ private:
>  
>  // For each copy relocation, we create an instance of this class to
>  // reserve space in .bss or .bss.rel.ro.
> -template <class ELFT>
> -class CopyRelSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class CopyRelSection final : public SyntheticSection {
>    typedef typename ELFT::uint uintX_t;
>  
>  public:
> @@ -166,8 +159,7 @@ public:
>    size_t Size;
>  };
>  
> -template <class ELFT>
> -class MipsGotSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class MipsGotSection final : public SyntheticSection {
>    typedef typename ELFT::uint uintX_t;
>  
>  public:
> @@ -266,8 +258,7 @@ private:
>    uintX_t Size = 0;
>  };
>  
> -template <class ELFT>
> -class GotPltSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class GotPltSection final : public SyntheticSection {
>    typedef typename ELFT::uint uintX_t;
>  
>  public:
> @@ -285,8 +276,7 @@ private:
>  // Symbols that will be relocated by Target->IRelativeRel.
>  // On most Targets the IgotPltSection will immediately follow the GotPltSection
>  // on ARM the IgotPltSection will immediately follow the GotSection.
> -template <class ELFT>
> -class IgotPltSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class IgotPltSection final : public SyntheticSection {
>    typedef typename ELFT::uint uintX_t;
>  
>  public:
> @@ -300,8 +290,7 @@ private:
>    std::vector<const SymbolBody *> Entries;
>  };
>  
> -template <class ELFT>
> -class StringTableSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class StringTableSection final : public SyntheticSection {
>  public:
>    typedef typename ELFT::uint uintX_t;
>    StringTableSection(StringRef Name, bool Dynamic);
> @@ -344,8 +333,7 @@ private:
>    int64_t Addend;
>  };
>  
> -template <class ELFT>
> -class DynamicSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class DynamicSection final : public SyntheticSection {
>    typedef typename ELFT::Dyn Elf_Dyn;
>    typedef typename ELFT::Rel Elf_Rel;
>    typedef typename ELFT::Rela Elf_Rela;
> @@ -392,8 +380,7 @@ private:
>    uintX_t Size = 0;
>  };
>  
> -template <class ELFT>
> -class RelocationSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class RelocationSection final : public SyntheticSection {
>    typedef typename ELFT::Rel Elf_Rel;
>    typedef typename ELFT::Rela Elf_Rela;
>    typedef typename ELFT::uint uintX_t;
> @@ -419,8 +406,7 @@ struct SymbolTableEntry {
>    size_t StrTabOffset;
>  };
>  
> -template <class ELFT>
> -class SymbolTableSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class SymbolTableSection final : public SyntheticSection {
>  public:
>    typedef typename ELFT::Shdr Elf_Shdr;
>    typedef typename ELFT::Sym Elf_Sym;
> @@ -456,7 +442,7 @@ private:
>  // Outputs GNU Hash section. For detailed explanation see:
>  // https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections
>  template <class ELFT>
> -class GnuHashTableSection final : public SyntheticSection<ELFT> {
> +class GnuHashTableSection final : public SyntheticSection {
>    typedef typename ELFT::Off Elf_Off;
>    typedef typename ELFT::Word Elf_Word;
>    typedef typename ELFT::uint uintX_t;
> @@ -493,8 +479,7 @@ private:
>    uintX_t Size = 0;
>  };
>  
> -template <class ELFT>
> -class HashTableSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class HashTableSection final : public SyntheticSection {
>    typedef typename ELFT::Word Elf_Word;
>  
>  public:
> @@ -511,7 +496,7 @@ private:
>  // header as its first entry that is used at run-time to resolve lazy binding.
>  // The latter is used for GNU Ifunc symbols, that will be subject to a
>  // Target->IRelativeRel.
> -template <class ELFT> class PltSection : public SyntheticSection<ELFT> {
> +template <class ELFT> class PltSection : public SyntheticSection {
>  public:
>    PltSection(size_t HeaderSize);
>    void writeTo(uint8_t *Buf) override;
> @@ -529,8 +514,7 @@ private:
>    size_t HeaderSize;
>  };
>  
> -template <class ELFT>
> -class GdbIndexSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class GdbIndexSection final : public SyntheticSection {
>    typedef typename ELFT::uint uintX_t;
>  
>    const unsigned OffsetTypeSize = 4;
> @@ -582,8 +566,7 @@ private:
>  // Detailed info about internals can be found in Ian Lance Taylor's blog:
>  // http://www.airs.com/blog/archives/460 (".eh_frame")
>  // http://www.airs.com/blog/archives/462 (".eh_frame_hdr")
> -template <class ELFT>
> -class EhFrameHeader final : public SyntheticSection<ELFT> {
> +template <class ELFT> class EhFrameHeader final : public SyntheticSection {
>    typedef typename ELFT::uint uintX_t;
>  
>  public:
> @@ -611,7 +594,7 @@ private:
>  // The section shall contain an array of Elf_Verdef structures, optionally
>  // followed by an array of Elf_Verdaux structures.
>  template <class ELFT>
> -class VersionDefinitionSection final : public SyntheticSection<ELFT> {
> +class VersionDefinitionSection final : public SyntheticSection {
>    typedef typename ELFT::Verdef Elf_Verdef;
>    typedef typename ELFT::Verdaux Elf_Verdaux;
>  
> @@ -634,7 +617,7 @@ private:
>  // The values 0 and 1 are reserved. All other values are used for versions in
>  // the own object or in any of the dependencies.
>  template <class ELFT>
> -class VersionTableSection final : public SyntheticSection<ELFT> {
> +class VersionTableSection final : public SyntheticSection {
>    typedef typename ELFT::Versym Elf_Versym;
>  
>  public:
> @@ -650,8 +633,7 @@ public:
>  // Elf_Verneed specifies the version requirements for a single DSO, and contains
>  // a reference to a linked list of Elf_Vernaux data structures which define the
>  // mapping from version identifiers to version names.
> -template <class ELFT>
> -class VersionNeedSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class VersionNeedSection final : public SyntheticSection {
>    typedef typename ELFT::Verneed Elf_Verneed;
>    typedef typename ELFT::Vernaux Elf_Vernaux;
>  
> @@ -677,7 +659,7 @@ public:
>  // we put them into MergeSyntheticSection synthetic input sections which are
>  // attached to regular output sections.
>  template <class ELFT>
> -class MergeSyntheticSection final : public SyntheticSection<ELFT> {
> +class MergeSyntheticSection final : public SyntheticSection {
>    typedef typename ELFT::uint uintX_t;
>  
>  public:
> @@ -700,7 +682,7 @@ private:
>  
>  // .MIPS.abiflags section.
>  template <class ELFT>
> -class MipsAbiFlagsSection final : public SyntheticSection<ELFT> {
> +class MipsAbiFlagsSection final : public SyntheticSection {
>    typedef llvm::object::Elf_Mips_ABIFlags<ELFT> Elf_Mips_ABIFlags;
>  
>  public:
> @@ -715,8 +697,7 @@ private:
>  };
>  
>  // .MIPS.options section.
> -template <class ELFT>
> -class MipsOptionsSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class MipsOptionsSection final : public SyntheticSection {
>    typedef llvm::object::Elf_Mips_Options<ELFT> Elf_Mips_Options;
>    typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
>  
> @@ -735,8 +716,7 @@ private:
>  };
>  
>  // MIPS .reginfo section.
> -template <class ELFT>
> -class MipsReginfoSection final : public SyntheticSection<ELFT> {
> +template <class ELFT> class MipsReginfoSection final : public SyntheticSection {
>    typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
>  
>  public:
> @@ -754,14 +734,14 @@ private:
>  // of executable file which is pointed to by the DT_MIPS_RLD_MAP entry.
>  // See "Dynamic section" in Chapter 5 in the following document:
>  // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
> -template <class ELFT> class MipsRldMapSection : public SyntheticSection<ELFT> {
> +template <class ELFT> class MipsRldMapSection : public SyntheticSection {
>  public:
>    MipsRldMapSection();
>    size_t getSize() const override { return sizeof(typename ELFT::uint); }
>    void writeTo(uint8_t *Buf) override;
>  };
>  
> -template <class ELFT> class ARMExidxSentinelSection : public SyntheticSection<ELFT> {
> +template <class ELFT> class ARMExidxSentinelSection : public SyntheticSection {
>  public:
>    ARMExidxSentinelSection();
>    size_t getSize() const override { return 8; }
> @@ -770,7 +750,7 @@ public:
>  
>  // A container for one or more linker generated thunks. Instances of these
>  // thunks including ARM interworking and Mips LA25 PI to non-PI thunks.
> -template <class ELFT> class ThunkSection : public SyntheticSection<ELFT> {
> +template <class ELFT> class ThunkSection : public SyntheticSection {
>  public:
>    // ThunkSection in OS, with desired OutSecOff of Off
>    ThunkSection(OutputSection *OS, uint64_t Off);
>
> Modified: lld/trunk/ELF/Writer.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=296313&r1=296312&r2=296313&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Writer.cpp (original)
> +++ lld/trunk/ELF/Writer.cpp Sun Feb 26 20:56:02 2017
> @@ -530,7 +530,7 @@ template <class ELFT> void Writer<ELFT>:
>      InputSection *IS = nullptr;
>      if (!Sec->Sections.empty())
>        IS = Sec->Sections[0];
> -    if (!IS || isa<SyntheticSection<ELFT>>(IS) || IS->Type == SHT_REL ||
> +    if (!IS || isa<SyntheticSection>(IS) || IS->Type == SHT_REL ||
>          IS->Type == SHT_RELA)
>        continue;
>      auto *B = new (BAlloc)
> @@ -1022,9 +1022,8 @@ template <class ELFT> void Writer<ELFT>:
>  }
>  
>  template <class ELFT>
> -static void
> -finalizeSynthetic(const std::vector<SyntheticSection<ELFT> *> &Sections) {
> -  for (SyntheticSection<ELFT> *SS : Sections)
> +static void finalizeSynthetic(const std::vector<SyntheticSection *> &Sections) {
> +  for (SyntheticSection *SS : Sections)
>      if (SS && SS->OutSec && !SS->empty()) {
>        SS->finalize();
>        SS->OutSec->Size = 0;
> @@ -1042,7 +1041,7 @@ static void removeUnusedSyntheticSection
>    // all regular ones. We iterate over them all and exit at first
>    // non-synthetic.
>    for (InputSectionBase *S : llvm::reverse(InputSections)) {
> -    SyntheticSection<ELFT> *SS = dyn_cast<SyntheticSection<ELFT>>(S);
> +    SyntheticSection *SS = dyn_cast<SyntheticSection>(S);
>      if (!SS)
>        return;
>      if (!SS->empty() || !SS->OutSec)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list