This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: binutils disassembler bug
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Paul Mackerras <paulus at samba dot org>, binutils at sourceware dot org
- Cc: Ben Elliston <bje at air dot net dot au>, benh at kernel dot crashing dot org
- Date: Thu, 27 Nov 2008 21:20:12 +1030
- Subject: Re: binutils disassembler bug
- References: <18734.4783.101478.171944@cargo.ozlabs.ibm.com>
On Thu, Nov 27, 2008 at 02:23:27PM +1100, Paul Mackerras wrote:
> Objdump disassembles mfspr with SPR number 268 or 269 (timebase and
> timebase upper) as moves from SPRG4 and SPRG5:
>
> $ cat >x.S <<EOF
> mfspr 0,268
> mfspr 0,269
> EOF
> $ cc -c x.S
> $ objdump -d x.o
>
> x.o: file format elf32-powerpc
>
>
> Disassembly of section .text:
>
> 00000000 <.text>:
> 0: 7c 0c 42 a6 mfsprg r0,4
> 4: 7c 0d 42 a6 mfsprg r0,5
>
> SPRG4 and SPRG5 are actually SPRs 276 and 277.
>
> This is with binutils 2.19.
Indeed. Wrong PPC_OPCODE flag since 403 and 405 have been given
separate flags, and the checks were wrong for 405 anyway.
* ppc-opc.c (extract_sprg): Correct operand range check.
Index: opcodes/ppc-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/ppc-opc.c,v
retrieving revision 1.110
diff -u -p -r1.110 ppc-opc.c
--- opcodes/ppc-opc.c 14 Aug 2008 13:56:00 -0000 1.110
+++ opcodes/ppc-opc.c 27 Nov 2008 10:43:28 -0000
@@ -1281,10 +1281,10 @@ extract_sprg (unsigned long insn,
/* mfsprg can use 260..263 and 272..279. mtsprg only uses spr 272..279
If not BOOKE or 405, then both use only 272..275. */
- if (val <= 3
- || (val < 0x10 && (insn & 0x100) != 0)
- || (val - 0x10 > 3
- && (dialect & (PPC_OPCODE_BOOKE | PPC_OPCODE_403)) == 0))
+ if ((val - 0x10 > 3 && (dialect & (PPC_OPCODE_BOOKE | PPC_OPCODE_405)) == 0)
+ || (val - 0x10 > 7 && (insn & 0x100) != 0)
+ || val <= 3
+ || (val & 8) != 0)
*invalid = 1;
return val & 7;
}
--
Alan Modra
Australia Development Lab, IBM