This is the mail archive of the
cgen@sourceware.org
mailing list for the CGEN project.
[cgen-ibld-dis] fill_cache vs variable sized opcodes
- From: DJ Delorie <dj at redhat dot com>
- To: cgen at sources dot redhat dot com, binutils at sources dot redhat dot com
- Date: Wed, 7 Dec 2005 17:13:16 -0500
- Subject: [cgen-ibld-dis] fill_cache vs variable sized opcodes
M32C opcodes range from one to ten bytes long, so occasionally
fill_cache would attempt to read a "word" that extended beyond the end
of the memory segment, and would fail (this shows up with "objdump
-d").
There was already a partial test for this, but it didn't account for
opcodes longer than a word. This patch changes the logic to account
for both short opcodes and long-but-not-whole-words opcodes, although
it uses "min_insn_bitsize < base_insn_bitsize" as a generic test for
"variable length opcodes".
Ok?
* cgen-ibld.in (extract_normal): Avoid memory range errors.
Index: cgen-ibld.in
===================================================================
RCS file: /cvs/src/src/opcodes/cgen-ibld.in,v
retrieving revision 1.18
diff -p -U3 -r1.18 cgen-ibld.in
--- cgen-ibld.in 1 Jul 2005 11:16:31 -0000 1.18
+++ cgen-ibld.in 7 Dec 2005 22:12:46 -0000
@@ -440,9 +440,8 @@ extract_normal (CGEN_CPU_DESC cd,
word_length may be too big. */
if (cd->min_insn_bitsize < cd->base_insn_bitsize)
{
- if (word_offset == 0
- && word_length > total_length)
- word_length = total_length;
+ if (word_offset + word_length > total_length)
+ word_length = total_length - word_offset;
}
/* Does the value reside in INSN_VALUE, and at the right alignment? */