[PATCH] Fixes -fsanitize=undefined warning about left-shifting a negative signed value.

Artem Belevich tra at google.com
Thu Jan 8 14:06:04 PST 2015


I've attached the patch.

The issue is that ubsan spotted a case where we extract 21 bits from a
negative signed addend value in order to encode it into binary
representation of reloc.

While behavior is harmless in this case, technically it does fall under
undefined behavior. The patch extracts relevant bits into an unsigned
variable first and then uses that unsigned value to shift bits around.

--Artem

On Thu, Jan 8, 2015 at 1:46 PM, Chandler Carruth <chandlerc at google.com>
wrote:

> FYI, could you attach the patch file rather than including it inline, or
> post it using Phabricator[1]?
>
> [1]: http://llvm.org/docs/Phabricator.html
>
>
> --
--Artem Belevich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150108/d11f06e0/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ubsan-warning-fix.patch
Type: text/x-patch
Size: 1302 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150108/d11f06e0/attachment.bin>


More information about the llvm-commits mailing list