http://sourceware.org/bugzilla/show_bug.cgi?id=15369
Bug #: 15369
Summary: Wrong endian is used in cgen-dis.c.
Product: binutils
Version: 2.24 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: binutils
AssignedTo: unassig...@sourceware.org
ReportedBy: cole...@gmail.com
Classification: Unclassified
Wrong endian is used in cgen-dis.c.
When manipulating instructions,
instruction endian (`cd->insn_endian') should be used, instead of default
endian.
I think hash_insn_list() and hash_insn_array() use the wrong endian in
cgen-dis.c
for building hash table.
int big_p = CGEN_CPU_ENDIAN (cd) == CGEN_ENDIAN_BIG;
***
Instruction endian should be used intead, just like cgen_get_insn_value() and
cgen_put_insn_value()
in cgen-opc.c.
int big_p = (cd->insn_endian == CGEN_ENDIAN_BIG);
***
Otherwise, it fails to look-up an instruction in hash-table
if instruction endian differs from data endian.
value = CGEN_INSN_BASE_VALUE (insn);
bfd_put_bits ((bfd_vma) value,
buf,
CGEN_INSN_MASK_BITSIZE (insn),
big_p);
The value put in `buf' will be in reverse order.
Put in other words, the byte order in `buf' passed from cgen_get_insn_value()
and hash_insn_list/array() to `cd->dis_hash' are inconsistent.
We, on behalf of Andes Technology, are planing to contribute binutils
along with gcc and gdb around July. In our ISA, instruction endian is always
big-endian,
but data endian may be little or small. Without this fix, our disassembler
cannot work properly.
>8 >8 >8 >8 >8 >8 >8
diff --git a/opcodes/cgen-dis.c b/opcodes/cgen-dis.c
--- a/opcodes/cgen-dis.c
+++ b/opcodes/cgen-dis.c
@@ -104,7 +104,7 @@ hash_insn_array (CGEN_CPU_DESC cd,
CGEN_INSN_LIST ** htable,
CGEN_INSN_LIST * hentbuf)
{
- int big_p = CGEN_CPU_ENDIAN (cd) == CGEN_ENDIAN_BIG;
+ int big_p = (cd->insn_endian == CGEN_ENDIAN_BIG);
int i;
for (i = count - 1; i >= 0; --i, ++hentbuf)
@@ -142,7 +142,7 @@ hash_insn_list (CGEN_CPU_DESC cd,
CGEN_INSN_LIST **htable,
CGEN_INSN_LIST *hentbuf)
{
- int big_p = CGEN_CPU_ENDIAN (cd) == CGEN_ENDIAN_BIG;
+ int big_p = (cd->insn_endian == CGEN_ENDIAN_BIG);
const CGEN_INSN_LIST *ilist;
for (ilist = insns; ilist != NULL; ilist = ilist->next, ++ hentbuf)
8< 8< 8< 8< 8< 8< 8<
Any suggestion?
Wei-cheng Wang
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils