]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libcpu: Make sure left shifts are done in unsigned context.
authorMark Wielaard <mark@klomp.org>
Sat, 7 Sep 2019 19:45:26 +0000 (21:45 +0200)
committerMark Wielaard <mark@klomp.org>
Sat, 7 Sep 2019 19:45:31 +0000 (21:45 +0200)
Use UINT64_C (0) instead of INT64_C (0) to make sure the calculation
is done on unsigned values. Otherwise the gcc undefined sanitizer will
warn:

libcpu/riscv_disasm.c:457:57: runtime error: left shift of negative value -1

Signed-off-by: Mark Wielaard <mark@klomp.org>
libcpu/ChangeLog
libcpu/riscv_disasm.c

index 883896a2ee588406a6be8ff7f0769187b6c090eb..e23097bd190e7d7ec09f0c5d18d09f9dac1b6d74 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-07  Mark Wielaard  <mark@klomp.org>
+
+       * riscv_disasm.c (riscv_disasm): Use UINT64_C to make calculation
+       unsigned.
+
 2019-07-05  Omar Sandoval  <osandov@fb.com>
 
        * Makefile.am: Combine libcpu_{i386,x86_64,bpf}.a into libcpu.a.
index bc4e02e5efbc4eb9a25583177064531dd86db137..bc0d8f371b5a6e3c503fcb6835dc1e36c55fc2d5 100644 (file)
@@ -453,7 +453,7 @@ riscv_disasm (Ebl *ebl,
              mne = "fsd";
              break;
            case 16:
-             opaddr = (((INT64_C (0) - ((first >> 12) & 0x1)) << 11)
+             opaddr = (((UINT64_C (0) - ((first >> 12) & 0x1)) << 11)
                        | ((first << 2) & 0x400)
                        | ((first >> 1) & 0x300)
                        | ((first << 1) & 0x80)