diff options
author | Lang Hames <lhames@gmail.com> | 2015-12-10 00:12:24 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2015-12-10 00:12:24 +0000 |
commit | 201c08f811cc2804e855185fbc52ca386a430d94 (patch) | |
tree | edf51c832f3e24dadf1e3e64a61913178fa891ed /lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp | |
parent | 26ba3870bfe15a54de390316d7d1bd2ceb6724ab (diff) | |
download | bcm5719-llvm-201c08f811cc2804e855185fbc52ca386a430d94.tar.gz bcm5719-llvm-201c08f811cc2804e855185fbc52ca386a430d94.zip |
[lld][MachO] Always reserve space for the empty string in the mach-o symbol
table.
The first entry in the MachO symbol table is always the empty string: make sure
we reserve space for it, or we will overflow the symbol table by one byte.
No test case - this manifests as an occasional memory error. In the near future
I hope to set up a bot building and runnnig LLD with sanitizers - that should
catch future instances of this issue.
llvm-svn: 255178
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp')
-rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp index 7afb2539579..45dea1c2742 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp @@ -1269,7 +1269,7 @@ void MachOFileLayout::computeSymbolTableSizes() { _symbolTableSize = nlistSize * (_file.localSymbols.size() + _file.globalSymbols.size() + _file.undefinedSymbols.size()); - _symbolStringPoolSize = 0; + _symbolStringPoolSize = 1; // Always reserve 1-byte for the empty string. for (const Symbol &sym : _file.localSymbols) { _symbolStringPoolSize += (sym.name.size()+1); } |