summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0ef562a)
This was the following in print_with_operands
case 4:
number
= buffer[2] + buffer[3] * 256 + buffer[4] * 65536
+ buffer[5] * 0x1000000;
and buffer[5] * 0x1000000 can indeed overflow. So to fix this we need
to use unsigned arithmetic where overflow semantics are specified.
But number is a long, and the expression is int which will be sign
extended to long. If we make the expression unsigned it will be zero
extended. So make number an int32_t and rearrange a little for some
of the places that need fixing.
* cris-dis.c (print_with_operands): Avoid signed integer
overflow when collecting bytes of a 32-bit integer.
+2019-12-11 Alan Modra <amodra@gmail.com>
+
+ * cris-dis.c (print_with_operands): Avoid signed integer
+ overflow when collecting bytes of a 32-bit integer.
+
2019-12-11 Alan Modra <amodra@gmail.com>
* cr16-dis.c (EXTRACT, SBM): Rewrite.
2019-12-11 Alan Modra <amodra@gmail.com>
* cr16-dis.c (EXTRACT, SBM): Rewrite.
case 'n':
{
/* Like N but pc-relative to the start of the insn. */
case 'n':
{
/* Like N but pc-relative to the start of the insn. */
- unsigned long number
- = (buffer[2] + buffer[3] * 256 + buffer[4] * 65536
- + buffer[5] * 0x1000000 + addr);
+ int32_t number = (buffer[2] + buffer[3] * 256 + buffer[4] * 65536
+ + buffer[5] * 0x1000000u);
/* Finish off and output previous formatted bytes. */
*tp = 0;
/* Finish off and output previous formatted bytes. */
*tp = 0;
(*info->fprintf_func) (info->stream, "%s", temp);
tp = temp;
(*info->fprintf_func) (info->stream, "%s", temp);
tp = temp;
- (*info->print_address_func) ((bfd_vma) number, info);
+ (*info->print_address_func) (addr + number, info);
}
break;
case 'u':
{
/* Like n but the offset is bits <3:0> in the instruction. */
}
break;
case 'u':
{
/* Like n but the offset is bits <3:0> in the instruction. */
- unsigned long number = (buffer[0] & 0xf) * 2 + addr;
+ unsigned int number = (buffer[0] & 0xf) * 2;
/* Finish off and output previous formatted bytes. */
*tp = 0;
/* Finish off and output previous formatted bytes. */
*tp = 0;
(*info->fprintf_func) (info->stream, "%s", temp);
tp = temp;
(*info->fprintf_func) (info->stream, "%s", temp);
tp = temp;
- (*info->print_address_func) ((bfd_vma) number, info);
+ (*info->print_address_func) (addr + number, info);
{
/* We're looking at [pc+], i.e. we need to output an immediate
number, where the size can depend on different things. */
{
/* We're looking at [pc+], i.e. we need to output an immediate
number, where the size can depend on different things. */
int signedp
= ((*cs == 'z' && (insn & 0x20))
|| opcodep->match == BDAP_QUICK_OPCODE);
int signedp
= ((*cs == 'z' && (insn & 0x20))
|| opcodep->match == BDAP_QUICK_OPCODE);
- number
- = buffer[2] + buffer[3] * 256 + buffer[4] * 65536
- + buffer[5] * 0x1000000;
+ number = (buffer[2] + buffer[3] * 256 + buffer[4] * 65536
+ + buffer[5] * 0x1000000u);
{
/* It's [pc+]. This cannot possibly be anything
but an address. */
{
/* It's [pc+]. This cannot possibly be anything
but an address. */
- unsigned long number
- = prefix_buffer[2] + prefix_buffer[3] * 256
- + prefix_buffer[4] * 65536
- + prefix_buffer[5] * 0x1000000;
+ int32_t number = (prefix_buffer[2]
+ + prefix_buffer[3] * 256
+ + prefix_buffer[4] * 65536
+ + prefix_buffer[5] * 0x1000000u);
info->target = (bfd_vma) number;
info->target = (bfd_vma) number;
if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
{
if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
{
unsigned int nbytes;
/* It's a value. Get its size. */
unsigned int nbytes;
/* It's a value. Get its size. */
- number
- = prefix_buffer[2] + prefix_buffer[3] * 256
- + prefix_buffer[4] * 65536
- + prefix_buffer[5] * 0x1000000;
+ number = (prefix_buffer[2] + prefix_buffer[3] * 256
+ + prefix_buffer[4] * 65536
+ + prefix_buffer[5] * 0x1000000u);