diff options
author | Alan Modra <amodra@gmail.com> | 2020-09-02 10:47:33 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-09-02 16:30:44 +0930 |
commit | b4b393495f506632a9be966277c6d6e668ba9778 (patch) | |
tree | c121efc078122fb23e0934a5215b76b6453ca92b /opcodes | |
parent | caf4537af57320ce15c66d61e4db91073b715236 (diff) | |
download | gdb-b4b393495f506632a9be966277c6d6e668ba9778.zip gdb-b4b393495f506632a9be966277c6d6e668ba9778.tar.gz gdb-b4b393495f506632a9be966277c6d6e668ba9778.tar.bz2 |
ubsan: i386-dis.c
i386-dis.c:12207 left shift of 128 by 24 places cannot be represented in type 'long int'
i386-dis.c:12220 left shift of 128 by 24 places cannot be represented in type 'long int'
i386-dis.c:12222 left shift of 1 by 31 places cannot be represented in type 'long int'
i386-dis.c:12222 signed integer overflow: 162254319 - -2147483648 cannot be represented in type 'long int'
* i386-dis.c (OP_E_memory): Don't cast to signed type when
negating.
(get32, get32s): Use unsigned types in shift expressions.
Diffstat (limited to 'opcodes')
-rw-r--r-- | opcodes/ChangeLog | 6 | ||||
-rw-r--r-- | opcodes/i386-dis.c | 26 |
2 files changed, 19 insertions, 13 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 20ff6c0..7c7d9f4 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,5 +1,11 @@ 2020-09-02 Alan Modra <amodra@gmail.com> + * i386-dis.c (OP_E_memory): Don't cast to signed type when + negating. + (get32, get32s): Use unsigned types in shift expressions. + +2020-09-02 Alan Modra <amodra@gmail.com> + * csky-dis.c (print_insn_csky): Use unsigned type for "given". 2020-09-02 Alan Modra <amodra@gmail.com> diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index cd8a9a8..6d80325 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -11908,7 +11908,7 @@ OP_E_memory (int bytemode, int sizeflag) { *obufp++ = '-'; *obufp = '\0'; - disp = - (bfd_signed_vma) disp; + disp = -disp; } if (havedisp) @@ -11996,7 +11996,7 @@ OP_E_memory (int bytemode, int sizeflag) { *obufp++ = '-'; *obufp = '\0'; - disp = - (bfd_signed_vma) disp; + disp = -disp; } print_displacement (scratchbuf, disp); @@ -12198,28 +12198,28 @@ get64 (void) static bfd_signed_vma get32 (void) { - bfd_signed_vma x = 0; + bfd_vma x = 0; FETCH_DATA (the_info, codep + 4); - x = *codep++ & (bfd_signed_vma) 0xff; - x |= (*codep++ & (bfd_signed_vma) 0xff) << 8; - x |= (*codep++ & (bfd_signed_vma) 0xff) << 16; - x |= (*codep++ & (bfd_signed_vma) 0xff) << 24; + x = *codep++ & (bfd_vma) 0xff; + x |= (*codep++ & (bfd_vma) 0xff) << 8; + x |= (*codep++ & (bfd_vma) 0xff) << 16; + x |= (*codep++ & (bfd_vma) 0xff) << 24; return x; } static bfd_signed_vma get32s (void) { - bfd_signed_vma x = 0; + bfd_vma x = 0; FETCH_DATA (the_info, codep + 4); - x = *codep++ & (bfd_signed_vma) 0xff; - x |= (*codep++ & (bfd_signed_vma) 0xff) << 8; - x |= (*codep++ & (bfd_signed_vma) 0xff) << 16; - x |= (*codep++ & (bfd_signed_vma) 0xff) << 24; + x = *codep++ & (bfd_vma) 0xff; + x |= (*codep++ & (bfd_vma) 0xff) << 8; + x |= (*codep++ & (bfd_vma) 0xff) << 16; + x |= (*codep++ & (bfd_vma) 0xff) << 24; - x = (x ^ ((bfd_signed_vma) 1 << 31)) - ((bfd_signed_vma) 1 << 31); + x = (x ^ ((bfd_vma) 1 << 31)) - ((bfd_vma) 1 << 31); return x; } |