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

Michael Spencer bigcheesegs at gmail.com
Tue Nov 13 16:07:44 PST 2012


On Tue, Nov 13, 2012 at 2:09 PM, Ulrich Weigand
<Ulrich.Weigand at de.ibm.com> wrote:
>
> 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)
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>

Fixed in r167893 by refactoring. Also fixed style issues and proper
error handling.

- Michael Spencer



More information about the llvm-commits mailing list