MIPS/GAS: Don't convert PC-relative REL relocs against absolute symbols
authorMaciej W. Rozycki <macro@imgtec.com>
Tue, 12 Jul 2016 00:31:29 +0000 (01:31 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Thu, 14 Jul 2016 19:11:03 +0000 (20:11 +0100)
Don't convert PC-relative REL relocations against absolute symbols to
section-relative references and retain the original symbol reference
instead.  Offsets into the absolute section may overflow the limited
range of their in-place addend field, causing an assembly error, e.g.:

$ cat test.s
.text
.globl foo
.ent foo
foo:
b bar
.end foo

.set bar, 0x12345678
$ as -EB -32 -o test.o test.s
test.s: Assembler messages:
test.s:3: Error: relocation overflow
$

With the original reference retained the source can now be assembled and
linked successfully:

$ as -EB -32 -o test.o test.s
$ objdump -dr test.o

test.o:     file format elf32-tradbigmips

Disassembly of section .text:

00000000 <foo>:
   0: 1000ffff  b 0 <foo>
0: R_MIPS_PC16 bar
   4: 00000000  nop
...
$ ld -melf32btsmip -Ttext 0x12340000 -e foo -o test test.o
$ objdump -dr test

test:     file format elf32-tradbigmips

Disassembly of section .text:

12340000 <foo>:
12340000: 1000159d  b 12345678 <bar>
12340004: 00000000  nop
...
$

For simplicity always retain the original symbol reference, even if it
would indeed fit.

Making TC_FORCE_RELOCATION_ABS separate from TC_FORCE_RELOCATION causes
R_MICROMIPS_PC7_S1, R_MICROMIPS_PC10_S1 and R_MICROMIPS_PC16_S1 branch
relocations against absolute symbols to be converted on RELA targets to
section-relative references.  This is an intended effect of this change.
Absolute symbols carry no ISA annotation in their `st_other' field and
their value is not going to change with linker relaxation, so it is safe
to discard the original reference and keep the calculated final symbol
value only in the relocation's addend.

Similarly R6 R_MIPS_PCHI16 and R_MIPS_PCLO16 relocations referring
absolute symbols can be safely converted even on REL targets, as there
the in-place addend of these relocations covers the entire 32-bit
address space so it can hold the calculated final symbol value, and
likewise the value referred won't be affected by any linker relaxation.

Add a set of suitable test cases and enable REL linker tests which now
work and were previously used as dump patterns for RELA tests only.

gas/
* config/tc-mips.h (TC_FORCE_RELOCATION_ABS): New macro.
(mips_force_relocation_abs): New prototype.
* config/tc-mips.c (mips_force_relocation_abs): New function.
* testsuite/gas/mips/branch-absolute.d: Adjust dump patterns.
* testsuite/gas/mips/mips16-branch-absolute.d: Likewise.
* testsuite/gas/mips/micromips-branch-absolute-n32.d: Likewise.
* testsuite/gas/mips/micromips-branch-absolute-n64.d: Likewise.
* testsuite/gas/mips/micromips-branch-absolute-addend-n32.d:
Likewise.
* testsuite/gas/mips/micromips-branch-absolute-addend-n64.d:
Likewise.
* testsuite/gas/mips/branch-absolute-addend.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-addend.d: New test.
* testsuite/gas/mips/micromips-branch-absolute-addend.d: New
test.
* testsuite/gas/mips/mips.exp: Run the new tests.

ld/
* testsuite/ld-mips-elf/mips-elf.exp: Run
`branch-absolute-addend', `mips16-branch-absolute',
`mips16-branch-absolute-addend' and
`micromips-branch-absolute-addend'.

15 files changed:
gas/ChangeLog
gas/config/tc-mips.c
gas/config/tc-mips.h
gas/testsuite/gas/mips/branch-absolute-addend.d [new file with mode: 0644]
gas/testsuite/gas/mips/branch-absolute.d
gas/testsuite/gas/mips/micromips-branch-absolute-addend-n32.d
gas/testsuite/gas/mips/micromips-branch-absolute-addend-n64.d
gas/testsuite/gas/mips/micromips-branch-absolute-addend.d [new file with mode: 0644]
gas/testsuite/gas/mips/micromips-branch-absolute-n32.d
gas/testsuite/gas/mips/micromips-branch-absolute-n64.d
gas/testsuite/gas/mips/mips.exp
gas/testsuite/gas/mips/mips16-branch-absolute-addend.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-absolute.d
ld/ChangeLog
ld/testsuite/ld-mips-elf/mips-elf.exp

index 13243ce7a6fdaad96b1906281b7ecc503efd5d0c..50f7cd98f6121c2367ba45072f2cf157b4f6738f 100644 (file)
@@ -1,3 +1,22 @@
+2016-07-14  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * config/tc-mips.h (TC_FORCE_RELOCATION_ABS): New macro.
+       (mips_force_relocation_abs): New prototype.
+       * config/tc-mips.c (mips_force_relocation_abs): New function.
+       * testsuite/gas/mips/branch-absolute.d: Adjust dump patterns.
+       * testsuite/gas/mips/mips16-branch-absolute.d: Likewise.
+       * testsuite/gas/mips/micromips-branch-absolute-n32.d: Likewise.
+       * testsuite/gas/mips/micromips-branch-absolute-n64.d: Likewise.
+       * testsuite/gas/mips/micromips-branch-absolute-addend-n32.d:
+       Likewise.
+       * testsuite/gas/mips/micromips-branch-absolute-addend-n64.d:
+       Likewise.
+       * testsuite/gas/mips/branch-absolute-addend.d: New test.
+       * testsuite/gas/mips/mips16-branch-absolute-addend.d: New test.
+       * testsuite/gas/mips/micromips-branch-absolute-addend.d: New
+       test.
+       * testsuite/gas/mips/mips.exp: Run the new tests.
+
 2016-07-14  Maciej W. Rozycki  <macro@imgtec.com>
 
        * config/tc-mips.c (md_apply_fix) <BFD_RELOC_MIPS16_16_PCREL_S1>
index 6c0be63d6402340ad020685babf00f96a9f4d9cb..cca545052dc67fb862e0cb34716bad32642fd4ec 100644 (file)
@@ -14814,6 +14814,22 @@ mips_force_relocation (fixS *fixp)
   return 0;
 }
 
