summaryrefslogtreecommitdiffstats
path: root/libcpu/i386_disasm.c
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2020-06-11 00:06:30 +0200
committerMark Wielaard <[email protected]>2020-06-11 03:58:27 +0200
commit49f13584d60322578c19b6118393ab04236ca7bf (patch)
tree88c79fbf73c54734c51b6b4a9a2a154e229f30c6 /libcpu/i386_disasm.c
parentc0d643e7d91fc002c9fecd83277c62a0e56ef76f (diff)
parent2c7c40373b68968cce20a60a28234e2a2cbc55cb (diff)
Merge tag 'elfutils-0.178' into mjw/RH-DTSdts-0.178
elfutils 0.178 release Adopt ebl backends loading from trunk.
Diffstat (limited to 'libcpu/i386_disasm.c')
-rw-r--r--libcpu/i386_disasm.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c
index a7e03f95..4422ffa2 100644
--- a/libcpu/i386_disasm.c
+++ b/libcpu/i386_disasm.c
@@ -610,7 +610,9 @@ i386_disasm (Ebl *ebl __attribute__((unused)),
/* Account for displacement. */
if ((modrm & 0xc7) == 5 || (modrm & 0xc0) == 0x80
- || ((modrm & 0xc7) == 0x4 && (codep[0] & 0x7) == 0x5))
+ || ((modrm & 0xc7) == 0x4
+ && param_start < end
+ && (codep[0] & 0x7) == 0x5))
param_start += 4;
else if ((modrm & 0xc0) == 0x40)
param_start += 1;
@@ -821,7 +823,8 @@ i386_disasm (Ebl *ebl __attribute__((unused)),
}
FALLTHROUGH;
default:
- assert (! "INVALID not handled");
+ str = "INVALID not handled";
+ break;
}
}
else
@@ -1030,7 +1033,7 @@ i386_disasm (Ebl *ebl __attribute__((unused)),
string_end_idx = bufcnt;
}
else
- bufcnt = string_end_idx;
+ start_idx = bufcnt = string_end_idx;
break;
case 'e':
@@ -1124,8 +1127,9 @@ i386_disasm (Ebl *ebl __attribute__((unused)),
/* Invalid (or at least unhandled) opcode. */
if (prefixes != 0)
goto print_prefix;
- assert (*startp == data);
- ++data;
+ /* Make sure we get past the unrecognized opcode if we haven't yet. */
+ if (*startp == data)
+ ++data;
ADD_STRING ("(bad)");
addr += data - begin;