aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2016-07-12 01:30:01 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2016-07-14 20:06:37 +0100
commit0c117286270e8166022900f4e5fef89719ccd2dc (patch)
tree18f975afeb0915c736a174dba92170844a274d65
parent7f131b39970944cb53b407715880d333c5248cac (diff)
downloadgdb-0c117286270e8166022900f4e5fef89719ccd2dc.zip
gdb-0c117286270e8166022900f4e5fef89719ccd2dc.tar.gz
gdb-0c117286270e8166022900f4e5fef89719ccd2dc.tar.bz2
BFD: Let targets handle relocations against absolute symbols
Fix a generic BFD issue with relocations against absolute symbols, which are installed without using any individual relocation handler provided by the backend. This causes any absolute section's addend to be lost on REL targets such as o32 MIPS, and also relocation-specific calculation adjustments are not made. As an example assembling this program: $ cat test.s .text foo: b bar b baz .set bar, 0x1234 $ as -EB -32 -o test-o32.o test.s $ as -EB -n32 -o test-n32.o test.s produces this binary code: $ objdump -dr test-o32.o test-n32.o test-o32.o: file format elf32-tradbigmips Disassembly of section .text: 00000000 <foo>: 0: 10000000 b 4 <foo+0x4> 0: R_MIPS_PC16 *ABS* 4: 00000000 nop 8: 1000ffff b 8 <foo+0x8> 8: R_MIPS_PC16 baz c: 00000000 nop test-n32.o: file format elf32-ntradbigmips Disassembly of section .text: 00000000 <foo>: 0: 10000000 b 4 <foo+0x4> 0: R_MIPS_PC16 *ABS*+0x1230 4: 00000000 nop 8: 10000000 b c <foo+0xc> 8: R_MIPS_PC16 baz-0x4 c: 00000000 nop $ where it is clearly visible in `test-o32.o', which uses REL relocations, that the absolute section's addend equivalent to the value of `bar' -- a reference to which cannot be fully resolved at the assembly time, because the reference is PC-relative -- has been lost, as has been the relocation-specific adjustment of -4, required to take into account the PC+4-relative calculation made by hardware with branches and seen in the external symbol reference to `baz' as the `ffff' addend encoded in the instruction word. In `test-n32.o', which uses RELA relocations, the absolute section's addend has been correctly retained. Give precedence then in `bfd_perform_relocation' and `bfd_install_relocation' to any individual relocation handler the backend selected may have provided, while still resorting to the generic calculation otherwise. This retains the semantics which we've had since forever or before the beginning of our repository history, and is at the very least compatible with `bfd_elf_generic_reloc' being used as the handler. Retain the `bfd_is_und_section' check unchanged at the beginning of `bfd_perform_relocation' since this does not affect the semantics of the function. The check returns the same `bfd_reloc_undefined' code the check for a null `howto' does, so swapping the two does not matter. Also the check is is mutually exclusive with the `bfd_is_abs_section' check, since a section cannot be absolute and undefined both at once, so swapping the two does not matter either. With this change applied the program quoted above now has the in-place addend correctly calculated and installed in the field being relocated: $ objdump -dr fixed-o32.o fixed-o32.o: file format elf32-tradbigmips Disassembly of section .text: 00000000 <foo>: 0: 1000048c b 1234 <bar> 0: R_MIPS_PC16 *ABS* 4: 00000000 nop 8: 1000ffff b 8 <foo+0x8> 8: R_MIPS_PC16 baz c: 00000000 nop $ Add a set of MIPS tests to cover the relevant cases, including absolute symbols with addends, and verifying that PC-relative relocations against symbols concerned resolve to the same value in the final link regardless of whether the REL or the RELA relocation form is used. Exclude linker tests though which would overflow the in-place addend on REL targets and use them as dump patterns for RELA targets only. bfd/ * reloc.c (bfd_perform_relocation): Try the `howto' handler first with relocations against absolute symbols. (bfd_install_relocation): Likewise. gas/ * testsuite/gas/mips/mips16-branch-absolute.d: Update patterns. * testsuite/gas/mips/branch-absolute.d: New test. * testsuite/gas/mips/branch-absolute-n32.d: New test. * testsuite/gas/mips/branch-absolute-n64.d: New test. * testsuite/gas/mips/branch-absolute-addend-n32.d: New test. * testsuite/gas/mips/branch-absolute-addend-n64.d: New test. * testsuite/gas/mips/mips16-branch-absolute-n32.d: New test. * testsuite/gas/mips/mips16-branch-absolute-n64.d: New test. * testsuite/gas/mips/mips16-branch-absolute-addend-n32.d: New test. * testsuite/gas/mips/mips16-branch-absolute-addend-n64.d: New test. * testsuite/gas/mips/micromips-branch-absolute.d: New test. * testsuite/gas/mips/micromips-branch-absolute-n32.d: New test. * testsuite/gas/mips/micromips-branch-absolute-n64.d: New test. * testsuite/gas/mips/micromips-branch-absolute-addend-n32.d: New test. * testsuite/gas/mips/micromips-branch-absolute-addend-n64.d: New test. * testsuite/gas/mips/branch-absolute.s: New test source. * testsuite/gas/mips/branch-absolute-addend.s: New test source. * testsuite/gas/mips/mips16-branch-absolute-addend.s: New test source. * testsuite/gas/mips/micromips-branch-absolute.s: New test source. * testsuite/gas/mips/micromips-branch-absolute-addend.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-mips-elf/branch-absolute.d: New test. * testsuite/ld-mips-elf/branch-absolute-n32.d: New test. * testsuite/ld-mips-elf/branch-absolute-n64.d: New test. * testsuite/ld-mips-elf/branch-absolute-addend.d: New test. * testsuite/ld-mips-elf/branch-absolute-addend-n32.d: New test. * testsuite/ld-mips-elf/branch-absolute-addend-n64.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute-n32.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute-n64.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute-addend.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d: New test. * testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests, except from `branch-absolute-addend' and `micromips-branch-absolute-addend', referred indirectly only.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/reloc.c39
-rw-r--r--gas/ChangeLog31
-rw-r--r--gas/testsuite/gas/mips/branch-absolute-addend-n32.d25
-rw-r--r--gas/testsuite/gas/mips/branch-absolute-addend-n64.d35
-rw-r--r--gas/testsuite/gas/mips/branch-absolute-addend.s20
-rw-r--r--gas/testsuite/gas/mips/branch-absolute-n32.d25
-rw-r--r--gas/testsuite/gas/mips/branch-absolute-n64.d35
-rw-r--r--gas/testsuite/gas/mips/branch-absolute.d24
-rw-r--r--gas/testsuite/gas/mips/branch-absolute.s20
-rw-r--r--gas/testsuite/gas/mips/micromips-branch-absolute-addend-n32.d26
-rw-r--r--gas/testsuite/gas/mips/micromips-branch-absolute-addend-n64.d36
-rw-r--r--gas/testsuite/gas/mips/micromips-branch-absolute-addend.s22
-rw-r--r--gas/testsuite/gas/mips/micromips-branch-absolute-n32.d26
-rw-r--r--gas/testsuite/gas/mips/micromips-branch-absolute-n64.d36
-rw-r--r--gas/testsuite/gas/mips/micromips-branch-absolute.d25
-rw-r--r--gas/testsuite/gas/mips/micromips-branch-absolute.s22
-rw-r--r--gas/testsuite/gas/mips/mips.exp20
-rw-r--r--gas/testsuite/gas/mips/mips16-branch-absolute-addend-n32.d21
-rw-r--r--gas/testsuite/gas/mips/mips16-branch-absolute-addend-n64.d31
-rw-r--r--gas/testsuite/gas/mips/mips16-branch-absolute-addend.s22
-rw-r--r--gas/testsuite/gas/mips/mips16-branch-absolute-n32.d21
-rw-r--r--gas/testsuite/gas/mips/mips16-branch-absolute-n64.d31
-rw-r--r--gas/testsuite/gas/mips/mips16-branch-absolute.d10
-rw-r--r--ld/ChangeLog23
-rw-r--r--ld/testsuite/ld-mips-elf/branch-absolute-addend-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/branch-absolute-addend-n64.d6
-rw-r--r--ld/testsuite/ld-mips-elf/branch-absolute-addend.d21
-rw-r--r--ld/testsuite/ld-mips-elf/branch-absolute-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/branch-absolute-n64.d6
-rw-r--r--ld/testsuite/ld-mips-elf/branch-absolute.d21
-rw-r--r--ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d6
-rw-r--r--ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend.d22
-rw-r--r--ld/testsuite/ld-mips-elf/micromips-branch-absolute-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/micromips-branch-absolute-n64.d6
-rw-r--r--ld/testsuite/ld-mips-elf/micromips-branch-absolute.d22
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp21
38 files changed, 765 insertions, 22 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7f64146..a889e56 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2016-07-14 Maciej W. Rozycki <macro@imgtec.com>
+
+ * reloc.c (bfd_perform_relocation): Try the `howto' handler
+ first with relocations against absolute symbols.
+ (bfd_install_relocation): Likewise.
+
2016-07-12 H.J. Lu <hongjiu.lu@intel.com>
* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Align
diff --git a/bfd/reloc.c b/bfd/reloc.c
index e962e71..0e5fde2 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -586,16 +586,6 @@ bfd_perform_relocation (bfd *abfd,
asymbol *symbol;
symbol = *(reloc_entry->sym_ptr_ptr);
- if (bfd_is_abs_section (symbol->section)
- && output_bfd != NULL)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* PR 17512: file: 0f67f69d. */
- if (howto == NULL)
- return bfd_reloc_undefined;
/* If we are not producing relocatable output, return an error if
the symbol is not defined. An undefined weak symbol is
@@ -608,7 +598,7 @@ bfd_perform_relocation (bfd *abfd,
/* If there is a function supplied to handle this relocation type,
call it. It'll return `bfd_reloc_continue' if further processing
can be done. */
- if (howto->special_function)
+ if (howto && howto->special_function)
{
bfd_reloc_status_type cont;
cont = howto->special_function (abfd, reloc_entry, symbol, data,
@@ -618,6 +608,17 @@ bfd_perform_relocation (bfd *abfd,
return cont;
}
+ if (bfd_is_abs_section (symbol->section)
+ && output_bfd != NULL)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* PR 17512: file: 0f67f69d. */
+ if (howto == NULL)
+ return bfd_reloc_undefined;
+
/* Is the address of the relocation really within the section?
Include the size of the reloc in the test for out of range addresses.
PR 17512: file: c146ab8b, 46dff27f, 38e53ebf. */
@@ -981,16 +982,11 @@ bfd_install_relocation (bfd *abfd,
bfd_byte *data;
symbol = *(reloc_entry->sym_ptr_ptr);
- if (bfd_is_abs_section (symbol->section))
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
/* If there is a function supplied to handle this relocation type,
call it. It'll return `bfd_reloc_continue' if further processing
can be done. */
- if (howto->special_function)
+ if (howto && howto->special_function)
{
bfd_reloc_status_type cont;
@@ -1005,6 +1001,15 @@ bfd_install_relocation (bfd *abfd,
return cont;
}
+ if (bfd_is_abs_section (symbol->section))
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ /* No need to check for howto != NULL if !bfd_is_abs_section as
+ it will have been checked in `bfd_perform_relocation already'. */
+
/* Is the address of the relocation really within the section? */
octets = reloc_entry->address * bfd_octets_per_byte (abfd);
if (octets + bfd_get_reloc_size (howto)
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 7ff3079..2e5015a 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,34 @@
+2016-07-14 Maciej W. Rozycki <macro@imgtec.com>
+
+ * testsuite/gas/mips/mips16-branch-absolute.d: Update patterns.
+ * testsuite/gas/mips/branch-absolute.d: New test.
+ * testsuite/gas/mips/branch-absolute-n32.d: New test.
+ * testsuite/gas/mips/branch-absolute-n64.d: New test.
+ * testsuite/gas/mips/branch-absolute-addend-n32.d: New test.
+ * testsuite/gas/mips/branch-absolute-addend-n64.d: New test.
+ * testsuite/gas/mips/mips16-branch-absolute-n32.d: New test.
+ * testsuite/gas/mips/mips16-branch-absolute-n64.d: New test.
+ * testsuite/gas/mips/mips16-branch-absolute-addend-n32.d: New
+ test.
+ * testsuite/gas/mips/mips16-branch-absolute-addend-n64.d: New
+ test.
+ * testsuite/gas/mips/micromips-branch-absolute.d: New test.
+ * testsuite/gas/mips/micromips-branch-absolute-n32.d: New test.
+ * testsuite/gas/mips/micromips-branch-absolute-n64.d: New test.
+ * testsuite/gas/mips/micromips-branch-absolute-addend-n32.d: New
+ test.
+ * testsuite/gas/mips/micromips-branch-absolute-addend-n64.d: New
+ test.
+ * testsuite/gas/mips/branch-absolute.s: New test source.
+ * testsuite/gas/mips/branch-absolute-addend.s: New test source.
+ * testsuite/gas/mips/mips16-branch-absolute-addend.s: New test
+ source.
+ * testsuite/gas/mips/micromips-branch-absolute.s: New test
+ source.
+ * testsuite/gas/mips/micromips-branch-absolute-addend.s: New
+ test source.
+ * testsuite/gas/mips/mips.exp: Run the new tests.
+
2016-07-13 Maciej W. Rozycki <macro@imgtec.com>
* testsuite/gas/mips/nal-1.d: New test.
diff --git a/gas/testsuite/gas/mips/branch-absolute-addend-n32.d b/gas/testsuite/gas/mips/branch-absolute-addend-n32.d
new file mode 100644
index 0000000..16447b7
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-absolute-addend-n32.d
@@ -0,0 +1,25 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch to absolute expression with addend (n32)
+#as: -n32 -march=from-abi
+#source: branch-absolute-addend.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 10000000 b 00001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04110000 bal 0000100c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04100000 bltzal zero,00001014 <foo\+0x14>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 10400000 beqz v0,0000101c <foo\+0x1c>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 14400000 bnez v0,00001024 <foo\+0x24>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/branch-absolute-addend-n64.d b/gas/testsuite/gas/mips/branch-absolute-addend-n64.d
new file mode 100644
index 0000000..38d9691
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-absolute-addend-n64.d
@@ -0,0 +1,35 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch to absolute expression with addend (n64)
+#as: -64 -march=from-abi
+#source: branch-absolute-addend.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 10000000 b 0000000000001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04110000 bal 000000000000100c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04100000 bltzal zero,0000000000001014 <foo\+0x14>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 10400000 beqz v0,000000000000101c <foo\+0x1c>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 14400000 bnez v0,0000000000001024 <foo\+0x24>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/branch-absolute-addend.s b/gas/testsuite/gas/mips/branch-absolute-addend.s
new file mode 100644
index 0000000..67c4e13
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-absolute-addend.s
@@ -0,0 +1,20 @@
+ .text
+
+ .space 0x1000
+
+ .globl foo
+ .ent foo
+foo:
+ b bar + 0x1234
+ bal bar + 0x1234
+ bltzal $0, bar + 0x1234
+ beqz $2, bar + 0x1234
+ bnez $2, bar + 0x1234
+ nop
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
+
+ .set bar, 0x12345678
diff --git a/gas/testsuite/gas/mips/branch-absolute-n32.d b/gas/testsuite/gas/mips/branch-absolute-n32.d
new file mode 100644
index 0000000..9dd4aad
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-absolute-n32.d
@@ -0,0 +1,25 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch to absolute expression (n32)
+#as: -n32 -march=from-abi
+#source: branch-absolute.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 10000000 b 00001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04110000 bal 0000100c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04100000 bltzal zero,00001014 <foo\+0x14>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 10400000 beqz v0,0000101c <foo\+0x1c>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 14400000 bnez v0,00001024 <foo\+0x24>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/branch-absolute-n64.d b/gas/testsuite/gas/mips/branch-absolute-n64.d
new file mode 100644
index 0000000..be31a08
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-absolute-n64.d
@@ -0,0 +1,35 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch to absolute expression (n64)
+#as: -64 -march=from-abi
+#source: branch-absolute.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 10000000 b 0000000000001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04110000 bal 000000000000100c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04100000 bltzal zero,0000000000001014 <foo\+0x14>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 10400000 beqz v0,000000000000101c <foo\+0x1c>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 14400000 bnez v0,0000000000001024 <foo\+0x24>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/branch-absolute.d b/gas/testsuite/gas/mips/branch-absolute.d
new file mode 100644
index 0000000..37e7fc5
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-absolute.d
@@ -0,0 +1,24 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch to absolute expression
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 1000048c b 00002234 <bar\+0x1000>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 0411048c bal 0000223c <bar\+0x1008>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 0410048c bltzal zero,00002244 <bar\+0x1010>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 1040048c beqz v0,0000224c <bar\+0x1018>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 1440048c bnez v0,00002254 <bar\+0x1020>
+[ ]*[0-9a-f]+: R_MIPS_PC16 \*ABS\*
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/branch-absolute.s b/gas/testsuite/gas/mips/branch-absolute.s
new file mode 100644
index 0000000..6e006cd
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-absolute.s
@@ -0,0 +1,20 @@
+ .text
+
+ .space 0x1000
+
+ .globl foo
+ .ent foo
+foo:
+ b bar
+ bal bar
+ bltzal $0, bar
+ beqz $2, bar
+ bnez $2, bar
+ nop
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
+
+ .set bar, 0x1234
diff --git a/gas/testsuite/gas/mips/micromips-branch-absolute-addend-n32.d b/gas/testsuite/gas/mips/micromips-branch-absolute-addend-n32.d
new file mode 100644
index 0000000..b5254be
--- /dev/null
+++ b/gas/testsuite/gas/mips/micromips-branch-absolute-addend-n32.d
@@ -0,0 +1,26 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS branch to absolute expression with addend (n32)
+#as: -n32 -march=from-abi
+#source: micromips-branch-absolute-addend.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 9400 0000 b 00001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0x1230
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 4060 0000 bal 0000100a <foo\+0xa>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0x1230
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 4020 0000 bltzal zero,00001012 <foo\+0x12>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0x1230
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 9402 0000 beqz v0,0000101a <foo\+0x1a>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0x1230
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> b402 0000 bnez v0,00001020 <foo\+0x20>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0x1230
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 0c00 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/micromips-branch-absolute-addend-n64.d b/gas/testsuite/gas/mips/micromips-branch-absolute-addend-n64.d
new file mode 100644
index 0000000..a66a4ff
--- /dev/null
+++ b/gas/testsuite/gas/mips/micromips-branch-absolute-addend-n64.d
@@ -0,0 +1,36 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS branch to absolute expression with addend (n64)
+#as: -64 -march=from-abi
+#source: micromips-branch-absolute-addend.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 9400 0000 b 0000000000001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 4060 0000 bal 000000000000100a <foo\+0xa>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 4020 0000 bltzal zero,0000000000001012 <foo\+0x12>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 9402 0000 beqz v0,000000000000101a <foo\+0x1a>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> b402 0000 bnez v0,0000000000001020 <foo\+0x20>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 0c00 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/micromips-branch-absolute-addend.s b/gas/testsuite/gas/mips/micromips-branch-absolute-addend.s
new file mode 100644
index 0000000..f22f40e
--- /dev/null
+++ b/gas/testsuite/gas/mips/micromips-branch-absolute-addend.s
@@ -0,0 +1,22 @@
+ .text
+
+ .space 0x1000
+
+ .globl foo
+ .ent foo
+ .set micromips
+foo:
+ b bar + 0x1234
+ bal bar + 0x1234
+ bltzal $0, bar + 0x1234
+ beqz $2, bar + 0x1234
+ bnez $2, bar + 0x1234
+ nop
+ .set nomips16
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
+
+ .set bar, 0x12345679
diff --git a/gas/testsuite/gas/mips/micromips-branch-absolute-n32.d b/gas/testsuite/gas/mips/micromips-branch-absolute-n32.d
new file mode 100644
index 0000000..85205ac
--- /dev/null
+++ b/gas/testsuite/gas/mips/micromips-branch-absolute-n32.d
@@ -0,0 +1,26 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS branch to absolute expression (n32)
+#as: -n32 -march=from-abi
+#source: micromips-branch-absolute.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 9400 0000 b 00001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar-0x4
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 4060 0000 bal 0000100a <foo\+0xa>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar-0x4
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 4020 0000 bltzal zero,00001012 <foo\+0x12>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar-0x4
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 9402 0000 beqz v0,0000101a <foo\+0x1a>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar-0x4
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> b402 0000 bnez v0,00001020 <foo\+0x20>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar-0x4
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 0c00 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/micromips-branch-absolute-n64.d b/gas/testsuite/gas/mips/micromips-branch-absolute-n64.d
new file mode 100644
index 0000000..453d650
--- /dev/null
+++ b/gas/testsuite/gas/mips/micromips-branch-absolute-n64.d
@@ -0,0 +1,36 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS branch to absolute expression (n64)
+#as: -64 -march=from-abi
+#source: micromips-branch-absolute.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 9400 0000 b 0000000000001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar-0x4
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*-0x4
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*-0x4
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 4060 0000 bal 000000000000100a <foo\+0xa>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar-0x4
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*-0x4
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*-0x4
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 4020 0000 bltzal zero,0000000000001012 <foo\+0x12>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar-0x4
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*-0x4
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*-0x4
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 9402 0000 beqz v0,000000000000101a <foo\+0x1a>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar-0x4
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*-0x4
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*-0x4
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> b402 0000 bnez v0,0000000000001020 <foo\+0x20>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar-0x4
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*-0x4
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*-0x4
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 0c00 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/micromips-branch-absolute.d b/gas/testsuite/gas/mips/micromips-branch-absolute.d
new file mode 100644
index 0000000..443285f
--- /dev/null
+++ b/gas/testsuite/gas/mips/micromips-branch-absolute.d
@@ -0,0 +1,25 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS branch to absolute expression
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 9400 fffe b 00001000 <foo>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 4060 fffe bal 00001006 <foo\+0x6>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 4020 fffe bltzal zero,0000100e <foo\+0xe>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 9402 fffe beqz v0,00001016 <foo\+0x16>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> b402 fffe bnez v0,0000101c <foo\+0x1c>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 0c00 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/micromips-branch-absolute.s b/gas/testsuite/gas/mips/micromips-branch-absolute.s
new file mode 100644
index 0000000..dcdd2bf
--- /dev/null
+++ b/gas/testsuite/gas/mips/micromips-branch-absolute.s
@@ -0,0 +1,22 @@
+ .text
+
+ .space 0x1000
+
+ .globl foo
+ .ent foo
+ .set micromips
+foo:
+ b bar
+ bal bar
+ bltzal $0, bar
+ beqz $2, bar
+ bnez $2, bar
+ nop
+ .set nomips16
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
+
+ .set bar, 0x1235
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index 157c24d..b22da67 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -611,6 +611,13 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "branch-local-n32-1"
run_dump_test "branch-local-n64-1"
}
+ run_dump_test "branch-absolute"
+ if $has_newabi {
+ run_dump_test "branch-absolute-n32"
+ run_dump_test "branch-absolute-addend-n32"
+ run_dump_test "branch-absolute-n64"
+ run_dump_test "branch-absolute-addend-n64"
+ }
run_dump_test_arches "nal-1" [mips_arch_list_matching mips1 !micromips]
run_dump_test_arches "nal-2" [mips_arch_list_matching mips1 !micromips]
@@ -1273,6 +1280,13 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "micromips-branch-delay"
run_dump_test "micromips-warn-branch-delay"
run_dump_test "micromips-warn-branch-delay-1"
+ run_dump_test "micromips-branch-absolute"
+ if $has_newabi {
+ run_dump_test "micromips-branch-absolute-n32"
+ run_dump_test "micromips-branch-absolute-addend-n32"
+ run_dump_test "micromips-branch-absolute-n64"
+ run_dump_test "micromips-branch-absolute-addend-n64"
+ }
run_dump_test "micromips-b16"
run_list_test "micromips-ill"
@@ -1379,6 +1393,12 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "mips16-branch-addend-2"
run_dump_test "mips16-branch-addend-3"
run_dump_test "mips16-branch-absolute"
+ if $has_newabi {
+ run_dump_test "mips16-branch-absolute-n32"
+ run_dump_test "mips16-branch-absolute-addend-n32"
+ run_dump_test "mips16-branch-absolute-n64"
+ run_dump_test "mips16-branch-absolute-addend-n64"
+ }
run_dump_test "mips16-absolute-reloc-0"
run_dump_test "mips16-absolute-reloc-1"
run_dump_test "mips16-absolute-reloc-2"
diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute-addend-n32.d b/gas/testsuite/gas/mips/mips16-branch-absolute-addend-n32.d
new file mode 100644
index 0000000..48aca38
--- /dev/null
+++ b/gas/testsuite/gas/mips/mips16-branch-absolute-addend-n32.d
@@ -0,0 +1,21 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 branch to absolute expression with addend (n32)
+#as: -n32 -march=from-abi
+#source: mips16-branch-absolute-addend.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> f000 1000 b 00001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> f000 6000 bteqz 00001008 <foo\+0x8>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> f000 6100 btnez 0000100c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> f000 2200 beqz v0,00001010 <foo\+0x10>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> f000 2a00 bnez v0,00001014 <foo\+0x14>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 6500 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute-addend-n64.d b/gas/testsuite/gas/mips/mips16-branch-absolute-addend-n64.d
new file mode 100644
index 0000000..f5770a9
--- /dev/null
+++ b/gas/testsuite/gas/mips/mips16-branch-absolute-addend-n64.d
@@ -0,0 +1,31 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 branch to absolute expression with addend (n64)
+#as: -64 -march=from-abi
+#source: mips16-branch-absolute-addend.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> f000 1000 b 0000000000001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> f000 6000 bteqz 0000000000001008 <foo\+0x8>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> f000 6100 btnez 000000000000100c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> f000 2200 beqz v0,0000000000001010 <foo\+0x10>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> f000 2a00 bnez v0,0000000000001014 <foo\+0x14>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x123468a8
+[0-9a-f]+ <[^>]*> 6500 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute-addend.s b/gas/testsuite/gas/mips/mips16-branch-absolute-addend.s
new file mode 100644
index 0000000..d663eb2
--- /dev/null
+++ b/gas/testsuite/gas/mips/mips16-branch-absolute-addend.s
@@ -0,0 +1,22 @@
+ .text
+
+ .space 0x1000
+
+ .globl foo
+ .ent foo
+ .set mips16
+foo:
+ b bar + 0x1234
+ bteqz bar + 0x1234
+ btnez bar + 0x1234
+ beqz $2, bar + 0x1234
+ bnez $2, bar + 0x1234
+ nop
+ .set nomips16
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
+
+ .set bar, 0x12345679
diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute-n32.d b/gas/testsuite/gas/mips/mips16-branch-absolute-n32.d
new file mode 100644
index 0000000..444edeb
--- /dev/null
+++ b/gas/testsuite/gas/mips/mips16-branch-absolute-n32.d
@@ -0,0 +1,21 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 branch to absolute expression (n32)
+#as: -n32 -march=from-abi
+#source: mips16-branch-absolute.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> f000 1000 b 00001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> f000 6000 bteqz 00001008 <foo\+0x8>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> f000 6100 btnez 0000100c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> f000 2200 beqz v0,00001010 <foo\+0x10>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> f000 2a00 bnez v0,00001014 <foo\+0x14>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 6500 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute-n64.d b/gas/testsuite/gas/mips/mips16-branch-absolute-n64.d
new file mode 100644
index 0000000..eebd5dd
--- /dev/null
+++ b/gas/testsuite/gas/mips/mips16-branch-absolute-n64.d
@@ -0,0 +1,31 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 branch to absolute expression (n64)
+#as: -64 -march=from-abi
+#source: mips16-branch-absolute.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> f000 1000 b 0000000000001004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> f000 6000 bteqz 0000000000001008 <foo\+0x8>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> f000 6100 btnez 000000000000100c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> f000 2200 beqz v0,0000000000001010 <foo\+0x10>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> f000 2a00 bnez v0,0000000000001014 <foo\+0x14>
+[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x1230
+[0-9a-f]+ <[^>]*> 6500 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute.d b/gas/testsuite/gas/mips/mips16-branch-absolute.d
index 3e1ec8e..35788bf 100644
--- a/gas/testsuite/gas/mips/mips16-branch-absolute.d
+++ b/gas/testsuite/gas/mips/mips16-branch-absolute.d
@@ -6,15 +6,15 @@
Disassembly of section \.text:
\.\.\.
-[0-9a-f]+ <[^>]*> f000 1000 b 00001004 <foo\+0x4>
+[0-9a-f]+ <[^>]*> f101 1018 b 00002234 <bar\+0x1000>
[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*
-[0-9a-f]+ <[^>]*> f000 6000 bteqz 00001008 <foo\+0x8>
+[0-9a-f]+ <[^>]*> f101 6018 bteqz 00002238 <bar\+0x1004>
[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*
-[0-9a-f]+ <[^>]*> f000 6100 btnez 0000100c <foo\+0xc>
+[0-9a-f]+ <[^>]*> f101 6118 btnez 0000223c <bar\+0x1008>
[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*
-[0-9a-f]+ <[^>]*> f000 2200 beqz v0,00001010 <foo\+0x10>
+[0-9a-f]+ <[^>]*> f101 2218 beqz v0,00002240 <bar\+0x100c>
[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*
-[0-9a-f]+ <[^>]*> f000 2a00 bnez v0,00001014 <foo\+0x14>
+[0-9a-f]+ <[^>]*> f101 2a18 bnez v0,00002244 <bar\+0x1010>
[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\*
[0-9a-f]+ <[^>]*> 6500 nop
\.\.\.
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 035db91..640b36f 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,26 @@
+2016-07-14 Maciej W. Rozycki <macro@imgtec.com>
+
+ * testsuite/ld-mips-elf/branch-absolute.d: New test.
+ * testsuite/ld-mips-elf/branch-absolute-n32.d: New test.
+ * testsuite/ld-mips-elf/branch-absolute-n64.d: New test.
+ * testsuite/ld-mips-elf/branch-absolute-addend.d: New test.
+ * testsuite/ld-mips-elf/branch-absolute-addend-n32.d: New test.
+ * testsuite/ld-mips-elf/branch-absolute-addend-n64.d: New test.
+ * testsuite/ld-mips-elf/micromips-branch-absolute.d: New test.
+ * testsuite/ld-mips-elf/micromips-branch-absolute-n32.d: New
+ test.
+ * testsuite/ld-mips-elf/micromips-branch-absolute-n64.d: New
+ test.
+ * testsuite/ld-mips-elf/micromips-branch-absolute-addend.d: New
+ test.
+ * testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d:
+ New test.
+ * testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d:
+ New test.
+ * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests, except
+ from `branch-absolute-addend' and
+ `micromips-branch-absolute-addend', referred indirectly only.
+
2016-07-14 Claudiu Zissulescu <claziss@synopsys.com>
* emulparams/arcelf.sh (SDATA_START_SYMBOLS): Add offset.
diff --git a/ld/testsuite/ld-mips-elf/branch-absolute-addend-n32.d b/ld/testsuite/ld-mips-elf/branch-absolute-addend-n32.d
new file mode 100644
index 0000000..82fd6c6
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/branch-absolute-addend-n32.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS link branch to absolute expression with addend (n32)
+#source: ../../../gas/testsuite/gas/mips/branch-absolute-addend.s
+#as: -EB -n32 -march=from-abi
+#ld: -EB -Ttext 0x12340000 -e foo
+#dump: branch-absolute-addend.d
diff --git a/ld/testsuite/ld-mips-elf/branch-absolute-addend-n64.d b/ld/testsuite/ld-mips-elf/branch-absolute-addend-n64.d
new file mode 100644
index 0000000..9bb7c8f
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/branch-absolute-addend-n64.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS link branch to absolute expression with addend (n64)
+#source: ../../../gas/testsuite/gas/mips/branch-absolute-addend.s
+#as: -EB -64 -march=from-abi
+#ld: -EB -Ttext 0x12340000 -e foo
+#dump: branch-absolute-addend.d
diff --git a/ld/testsuite/ld-mips-elf/branch-absolute-addend.d b/ld/testsuite/ld-mips-elf/branch-absolute-addend.d
new file mode 100644
index 0000000..063962b
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/branch-absolute-addend.d
@@ -0,0 +1,21 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS link branch to absolute expression with addend
+#source: ../../../gas/testsuite/gas/mips/branch-absolute-addend.s
+#as: -EB -32
+#ld: -EB -Ttext 0x12340000 -e foo
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 1000162a b 0*123468ac <bar\+0x1234>
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04111628 bal 0*123468ac <bar\+0x1234>
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04101626 bltzal zero,0*123468ac <bar\+0x1234>
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 10401624 beqz v0,0*123468ac <bar\+0x1234>
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 14401622 bnez v0,0*123468ac <bar\+0x1234>
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/branch-absolute-n32.d b/ld/testsuite/ld-mips-elf/branch-absolute-n32.d
new file mode 100644
index 0000000..b1ecf64
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/branch-absolute-n32.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS link branch to absolute expression (n32)
+#source: ../../../gas/testsuite/gas/mips/branch-absolute.s
+#as: -EB -n32 -march=from-abi
+#ld: -EB -Ttext 0 -e foo
+#dump: branch-absolute.d
diff --git a/ld/testsuite/ld-mips-elf/branch-absolute-n64.d b/ld/testsuite/ld-mips-elf/branch-absolute-n64.d
new file mode 100644
index 0000000..9b8dcff
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/branch-absolute-n64.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS link branch to absolute expression (n64)
+#source: ../../../gas/testsuite/gas/mips/branch-absolute.s
+#as: -EB -64 -march=from-abi
+#ld: -EB -Ttext 0 -e foo
+#dump: branch-absolute.d
diff --git a/ld/testsuite/ld-mips-elf/branch-absolute.d b/ld/testsuite/ld-mips-elf/branch-absolute.d
new file mode 100644
index 0000000..65e4317
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/branch-absolute.d
@@ -0,0 +1,21 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS link branch to absolute expression
+#source: ../../../gas/testsuite/gas/mips/branch-absolute.s
+#as: -EB -32
+#ld: -EB -Ttext 0 -e foo
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 1000008c b 0+001234 <bar>
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 0411008a bal 0+001234 <bar>
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 04100088 bltzal zero,0+001234 <bar>
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 10400086 beqz v0,0+001234 <bar>
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 14400084 bnez v0,0+001234 <bar>
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d b/ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d
new file mode 100644
index 0000000..2051cea
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS link branch to absolute expression with addend (n32)
+#source: ../../../gas/testsuite/gas/mips/micromips-branch-absolute-addend.s
+#as: -EB -n32 -march=from-abi
+#ld: -EB -Ttext 0x12340000 -e foo
+#dump: micromips-branch-absolute-addend.d
diff --git a/ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d b/ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d
new file mode 100644
index 0000000..3814a0a
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS link branch to absolute expression with addend (n64)
+#source: ../../../gas/testsuite/gas/mips/micromips-branch-absolute-addend.s
+#as: -EB -64 -march=from-abi
+#ld: -EB -Ttext 0x12340000 -e foo
+#dump: micromips-branch-absolute-addend.d
diff --git a/ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend.d b/ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend.d
new file mode 100644
index 0000000..ec78ff9
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/micromips-branch-absolute-addend.d
@@ -0,0 +1,22 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS link branch to absolute expression with addend
+#source: ../../../gas/testsuite/gas/mips/micromips-branch-absolute-addend.s
+#as: -EB -32
+#ld: -EB -Ttext 0x12340000 -e foo
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 9400 2c54 b 0*123468ac <bar\+0x1233>
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 4060 2c51 bal 0*123468ac <bar\+0x1233>
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 4020 2c4d bltzal zero,0*123468ac <bar\+0x1233>
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 9402 2c49 beqz v0,0*123468ac <bar\+0x1233>
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> b402 2c46 bnez v0,0*123468ac <bar\+0x1233>
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 0c00 nop
+ \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/micromips-branch-absolute-n32.d b/ld/testsuite/ld-mips-elf/micromips-branch-absolute-n32.d
new file mode 100644
index 0000000..7b1dd46
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/micromips-branch-absolute-n32.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS link branch to absolute expression (n32)
+#source: ../../../gas/testsuite/gas/mips/micromips-branch-absolute.s
+#as: -EB -n32 -march=from-abi
+#ld: -EB -Ttext 0 -e foo
+#dump: micromips-branch-absolute.d
diff --git a/ld/testsuite/ld-mips-elf/micromips-branch-absolute-n64.d b/ld/testsuite/ld-mips-elf/micromips-branch-absolute-n64.d
new file mode 100644
index 0000000..e661935
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/micromips-branch-absolute-n64.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS link branch to absolute expression (n64)
+#source: ../../../gas/testsuite/gas/mips/micromips-branch-absolute.s
+#as: -EB -64 -march=from-abi
+#ld: -EB -Ttext 0 -e foo
+#dump: micromips-branch-absolute.d
diff --git a/ld/testsuite/ld-mips-elf/micromips-branch-absolute.d b/ld/testsuite/ld-mips-elf/micromips-branch-absolute.d
new file mode 100644
index 0000000..f07ad1b
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/micromips-branch-absolute.d
@@ -0,0 +1,22 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS link branch to absolute expression
+#source: ../../../gas/testsuite/gas/mips/micromips-branch-absolute.s
+#as: -EB -32
+#ld: -EB -Ttext 0 -e foo
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 9400 0118 b 0+001234 <foo\+0x234>
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 4060 0115 bal 0+001234 <foo\+0x234>
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 4020 0111 bltzal zero,0+001234 <foo\+0x234>
+[0-9a-f]+ <[^>]*> 0000 0000 nop
+[0-9a-f]+ <[^>]*> 9402 010d beqz v0,0+001234 <foo\+0x234>
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> b402 010a bnez v0,0+001234 <foo\+0x234>
+[0-9a-f]+ <[^>]*> 0c00 nop
+[0-9a-f]+ <[^>]*> 0c00 nop
+ \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index f4202f4..21867f1 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -143,12 +143,33 @@ run_dump_test "mips16-1"
# MIPS branch offset final link checking.
run_dump_test "branch-misc-1"
run_dump_test "branch-misc-2"
+run_dump_test "branch-absolute" [list [list ld $abi_ldflags(o32)]]
+if $has_newabi {
+ run_dump_test "branch-absolute-n32" [list [list ld $abi_ldflags(n32)]]
+ run_dump_test "branch-absolute-addend-n32" \
+ [list [list ld $abi_ldflags(n32)]]
+ run_dump_test "branch-absolute-n64" [list [list ld $abi_ldflags(n64)]]
+ run_dump_test "branch-absolute-addend-n64" \
+ [list [list ld $abi_ldflags(n64)]]
+}
run_dump_test "mips16-branch-2" [list [list ld $abi_ldflags(o32)]]
run_dump_test "mips16-branch-3" [list [list ld $abi_ldflags(o32)]]
run_dump_test "mips16-branch-addend-2" [list [list ld $abi_ldflags(o32)]]
run_dump_test "mips16-branch-addend-3" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "micromips-branch-absolute" [list [list ld $abi_ldflags(o32)]]
+if $has_newabi {
+ run_dump_test "micromips-branch-absolute-n32" \
+ [list [list ld $abi_ldflags(n32)]]
+ run_dump_test "micromips-branch-absolute-addend-n32" \
+ [list [list ld $abi_ldflags(n32)]]
+ run_dump_test "micromips-branch-absolute-n64" \
+ [list [list ld $abi_ldflags(n64)]]
+ run_dump_test "micromips-branch-absolute-addend-n64" \
+ [list [list ld $abi_ldflags(n64)]]
+}
+
# Jalx test
run_dump_test "jalx-1"