* ubsan: i386-dis.c
@ 2020-09-02 8:43 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-09-02 8:43 UTC (permalink / raw)
To: binutils
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.
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index cd8a9a8d75..6d803258ef 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;
}
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-02 8:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02 8:43 ubsan: i386-dis.c Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).