[yaml2obj][ELF] Remove relationship between ELFState
authorSimon Atanasyan <simon@atanasyan.com>
Wed, 2 Apr 2014 16:34:34 +0000 (16:34 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Wed, 2 Apr 2014 16:34:34 +0000 (16:34 +0000)
and ContiguousBlobAccumulator classes. Pass ContiguousBlobAccumulator to
the handleSymtabSectionHeader function directly.

No functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205431 91177308-0d34-0410-b5e6-96231b3b80d8

tools/yaml2obj/yaml2elf.cpp

index e79ddcd82423e90e6fe551ecf5596215d71bfa8e..e02c12599f81953926a46854e62ccb8e747d79ef 100644 (file)
@@ -156,23 +156,16 @@ class ELFState {
   StringTableBuilder DotStrtab;
   /// \brief The section number of the ".strtab" section.
   unsigned DotStrtabSecNo;
-  /// \brief The accumulated contents of all sections so far.
-  ContiguousBlobAccumulator &SectionContentAccum;
   typedef typename object::ELFFile<ELFT>::Elf_Ehdr Elf_Ehdr;
 
   SectionNameToIdxMap &SN2I;
 
 public:
-  ELFState(ContiguousBlobAccumulator &Accum, unsigned DotStrtabSecNo_,
-           SectionNameToIdxMap &SN2I_)
-      : DotStrtab(), DotStrtabSecNo(DotStrtabSecNo_),
-        SectionContentAccum(Accum), SN2I(SN2I_) {}
+  ELFState(unsigned DotStrtabSecNo_, SectionNameToIdxMap &SN2I_)
+      : DotStrtab(), DotStrtabSecNo(DotStrtabSecNo_), SN2I(SN2I_) {}
 
   unsigned getDotStrTabSecNo() const { return DotStrtabSecNo; }
   StringTableBuilder &getStringTable() { return DotStrtab; }
-  ContiguousBlobAccumulator &getSectionContentAccum() {
-    return SectionContentAccum;
-  }
   SectionNameToIdxMap &getSN2I() { return SN2I; }
 };
 } // end anonymous namespace
@@ -211,7 +204,8 @@ template <class ELFT>
 static void
 handleSymtabSectionHeader(const ELFYAML::LocalGlobalWeakSymbols &Symbols,
                           ELFState<ELFT> &State,
-                          typename object::ELFFile<ELFT>::Elf_Shdr &SHeader) {
+                          typename object::ELFFile<ELFT>::Elf_Shdr &SHeader,
+                          ContiguousBlobAccumulator &CBA) {
 
   typedef typename object::ELFFile<ELFT>::Elf_Sym Elf_Sym;
   SHeader.sh_type = ELF::SHT_SYMTAB;
@@ -231,7 +225,6 @@ handleSymtabSectionHeader(const ELFYAML::LocalGlobalWeakSymbols &Symbols,
   addSymbols(Symbols.Global, State, Syms, ELF::STB_GLOBAL);
   addSymbols(Symbols.Weak, State, Syms, ELF::STB_WEAK);
 
-  ContiguousBlobAccumulator &CBA = State.getSectionContentAccum();
   writeArrayData(CBA.getOSAndAlignedOffset(SHeader.sh_offset),
                  makeArrayRef(Syms));
   SHeader.sh_size = arrayDataSize(makeArrayRef(Syms));
@@ -299,7 +292,7 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) {
     }
   }
 
-  ELFState<ELFT> State(CBA, DotStrtabSecNo, SN2I);
+  ELFState<ELFT> State(DotStrtabSecNo, SN2I);
 
   StringTableBuilder SHStrTab;
   std::vector<Elf_Shdr> SHeaders;
@@ -340,7 +333,7 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) {
   Elf_Shdr SymtabSHeader;
   zero(SymtabSHeader);
   SymtabSHeader.sh_name = SHStrTab.addString(StringRef(".symtab"));
-  handleSymtabSectionHeader<ELFT>(Doc.Symbols, State, SymtabSHeader);
+  handleSymtabSectionHeader<ELFT>(Doc.Symbols, State, SymtabSHeader, CBA);
   SHeaders.push_back(SymtabSHeader);
 
   // .strtab string table header.