+/* Implement TC_FORCE_RELOCATION_ABS.  */
+
+bfd_boolean
+mips_force_relocation_abs (fixS *fixp)
+{
+  if (generic_force_reloc (fixp))
+    return TRUE;
+
+  /* These relocations do not have enough bits in the in-place addend
+     to hold an arbitrary absolute section's offset.  */
+  if (HAVE_IN_PLACE_ADDENDS && limited_pcrel_reloc_p (fixp->fx_r_type))
+    return TRUE;
+
+  return FALSE;
+}
+
 /* Read the instruction associated with RELOC from BUF.  */
 
 static unsigned int
index 45e779d392059f27e4dc32d0bf29990a0641cc8c..b4726730d767556d72d2d0a8ce2d6ea6afeca916 100644 (file)
@@ -142,6 +142,9 @@ extern int mips_force_relocation (struct fix *);
 #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
   (! SEG_NORMAL (SEG) || mips_force_relocation (FIX))
 
+#define TC_FORCE_RELOCATION_ABS(FIX) mips_force_relocation_abs (FIX)
+extern bfd_boolean mips_force_relocation_abs (struct fix *);
+
 /* Register mask variables.  These are set by the MIPS assembly code
    and used by ECOFF and possibly other object file formats.  */
 extern unsigned long mips_gprmask;
