diff options
author | Sean Silva <silvas@purdue.edu> | 2013-06-18 21:37:50 +0000 |
---|---|---|
committer | Sean Silva <silvas@purdue.edu> | 2013-06-18 21:37:50 +0000 |
commit | a7bd8549fdcb18c686bdadf46000452c927d3b5d (patch) | |
tree | aa9cbb4aa5b89dc8d3d6822d73a30674789a1e72 /tools/yaml2obj | |
parent | f2db8dfa84ead80df2e0ca8a56e9f0ae18d67a5e (diff) | |
download | external_llvm-a7bd8549fdcb18c686bdadf46000452c927d3b5d.zip external_llvm-a7bd8549fdcb18c686bdadf46000452c927d3b5d.tar.gz external_llvm-a7bd8549fdcb18c686bdadf46000452c927d3b5d.tar.bz2 |
[yaml2obj][ELF] Add dummy .strtab section.
This will be needed later for holding symbol names, due to the libObject
issue mentioned in the commit message of r184161.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184242 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/yaml2obj')
-rw-r--r-- | tools/yaml2obj/yaml2elf.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp index 3a4f5e0..b83dd1d 100644 --- a/tools/yaml2obj/yaml2elf.cpp +++ b/tools/yaml2obj/yaml2elf.cpp @@ -177,10 +177,10 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) { zero(S.AddressAlign); Sections.insert(Sections.begin(), S); } - // "+ 1" for string table. - Header.e_shnum = Sections.size() + 1; + // "+ 2" for string table and section header string table. + Header.e_shnum = Sections.size() + 2; // Place section header string table last. - Header.e_shstrndx = Sections.size(); + Header.e_shstrndx = Sections.size() + 1; SectionNameToIdxMap SN2I; for (unsigned i = 0, e = Sections.size(); i != e; ++i) { @@ -230,6 +230,13 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) { SHeaders.push_back(SHeader); } + // .strtab string table header. Currently emitted empty. + StringTableBuilder DotStrTab; + Elf_Shdr DotStrTabSHeader; + zero(DotStrTabSHeader); + DotStrTabSHeader.sh_name = SHStrTab.addString(StringRef(".strtab")); + createStringTableSectionHeader(DotStrTabSHeader, DotStrTab, CBA); + // Section header string table header. Elf_Shdr SHStrTabSHeader; zero(SHStrTabSHeader); @@ -237,6 +244,7 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) { OS.write((const char *)&Header, sizeof(Header)); writeVectorData(OS, SHeaders); + OS.write((const char *)&DotStrTabSHeader, sizeof(DotStrTabSHeader)); OS.write((const char *)&SHStrTabSHeader, sizeof(SHStrTabSHeader)); CBA.writeBlobToStream(OS); return 0; |