-// FIXME: This function is hideous. Between the sheer number of parameters
-// and the hideous ELF typenames, it's just a travesty. Factor the ELF
-// output into a class (templated on ELFT) and share some typedefs.
+namespace {
+/// \brief "Single point of truth" for the ELF file construction.
+/// TODO: This class still has a ways to go before it is truly a "single
+/// point of truth".
+template <class ELFT>
+class ELFState {
+ /// \brief The future ".strtab" section.
+ 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::ELFObjectFile<ELFT>::Elf_Ehdr Elf_Ehdr;
+ /// \brief The ELF file header.
+ Elf_Ehdr &Header;
+
+ SectionNameToIdxMap &SN2I;
+
+public:
+
+ ELFState(Elf_Ehdr &Header_, ContiguousBlobAccumulator &Accum,
+ unsigned DotStrtabSecNo_, SectionNameToIdxMap &SN2I_)
+ : DotStrtab(), DotStrtabSecNo(DotStrtabSecNo_),
+ SectionContentAccum(Accum), Header(Header_), SN2I(SN2I_) {}
+
+ unsigned getDotStrTabSecNo() const { return DotStrtabSecNo; }
+ StringTableBuilder &getStringTable() { return DotStrtab; }
+ ContiguousBlobAccumulator &getSectionContentAccum() {
+ return SectionContentAccum;
+ }
+ SectionNameToIdxMap &getSN2I() { return SN2I; }
+};
+} // end anonymous namespace
+
+// FIXME: This function is hideous. The hideous ELF type names are hideous.
+// Factor the ELF output into a class (templated on ELFT) and share some
+// typedefs.