binutils-gdb/opcodes
Maciej W. Rozycki 92281a5b06 MIPS/opcodes: Address issues with NAL disassembly
Address issues with the disassembly of the NAL assembly idiom and R6
instruction introduced with commit 7361da2c95 ("Add support for MIPS
R6.") and then further tweaked with commit b9121b573e ("Add in a JALRC
alias and fix the NAL instruction.").  As from R6 this instruction has
replaced the encoding of `bltzal $0, . + 4' as the solely supported form
of the former BLTZAL instruction for the regular MIPS ISA.

The instruction is marked as an alias only in our regular MIPS opcode
table, making it fail to disassemble in R6 code if the `no-aliases'
machine option has been passed to `objdump':

$ cat test.s
	.text
foo:
	nal
$ as -mips64r6 -o test.o test.s
$ objdump -dr --prefix-addresses --show-raw-insn -M no-aliases test.o

nal.o:     file format elf32-tradbigmips

Disassembly of section .text:
00000000 <foo> 04100000 	0x4100000
	...
$

This is because the `bltzal' entry has been marked as pre-R6 only in the
opcode table and there is no other opcode pattern to match.

Additionally the changes referred made NAL replace the equivalent
`bltzal $0, . + 4' instruction in disassembly, unless the `no-aliases'
machine option has been used, in legacy code.  Seeing NAL, especially in
its updated form lacking the branch target argument, in the disassembly
of such code may be confusing to people.  This is because unlike with
EHB only used in R2 and newer code -- the machine encoding of which we
anyway always disassemble to its corresponding current architecture's
mnemonic rather than its legacy meaning of `sll $0, $0, 3' -- BLTZAL has
been indeed used in legacy code.  Even though `bltzal $0, . + 8' and its
machine code encoding (0x04100001) -- which is not equivalent to NAL and
still disassembles as BLTZAL -- has been the predominant form as opposed
to NAL's `bltzal $0, . + 4' (0x04100000), it makes sense to always keep
the old form in disassembly, while still accepting `nal' in assembly.

Remove the alias marking then from the the `nal' instruction pattern,
making it always match for R6 code, even with the `no-aliases' option.
And move the entry beyond the `bltzal' entry, making the latter one take
precedence for legacy binary code, while letting the former still match
any `nal' mnemonic in source code assembled for a legacy target.

Add a suitable test case to the GAS test suite.  While the change
affects the disassembler more than the assembler, so placing the test
case in the binutils test suite might be more appropriate, the intent is
also to verify that `nal' is still accepted by GAS for legacy targets,
plus we have test infrastructure available in the GAS test suite for
automatic multiple ISA level testing, which we lack from the binutils
framework.

	opcodes/
	* mips-opc.c (mips_builtin_opcodes): Remove the INSN2_ALIAS
	annotation from the "nal" entry and reorder it beyond "bltzal".

	gas/
	* testsuite/gas/mips/nal-1.d: New test.
	* testsuite/gas/mips/mipsr6@nal-1.d: New test.
	* testsuite/gas/mips/nal-2.d: New test.
	* testsuite/gas/mips/mipsr6@nal-2.d: New test.
	* testsuite/gas/mips/nal.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new tests.
2016-07-13 17:42:43 +01:00
..
po
.gitignore
aarch64-asm-2.c
aarch64-asm.c
aarch64-asm.h
aarch64-dis-2.c
aarch64-dis.c Add support to AArch64 disassembler for verifying instructions. Add verifier for LDPSW. 2016-04-28 09:11:03 +01:00
aarch64-dis.h
aarch64-gen.c Fix generation of AArhc64 instruction table. 2016-05-03 11:48:56 +01:00
aarch64-opc-2.c
aarch64-opc.c [AArch64] Make register indices be full 64-bit values 2016-06-28 09:21:04 +01:00
aarch64-opc.h Fix generation of AArhc64 instruction table. 2016-05-03 11:48:56 +01:00
aarch64-tbl.h Fix generation of AArhc64 instruction table. 2016-05-03 11:48:56 +01:00
aclocal.m4 Regenerate Makefile.in/aclocal.m4 automake 1.11.6 2016-04-15 16:20:55 -07:00
alpha-dis.c update many old style function definitions 2016-04-20 07:04:49 -04:00
alpha-opc.c
arc-dis.c Arc assembler: Convert nps400 from a machine type to an extension. 2016-06-21 14:03:08 +01:00
arc-dis.h
arc-ext-tbl.h
arc-ext.c [ARC] Add SYNTAX_NOP and SYNTAX_1OP for extension instructions 2016-05-04 16:18:32 +02:00
arc-ext.h addmore extern C 2016-06-22 12:59:58 -04:00
arc-fxi.h
arc-nps400-tbl.h Arc assembler: Convert nps400 from a machine type to an extension. 2016-06-21 14:03:08 +01:00
arc-opc.c [ARC] Misc minor edits/fixes 2016-06-23 09:57:42 +01:00
arc-regs.h Add support for .extCondCode, .extCoreRegister and .extAuxRegister. 2016-04-12 10:21:06 +02:00
arc-tbl.h [ARC] Update instruction type and delay slot info. 2016-05-23 17:41:54 +02:00
arm-dis.c Fix typo in comment 2016-06-30 16:03:07 +01:00
avr-dis.c Print symbol names in comments for LDS/STS disassembly. 2016-06-09 19:00:57 +03:00
bfin-dis.c
cgen-asm.c
cgen-asm.in
cgen-bitset.c
cgen-dis.c
cgen-dis.in
cgen-ibld.in
cgen-opc.c
cgen.sh
ChangeLog MIPS/opcodes: Address issues with NAL disassembly 2016-07-13 17:42:43 +01:00
ChangeLog-0001
ChangeLog-0203
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-9297
ChangeLog-9899
config.in
configure Regenerate configure 2016-05-09 17:24:30 +09:30
configure.ac
configure.com
cr16-dis.c
cr16-opc.c
cris-dis.c
cris-opc.c
crx-dis.c update many old style function definitions 2016-04-20 07:04:49 -04:00
crx-opc.c
d10v-dis.c
d10v-opc.c
d30v-dis.c
d30v-opc.c
dep-in.sed
dis-buf.c
dis-init.c
disassemble.c update many old style function definitions 2016-04-20 07:04:49 -04:00
dlx-dis.c
epiphany-asm.c
epiphany-desc.c
epiphany-desc.h
epiphany-dis.c
epiphany-ibld.c
epiphany-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
epiphany-opc.h
fr30-asm.c
fr30-desc.c
fr30-desc.h
fr30-dis.c
fr30-ibld.c
fr30-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
fr30-opc.h
frv-asm.c
frv-desc.c
frv-desc.h
frv-dis.c
frv-ibld.c
frv-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
frv-opc.h
ft32-dis.c
ft32-opc.c FT32: adjust disassembly opcode match fields 2016-07-08 11:38:35 -07:00
h8300-dis.c
h8500-dis.c
h8500-opc.h
hppa-dis.c
i370-dis.c
i370-opc.c
i386-dis-evex.h
i386-dis.c Handle indirect branches for AMD64 and Intel64 2016-06-03 15:55:29 -07:00
i386-gen.c Add .noavx512XX directives to x86 assembler 2016-05-29 07:56:23 -07:00
i386-init.h Add .noavx512XX directives to x86 assembler 2016-05-29 07:56:23 -07:00
i386-opc.c
i386-opc.h Update x86 CPU_XXX_FLAGS handling 2016-05-27 10:05:57 -07:00
i386-opc.tbl x86: allow suffix-less movzw and 64-bit movzb 2016-07-01 09:01:41 +02:00
i386-reg.tbl
i386-tbl.h x86: allow suffix-less movzw and 64-bit movzb 2016-07-01 09:01:41 +02:00
i860-dis.c
i960-dis.c
ia64-asmtab.c
ia64-asmtab.h
ia64-dis.c
ia64-gen.c
ia64-ic.tbl
ia64-opc-a.c
ia64-opc-b.c
ia64-opc-d.c
ia64-opc-f.c
ia64-opc-i.c
ia64-opc-m.c
ia64-opc-x.c
ia64-opc.c
ia64-opc.h
ia64-raw.tbl
ia64-war.tbl
ia64-waw.tbl
ip2k-asm.c
ip2k-desc.c
ip2k-desc.h
ip2k-dis.c
ip2k-ibld.c
ip2k-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
ip2k-opc.h
iq2000-asm.c
iq2000-desc.c
iq2000-desc.h
iq2000-dis.c
iq2000-ibld.c
iq2000-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
iq2000-opc.h
lm32-asm.c
lm32-desc.c
lm32-desc.h
lm32-dis.c
lm32-ibld.c
lm32-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
lm32-opc.h
lm32-opinst.c update many old style function definitions 2016-04-20 07:04:49 -04:00
m32c-asm.c
m32c-desc.c
m32c-desc.h
m32c-dis.c
m32c-ibld.c
m32c-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
m32c-opc.h
m32r-asm.c
m32r-desc.c
m32r-desc.h
m32r-dis.c
m32r-ibld.c
m32r-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
m32r-opc.h
m32r-opinst.c update many old style function definitions 2016-04-20 07:04:49 -04:00
m68hc11-dis.c
m68hc11-opc.c
m68k-dis.c
m68k-opc.c
m88k-dis.c
m10200-dis.c
m10200-opc.c
m10300-dis.c
m10300-opc.c
MAINTAINERS
Makefile.am
Makefile.in Regenerate Makefile.in/aclocal.m4 automake 1.11.6 2016-04-15 16:20:55 -07:00
makefile.vms
mcore-dis.c remove a few sentinals 2016-06-25 11:54:28 -04:00
mcore-opc.h remove a few sentinals 2016-06-25 11:54:28 -04:00
mep-asm.c
mep-desc.c
mep-desc.h
mep-dis.c
mep-ibld.c
mep-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
mep-opc.h
metag-dis.c
microblaze-dis.c
microblaze-dis.h
microblaze-opc.h
microblaze-opcm.h
micromips-opc.c
mips16-opc.c
mips-dis.c MIPS/opcodes: Correct mixed MIPS16 and microMIPS disassembly 2016-05-18 13:07:24 +01:00
mips-formats.h
mips-opc.c MIPS/opcodes: Address issues with NAL disassembly 2016-07-13 17:42:43 +01:00
mmix-dis.c
mmix-opc.c
moxie-dis.c
moxie-opc.c
msp430-decode.c
msp430-decode.opc
msp430-dis.c Improve the MSP430 disassembler's handling of memory read errors. 2016-05-27 13:49:58 +01:00
mt-asm.c
mt-desc.c
mt-desc.h
mt-dis.c
mt-ibld.c
mt-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
mt-opc.h
nds32-asm.c
nds32-asm.h add more extern C 2016-06-01 21:26:32 -04:00
nds32-dis.c Fix simple gas testsuite failures. 2016-06-15 16:25:34 +01:00
nds32-opc.h
nios2-dis.c
nios2-opc.c
ns32k-dis.c
opc2c.c
opintl.h
or1k-asm.c
or1k-desc.c
or1k-desc.h
or1k-dis.c
or1k-ibld.c
or1k-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
or1k-opc.h
or1k-opinst.c update many old style function definitions 2016-04-20 07:04:49 -04:00
pdp11-dis.c
pdp11-opc.c
pj-dis.c
pj-opc.c
ppc-dis.c PowerPC VLE 2016-06-07 22:04:38 +09:30
ppc-opc.c Add support for yet some more new ISA 3.0 instructions. 2016-06-22 17:55:17 -05:00
rl78-decode.c
rl78-decode.opc
rl78-dis.c
rx-decode.c
rx-decode.opc
rx-dis.c
s390-dis.c S/390: Dump unknown instructions according to their length. 2016-06-10 13:41:42 +02:00
s390-mkopc.c
s390-opc.c
s390-opc.txt
score7-dis.c
score-dis.c
score-opc.h
sh64-dis.c
sh64-opc.c
sh64-opc.h
sh-dis.c
sh-opc.h add more extern C 2016-06-01 21:26:32 -04:00
sparc-dis.c opcodes,gas: sparc: fix rdasr,wrasr,rdpr,wrpr,rdhpr,wrhpr insns. 2016-06-17 02:15:43 -07:00
sparc-opc.c opcodes,gas: support for the ldtxa SPARC instructions. 2016-07-13 16:05:40 +02:00
spu-dis.c
spu-opc.c
stamp-h.in
sysdep.h
tic4x-dis.c
tic6x-dis.c
tic30-dis.c
tic54x-dis.c tic54x: rename typedef of struct symbol_ 2016-05-23 01:17:12 -04:00
tic54x-opc.c tic54x: rename typedef of struct symbol_ 2016-05-23 01:17:12 -04:00
tic80-dis.c
tic80-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
tilegx-dis.c
tilegx-opc.c
tilepro-dis.c
tilepro-opc.c
v850-dis.c
v850-opc.c Fix disassembly of the V850's LD.BU instruction. 2016-04-13 15:09:25 +01:00
vax-dis.c
visium-dis.c
visium-opc.c
w65-dis.c
w65-opc.h
xc16x-asm.c
xc16x-desc.c
xc16x-desc.h
xc16x-dis.c
xc16x-ibld.c
xc16x-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
xc16x-opc.h
xgate-dis.c
xgate-opc.c
xstormy16-asm.c
xstormy16-desc.c
xstormy16-desc.h
xstormy16-dis.c
xstormy16-ibld.c
xstormy16-opc.c update many old style function definitions 2016-04-20 07:04:49 -04:00
xstormy16-opc.h
xtensa-dis.c
z8k-dis.c
z8k-opc.h
z8kgen.c
z80-dis.c