summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Silva <silvas@purdue.edu>2013-06-20 20:59:34 +0000
committerSean Silva <silvas@purdue.edu>2013-06-20 20:59:34 +0000
commitc18f66e70dea8abc8c9d86d40088fc8fc8247b20 (patch)
tree2684a663d9e84b2989b4e3433ce586885e5cf2fb
parent11ca2e508c2152732c364d02e5b381e61c851084 (diff)
downloadllvm-c18f66e70dea8abc8c9d86d40088fc8fc8247b20.tar.gz
llvm-c18f66e70dea8abc8c9d86d40088fc8fc8247b20.tar.bz2
llvm-c18f66e70dea8abc8c9d86d40088fc8fc8247b20.tar.xz
[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
-rw-r--r--tools/yaml2obj/yaml2elf.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp
index 501dc2b46f..667718af38 100644
--- a/tools/yaml2obj/yaml2elf.cpp
+++ b/tools/yaml2obj/yaml2elf.cpp
@@ -150,18 +150,21 @@ class ELFState {
/// \brief The ELF file header.
Elf_Ehdr &Header;
+ SectionNameToIdxMap &SN2I;
+
public:
ELFState(Elf_Ehdr &Header_, ContiguousBlobAccumulator &Accum,
- unsigned DotStrtabSecNo_)
+ unsigned DotStrtabSecNo_, SectionNameToIdxMap &SN2I_)
: DotStrtab(), DotStrtabSecNo(DotStrtabSecNo_),
- SectionContentAccum(Accum), Header(Header_) {}
+ 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
@@ -252,8 +255,6 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) {
const size_t SectionContentBeginOffset =
Header.e_ehsize + Header.e_shentsize * Header.e_shnum;
ContiguousBlobAccumulator CBA(SectionContentBeginOffset);
- ELFState<ELFT> State(Header, CBA, DotStrtabSecNo);
-
SectionNameToIdxMap SN2I;
for (unsigned i = 0, e = Sections.size(); i != e; ++i) {
StringRef Name = Sections[i].Name;
@@ -267,6 +268,8 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) {
}
}
+ ELFState<ELFT> State(Header, CBA, DotStrtabSecNo, SN2I);
+
StringTableBuilder SHStrTab;
std::vector<Elf_Shdr> SHeaders;
{