This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] MIPS/opcodes: Address issues with NAL disassembly


*** TEST RESULTS FOR COMMIT 92281a5b06dd83a2a7d96ab8d83ae40b4e519acd ***

Author: Maciej W. Rozycki <macro@imgtec.com>
Branch: master
Commit: 92281a5b06dd83a2a7d96ab8d83ae40b4e519acd

MIPS/opcodes: Address issues with NAL disassembly

Address issues with the disassembly of the NAL assembly idiom and R6
instruction introduced with commit 7361da2c952e ("Add support for MIPS
R6.") and then further tweaked with commit b9121b573e2e ("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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]