This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

[PATCH 4.0/4 v4] MIPS/GAS/testsuite: Branch to self/label tests


On Thu, 9 Dec 2010, Maciej W. Rozycki wrote:

> > You haven't answered my question, or at least not in a way that
> > makes me understand it.  The testcase in your original message
> > was a very artificial one, artificial enough that the correct
> > disassembly is open to debate.  Do you have a real-world example
> > of people writing code like this?
> 
>  OK, fair enough -- I did all kinds of weird assembly programming stuff in 
> my life (mainly back in my MS-DOS days in early 1990s), so this kind of 
> coding is nothing unusual to me, but no, I don't have a current real-world 
> example that would absolutely require this kind of an arrangement to work.  
> And I can understand your reluctance to make changes to generic parts of 
> GAS for the lone purpose of getting things 100% right where that would 
> hardly ever matter for anyone.
> 
>  Given code actually produced is already correct, I insist on including 
> the test case itself though.  I'll see if I can make the disassembly right 
> by interspersing the instructions with some otherwise unused labels.  
> Would it be a solution that would satisfy you?
> 
>  Otherwise chances are the microMIPS change by its nature will fix the 
> problem automatically -- I'll check that too before fiddling with the test 
> case itself.  The thing is for the purpose of correct microMIPS 
> disassembly Chao-ying was kind enough to provide a piece of code to scan 
> the symbol table and see if a location is within the span of any function 
> symbol with the microMIPS annotation present and switch to the microMIPS 
> mode if so.  In the course of the recent rewrite I extended that approach 
> to MIPS16 symbols as well.  I hope you agree that is reasonable too.

 The new code in _print_insn_mips() only checks symbols starting at the 
closest address lower than or equal to one an instruction being 
disassembled is at and does not check the span of any located at lower 
addresses.  Therefore I have come with the following update to the test 
case, adding the "blah" label with the ISA bit set appropriately at the 
same place as "frob" so that the ISA bit determines the correct 
disassembly mode.

 As symbols are sorted alphabetically before _print_insn_mips() is called 
this test does not rely on the microMIPS change for correct operation in 
the MIPS16 mode and can be applied as it is.  With the update included 
with the microMIPS change the test won't rely on label names and objdump's 
internal sorting rules for correct operation.

 Regression tested with mips-sde-elf and mips-gnu-linux, as usually.

2010-12-10  Maciej W. Rozycki  <macro@codesourcery.com>

	gas/testsuite/
	* gas/mips/branch-self.d: New test for various definitions of
	labels.
	* gas/mips/branch-self.s: Source for the new test.
	* gas/mips/mips.exp: Run the new test.  Remove -mmips:16 from
	"mips16" architecture.

  Maciej

binutils-gas-test-branch-self.diff
Index: binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/branch-self.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/branch-self.d	2010-12-10 21:56:43.000000000 +0000
@@ -0,0 +1,30 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branches to self
+#as: -32
+#source: branch-self.s
+
+# Test various ways to request a branch to self.
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+([0-9a-f]+) <[^>]*> ac620000 	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 1000ffff 	b	\1 <.*>
+([0-9a-f]+) <[^>]*> 00000000 	nop
+([0-9a-f]+) <[^>]*> ac620000 	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 1000ffff 	b	\1 <.*>
+([0-9a-f]+) <[^>]*> 00000000 	nop
+([0-9a-f]+) <[^>]*> ac620000 	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 1000ffff 	b	\1 <.*>
+([0-9a-f]+) <[^>]*> 00000000 	nop
+([0-9a-f]+) <[^>]*> ac620000 	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 1000ffff 	b	\1 <.*>
+([0-9a-f]+) <[^>]*> 00000000 	nop
+([0-9a-f]+) <[^>]*> ac620000 	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 1000ffff 	b	\1 <.*>
+([0-9a-f]+) <[^>]*> 00000000 	nop
+([0-9a-f]+) <[^>]*> ac620000 	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 1000ffff 	b	\1 <.*>
+([0-9a-f]+) <[^>]*> 00000000 	nop
+	\.\.\.
+	\.\.\.
Index: binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/branch-self.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/branch-self.s	2010-12-10 21:56:43.000000000 +0000
@@ -0,0 +1,38 @@
+# Source file used to test branches to self.
+	.text
+foo:
+	sw	$2, ($3)
+	b	.
+
+	sw	$2, ($3)
+0:
+	b	0b
+
+	sw	$2, ($3)
+bar:
+	b	bar
+
+	sw	$2, ($3)
+# Put a label here to keep the ISA bit for correct disassembly.
+blah:
+	.set	frob, .
+	b	frob
+
+	.eqv	fnord, .
+	sw	$2, ($3)
+	b	fnord
+
+	.eqv	foobar, fnord + 4
+	.eqv	foobaz, foobar - 16
+	sw	$2, ($3)
+	b	foobaz + 12
+
+# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	2
+	.space	8
+
+# Move the location counter away from the end of code to avoid the final
+# values of symbols equated to expressions involving the counter interfering
+# with disassembly.
+	.align	4
+	.space	16
Index: binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/mips.exp
===================================================================
--- binutils-fsf-trunk-quilt.orig/gas/testsuite/gas/mips/mips.exp	2010-12-10 21:56:42.000000000 +0000
+++ binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/mips.exp	2010-12-10 21:56:43.000000000 +0000
@@ -390,7 +390,7 @@ mips_arch_create mips64r2 64	mips64	{ mi
 			{ -mmips:isa64r2 } \
 			{ mipsisa64r2-*-* mipsisa64r2el-*-* }
 mips_arch_create mips16	32	{}	{} \
-			{ -march=mips1 -mips16 } { -mmips:16 }
+			{ -march=mips1 -mips16 } {}
 mips_arch_create r3000 	32	mips1	{} \
 			{ -march=r3000 -mtune=r3000 } { -mmips:3000 }
 mips_arch_create r3900 	32	mips1	{ gpr_ilocks } \
@@ -466,6 +466,7 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test_arches "branch-misc-2pic-64" [mips_arch_list_matching mips3]
     run_dump_test "branch-misc-3"
     run_dump_test "branch-swap"
+    run_dump_test_arches "branch-self"	[mips_arch_list_all]
     run_dump_test "div"
 
     if { !$addr32 } {
Index: binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/mips16@branch-self.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/gas/testsuite/gas/mips/mips16@branch-self.d	2010-12-10 21:56:43.000000000 +0000
@@ -0,0 +1,24 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branches to self
+#as: -32
+#source: branch-self.s
+
+# Test various ways to request a branch to self (MIPS16).
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+([0-9a-f]+) <[^>]*> db40      	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 17ff      	b	\1 <.*>
+([0-9a-f]+) <[^>]*> db40      	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 17ff      	b	\1 <.*>
+([0-9a-f]+) <[^>]*> db40      	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 17ff      	b	\1 <.*>
+([0-9a-f]+) <[^>]*> db40      	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 17ff      	b	\1 <.*>
+([0-9a-f]+) <[^>]*> db40      	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 17ff      	b	\1 <.*>
+([0-9a-f]+) <[^>]*> db40      	sw	v0,0\(v1\)
+([0-9a-f]+) <[^>]*> 17ff      	b	\1 <.*>
+	\.\.\.
+	\.\.\.


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