[llvm] r184242 - [yaml2obj][ELF] Add dummy .strtab section.
Sean Silva
silvas at purdue.edu
Tue Jun 18 14:37:51 PDT 2013
Author: silvas
Date: Tue Jun 18 16:37:50 2013
New Revision: 184242
URL: http://llvm.org/viewvc/llvm-project?rev=184242&view=rev
Log:
[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.
Modified:
llvm/trunk/tools/yaml2obj/yaml2elf.cpp
Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=184242&r1=184241&r2=184242&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Tue Jun 18 16:37:50 2013
@@ -177,10 +177,10 @@ static int writeELF(raw_ostream &OS, con
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, con
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, con
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;
More information about the llvm-commits
mailing list