[lld] r194987 - Add an assert for NativeReferenceIvarsV1.

Rui Ueyama ruiu at google.com
Sun Nov 17 19:50:50 PST 2013

Author: ruiu
Date: Sun Nov 17 21:50:50 2013
New Revision: 194987

URL: http://llvm.org/viewvc/llvm-project?rev=194987&view=rev
Add an assert for NativeReferenceIvarsV1.

The maximum number of references the file with NativeReferenceIvarsV1 can
contain is 65534. If a file larger than that is converted to Native format,
the conversion will fail without any error message. This caused a subtle bug
that the LLD would produce a broken executable only when input files contain
too many references.

This issue exists since the RoundTripNativeTest is introduced in r193585. Since
then, it seems that nobody have linked any program having more than 65534
relocations with the LLD. Otherwise we would have found it earlier.


Modified: lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp?rev=194987&r1=194986&r2=194987&view=diff
--- lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp (original)
+++ lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp Sun Nov 17 21:50:50 2013
@@ -18,6 +18,7 @@
 #include "NativeFileFormat.h"
+#include <limits>
 #include <vector>
 namespace lld {
@@ -404,6 +405,7 @@ private:
     uint32_t result = _targetsTableIndex.size();
     _targetsTableIndex[target] = result;
+    assert(result < NativeReferenceIvarsV1::noTarget);
     return result;

More information about the llvm-commits mailing list