PECOFF: Fix dummy symbol table in executable.

If the name field of a symbol table entry is all zero, it's interpreted
as it's pointing to the beginning of the string table. The first four
bytes of the string table is the size field, so dumpbin dumps that number
as an ASCIZ string.

This patch fills a dummy value to name field.

llvm-svn: 228971
This commit is contained in:
Rui Ueyama 2015-02-12 22:46:16 +00:00
parent 7548aeeb9f
commit acbe51a0e3
1 changed files with 4 additions and 0 deletions

View File

@ -195,6 +195,10 @@ public:
// We also need to reserve 4 bytes for the string table header.
int size = sizeof(llvm::object::coff_symbol16) + 4;
_stringTable.insert(_stringTable.begin(), size, 0);
// Set the name of the dummy symbol to the first string table entry.
// It's better than letting dumpbin print out a garabage as a symbol name.
char *off = _stringTable.data() + 4;
*reinterpret_cast<ulittle32_t *>(off) = 4;
}
uint32_t offset = _stringTable.size();
_stringTable.insert(_stringTable.end(), sectionName.begin(),