From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32067 invoked by alias); 7 Dec 2005 22:13:28 -0000 Received: (qmail 32052 invoked by uid 22791); 7 Dec 2005 22:13:26 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 07 Dec 2005 22:13:25 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id jB7MDOq4012832; Wed, 7 Dec 2005 17:13:24 -0500 Received: from post-office.corp.redhat.com (post-office.corp.redhat.com [172.16.52.227]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id jB7MDNV06069; Wed, 7 Dec 2005 17:13:23 -0500 Received: from greed.delorie.com (dj.cipe.redhat.com [10.0.0.222]) by post-office.corp.redhat.com (8.11.6/8.11.6) with ESMTP id jB7MDMR16745; Wed, 7 Dec 2005 17:13:23 -0500 Received: from greed.delorie.com (greed.delorie.com [127.0.0.1]) by greed.delorie.com (8.13.1/8.13.1) with ESMTP id jB7MDLk7015694; Wed, 7 Dec 2005 17:13:21 -0500 Received: (from dj@localhost) by greed.delorie.com (8.13.1/8.13.1/Submit) id jB7MDGMD015691; Wed, 7 Dec 2005 17:13:16 -0500 Date: Wed, 07 Dec 2005 22:13:00 -0000 Message-Id: <200512072213.jB7MDGMD015691@greed.delorie.com> From: DJ Delorie To: cgen@sources.redhat.com, binutils@sources.redhat.com Subject: [cgen-ibld-dis] fill_cache vs variable sized opcodes Mailing-List: contact cgen-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sourceware.org X-SW-Source: 2005-q4/txt/msg00050.txt.bz2 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? */