diff --git a/gas/testsuite/gas/mips/branch-absolute-addend.d b/gas/testsuite/gas/mips/branch-absolute-addend.d
new file mode 100644 (file)
index 0000000..df86846
--- /dev/null
@@ -0,0 +1,24 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch to absolute expression with addend
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> 1000048c     b       00002234 <foo\+0x1234>
+[      ]*[0-9a-f]+: R_MIPS_PC16        bar
+[0-9a-f]+ <[^>]*> 00000000     nop
+[0-9a-f]+ <[^>]*> 0411048c     bal     0000223c <foo\+0x123c>
+[      ]*[0-9a-f]+: R_MIPS_PC16        bar
+[0-9a-f]+ <[^>]*> 00000000     nop
+[0-9a-f]+ <[^>]*> 0410048c     bltzal  zero,00002244 <foo\+0x1244>
+[      ]*[0-9a-f]+: R_MIPS_PC16        bar
+[0-9a-f]+ <[^>]*> 00000000     nop
+[0-9a-f]+ <[^>]*> 1040048c     beqz    v0,0000224c <foo\+0x124c>
+[      ]*[0-9a-f]+: R_MIPS_PC16        bar
+[0-9a-f]+ <[^>]*> 00000000     nop
+[0-9a-f]+ <[^>]*> 1440048c     bnez    v0,00002254 <foo\+0x1254>
+[      ]*[0-9a-f]+: R_MIPS_PC16        bar
+[0-9a-f]+ <[^>]*> 00000000     nop
+       \.\.\.
index 37e7fc558fe4da125f60bdf3df5ff8daa1991652..816c139e778e98b91088df837568a9919ce913ea 100644 (file)
@@ -6,19 +6,19 @@
 
 Disassembly of section \.text:
        \.\.\.
-[0-9a-f]+ <[^>]*> 1000048c     b       00002234 <bar\+0x1000>
-[      ]*[0-9a-f]+: R_MIPS_PC16        \*ABS\*
+[0-9a-f]+ <[^>]*> 1000ffff     b       00001000 <foo>
+[      ]*[0-9a-f]+: R_MIPS_PC16        bar
 [0-9a-f]+ <[^>]*> 00000000     nop
-[0-9a-f]+ <[^>]*> 0411048c     bal     0000223c <bar\+0x1008>
-[      ]*[0-9a-f]+: R_MIPS_PC16        \*ABS\*
+[0-9a-f]+ <[^>]*> 0411ffff     bal     00001008 <foo\+0x8>
+[      ]*[0-9a-f]+: R_MIPS_PC16        bar
 [0-9a-f]+ <[^>]*> 00000000     nop
-[0-9a-f]+ <[^>]*> 0410048c     bltzal  zero,00002244 <bar\+0x1010>
-[      ]*[0-9a-f]+: R_MIPS_PC16        \*ABS\*
+[0-9a-f]+ <[^>]*> 0410ffff     bltzal  zero,00001010 <foo\+0x10>
+[      ]*[0-9a-f]+: R_MIPS_PC16        bar
 [0-9a-f]+ <[^>]*> 00000000     nop
-[0-9a-f]+ <[^>]*> 1040048c     beqz    v0,0000224c <bar\+0x1018>
-[      ]*[0-9a-f]+: R_MIPS_PC16        \*ABS\*
+[0-9a-f]+ <[^>]*> 1040ffff     beqz    v0,00001018 <foo\+0x18>
+[      ]*[0-9a-f]+: R_MIPS_PC16        bar
 [0-9a-f]+ <[^>]*> 00000000     nop
-[0-9a-f]+ <[^>]*> 1440048c     bnez    v0,00002254 <bar\+0x1020>
-[      ]*[0-9a-f]+: R_MIPS_PC16        \*ABS\*
+[0-9a-f]+ <[^>]*> 1440ffff     bnez    v0,00001020 <foo\+0x20>
+[      ]*[0-9a-f]+: R_MIPS_PC16        bar
 [0-9a-f]+ <[^>]*> 00000000     nop
        \.\.\.
index b5254be5c5af1e4bbf090239b09ad6b2f15a9efa..4f630f0ccb8eb10d9b4478404a764f1e7a356221 100644 (file)
@@ -8,19 +8,19 @@
 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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x123468a9
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x123468a9
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x123468a9
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x123468a9
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x123468a9
 [0-9a-f]+ <[^>]*> 0c00         nop
 [0-9a-f]+ <[^>]*> 0c00         nop
        \.\.\.
index a66a4ff2c739a24300b32d11422527e5704d6e9d..0e14396be191ed2b02510ec9c4b4bf80d3024f81 100644 (file)
@@ -8,29 +8,29 @@
 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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x123468a9
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x123468a9
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x123468a9
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x123468a9
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x123468a9
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x123468a9
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x123468a9
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x123468a9
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x123468a9
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x123468a9
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x123468a9
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x123468a9
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x123468a9
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x123468a9
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x123468a9
 [0-9a-f]+ <[^>]*> 0c00         nop
 [0-9a-f]+ <[^>]*> 0c00         nop
        \.\.\.
