[lld] r228971 - PECOFF: Fix dummy symbol table in executable.

Rui Ueyama ruiu at google.com
Thu Feb 12 14:46:16 PST 2015


Author: ruiu
Date: Thu Feb 12 16:46:16 2015
New Revision: 228971

URL: http://llvm.org/viewvc/llvm-project?rev=228971&view=rev
Log:
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.

Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp

Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=228971&r1=228970&r2=228971&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Thu Feb 12 16:46:16 2015
@@ -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(),





More information about the llvm-commits mailing list