projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add multi-target tests
[deliverable/binutils-gdb.git]
/
opcodes
/
wasm32-dis.c
diff --git
a/opcodes/wasm32-dis.c
b/opcodes/wasm32-dis.c
index b1042793a5e42538d551ae07cd6c496f94f4ea58..aea93b81c2f3bc76230bdae5610bbf434ecf9bf7 100644
(file)
--- a/
opcodes/wasm32-dis.c
+++ b/
opcodes/wasm32-dis.c
@@
-1,5
+1,5
@@
/* Opcode printing code for the WebAssembly target
/* Opcode printing code for the WebAssembly target
- Copyright (C) 2017-20
19
Free Software Foundation, Inc.
+ Copyright (C) 2017-20
20
Free Software Foundation, Inc.
This file is part of libopcodes.
This file is part of libopcodes.
@@
-192,29
+192,36
@@
wasm_read_leb128 (bfd_vma pc,
unsigned int num_read = 0;
unsigned int shift = 0;
unsigned char byte = 0;
unsigned int num_read = 0;
unsigned int shift = 0;
unsigned char byte = 0;
-
bfd_boolean success = FALSE
;
+
int status = 1
;
while (info->read_memory_func (pc + num_read, &byte, 1, info) == 0)
{
num_read++;
while (info->read_memory_func (pc + num_read, &byte, 1, info) == 0)
{
num_read++;
- result |= ((bfd_vma) (byte & 0x7f)) << shift;
+ if (shift < sizeof (result) * 8)
+ {
+ result |= ((uint64_t) (byte & 0x7f)) << shift;
+ if ((result >> shift) != (byte & 0x7f))
+ /* Overflow. */
+ status |= 2;
+ shift += 7;
+ }
+ else if ((byte & 0x7f) != 0)
+ status |= 2;
- shift += 7;
if ((byte & 0x80) == 0)
if ((byte & 0x80) == 0)
- {
- success = TRUE;
- break;
- }
+ {
+ status &= ~1;
+ if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40))
+ result |= -((uint64_t) 1 << shift);
+ break;
+ }
}
if (length_return != NULL)
*length_return = num_read;
if (error_return != NULL)
}
if (length_return != NULL)
*length_return = num_read;
if (error_return != NULL)
- *error_return = ! success;
-
- if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40))
- result |= -((uint64_t) 1 << shift);
+ *error_return = status != 0;
return result;
}
return result;
}
This page took
0.02388 seconds
and
4
git commands to generate.