summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Silva <silvas@purdue.edu>2013-06-18 21:37:50 +0000
committerSean Silva <silvas@purdue.edu>2013-06-18 21:37:50 +0000
commitc3131926c0f010061c4931d4bf92791955969bad (patch)
treed1c326d4b2d92f338e9d7333dc428a43f04f19cf
parent362f5035194fc9370a973db1510dd68e97790f40 (diff)
downloadbcm5719-llvm-c3131926c0f010061c4931d4bf92791955969bad.tar.gz
bcm5719-llvm-c3131926c0f010061c4931d4bf92791955969bad.zip
[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. llvm-svn: 184242
-rw-r--r--llvm/tools/yaml2obj/yaml2elf.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp
index 3a4f5e04502..b83dd1d1a35 100644
--- a/llvm/tools/yaml2obj/yaml2elf.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud