llvm.org GIT mirror llvm / c18f66e
[yaml2obj][ELF] Add the section name -> section index map to State. One of the key things that the YAML format abstracts over is the use of section numbers for referencing sections. Instead, textual section names are used, which yaml2obj then translates into appropriate section numbers. (Technically ELF doesn't care about section names (only section numbers), but since this is a testing tool, readability counts). This simplifies using section names as symbolic references in various parts of the code. An upcoming commit will use this to allow symbols to reference sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184467 91177308-0d34-0410-b5e6-96231b3b80d8 Sean Silva 7 years ago
1 changed file(s) with 7 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
149149 /// \brief The ELF file header.
150150 Elf_Ehdr &Header;
151151
152 SectionNameToIdxMap &SN2I;
153
152154 public:
153155
154156 ELFState(Elf_Ehdr &Header_, ContiguousBlobAccumulator &Accum,
155 unsigned DotStrtabSecNo_)
157 unsigned DotStrtabSecNo_, SectionNameToIdxMap &SN2I_)
156158 : DotStrtab(), DotStrtabSecNo(DotStrtabSecNo_),
157 SectionContentAccum(Accum), Header(Header_) {}
159 SectionContentAccum(Accum), Header(Header_), SN2I(SN2I_) {}
158160
159161 unsigned getDotStrTabSecNo() const { return DotStrtabSecNo; }
160162 StringTableBuilder &getStringTable() { return DotStrtab; }
161163 ContiguousBlobAccumulator &getSectionContentAccum() {
162164 return SectionContentAccum;
163165 }
166 SectionNameToIdxMap &getSN2I() { return SN2I; }
164167 };
165168 } // end anonymous namespace
166169
251254 const size_t SectionContentBeginOffset =
252255 Header.e_ehsize + Header.e_shentsize * Header.e_shnum;
253256 ContiguousBlobAccumulator CBA(SectionContentBeginOffset);
254 ELFState State(Header, CBA, DotStrtabSecNo);
255
256257 SectionNameToIdxMap SN2I;
257258 for (unsigned i = 0, e = Sections.size(); i != e; ++i) {
258259 StringRef Name = Sections[i].Name;
265266 return 1;
266267 }
267268 }
269
270 ELFState State(Header, CBA, DotStrtabSecNo, SN2I);
268271
269272 StringTableBuilder SHStrTab;
270273 std::vector SHeaders;