]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
MIPS: Add tests for orphan REL HI16 relocation addend processing
authorMaciej W. Rozycki <macro@orcam.me.uk>
Wed, 14 Jan 2026 22:28:44 +0000 (22:28 +0000)
committerMaciej W. Rozycki <macro@orcam.me.uk>
Wed, 14 Jan 2026 22:28:44 +0000 (22:28 +0000)
Add GAS and LD test cases for orphan REL HI16 relocation processing,
including verification of the addends produced as well as the warning
messages expected.

Due to the ordering used for the list of oustanding cached HI16 reloc
entries warnings for non-ELF links are issued in the reverse order
compared to one for ELF links.  This is not considered a defect as all
the required warnings are produced in both cases, however separate
warning lists are required and included here for ELF and srec output.

27 files changed:
gas/testsuite/gas/mips/micromips-hi16-orphan-addend.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips-hi16-orphan-addend.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips-hi16-orphan-addend.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips.exp
gas/testsuite/gas/mips/mips16-hi16-orphan-addend.d [new file with mode: 0644]
gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.d [new file with mode: 0644]
gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.l [new file with mode: 0644]
gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend-srec.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend-srec.l [new file with mode: 0644]
ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend.l [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-elf.exp
ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend-srec.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend-srec.l [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.l [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.ld [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend-srec.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend-srec.l [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend.l [new file with mode: 0644]
ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend-srec.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend-srec.l [new file with mode: 0644]
ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend.l [new file with mode: 0644]

diff --git a/gas/testsuite/gas/mips/micromips-hi16-orphan-addend.d b/gas/testsuite/gas/mips/micromips-hi16-orphan-addend.d
new file mode 100644 (file)
index 0000000..f90f55e
--- /dev/null
@@ -0,0 +1,51 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#as: -mabi=32 -march=mips1 -mno-pdr --defsym micromips=1
+#name: MIPS and microMIPS orphan HI16 REL relocation addends
+#warning_output: mips-hi16-orphan-addend.l
+#source: mips-hi16-orphan-addend.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+00000000 <[^>]*> 24025677      li      v0,22135
+                       0: R_MIPS_LO16  var1
+00000004 <[^>]*> 24045677      li      a0,22135
+                       4: R_MIPS_TLS_DTPREL_LO16       var2
+00000008 <[^>]*> 03e00008      jr      ra
+0000000c <[^>]*> 24065677      li      a2,22135
+                       c: R_MIPS_TLS_TPREL_LO16        var3
+00000010 <[^>]*> 3040 5677     li      v0,22135
+                       10: R_MICROMIPS_LO16    var1
+00000014 <[^>]*> 3080 5677     li      a0,22135
+                       14: R_MICROMIPS_TLS_DTPREL_LO16 var2
+00000018 <[^>]*> 459f          jr      ra
+0000001a <[^>]*> 30c0 5677     li      a2,22135
+                       1a: R_MICROMIPS_TLS_TPREL_LO16  var3
+       \.\.\.
+00000020 <[^>]*> 2407b1a3      li      a3,-20061
+                       20: R_MIPS_TLS_TPREL_HI16       var3
+00000024 <[^>]*> 24061234      li      a2,4660
+                       24: R_MIPS_TLS_TPREL_HI16       var3
+00000028 <[^>]*> 2405b1a3      li      a1,-20061
+                       28: R_MIPS_TLS_DTPREL_HI16      var2
+0000002c <[^>]*> 24041234      li      a0,4660
+                       2c: R_MIPS_TLS_DTPREL_HI16      var2
+00000030 <[^>]*> 2403b1a3      li      v1,-20061
+                       30: R_MIPS_HI16 var1
+00000034 <[^>]*> 03e00008      jr      ra
+00000038 <[^>]*> 24021234      li      v0,4660
+                       38: R_MIPS_HI16 var1
+0000003c <[^>]*> 30e0 b1a3     li      a3,-20061
+                       3c: R_MICROMIPS_TLS_TPREL_HI16  var3
+00000040 <[^>]*> 30c0 1234     li      a2,4660
+                       40: R_MICROMIPS_TLS_TPREL_HI16  var3
+00000044 <[^>]*> 30a0 b1a3     li      a1,-20061
+                       44: R_MICROMIPS_TLS_DTPREL_HI16 var2
+00000048 <[^>]*> 3080 1234     li      a0,4660
+                       48: R_MICROMIPS_TLS_DTPREL_HI16 var2
+0000004c <[^>]*> 3060 b1a3     li      v1,-20061
+                       4c: R_MICROMIPS_HI16    var1
+00000050 <[^>]*> 459f          jr      ra
+00000052 <[^>]*> 3040 1234     li      v0,4660
+                       52: R_MICROMIPS_HI16    var1
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips-hi16-orphan-addend.l b/gas/testsuite/gas/mips/mips-hi16-orphan-addend.l
new file mode 100644 (file)
index 0000000..c13e83d
--- /dev/null
@@ -0,0 +1,13 @@
+.*: Assembler messages:
+.*:57: Warning: can't find matching low-part relocation for %hi operator
+.*:56: Warning: can't find matching low-part relocation for %hi operator
+.*:55: Warning: can't find matching low-part relocation for %dtprel_hi operator
+.*:54: Warning: can't find matching low-part relocation for %dtprel_hi operator
+.*:53: Warning: can't find matching low-part relocation for %tprel_hi operator
+.*:52: Warning: can't find matching low-part relocation for %tprel_hi operator
+.*:38: Warning: can't find matching low-part relocation for %hi operator
+.*:37: Warning: can't find matching low-part relocation for %hi operator
+.*:36: Warning: can't find matching low-part relocation for %dtprel_hi operator
+.*:35: Warning: can't find matching low-part relocation for %dtprel_hi operator
+.*:34: Warning: can't find matching low-part relocation for %tprel_hi operator
+.*:33: Warning: can't find matching low-part relocation for %tprel_hi operator
diff --git a/gas/testsuite/gas/mips/mips-hi16-orphan-addend.s b/gas/testsuite/gas/mips/mips-hi16-orphan-addend.s
new file mode 100644 (file)
index 0000000..538e3ff
--- /dev/null
@@ -0,0 +1,66 @@
+       .text
+       .globl  fun1
+       .ent    fun1
+fun1:
+       li      $2, %lo(var1 + 0x12345677)
+       li      $4, %dtprel_lo(var2 + 0x12345677)
+       li      $6, %tprel_lo(var3 + 0x12345677)
+       jr      $31
+       .end    fun1
+
+       .set    push
+       .ifdef  micromips
+       .set    micromips
+       .else
+       .set    mips16
+       .endif
+
+       .globl  fun2
+       .ent    fun2
+fun2:
+       li      $2, %lo(var1 + 0x12345677)
+       li      $4, %dtprel_lo(var2 + 0x12345677)
+       li      $6, %tprel_lo(var3 + 0x12345677)
+       jr      $31
+       .end    fun2
+
+       .set    pop
+       .align  2
+
+       .globl  fun3
+       .ent    fun3
+fun3:
+       li      $7, %tprel_hi(var3 + 0xb1a29384)
+       li      $6, %tprel_hi(var3 + 0x12345678)
+       li      $5, %dtprel_hi(var2 + 0xb1a29384)
+       li      $4, %dtprel_hi(var2 + 0x12345678)
+       li      $3, %hi(var1 + 0xb1a29384)
+       li      $2, %hi(var1 + 0x12345678)
+       jr      $31
+       .end    fun3
+
+       .set    push
+       .ifdef  micromips
+       .set    micromips
+       .else
+       .set    mips16
+       .endif
+
+       .globl  fun4
+       .ent    fun4
+fun4:
+       li      $7, %tprel_hi(var3 + 0xb1a29384)
+       li      $6, %tprel_hi(var3 + 0x12345678)
+       li      $5, %dtprel_hi(var2 + 0xb1a29384)
+       li      $4, %dtprel_hi(var2 + 0x12345678)
+       li      $3, %hi(var1 + 0xb1a29384)
+       li      $2, %hi(var1 + 0x12345678)
+       jr      $31
+       .end    fun4
+
+       .set    pop
+       .align  2
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .space  16
+       .align  4, 0
index fcb1ad6e68e629dd5af204b4553f61da2f3d7773..4ae4a48e286f842dac254ea4be59cedec969a40e 100644 (file)
@@ -1059,6 +1059,7 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test "mips16-hilo-match"
     run_dump_test "mips16-tls-hilo-match"
     run_dump_test "mips16-tls-hilo-addend"
+    run_dump_test "mips16-hi16-orphan-addend"
     run_dump_test "mips16-reloc-error"
     run_dump_test "mips16e2-reloc-error"
     run_dump_test "mips16-reg-error"
@@ -1678,6 +1679,7 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test "micromips-hilo-match"
     run_dump_test "micromips-tls-hilo-match"
     run_dump_test "micromips-tls-hilo-addend"
+    run_dump_test "micromips-hi16-orphan-addend"
 
     run_dump_test_arches "mcu"         [mips_arch_list_matching mips32r2 \
                                            !octeon]
diff --git a/gas/testsuite/gas/mips/mips16-hi16-orphan-addend.d b/gas/testsuite/gas/mips/mips16-hi16-orphan-addend.d
new file mode 100644 (file)
index 0000000..17a42ce
--- /dev/null
@@ -0,0 +1,52 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#as: -mabi=32 -march=mips1 -mno-pdr
+#name: MIPS and MIPS16 orphan HI16 REL relocation addends
+#warning_output: mips-hi16-orphan-addend.l
+#source: mips-hi16-orphan-addend.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+00000000 <[^>]*> 24025677      li      v0,22135
+                       0: R_MIPS_LO16  var1
+00000004 <[^>]*> 24045677      li      a0,22135
+                       4: R_MIPS_TLS_DTPREL_LO16       var2
+00000008 <[^>]*> 03e00008      jr      ra
+0000000c <[^>]*> 24065677      li      a2,22135
+                       c: R_MIPS_TLS_TPREL_LO16        var3
+00000010 <[^>]*> f66a 6a17     li      v0,22135
+                       10: R_MIPS16_LO16       var1
+00000014 <[^>]*> f66a 6c17     li      a0,22135
+                       14: R_MIPS16_TLS_DTPREL_LO16    var2
+00000018 <[^>]*> f66a 6e17     li      a2,22135
+                       18: R_MIPS16_TLS_TPREL_LO16     var3
+0000001c <[^>]*> e820          jr      ra
+0000001e <[^>]*> 6500          nop
+00000020 <[^>]*> 2407b1a3      li      a3,-20061
+                       20: R_MIPS_TLS_TPREL_HI16       var3
+00000024 <[^>]*> 24061234      li      a2,4660
+                       24: R_MIPS_TLS_TPREL_HI16       var3
+00000028 <[^>]*> 2405b1a3      li      a1,-20061
+                       28: R_MIPS_TLS_DTPREL_HI16      var2
+0000002c <[^>]*> 24041234      li      a0,4660
+                       2c: R_MIPS_TLS_DTPREL_HI16      var2
+00000030 <[^>]*> 2403b1a3      li      v1,-20061
+                       30: R_MIPS_HI16 var1
+00000034 <[^>]*> 03e00008      jr      ra
+00000038 <[^>]*> 24021234      li      v0,4660
+                       38: R_MIPS_HI16 var1
+0000003c <[^>]*> f1b6 6f03     li      a3,45475
+                       3c: R_MIPS16_TLS_TPREL_HI16     var3
+00000040 <[^>]*> f222 6e14     li      a2,4660
+                       40: R_MIPS16_TLS_TPREL_HI16     var3
+00000044 <[^>]*> f1b6 6d03     li      a1,45475
+                       44: R_MIPS16_TLS_DTPREL_HI16    var2
+00000048 <[^>]*> f222 6c14     li      a0,4660
+                       48: R_MIPS16_TLS_DTPREL_HI16    var2
+0000004c <[^>]*> f1b6 6b03     li      v1,45475
+                       4c: R_MIPS16_HI16       var1
+00000050 <[^>]*> f222 6a14     li      v0,4660
+                       50: R_MIPS16_HI16       var1
+00000054 <[^>]*> e820          jr      ra
+00000056 <[^>]*> 6500          nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.d b/gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.d
new file mode 100644 (file)
index 0000000..ba8c17a
--- /dev/null
@@ -0,0 +1,20 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#as: -mabi=32 -mips32r6 -mno-pdr
+#name: MIPS orphan PCHI16 REL relocation addends
+#warning_output: mips-hi16-orphan-addend.l
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+00000000 <[^>]*> 24029384      li      v0,-27772
+                       0: R_MIPS_PCLO16        var1
+00000004 <[^>]*> 03e00009      jr      ra
+00000008 <[^>]*> 24035678      li      v1,22136
+                       8: R_MIPS_PCLO16        var2
+00000010 <[^>]*> ec5eb1a3      auipc   v0,0xb1a3
+                       10: R_MIPS_PCHI16       var1
+00000014 <[^>]*> ec7e1234      auipc   v1,0x1234
+                       14: R_MIPS_PCHI16       var2
+00000018 <[^>]*> 03e00009      jr      ra
+0000001c <[^>]*> 00000000      nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.l b/gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.l
new file mode 100644 (file)
index 0000000..7578f72
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:14: Warning: can't find matching low-part relocation for %pcrel_hi operator
+.*:13: Warning: can't find matching low-part relocation for %pcrel_hi operator
diff --git a/gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.s b/gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.s
new file mode 100644 (file)
index 0000000..70122cd
--- /dev/null
@@ -0,0 +1,20 @@
+       .text
+       .globl  fun1
+       .ent    fun1
+fun1:
+       li      $2, %pcrel_lo(var1 + 0xb1a29384)
+       li      $3, %pcrel_lo(var2 + 0x12345678)
+       jr      $31
+       .end    fun1
+
+       .globl  fun2
+       .ent    fun2
+fun2:
+       auipc   $2, %pcrel_hi(var1 + 0xb1a29384)
+       auipc   $3, %pcrel_hi(var2 + 0x12345678)
+       jr      $31
+       .end    fun2
+
+       # Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend-srec.d b/ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend-srec.d
new file mode 100644 (file)
index 0000000..c521b40
--- /dev/null
@@ -0,0 +1,7 @@
+#name: microMIPS orphan HI16 relocation addends srec
+#source: mips-hi16-orphan-addend.s
+#as: -mno-pdr -mips1 -mmicromips -no-warn
+#ld: --oformat=srec -e 0 --defsym=var1=0xfedcba98 --defsym=var2=0x12345678 --defsym=var3=0x56789abc -T mips-hi16-orphan-addend.ld
+#warning_output: micromips-hi16-orphan-addend-srec.l
+#objdump: -mmips:micromips -j .sec1 -D --prefix-addresses --show-raw-insn
+#dump: micromips-hi16-orphan-addend.d
diff --git a/ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend-srec.l b/ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend-srec.l
new file mode 100644 (file)
index 0000000..fd82d15
--- /dev/null
@@ -0,0 +1,7 @@
+.*\.o: in function `fun2':
+\(\.text\+0x26\): warning: can't find matching LO16 reloc against `var1' for R_MICROMIPS_HI16 at 0x26 in section `.text'
+.*: \(\.text\+0x20\): warning: can't find matching LO16 reloc against `var1' for R_MICROMIPS_HI16 at 0x20 in section `.text'
+.*: \(\.text\+0x1c\): warning: can't find matching LO16 reloc against `var2' for R_MICROMIPS_TLS_DTPREL_HI16 at 0x1c in section `.text'
+.*: \(\.text\+0x18\): warning: can't find matching LO16 reloc against `var2' for R_MICROMIPS_TLS_DTPREL_HI16 at 0x18 in section `.text'
+.*: \(\.text\+0x14\): warning: can't find matching LO16 reloc against `var3' for R_MICROMIPS_TLS_TPREL_HI16 at 0x14 in section `.text'
+.*\(\.text\+0x10\): warning: can't find matching LO16 reloc against `var3' for R_MICROMIPS_TLS_TPREL_HI16 at 0x10 in section `.text'
diff --git a/ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend.d b/ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend.d
new file mode 100644 (file)
index 0000000..5abc1dc
--- /dev/null
@@ -0,0 +1,23 @@
+#name: microMIPS orphan HI16 relocation addends
+#source: mips-hi16-orphan-addend.s
+#as: -mno-pdr -mips1 -mmicromips -no-warn
+#ld: -e 0 --defsym=var1=0xfedcba98 --defsym=var2=0x12345678 --defsym=var3=0x56789abc -T mips-hi16-orphan-addend.ld
+#warning_output: micromips-hi16-orphan-addend.l
+#objdump: -d --prefix-addresses --show-raw-insn
+
+.*: +file format (:?elf.*mips.*|srec)
+
+Disassembly of section \.(:?text|sec1):
+(?:0x0*)?10000000 (?:.* )?3040 110f    li      v0,4367
+(?:0x0*)?10000004 (?:.* )?3080 acef    li      a0,-21265
+(?:0x0*)?10000008 (?:.* )?459f         jr      ra
+(?:0x0*)?1000000a (?:.* )?30c0 f133    li      a2,-3789
+(?:0x0*)?1000000e (?:.* )?0c00         nop
+(?:0x0*)?10000010 (?:.* )?30e0 081c    li      a3,2076
+(?:0x0*)?10000014 (?:.* )?30c0 68ad    li      a2,26797
+(?:0x0*)?10000018 (?:.* )?30a0 c3d7    li      a1,-15401
+(?:0x0*)?1000001c (?:.* )?3080 2468    li      a0,9320
+(?:0x0*)?10000020 (?:.* )?3060 b080    li      v1,-20352
+(?:0x0*)?10000024 (?:.* )?459f         jr      ra
+(?:0x0*)?10000026 (?:.* )?3040 1111    li      v0,4369
+       \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend.l b/ld/testsuite/ld-mips-elf/micromips-hi16-orphan-addend.l
new file mode 100644 (file)
index 0000000..721610f
--- /dev/null
@@ -0,0 +1,7 @@
+.*\.o: in function `fun2':
+\(\.text\+0x10\): warning: can't find matching LO16 reloc against `var3' for R_MICROMIPS_TLS_TPREL_HI16 at 0x10 in section `.text'
+.*: \(\.text\+0x14\): warning: can't find matching LO16 reloc against `var3' for R_MICROMIPS_TLS_TPREL_HI16 at 0x14 in section `.text'
+.*: \(\.text\+0x18\): warning: can't find matching LO16 reloc against `var2' for R_MICROMIPS_TLS_DTPREL_HI16 at 0x18 in section `.text'
+.*: \(\.text\+0x1c\): warning: can't find matching LO16 reloc against `var2' for R_MICROMIPS_TLS_DTPREL_HI16 at 0x1c in section `.text'
+.*: \(\.text\+0x20\): warning: can't find matching LO16 reloc against `var1' for R_MICROMIPS_HI16 at 0x20 in section `.text'
+.*: \(\.text\+0x26\): warning: can't find matching LO16 reloc against `var1' for R_MICROMIPS_HI16 at 0x26 in section `.text'
index efef8541b52c6ae73605bcdcea5354c8eaf84449..38db5460176678a8114a338918f974537d4c638a 100644 (file)
@@ -893,6 +893,19 @@ run_dump_test_o32 "pr19977-r"
 run_dump_test_o32 "pr19977-r-mips16" noarch
 run_dump_test_o32 "pr19977-r-micromips" noarch
 
+run_dump_test_o32 "mips-hi16-orphan-addend"
+run_dump_test_o32 "mips-hi16-orphan-addend-srec" \
+       [list [list objdump [expr { [istarget *el-*-*] ? "-EL" : "-EB" }]]]
+run_dump_test_o32 "mips16-hi16-orphan-addend"
+run_dump_test_o32 "mips16-hi16-orphan-addend-srec" \
+       [list [list objdump [expr { [istarget *el-*-*] ? "-EL" : "-EB" }]]]
+run_dump_test_o32 "micromips-hi16-orphan-addend"
+run_dump_test_o32 "micromips-hi16-orphan-addend-srec" \
+       [list [list objdump [expr { [istarget *el-*-*] ? "-EL" : "-EB" }]]]
+run_dump_test_o32 "pcrel-hi16-orphan-addend"
+run_dump_test_o32 "pcrel-hi16-orphan-addend-srec" \
+       [list [list objdump [expr { [istarget *el-*-*] ? "-EL" : "-EB" }]]]
+
 if { $linux_gnu } {
     run_dump_test_n32 "textrel-1"
     run_dump_test "got-page-1"
diff --git a/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend-srec.d b/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend-srec.d
new file mode 100644 (file)
index 0000000..629408f
--- /dev/null
@@ -0,0 +1,7 @@
+#name: MIPS orphan HI16 relocation addends srec
+#source: mips-hi16-orphan-addend.s
+#as: -mno-pdr -mips1 -no-warn
+#ld: --oformat=srec -e 0 --defsym=var1=0xfedcba98 --defsym=var2=0x12345678 --defsym=var3=0x56789abc -T mips-hi16-orphan-addend.ld
+#warning_output: mips-hi16-orphan-addend-srec.l
+#objdump: -mmips:3000 -j .sec1 -D --prefix-addresses --show-raw-insn
+#dump: mips-hi16-orphan-addend.d
diff --git a/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend-srec.l b/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend-srec.l
new file mode 100644 (file)
index 0000000..79e8004
--- /dev/null
@@ -0,0 +1,7 @@
+.*\.o: in function `fun2':
+\(\.text\+0x2c\): warning: can't find matching LO16 reloc against `var1' for R_MIPS_HI16 at 0x2c in section `.text'
+.*: \(\.text\+0x24\): warning: can't find matching LO16 reloc against `var1' for R_MIPS_HI16 at 0x24 in section `.text'
+.*: \(\.text\+0x20\): warning: can't find matching LO16 reloc against `var2' for R_MIPS_TLS_DTPREL_HI16 at 0x20 in section `.text'
+.*: \(\.text\+0x1c\): warning: can't find matching LO16 reloc against `var2' for R_MIPS_TLS_DTPREL_HI16 at 0x1c in section `.text'
+.*: \(\.text\+0x18\): warning: can't find matching LO16 reloc against `var3' for R_MIPS_TLS_TPREL_HI16 at 0x18 in section `.text'
+.*: \(\.text\+0x14\): warning: can't find matching LO16 reloc against `var3' for R_MIPS_TLS_TPREL_HI16 at 0x14 in section `.text'
diff --git a/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.d b/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.d
new file mode 100644 (file)
index 0000000..b12a844
--- /dev/null
@@ -0,0 +1,22 @@
+#name: MIPS orphan HI16 relocation addends
+#as: -mno-pdr -mips1 -no-warn
+#ld: -e 0 --defsym=var1=0xfedcba98 --defsym=var2=0x12345678 --defsym=var3=0x56789abc -T mips-hi16-orphan-addend.ld
+#warning_output: mips-hi16-orphan-addend.l
+#objdump: -d --prefix-addresses --show-raw-insn
+
+.*: +file format (:?elf.*mips.*|srec)
+
+Disassembly of section \.(:?text|sec1):
+(?:0x0*)?10000000 (?:.* )?2402110f     li      v0,4367
+(?:0x0*)?10000004 (?:.* )?2404acef     li      a0,-21265
+(?:0x0*)?10000008 (?:.* )?03e00008     jr      ra
+(?:0x0*)?1000000c (?:.* )?2406f133     li      a2,-3789
+(?:0x0*)?10000010 (?:.* )?00000000     nop
+(?:0x0*)?10000014 (?:.* )?2407081c     li      a3,2076
+(?:0x0*)?10000018 (?:.* )?240668ad     li      a2,26797
+(?:0x0*)?1000001c (?:.* )?2405c3d7     li      a1,-15401
+(?:0x0*)?10000020 (?:.* )?24042468     li      a0,9320
+(?:0x0*)?10000024 (?:.* )?2403b080     li      v1,-20352
+(?:0x0*)?10000028 (?:.* )?03e00008     jr      ra
+(?:0x0*)?1000002c (?:.* )?24021111     li      v0,4369
+       \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.l b/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.l
new file mode 100644 (file)
index 0000000..c46949f
--- /dev/null
@@ -0,0 +1,7 @@
+.*\.o: in function `fun2':
+\(\.text\+0x14\): warning: can't find matching LO16 reloc against `var3' for R_MIPS_TLS_TPREL_HI16 at 0x14 in section `.text'
+.*: \(\.text\+0x18\): warning: can't find matching LO16 reloc against `var3' for R_MIPS_TLS_TPREL_HI16 at 0x18 in section `.text'
+.*: \(\.text\+0x1c\): warning: can't find matching LO16 reloc against `var2' for R_MIPS_TLS_DTPREL_HI16 at 0x1c in section `.text'
+.*: \(\.text\+0x20\): warning: can't find matching LO16 reloc against `var2' for R_MIPS_TLS_DTPREL_HI16 at 0x20 in section `.text'
+.*: \(\.text\+0x24\): warning: can't find matching LO16 reloc against `var1' for R_MIPS_HI16 at 0x24 in section `.text'
+.*: \(\.text\+0x2c\): warning: can't find matching LO16 reloc against `var1' for R_MIPS_HI16 at 0x2c in section `.text'
diff --git a/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.ld b/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.ld
new file mode 100644 (file)
index 0000000..c8c1cc6
--- /dev/null
@@ -0,0 +1,12 @@
+MEMORY
+{
+  text (rx) : ORIGIN = 0x10000000, LENGTH = 0x20000
+}
+SECTIONS
+{
+  .text : { *(.text) } >text
+  .symtab : { *(.symtab) }
+  .strtab : { *(.strtab) }
+  .shstrtab : { *(.shstrtab) }
+  /DISCARD/ : { *(*) }
+}
diff --git a/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.s b/ld/testsuite/ld-mips-elf/mips-hi16-orphan-addend.s
new file mode 100644 (file)
index 0000000..248da29
--- /dev/null
@@ -0,0 +1,29 @@
+       .text
+       .globl  fun1
+       .ent    fun1
+fun1:
+       li      $2, %lo(var1 + 0x12345677)
+       li      $4, %dtprel_lo(var2 + 0x12345677)
+       li      $6, %tprel_lo(var3 + 0x12345677)
+       jr      $31
+       .end    fun1
+
+       .globl  fun2
+       .ent    fun2
+fun2:
+# Prevent from the end of `fun1' overrunning the beginning of `fun2'
+# causing the wrong function name to be printed due to an oddity in
+# ISA bit handling.
+       nop
+       li      $7, %tprel_hi(var3 + 0xb1a29384)
+       li      $6, %tprel_hi(var3 + 0x12345678)
+       li      $5, %dtprel_hi(var2 + 0xb1a29384)
+       li      $4, %dtprel_hi(var2 + 0x12345678)
+       li      $3, %hi(var1 + 0xb1a29384)
+       li      $2, %hi(var1 + 0x12345678)
+       jr      $31
+       .end    fun2
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .space  16
+       .align  4, 0
diff --git a/ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend-srec.d b/ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend-srec.d
new file mode 100644 (file)
index 0000000..297deae
--- /dev/null
@@ -0,0 +1,7 @@
+#name: MIPS16 orphan HI16 relocation addends srec
+#source: mips-hi16-orphan-addend.s
+#as: -mno-pdr -mips1 -mips16 -no-warn
+#ld: --oformat=srec -e 0 --defsym=var1=0xfedcba98 --defsym=var2=0x12345678 --defsym=var3=0x56789abc -T mips-hi16-orphan-addend.ld
+#warning_output: mips16-hi16-orphan-addend-srec.l
+#objdump: -mmips:16 -j .sec1 -D --prefix-addresses --show-raw-insn
+#dump: mips16-hi16-orphan-addend.d
diff --git a/ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend-srec.l b/ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend-srec.l
new file mode 100644 (file)
index 0000000..e9fd0cb
--- /dev/null
@@ -0,0 +1,7 @@
+.*\.o: in function `fun2':
+\(\.text\+0x26\): warning: can't find matching LO16 reloc against `var1' for R_MIPS16_HI16 at 0x26 in section `.text'
+.*: \(\.text\+0x22\): warning: can't find matching LO16 reloc against `var1' for R_MIPS16_HI16 at 0x22 in section `.text'
+.*: \(\.text\+0x1e\): warning: can't find matching LO16 reloc against `var2' for R_MIPS16_TLS_DTPREL_HI16 at 0x1e in section `.text'
+.*: \(\.text\+0x1a\): warning: can't find matching LO16 reloc against `var2' for R_MIPS16_TLS_DTPREL_HI16 at 0x1a in section `.text'
+.*: \(\.text\+0x16\): warning: can't find matching LO16 reloc against `var3' for R_MIPS16_TLS_TPREL_HI16 at 0x16 in section `.text'
+.*: \(\.text\+0x12\): warning: can't find matching LO16 reloc against `var3' for R_MIPS16_TLS_TPREL_HI16 at 0x12 in section `.text'
diff --git a/ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend.d b/ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend.d
new file mode 100644 (file)
index 0000000..696881d
--- /dev/null
@@ -0,0 +1,25 @@
+#name: MIPS16 orphan HI16 relocation addends
+#source: mips-hi16-orphan-addend.s
+#as: -mno-pdr -mips1 -mips16 -no-warn
+#ld: -e 0 --defsym=var1=0xfedcba98 --defsym=var2=0x12345678 --defsym=var3=0x56789abc -T mips-hi16-orphan-addend.ld
+#warning_output: mips16-hi16-orphan-addend.l
+#objdump: -d --prefix-addresses --show-raw-insn
+
+.*: +file format (:?elf.*mips.*|srec)
+
+Disassembly of section \.(:?text|sec1):
+(?:0x0*)?10000000 (?:.* )?f102 6a0f    li      v0,4367
+(?:0x0*)?10000004 (?:.* )?f4f5 6c0f    li      a0,44271
+(?:0x0*)?10000008 (?:.* )?f13e 6e13    li      a2,61747
+(?:0x0*)?1000000c (?:.* )?e820         jr      ra
+(?:0x0*)?1000000e (?:.* )?6500         nop
+(?:0x0*)?10000010 (?:.* )?6500         nop
+(?:0x0*)?10000012 (?:.* )?f001 6f1c    li      a3,2076
+(?:0x0*)?10000016 (?:.* )?f0ad 6e0d    li      a2,26797
+(?:0x0*)?1000001a (?:.* )?f3d8 6d17    li      a1,50135
+(?:0x0*)?1000001e (?:.* )?f464 6c08    li      a0,9320
+(?:0x0*)?10000022 (?:.* )?f096 6b00    li      v1,45184
+(?:0x0*)?10000026 (?:.* )?f102 6a11    li      v0,4369
+(?:0x0*)?1000002a (?:.* )?e820         jr      ra
+(?:0x0*)?1000002c (?:.* )?6500         nop
+       \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend.l b/ld/testsuite/ld-mips-elf/mips16-hi16-orphan-addend.l
new file mode 100644 (file)
index 0000000..332ab27
--- /dev/null
@@ -0,0 +1,7 @@
+.*\.o: in function `fun2':
+\(\.text\+0x12\): warning: can't find matching LO16 reloc against `var3' for R_MIPS16_TLS_TPREL_HI16 at 0x12 in section `.text'
+.*: \(\.text\+0x16\): warning: can't find matching LO16 reloc against `var3' for R_MIPS16_TLS_TPREL_HI16 at 0x16 in section `.text'
+.*: \(\.text\+0x1a\): warning: can't find matching LO16 reloc against `var2' for R_MIPS16_TLS_DTPREL_HI16 at 0x1a in section `.text'
+.*: \(\.text\+0x1e\): warning: can't find matching LO16 reloc against `var2' for R_MIPS16_TLS_DTPREL_HI16 at 0x1e in section `.text'
+.*: \(\.text\+0x22\): warning: can't find matching LO16 reloc against `var1' for R_MIPS16_HI16 at 0x22 in section `.text'
+.*: \(\.text\+0x26\): warning: can't find matching LO16 reloc against `var1' for R_MIPS16_HI16 at 0x26 in section `.text'
diff --git a/ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend-srec.d b/ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend-srec.d
new file mode 100644 (file)
index 0000000..c9ad282
--- /dev/null
@@ -0,0 +1,7 @@
+#name: MIPS orphan PCHI16 relocation addend srec
+#source: ../../../gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.s
+#as: -mno-pdr -mips32r6 -no-warn
+#ld: --oformat=srec -e 0 --defsym=var1=0xfedcba98 --defsym=var2=0x12345678 -T mips-hi16-orphan-addend.ld
+#warning_output: pcrel-hi16-orphan-addend-srec.l
+#objdump: -mmips:isa32r6 -j .sec1 -D --prefix-addresses --show-raw-insn
+#dump: pcrel-hi16-orphan-addend.d
diff --git a/ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend-srec.l b/ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend-srec.l
new file mode 100644 (file)
index 0000000..ec3c339
--- /dev/null
@@ -0,0 +1,3 @@
+.*\.o: in function `fun2':
+\(\.text\+0x10\): warning: can't find matching LO16 reloc against `var2' for R_MIPS_PCHI16 at 0x10 in section `.text'
+.*: \(\.text\+0xc\): warning: can't find matching LO16 reloc against `var1' for R_MIPS_PCHI16 at 0xc in section `.text'
diff --git a/ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend.d b/ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend.d
new file mode 100644 (file)
index 0000000..aad4e79
--- /dev/null
@@ -0,0 +1,20 @@
+#name: MIPS orphan PCHI16 relocation addend
+#source: ../../../gas/testsuite/gas/mips/pcrel-hi16-orphan-addend.s
+#as: -mno-pdr -mips32r6 -no-warn
+#ld: -e 0 --defsym=var1=0xfedcba98 --defsym=var2=0x12345678 -T mips-hi16-orphan-addend.ld
+# ISA is overridden to R5900 in the file header, clobbering R6 disassembly.
+#notarget: mips*el-ps2-elf*
+#warning_output: pcrel-hi16-orphan-addend.l
+#objdump: -d --prefix-addresses --show-raw-insn
+
+.*: +file format (:?elf.*mips.*|srec)
+
+Disassembly of section \.(:?text|sec1):
+(?:0x0*)?10000000 (?:.* )?24024e1c     li      v0,19996
+(?:0x0*)?10000004 (?:.* )?03e00009     jr      ra
+(?:0x0*)?10000008 (?:.* )?2403ace8     li      v1,-21272
+(?:0x0*)?1000000c (?:.* )?ec5ea080     auipc   v0,0xa080
+(?:0x0*)?10000010 (?:.* )?ec7e1468     auipc   v1,0x1468
+(?:0x0*)?10000014 (?:.* )?03e00009     jr      ra
+(?:0x0*)?10000018 (?:.* )?00000000     nop
+       \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend.l b/ld/testsuite/ld-mips-elf/pcrel-hi16-orphan-addend.l
new file mode 100644 (file)
index 0000000..87791de
--- /dev/null
@@ -0,0 +1,3 @@
+.*\.o: in function `fun2':
+\(\.text\+0xc\): warning: can't find matching LO16 reloc against `var1' for R_MIPS_PCHI16 at 0xc in section `.text'
+.*: \(\.text\+0x10\): warning: can't find matching LO16 reloc against `var2' for R_MIPS_PCHI16 at 0x10 in section `.text'