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

Chandler Carruth chandlerc at google.com
Thu Jan 8 13:46:29 PST 2015


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

On Thu, Jan 8, 2015 at 1:38 PM, Artem Belevich <tra at google.com> wrote:

> Ping!
>
> BTW, the issue the patch fixes is a ubsan warning in the following test
> case:
>
> test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s
> /tmp/foo.o
> third_party/llvm/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h:186:47:
> runtime error: left shift of negative value -57344
>
> --Artem
>
>
> On Tue, Dec 23, 2014 at 1:02 PM, Artem Belevich <tra at google.com> wrote:
> >
> > ---
> >  lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h | 5
> +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git
> a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
> b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
> > index 274c552..8fc58ee 100644
> > --- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
> > +++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
> > @@ -183,8 +183,9 @@ public:
> >        assert(isInt<33>(Addend) && "Invalid page reloc value.");
> >
> >        // Encode the addend into the instruction.
> > -      uint32_t ImmLoValue = (uint32_t)(Addend << 17) & 0x60000000;
> > -      uint32_t ImmHiValue = (uint32_t)(Addend >> 9) & 0x00FFFFE0;
> > +      uint64_t AddressBits = Addend & 0x1FFFFF000;
> > +      uint32_t ImmLoValue = (uint32_t)(AddressBits << 17) & 0x60000000;
> > +      uint32_t ImmHiValue = (uint32_t)(AddressBits >> 9) & 0x00FFFFE0;
> >        *p = (*p & 0x9F00001F) | ImmHiValue | ImmLoValue;
> >        break;
> >      }
> > --
> > 2.2.0.rc0.207.ga3a616c
> >
>
>
>
> --
> --Artem Belevich
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150108/254778df/attachment.html>


More information about the llvm-commits mailing list