diff --git a/gas/testsuite/gas/mips/micromips-branch-absolute-addend.d b/gas/testsuite/gas/mips/micromips-branch-absolute-addend.d
new file mode 100644 (file)
index 0000000..316adad
--- /dev/null
@@ -0,0 +1,25 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS branch to absolute expression with addend
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> 9400 0918    b       00002234 <foo\+0x1234>
+[      ]*[0-9a-f]+: R_MICROMIPS_PC16_S1        bar
+[0-9a-f]+ <[^>]*> 0c00         nop
+[0-9a-f]+ <[^>]*> 4060 0918    bal     0000223a <foo\+0x123a>
+[      ]*[0-9a-f]+: R_MICROMIPS_PC16_S1        bar
+[0-9a-f]+ <[^>]*> 0000 0000    nop
+[0-9a-f]+ <[^>]*> 4020 0918    bltzal  zero,00002242 <foo\+0x1242>
+[      ]*[0-9a-f]+: R_MICROMIPS_PC16_S1        bar
+[0-9a-f]+ <[^>]*> 0000 0000    nop
+[0-9a-f]+ <[^>]*> 9402 0918    beqz    v0,0000224a <foo\+0x124a>
+[      ]*[0-9a-f]+: R_MICROMIPS_PC16_S1        bar
+[0-9a-f]+ <[^>]*> 0c00         nop
+[0-9a-f]+ <[^>]*> b402 0918    bnez    v0,00002250 <foo\+0x1250>
+[      ]*[0-9a-f]+: R_MICROMIPS_PC16_S1        bar
+[0-9a-f]+ <[^>]*> 0c00         nop
+[0-9a-f]+ <[^>]*> 0c00         nop
+       \.\.\.
index 85205ac0fd29fe35dc44ab8c8a785ac2864e4e18..212caaaad13fda2cd8f966e67c4ee5032ae58c8f 100644 (file)
@@ -8,19 +8,19 @@
 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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x1231
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x1231
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x1231
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x1231
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x1231
 [0-9a-f]+ <[^>]*> 0c00         nop
 [0-9a-f]+ <[^>]*> 0c00         nop
        \.\.\.
index 453d6501af4c9a20e2e3dd8107c10ac8811c3eec..443ef50da605a43771204185a1c987cfa0502979 100644 (file)
@@ -8,29 +8,29 @@
 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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x1231
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x1231
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x1231
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x1231
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x1231
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x1231
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x1231
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x1231
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x1231
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x1231
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x1231
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x1231
 [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]+: R_MICROMIPS_PC16_S1        \*ABS\*\+0x1231
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x1231
+[      ]*[0-9a-f]+: R_MIPS_NONE        \*ABS\*\+0x1231
 [0-9a-f]+ <[^>]*> 0c00         nop
 [0-9a-f]+ <[^>]*> 0c00         nop
        \.\.\.
index b22da6754bb612953f940cfde021d9a663c1d92e..8bdddbfba157d712beb0ff387ebecaf214d6bd65 100644 (file)
@@ -612,6 +612,7 @@ if { [istarget mips*-*-vxworks*] } {
        run_dump_test "branch-local-n64-1"
     }
     run_dump_test "branch-absolute"
