public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* [cgen-ibld-dis] fill_cache vs variable sized opcodes
@ 2005-12-07 22:13 DJ Delorie
  2005-12-27 16:39 ` Nick Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: DJ Delorie @ 2005-12-07 22:13 UTC (permalink / raw)
  To: cgen, binutils


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?  */


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [cgen-ibld-dis] fill_cache vs variable sized opcodes
  2005-12-07 22:13 [cgen-ibld-dis] fill_cache vs variable sized opcodes DJ Delorie
@ 2005-12-27 16:39 ` Nick Clifton
  2006-01-03 22:07   ` DJ Delorie
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2005-12-27 16:39 UTC (permalink / raw)
  To: DJ Delorie; +Cc: cgen, binutils

Hi DJ,

> 	* cgen-ibld.in (extract_normal): Avoid memory range errors.

Approved - please apply.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [cgen-ibld-dis] fill_cache vs variable sized opcodes
  2005-12-27 16:39 ` Nick Clifton
@ 2006-01-03 22:07   ` DJ Delorie
  0 siblings, 0 replies; 3+ messages in thread
From: DJ Delorie @ 2006-01-03 22:07 UTC (permalink / raw)
  To: nickc; +Cc: cgen, binutils


> > 	* cgen-ibld.in (extract_normal): Avoid memory range errors.
> 
> Approved - please apply.

Done.  Note that there's a second place where this logic is used
(insert_normal), but I couldn't guarantee that the change was valid
for that case, so I left it alone.

That, and it hasn't bitten me yet ;-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-01-03 22:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-07 22:13 [cgen-ibld-dis] fill_cache vs variable sized opcodes DJ Delorie
2005-12-27 16:39 ` Nick Clifton
2006-01-03 22:07   ` DJ Delorie

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).