diff options
author | Pete Cooper <peter_cooper@apple.com> | 2016-08-08 23:20:04 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2016-08-08 23:20:04 +0000 |
commit | 5559b2493526d5ff38a66cb38b276c2a7e93b0c9 (patch) | |
tree | 4f52db12740a987c67ceb5431671151d6112ffe2 /lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp | |
parent | f53c8cb4394e5a560a2a1bbfcd8da00af72a645e (diff) | |
download | bcm5719-llvm-5559b2493526d5ff38a66cb38b276c2a7e93b0c9.tar.gz bcm5719-llvm-5559b2493526d5ff38a66cb38b276c2a7e93b0c9.zip |
The first string table entry should be a null terminated space, not just null.
This matches the behaviour of ld64 which initializes the string table with
' ' then '\0'. lld only had the '\0' and needed the ' '.
llvm-svn: 278071
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp')
-rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp index a0609a5e926..89b0f6f55a5 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp @@ -1106,7 +1106,9 @@ void MachOFileLayout::writeSymbolTable() { // Write symbol table and symbol strings in parallel. uint32_t symOffset = _startOfSymbols; uint32_t strOffset = _startOfSymbolStrings; - _buffer[strOffset++] = '\0'; // Reserve n_strx offset of zero to mean no name. + // Reserve n_strx offset of zero to mean no name. + _buffer[strOffset++] = ' '; + _buffer[strOffset++] = '\0'; appendSymbols(_file.stabsSymbols, symOffset, strOffset); appendSymbols(_file.localSymbols, symOffset, strOffset); appendSymbols(_file.globalSymbols, symOffset, strOffset); @@ -1448,7 +1450,8 @@ void MachOFileLayout::computeSymbolTableSizes() { + _file.localSymbols.size() + _file.globalSymbols.size() + _file.undefinedSymbols.size()); - _symbolStringPoolSize = 1; // Always reserve 1-byte for the empty string. + // Always reserve 1-byte for the empty string and 1-byte for its terminator. + _symbolStringPoolSize = 2; for (const Symbol &sym : _file.stabsSymbols) { _symbolStringPoolSize += (sym.name.size()+1); } |