[llvm-commits] [PATCH] Fix llvm-nm crash on big-endian systems caused by r167853

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Tue Nov 13 14:09:37 PST 2012


Hello,

this change (part of r167853):

+    uint32_t *offsetaddr =
+             (uint32_t *)(reinterpret_cast<const support::ulittle32_t*>
(offsets)
+                          + (offsetindex - 1));
+    assert((const char *)offsetaddr <
+           Parent->SymbolTable->getBuffer()->getBufferEnd());
+    offset = *(offsetaddr);

causes crashes when llvm-nm is compiled on a big-endian host; note how the
"support::ulittle32_t" pointer is cast back right away to a plain uint32_t
pointer, which gets dereferenced using the host endianness.

The attached patch fixes this (fixing the Object/coff-archive.test test
case on PowerPC), and removes a const-violation warning as well.

OK to commit?

Bye,
Ulrich
(See attached file: diff-llvm-archive-lefix)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff-llvm-archive-lefix
Type: application/octet-stream
Size: 836 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121113/a7ac4391/attachment.obj>


More information about the llvm-commits mailing list