+    run_dump_test "branch-absolute-addend"
     if $has_newabi {
        run_dump_test "branch-absolute-n32"
        run_dump_test "branch-absolute-addend-n32"
@@ -1281,6 +1282,7 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test "micromips-warn-branch-delay"
     run_dump_test "micromips-warn-branch-delay-1"
     run_dump_test "micromips-branch-absolute"
+    run_dump_test "micromips-branch-absolute-addend"
     if $has_newabi {
        run_dump_test "micromips-branch-absolute-n32"
        run_dump_test "micromips-branch-absolute-addend-n32"
@@ -1393,6 +1395,7 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test "mips16-branch-addend-2"
     run_dump_test "mips16-branch-addend-3"
     run_dump_test "mips16-branch-absolute"
+    run_dump_test "mips16-branch-absolute-addend"
     if $has_newabi {
        run_dump_test "mips16-branch-absolute-n32"
        run_dump_test "mips16-branch-absolute-addend-n32"
diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute-addend.d b/gas/testsuite/gas/mips/mips16-branch-absolute-addend.d
new file mode 100644 (file)
index 0000000..de64afb
--- /dev/null
@@ -0,0 +1,20 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 branch to absolute expression with addend
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> f101 1018    b       00002234 <foo\+0x1234>
+[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   bar
+[0-9a-f]+ <[^>]*> f101 6018    bteqz   00002238 <foo\+0x1238>
+[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   bar
+[0-9a-f]+ <[^>]*> f101 6118    btnez   0000223c <foo\+0x123c>
+[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   bar
+[0-9a-f]+ <[^>]*> f101 2218    beqz    v0,00002240 <foo\+0x1240>
+[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   bar
+[0-9a-f]+ <[^>]*> f101 2a18    bnez    v0,00002244 <foo\+0x1244>
+[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   bar
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
index 4d2c9d31e271a8e1877165fcc9e12a67629c5309..68b3fb4e8d08047fc524e1f40ecc69b052f3d5ad 100644 (file)
@@ -6,15 +6,15 @@
 
 Disassembly of section \.text:
        \.\.\.
-[0-9a-f]+ <[^>]*> f101 1018    b       00002234 <bar\+0xfff>
-[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   \*ABS\*
-[0-9a-f]+ <[^>]*> f101 6018    bteqz   00002238 <bar\+0x1003>
-[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   \*ABS\*
-[0-9a-f]+ <[^>]*> f101 6118    btnez   0000223c <bar\+0x1007>
-[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   \*ABS\*
-[0-9a-f]+ <[^>]*> f101 2218    beqz    v0,00002240 <bar\+0x100b>
-[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   \*ABS\*
-[0-9a-f]+ <[^>]*> f101 2a18    bnez    v0,00002244 <bar\+0x100f>
-[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   \*ABS\*
+[0-9a-f]+ <[^>]*> f7ff 101e    b       00001000 <foo>
+[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   bar
+[0-9a-f]+ <[^>]*> f7ff 601e    bteqz   00001004 <foo\+0x4>
+[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   bar
+[0-9a-f]+ <[^>]*> f7ff 611e    btnez   00001008 <foo\+0x8>
+[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   bar
+[0-9a-f]+ <[^>]*> f7ff 221e    beqz    v0,0000100c <foo\+0xc>
+[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   bar
+[0-9a-f]+ <[^>]*> f7ff 2a1e    bnez    v0,00001010 <foo\+0x10>
+[      ]*[0-9a-f]+: R_MIPS16_PC16_S1   bar
 [0-9a-f]+ <[^>]*> 6500         nop
        \.\.\.
index 1f8a499eec4d539eb4207702d3779b7344ebc822..250d076c4a90ac9d20e26d1852c54147dcb59050 100644 (file)
@@ -1,3 +1,10 @@
+2016-07-14  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * testsuite/ld-mips-elf/mips-elf.exp: Run
+       `branch-absolute-addend', `mips16-branch-absolute',
+       `mips16-branch-absolute-addend' and
+       `micromips-branch-absolute-addend'.
+
 2016-07-14  Maciej W. Rozycki  <macro@imgtec.com>
 
        * testsuite/ld-mips-elf/mips16-branch-absolute.d: New test.
index cca6695d2a2977d1a2141951fb4a5477a6ba0e53..5c417c73e899278c9fad08114efb37a6b6b1b7c5 100644 (file)
@@ -144,6 +144,7 @@ run_dump_test "mips16-1"
 run_dump_test "branch-misc-1"
 run_dump_test "branch-misc-2"
 run_dump_test "branch-absolute" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "branch-absolute-addend" [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" \
@@ -157,6 +158,9 @@ 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 "mips16-branch-absolute" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "mips16-branch-absolute-addend" \
+                                       [list [list ld $abi_ldflags(o32)]]
 if $has_newabi {
     run_dump_test "mips16-branch-absolute-n32" \
                                        [list [list ld $abi_ldflags(n32)]]
@@ -169,6 +173,8 @@ if $has_newabi {
 }
 
 run_dump_test "micromips-branch-absolute" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "micromips-branch-absolute-addend" \
+                                       [list [list ld $abi_ldflags(o32)]]
 if $has_newabi {
     run_dump_test "micromips-branch-absolute-n32" \
                                        [list [list ld $abi_ldflags(n32)]]