[lld] r193909 - [MachO] Fix uninitialized field bug found on Windows.
Rui Ueyama
ruiu at google.com
Fri Nov 1 20:35:45 PDT 2013
Author: ruiu
Date: Fri Nov 1 22:35:45 2013
New Revision: 193909
URL: http://llvm.org/viewvc/llvm-project?rev=193909&view=rev
Log:
[MachO] Fix uninitialized field bug found on Windows.
n_desc field in MachO string table was not initialized. On Unix,
test/darwin/hello-world.objtxt did not fail because I think an nlist object
is always allocated to a fresh heap initialized with zeros. On Windows,
uninitialized fields are filled with 0xCC when compiled with /GZ. Because
of that the test was failing on Windows.
Modified:
lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp
Modified: lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp?rev=193909&r1=193908&r2=193909&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp Fri Nov 1 22:35:45 2013
@@ -1201,6 +1201,7 @@ void SymbolTableChunk::computeSize(const
sym.n_strx = _stringsChunk.stringIndex(info.atom->name());
sym.n_type = this->nType(info.atom);
sym.n_sect = sectionIndex;
+ sym.n_desc = 0;
sym.n_value = atomAddress;
if ( info.atom->scope() == DefinedAtom::scopeGlobal )
_globalDefinedsymbols.push_back(sym);
@@ -1216,6 +1217,7 @@ void SymbolTableChunk::computeSize(const
sym.n_strx = _stringsChunk.stringIndex(atom->name());
sym.n_type = N_UNDF;
sym.n_sect = 0;
+ sym.n_desc = 0;
sym.n_value = 0;
_undefinedsymbols.push_back(sym);
}
More information about the llvm-commits
mailing list