summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Silva <silvas@purdue.edu>2013-06-18 01:11:24 +0000
committerSean Silva <silvas@purdue.edu>2013-06-18 01:11:24 +0000
commit7dc89c1f3ab870e5f517aa201d98befd6249ed5f (patch)
treef8da614654bebf82e5da388452077131e0996630
parent13a8e2da7636b9f90d10cd77ac2a9194aa492cb4 (diff)
downloadllvm-7dc89c1f3ab870e5f517aa201d98befd6249ed5f.tar.gz
llvm-7dc89c1f3ab870e5f517aa201d98befd6249ed5f.tar.bz2
llvm-7dc89c1f3ab870e5f517aa201d98befd6249ed5f.tar.xz
[yaml2obj][ELF] Refer specifically to the section header string table.
A bug in libObject will cause it to assert() if a symbol table's string table and the section header string table are the same section, so we need to ensure that we emit two different string tables (among other things). The problematic code is the hardcoded usage of ".strtab" (`dot_strtab_sec`) for looking up symbol names in ELFObjectFile<ELFT>::getSymbolName. I discussed this with Michael, and he has some local improvements to the ELF code in libObject that, among other things, should fix our handling of this scenario. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184161 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/yaml2obj/yaml2elf.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp
index 8e0383c022..2ae6e152de 100644
--- a/tools/yaml2obj/yaml2elf.cpp
+++ b/tools/yaml2obj/yaml2elf.cpp
@@ -181,7 +181,7 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) {
}
}
- StringTableBuilder StrTab;
+ StringTableBuilder SHStrTab;
SmallVector<char, 128> Buf;
// XXX: This offset is tightly coupled with the order that we write
// things to `OS`.
@@ -193,7 +193,7 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) {
const ELFYAML::Section &Sec = Sections[i];
Elf_Shdr SHeader;
zero(SHeader);
- SHeader.sh_name = StrTab.addString(Sec.Name);
+ SHeader.sh_name = SHStrTab.addString(Sec.Name);
SHeader.sh_type = Sec.Type;
SHeader.sh_flags = Sec.Flags;
SHeader.sh_addr = Sec.Address;
@@ -217,24 +217,24 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) {
SHeaders.push_back(SHeader);
}
- // String table header.
- Elf_Shdr StrTabSHeader;
- zero(StrTabSHeader);
- StrTabSHeader.sh_name = 0;
- StrTabSHeader.sh_type = SHT_STRTAB;
- StrTabSHeader.sh_flags = 0;
- StrTabSHeader.sh_addr = 0;
- StrTabSHeader.sh_offset = CBA.currentOffset();
- StrTabSHeader.sh_size = StrTab.size();
- StrTab.writeToStream(CBA.getOS());
- StrTabSHeader.sh_link = 0;
- StrTabSHeader.sh_info = 0;
- StrTabSHeader.sh_addralign = 1;
- StrTabSHeader.sh_entsize = 0;
+ // Section header string table header.
+ Elf_Shdr SHStrTabSHeader;
+ zero(SHStrTabSHeader);
+ SHStrTabSHeader.sh_name = 0;
+ SHStrTabSHeader.sh_type = SHT_STRTAB;
+ SHStrTabSHeader.sh_flags = 0;
+ SHStrTabSHeader.sh_addr = 0;
+ SHStrTabSHeader.sh_offset = CBA.currentOffset();
+ SHStrTabSHeader.sh_size = SHStrTab.size();
+ SHStrTab.writeToStream(CBA.getOS());
+ SHStrTabSHeader.sh_link = 0;
+ SHStrTabSHeader.sh_info = 0;
+ SHStrTabSHeader.sh_addralign = 1;
+ SHStrTabSHeader.sh_entsize = 0;
OS.write((const char *)&Header, sizeof(Header));
writeVectorData(OS, SHeaders);
- OS.write((const char *)&StrTabSHeader, sizeof(StrTabSHeader));
+ OS.write((const char *)&SHStrTabSHeader, sizeof(SHStrTabSHeader));
CBA.writeBlobToStream(OS);
return 0;
}