[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
This commit is contained in:
Lang Hames
2015-12-10 00:12:24 +00:00
parent 26ba3870bf
commit 201c08f811

View File

@@ -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);
}