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

Shankar Easwaran shankare at codeaurora.org
Tue Nov 13 14:56:19 PST 2012


On 11/13/2012 4:09 PM, Ulrich Weigand 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)
Looks fine to me. Thanks for fixing the problem.

Thanks

Shankar Easwaran

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation




More information about the llvm-commits mailing list