From acbe51a0e30bc9f6163f0df6e303799e99f65e14 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 12 Feb 2015 22:46:16 +0000 Subject: [PATCH] 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 --- lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp index 099c370..c854820 100644 --- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp @@ -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(off) = 4; } uint32_t offset = _stringTable.size(); _stringTable.insert(_stringTable.end(), sectionName.begin(), -- 2.7.4