[binutils-gdb] MIPS/BFD: Report `bfd_reloc_outofrange' errors as such

Maciej W.Rozycki macro@sourceware.org
Wed May 25 20:07:00 GMT 2016


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=de341542a60f7d3a80cc339db7d341b615cfa52f

commit de341542a60f7d3a80cc339db7d341b615cfa52f
Author: Maciej W. Rozycki <macro@imgtec.com>
Date:   Wed May 25 20:59:37 2016 +0100

    MIPS/BFD: Report `bfd_reloc_outofrange' errors as such
    
    A `bfd_reloc_outofrange' condition from `mips_elf_calculate_relocation'
    currently triggers the warning callback, which in the case of LD prints
    messages like:
    
    foo.o: In function `foo':
    (.text+0x0): warning: JALX to a non-word-aligned address
    
    or:
    
    foo.o: In function `foo':
    (.text+0x0): warning: PC-relative load from unaligned address
    
    and nothing else, which suggests this is a benign condition and link has
    otherwise successfully run to completion.  This is however not the case,
    the link terminates right away with no further messages and no output
    produced.
    
    Use the general error or warning info callback then, preserving the
    message format.  Also set a BFD error condition so that a failure is
    unambiguously reported.  Complement the change with a set of suitable
    test suite additions.
    
    	bfd/
    	* elfxx-mips.c (_bfd_mips_elf_relocate_section)
    	<bfd_reloc_outofrange>: Call `->einfo' rather than `->warning'.
    	Call `bfd_set_error'.
    
    	ld/
    	* testsuite/ld-mips-elf/unaligned-jalx-0.d: New test.
    	* testsuite/ld-mips-elf/unaligned-jalx-1.d: New test.
    	* testsuite/ld-mips-elf/unaligned-jalx-2.d: New test.
    	* testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d: New test.
    	* testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d: New test.
    	* testsuite/ld-mips-elf/unaligned-jalx-mips16-2.d: New test.
    	* testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d: New test.
    	* testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d: New test.
    	* testsuite/ld-mips-elf/unaligned-jalx-micromips-2.d: New test.
    	* testsuite/ld-mips-elf/unaligned-lwpc-0.d: New test.
    	* testsuite/ld-mips-elf/unaligned-lwpc-1.d: New test.
    	* testsuite/ld-mips-elf/unaligned-lwpc-2.d: New test.
    	* testsuite/ld-mips-elf/unaligned-lwpc-3.d: New test.
    	* testsuite/ld-mips-elf/unaligned-ldpc-0.d: New test.
    	* testsuite/ld-mips-elf/unaligned-ldpc-1.d: New test.
    	* testsuite/ld-mips-elf/unaligned-ldpc-2.d: New test.
    	* testsuite/ld-mips-elf/unaligned-ldpc-3.d: New test.
    	* testsuite/ld-mips-elf/unaligned-ldpc-4.d: New test.
    	* testsuite/ld-mips-elf/unaligned-jalx-0.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-jalx-1.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-jalx-2.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-insn.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-lwpc-0.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-lwpc-1.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-lwpc-2.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-lwpc-3.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-ldpc-0.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-ldpc-1.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-ldpc-2.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-ldpc-3.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-ldpc-4.s: New test source.
    	* testsuite/ld-mips-elf/unaligned-syms.s: New test source.
    	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.

Diff:
---
 bfd/ChangeLog                                      |  6 ++++
 bfd/elfxx-mips.c                                   |  5 +--
 ld/ChangeLog                                       | 36 ++++++++++++++++++++++
 ld/testsuite/ld-mips-elf/mips-elf.exp              | 20 ++++++++++++
 ld/testsuite/ld-mips-elf/unaligned-insn.s          | 15 +++++++++
 ld/testsuite/ld-mips-elf/unaligned-jalx-0.d        | 21 +++++++++++++
 ld/testsuite/ld-mips-elf/unaligned-jalx-0.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-jalx-1.d        |  8 +++++
 ld/testsuite/ld-mips-elf/unaligned-jalx-1.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-jalx-2.d        | 21 +++++++++++++
 ld/testsuite/ld-mips-elf/unaligned-jalx-2.s        | 11 +++++++
 .../ld-mips-elf/unaligned-jalx-micromips-0.d       | 21 +++++++++++++
 .../ld-mips-elf/unaligned-jalx-micromips-1.d       |  8 +++++
 .../ld-mips-elf/unaligned-jalx-micromips-2.d       | 21 +++++++++++++
 ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d | 21 +++++++++++++
 ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d |  8 +++++
 ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-2.d | 21 +++++++++++++
 ld/testsuite/ld-mips-elf/unaligned-ldpc-0.d        | 12 ++++++++
 ld/testsuite/ld-mips-elf/unaligned-ldpc-0.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-ldpc-1.d        |  8 +++++
 ld/testsuite/ld-mips-elf/unaligned-ldpc-1.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-ldpc-2.d        |  8 +++++
 ld/testsuite/ld-mips-elf/unaligned-ldpc-2.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-ldpc-3.d        |  8 +++++
 ld/testsuite/ld-mips-elf/unaligned-ldpc-3.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-ldpc-4.d        | 12 ++++++++
 ld/testsuite/ld-mips-elf/unaligned-ldpc-4.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-lwpc-0.d        | 12 ++++++++
 ld/testsuite/ld-mips-elf/unaligned-lwpc-0.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-lwpc-1.d        |  8 +++++
 ld/testsuite/ld-mips-elf/unaligned-lwpc-1.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-lwpc-2.d        |  8 +++++
 ld/testsuite/ld-mips-elf/unaligned-lwpc-2.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-lwpc-3.d        | 12 ++++++++
 ld/testsuite/ld-mips-elf/unaligned-lwpc-3.s        | 11 +++++++
 ld/testsuite/ld-mips-elf/unaligned-syms.s          | 15 +++++++++
 36 files changed, 465 insertions(+), 2 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e478afb..3250acc 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2016-05-25  Maciej W. Rozycki  <macro@imgtec.com>
+    
+	* elfxx-mips.c (_bfd_mips_elf_relocate_section)
+	<bfd_reloc_outofrange>: Call `->einfo' rather than `->warning'.
+	Call `bfd_set_error'.
+
 2016-05-25  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR binutils/14625
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index d09cbf1..c695278 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -10266,8 +10266,9 @@ _bfd_mips_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 	    msg = _("PC-relative load from unaligned address");
 	  if (msg)
 	    {
-	      info->callbacks->warning
-		(info, msg, name, input_bfd, input_section, rel->r_offset);
+	      info->callbacks->einfo
+		("%C: %s\n", input_bfd, input_section, rel->r_offset, msg);
+	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
 	  /* Fall through.  */
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 181eec8..dabaf55 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,39 @@
+2016-05-25  Maciej W. Rozycki  <macro@imgtec.com>
+    
+	* testsuite/ld-mips-elf/unaligned-jalx-0.d: New test.
+	* testsuite/ld-mips-elf/unaligned-jalx-1.d: New test.
+	* testsuite/ld-mips-elf/unaligned-jalx-2.d: New test.
+	* testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d: New test.
+	* testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d: New test.
+	* testsuite/ld-mips-elf/unaligned-jalx-mips16-2.d: New test.
+	* testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d: New test.
+	* testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d: New test.
+	* testsuite/ld-mips-elf/unaligned-jalx-micromips-2.d: New test.
+	* testsuite/ld-mips-elf/unaligned-lwpc-0.d: New test.
+	* testsuite/ld-mips-elf/unaligned-lwpc-1.d: New test.
+	* testsuite/ld-mips-elf/unaligned-lwpc-2.d: New test.
+	* testsuite/ld-mips-elf/unaligned-lwpc-3.d: New test.
+	* testsuite/ld-mips-elf/unaligned-ldpc-0.d: New test.
+	* testsuite/ld-mips-elf/unaligned-ldpc-1.d: New test.
+	* testsuite/ld-mips-elf/unaligned-ldpc-2.d: New test.
+	* testsuite/ld-mips-elf/unaligned-ldpc-3.d: New test.
+	* testsuite/ld-mips-elf/unaligned-ldpc-4.d: New test.
+	* testsuite/ld-mips-elf/unaligned-jalx-0.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-jalx-1.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-jalx-2.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-insn.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-lwpc-0.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-lwpc-1.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-lwpc-2.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-lwpc-3.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-ldpc-0.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-ldpc-1.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-ldpc-2.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-ldpc-3.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-ldpc-4.s: New test source.
+	* testsuite/ld-mips-elf/unaligned-syms.s: New test source.
+	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
+
 2016-05-25  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/20103
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 615f173..ceb588d 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -177,6 +177,26 @@ if $has_newabi {
     run_dump_test "jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
 }
 
+run_dump_test "unaligned-jalx-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-1" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-2" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-mips16-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-mips16-1" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-mips16-2" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-micromips-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-micromips-1" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-micromips-2" [list [list ld $abi_ldflags(o32)]]
+
+run_dump_test "unaligned-lwpc-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-lwpc-1" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-lwpc-2" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-lwpc-3" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-ldpc-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-ldpc-1" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-ldpc-2" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-ldpc-3" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-ldpc-4" [list [list ld $abi_ldflags(o32)]]
+
 # Test multi-got link.  We only do this on GNU/Linux because it requires
 # the "traditional" emulations.
 if { $linux_gnu } {
diff --git a/ld/testsuite/ld-mips-elf/unaligned-insn.s b/ld/testsuite/ld-mips-elf/unaligned-insn.s
new file mode 100644
index 0000000..10649de
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-insn.s
@@ -0,0 +1,15 @@
+	.macro	sym n:req
+	.if	\n
+	.globl	bar\@
+	.type	bar\@, @function
+bar\@ :
+	.insn
+	.hword	0
+	.size	bar\@, . - bar\@
+	sym	\n - 1
+	.endif
+	.endm
+
+	.text
+	.align	4
+	sym	8
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-0.d b/ld/testsuite/ld-mips-elf/unaligned-jalx-0.d
new file mode 100644
index 0000000..571a293
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-0.d
@@ -0,0 +1,21 @@
+#name: MIPS JALX to unaligned symbol 0
+#source: unaligned-jalx-0.s
+#source: unaligned-insn.s -mips16
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 77000008 	jalx	1c000020 <bar0>
+[0-9a-f]+ <[^>]*> 00000000 	nop
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-0.s b/ld/testsuite/ld-mips-elf/unaligned-jalx-0.s
new file mode 100644
index 0000000..11e874a
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-0.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	jal	bar0
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-1.d b/ld/testsuite/ld-mips-elf/unaligned-jalx-1.d
new file mode 100644
index 0000000..9cbf654
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-1.d
@@ -0,0 +1,8 @@
+#name: MIPS JALX to unaligned symbol 1
+#source: unaligned-jalx-1.s
+#source: unaligned-insn.s -mips16
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#error: \A[^\n]*: In function `foo':\n
+#error:   \(\.text\+0x[0-9a-f]+\): JALX to a non-word-aligned address\n
+#error:   [^\n]*: final link failed: Bad value\Z
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-1.s b/ld/testsuite/ld-mips-elf/unaligned-jalx-1.s
new file mode 100644
index 0000000..d3ccfb4
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-1.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	jal	bar1
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-2.d b/ld/testsuite/ld-mips-elf/unaligned-jalx-2.d
new file mode 100644
index 0000000..c401cfe
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-2.d
@@ -0,0 +1,21 @@
+#name: MIPS JALX to unaligned symbol 2
+#source: unaligned-jalx-2.s
+#source: unaligned-insn.s -mips16
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 77000009 	jalx	1c000024 <bar2>
+[0-9a-f]+ <[^>]*> 00000000 	nop
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-2.s b/ld/testsuite/ld-mips-elf/unaligned-jalx-2.s
new file mode 100644
index 0000000..34de139
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-2.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	jal	bar2
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d b/ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d
new file mode 100644
index 0000000..5b3dea1
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d
@@ -0,0 +1,21 @@
+#name: microMIPS JALX to unaligned symbol 0
+#source: unaligned-jalx-0.s -mmicromips
+#source: unaligned-insn.s
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> f300 0008 	jalx	1c000020 <bar0>
+[0-9a-f]+ <[^>]*> 0000 0000 	nop
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d b/ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d
new file mode 100644
index 0000000..a63fa31
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d
@@ -0,0 +1,8 @@
+#name: microMIPS JALX to unaligned symbol 1
+#source: unaligned-jalx-1.s -mmicromips
+#source: unaligned-insn.s
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#error: \A[^\n]*: In function `foo':\n
+#error:   \(\.text\+0x[0-9a-f]+\): JALX to a non-word-aligned address\n
+#error:   [^\n]*: final link failed: Bad value\Z
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-2.d b/ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-2.d
new file mode 100644
index 0000000..8c07023
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-2.d
@@ -0,0 +1,21 @@
+#name: microMIPS JALX to unaligned symbol 2
+#source: unaligned-jalx-2.s -mmicromips
+#source: unaligned-insn.s
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> f300 0009 	jalx	1c000024 <bar2>
+[0-9a-f]+ <[^>]*> 0000 0000 	nop
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d b/ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d
new file mode 100644
index 0000000..9609736
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d
@@ -0,0 +1,21 @@
+#name: MIPS16 JALX to unaligned symbol 0
+#source: unaligned-jalx-0.s -mips16
+#source: unaligned-insn.s
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 1c18 0008 	jalx	1c000020 <bar0>
+[0-9a-f]+ <[^>]*> 6500      	nop
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d b/ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d
new file mode 100644
index 0000000..45188e0
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d
@@ -0,0 +1,8 @@
+#name: MIPS16 JALX to unaligned symbol 1
+#source: unaligned-jalx-1.s -mips16
+#source: unaligned-insn.s
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#error: \A[^\n]*: In function `foo':\n
+#error:   \(\.text\+0x[0-9a-f]+\): JALX to a non-word-aligned address\n
+#error:   [^\n]*: final link failed: Bad value\Z
diff --git a/ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-2.d b/ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-2.d
new file mode 100644
index 0000000..d406651
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-2.d
@@ -0,0 +1,21 @@
+#name: MIPS16 JALX to unaligned symbol 2
+#source: unaligned-jalx-2.s -mips16
+#source: unaligned-insn.s
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 1c18 0009 	jalx	1c000024 <bar2>
+[0-9a-f]+ <[^>]*> 6500      	nop
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
+	\.\.\.
diff --git a/ld/testsuite/ld-mips-elf/unaligned-ldpc-0.d b/ld/testsuite/ld-mips-elf/unaligned-ldpc-0.d
new file mode 100644
index 0000000..126c1b1
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-ldpc-0.d
@@ -0,0 +1,12 @@
+#name: MIPS LDPC from unaligned symbol 0
+#source: unaligned-ldpc-0.s
+#source: unaligned-syms.s
+#as: -EB -32 -mips64r6
+#ld: -EB -Ttext 0x1c000000 -Tdata 0x1c080000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> ec590004 	ldpc	v0,1c080020 <bar0>
+	\.\.\.
diff --git a/ld/testsuite/ld-mips-elf/unaligned-ldpc-0.s b/ld/testsuite/ld-mips-elf/unaligned-ldpc-0.s
new file mode 100644
index 0000000..c99b4b7
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-ldpc-0.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	ldpc	$2, bar0
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-ldpc-1.d b/ld/testsuite/ld-mips-elf/unaligned-ldpc-1.d
new file mode 100644
index 0000000..1213cd0
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-ldpc-1.d
@@ -0,0 +1,8 @@
+#name: MIPS LDPC from unaligned symbol 1
+#source: unaligned-ldpc-1.s
+#source: unaligned-syms.s
+#as: -EB -32 -mips64r6
+#ld: -EB -Ttext 0x1c000000 -Tdata 0x1c080000 -e 0x1c000000
+#error: \A[^\n]*: In function `foo':\n
+#error:   \(\.text\+0x[0-9a-f]+\): PC-relative load from unaligned address\n
+#error:   [^\n]*: final link failed: Bad value\Z
diff --git a/ld/testsuite/ld-mips-elf/unaligned-ldpc-1.s b/ld/testsuite/ld-mips-elf/unaligned-ldpc-1.s
new file mode 100644
index 0000000..4afe849
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-ldpc-1.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	ldpc	$2, bar1
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-ldpc-2.d b/ld/testsuite/ld-mips-elf/unaligned-ldpc-2.d
new file mode 100644
index 0000000..6c0176c
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-ldpc-2.d
@@ -0,0 +1,8 @@
+#name: MIPS LDPC from unaligned symbol 2
+#source: unaligned-ldpc-2.s
+#source: unaligned-syms.s
+#as: -EB -32 -mips64r6
+#ld: -EB -Ttext 0x1c000000 -Tdata 0x1c080000 -e 0x1c000000
+#error: \A[^\n]*: In function `foo':\n
+#error:   \(\.text\+0x[0-9a-f]+\): PC-relative load from unaligned address\n
+#error:   [^\n]*: final link failed: Bad value\Z
diff --git a/ld/testsuite/ld-mips-elf/unaligned-ldpc-2.s b/ld/testsuite/ld-mips-elf/unaligned-ldpc-2.s
new file mode 100644
index 0000000..11e88f6
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-ldpc-2.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	ldpc	$2, bar2
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-ldpc-3.d b/ld/testsuite/ld-mips-elf/unaligned-ldpc-3.d
new file mode 100644
index 0000000..7a95d1c
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-ldpc-3.d
@@ -0,0 +1,8 @@
+#name: MIPS LDPC from unaligned symbol 3
+#source: unaligned-ldpc-3.s
+#source: unaligned-syms.s
+#as: -EB -32 -mips64r6
+#ld: -EB -Ttext 0x1c000000 -Tdata 0x1c080000 -e 0x1c000000
+#error: \A[^\n]*: In function `foo':\n
+#error:   \(\.text\+0x[0-9a-f]+\): PC-relative load from unaligned address\n
+#error:   [^\n]*: final link failed: Bad value\Z
diff --git a/ld/testsuite/ld-mips-elf/unaligned-ldpc-3.s b/ld/testsuite/ld-mips-elf/unaligned-ldpc-3.s
new file mode 100644
index 0000000..dac870f
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-ldpc-3.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	ldpc	$2, bar4
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-ldpc-4.d b/ld/testsuite/ld-mips-elf/unaligned-ldpc-4.d
new file mode 100644
index 0000000..d5610a7
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-ldpc-4.d
@@ -0,0 +1,12 @@
+#name: MIPS LDPC from unaligned symbol 4
+#source: unaligned-ldpc-4.s
+#source: unaligned-syms.s
+#as: -EB -32 -mips64r6
+#ld: -EB -Ttext 0x1c000000 -Tdata 0x1c080000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> ec590005 	ldpc	v0,1c080028 <bar8>
+	\.\.\.
diff --git a/ld/testsuite/ld-mips-elf/unaligned-ldpc-4.s b/ld/testsuite/ld-mips-elf/unaligned-ldpc-4.s
new file mode 100644
index 0000000..596cccb
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-ldpc-4.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	ldpc	$2, bar8
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-lwpc-0.d b/ld/testsuite/ld-mips-elf/unaligned-lwpc-0.d
new file mode 100644
index 0000000..89c56c8
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-lwpc-0.d
@@ -0,0 +1,12 @@
+#name: MIPS LWPC from unaligned symbol 0
+#source: unaligned-lwpc-0.s
+#source: unaligned-syms.s
+#as: -EB -32 -mips32r6
+#ld: -EB -Ttext 0x1c000000 -Tdata 0x1c080000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> ec4a0008 	lwpc	v0,1c080020 <bar0>
+	\.\.\.
diff --git a/ld/testsuite/ld-mips-elf/unaligned-lwpc-0.s b/ld/testsuite/ld-mips-elf/unaligned-lwpc-0.s
new file mode 100644
index 0000000..5d997f5
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-lwpc-0.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	lwpc	$2, bar0
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-lwpc-1.d b/ld/testsuite/ld-mips-elf/unaligned-lwpc-1.d
new file mode 100644
index 0000000..f4cf317
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-lwpc-1.d
@@ -0,0 +1,8 @@
+#name: MIPS LWPC from unaligned symbol 1
+#source: unaligned-lwpc-1.s
+#source: unaligned-syms.s
+#as: -EB -32 -mips32r6
+#ld: -EB -Ttext 0x1c000000 -Tdata 0x1c080000 -e 0x1c000000
+#error: \A[^\n]*: In function `foo':\n
+#error:   \(\.text\+0x[0-9a-f]+\): PC-relative load from unaligned address\n
+#error:   [^\n]*: final link failed: Bad value\Z
diff --git a/ld/testsuite/ld-mips-elf/unaligned-lwpc-1.s b/ld/testsuite/ld-mips-elf/unaligned-lwpc-1.s
new file mode 100644
index 0000000..595ebb9
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-lwpc-1.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	lwpc	$2, bar1
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-lwpc-2.d b/ld/testsuite/ld-mips-elf/unaligned-lwpc-2.d
new file mode 100644
index 0000000..2875828
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-lwpc-2.d
@@ -0,0 +1,8 @@
+#name: MIPS LWPC from unaligned symbol 2
+#source: unaligned-lwpc-2.s
+#source: unaligned-syms.s
+#as: -EB -32 -mips32r6
+#ld: -EB -Ttext 0x1c000000 -Tdata 0x1c080000 -e 0x1c000000
+#error: \A[^\n]*: In function `foo':\n
+#error:   \(\.text\+0x[0-9a-f]+\): PC-relative load from unaligned address\n
+#error:   [^\n]*: final link failed: Bad value\Z
diff --git a/ld/testsuite/ld-mips-elf/unaligned-lwpc-2.s b/ld/testsuite/ld-mips-elf/unaligned-lwpc-2.s
new file mode 100644
index 0000000..1debe4d
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-lwpc-2.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	lwpc	$2, bar2
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-lwpc-3.d b/ld/testsuite/ld-mips-elf/unaligned-lwpc-3.d
new file mode 100644
index 0000000..bda99c3
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-lwpc-3.d
@@ -0,0 +1,12 @@
+#name: MIPS LWPC from unaligned symbol 3
+#source: unaligned-lwpc-3.s
+#source: unaligned-syms.s
+#as: -EB -32 -mips32r6
+#ld: -EB -Ttext 0x1c000000 -Tdata 0x1c080000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> ec4a0009 	lwpc	v0,1c080024 <bar4>
+	\.\.\.
diff --git a/ld/testsuite/ld-mips-elf/unaligned-lwpc-3.s b/ld/testsuite/ld-mips-elf/unaligned-lwpc-3.s
new file mode 100644
index 0000000..667d7d9
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-lwpc-3.s
@@ -0,0 +1,11 @@
+	.text
+	.align	4
+	.globl	foo
+	.ent	foo
+foo:
+	lwpc	$2, bar4
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
diff --git a/ld/testsuite/ld-mips-elf/unaligned-syms.s b/ld/testsuite/ld-mips-elf/unaligned-syms.s
new file mode 100644
index 0000000..e865a13
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/unaligned-syms.s
@@ -0,0 +1,15 @@
+	.macro	sym n:req
+	.if	\n
+	.globl	bar\@
+	.type	bar\@, @object
+bar\@ :
+	.byte	0
+	.size	bar\@, . - bar\@
+	sym	\n - 1
+	.endif
+	.endm
+
+	.data
+	.align	4
+	.space	32
+	sym	16



More information about the Binutils-cvs mailing list