aboutsummaryrefslogtreecommitdiff
path: root/gas/testsuite
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-07-01 00:42:19 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2017-07-01 00:42:19 +0100
commit9f00292e69635d48623372c7a3e390dc5d159a8f (patch)
treed625f865ccb7101eea8a9e3b46f4deb0c4c55d93 /gas/testsuite
parent32f76c677333510350f21a40db062a8d17995c53 (diff)
downloadgdb-9f00292e69635d48623372c7a3e390dc5d159a8f.zip
gdb-9f00292e69635d48623372c7a3e390dc5d159a8f.tar.gz
gdb-9f00292e69635d48623372c7a3e390dc5d159a8f.tar.bz2
MIPS/GAS: Use non-zero frag offset directly in PIC branch relaxation
Use frag symbols with a non-zero offset directly in `fix_new_exp' calls made in PIC branch relaxation. There is no need here to make a helper symbol to hold the result of a `symbol+offset' calculation requested as only branches to local symbols are relaxed and in this case the LO16 part of the PIC address load sequence will have the offset accounted for in calculation against the local GOT entry retrieved as the GOT16 high part. Consequently actual code produed is identical whether a helper symbol is used or the original `symbol+offset' expression used directly. Verify that this is indeed the case with GAS and LD tests. gas/ * config/tc-mips.c (md_convert_frag): Don't make a helper expression symbol for `fix_new_exp' called with a non-zero offset. * testsuite/gas/mips/relax-offset.d: New test. * testsuite/gas/mips/mips1@relax-offset.d: New test. * testsuite/gas/mips/r3000@relax-offset.d: New test. * testsuite/gas/mips/r3900@relax-offset.d: New test. * testsuite/gas/mips/micromips@relax-offset.d: New test. * testsuite/gas/mips/relax-offset.l: New stderr output. * testsuite/gas/mips/relax-offset.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-mips-elf/relax-offset.dd: New test. * testsuite/ld-mips-elf/relax-offset.gd: New test. * testsuite/ld-mips-elf/relax-offset-umips.dd: New test. * testsuite/ld-mips-elf/relax-offset-umips.gd: New test. * testsuite/ld-mips-elf/relax-offset.ld: New test linker script. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests. (prune_warnings): New temporary procedure.
Diffstat (limited to 'gas/testsuite')
-rw-r--r--gas/testsuite/gas/mips/micromips@relax-offset.d26
-rw-r--r--gas/testsuite/gas/mips/mips.exp2
-rw-r--r--gas/testsuite/gas/mips/mips1@relax-offset.d30
-rw-r--r--gas/testsuite/gas/mips/r3000@relax-offset.d6
-rw-r--r--gas/testsuite/gas/mips/r3900@relax-offset.d6
-rw-r--r--gas/testsuite/gas/mips/relax-offset.d28
-rw-r--r--gas/testsuite/gas/mips/relax-offset.l2
-rw-r--r--gas/testsuite/gas/mips/relax-offset.s23
8 files changed, 123 insertions, 0 deletions
diff --git a/gas/testsuite/gas/mips/micromips@relax-offset.d b/gas/testsuite/gas/mips/micromips@relax-offset.d
new file mode 100644
index 0000000..95fbf11
--- /dev/null
+++ b/gas/testsuite/gas/mips/micromips@relax-offset.d
@@ -0,0 +1,26 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS PIC branch relaxation with offset
+#as: -32 -relax-branch
+#stderr: relax-offset.l
+#source: relax-offset.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 41bc 0000 lui gp,0x0
+[ ]*[0-9a-f]+: R_MICROMIPS_HI16 _gp_disp
+[0-9a-f]+ <[^>]*> 339c 0000 addiu gp,gp,0
+[ ]*[0-9a-f]+: R_MICROMIPS_LO16 _gp_disp
+[0-9a-f]+ <[^>]*> 033c e150 addu gp,gp,t9
+[0-9a-f]+ <[^>]*> 40a4 fffe bnezc a0,0000000c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 .*
+[0-9a-f]+ <[^>]*> fc3c 0002 lw at,2\(gp\)
+[ ]*[0-9a-f]+: R_MICROMIPS_GOT16 \.text
+[0-9a-f]+ <[^>]*> 3021 0025 addiu at,at,37
+[ ]*[0-9a-f]+: R_MICROMIPS_LO16 \.text
+[0-9a-f]+ <[^>]*> 45a1 jrc at
+[0-9a-f]+ <[^>]*> 45bf jrc ra
+ \.\.\.
+[0-9a-f]+ <[^>]*> 0000 8b7c syscall
+[0-9a-f]+ <[^>]*> 45bf jrc ra
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index 81dfd34..0ea9f61 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -1069,6 +1069,8 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test_arches "relax" [mips_arch_list_matching mips2 !mips32r6]
run_dump_test_arches "relax-at" [mips_arch_list_matching mips2 !mips32r6]
+ run_dump_test_arches "relax-offset" [mips_arch_list_matching mips1 \
+ !mips32r6]
run_dump_test "relax-swap1-mips1"
run_dump_test "relax-swap1-mips2"
run_dump_test "relax-swap2"
diff --git a/gas/testsuite/gas/mips/mips1@relax-offset.d b/gas/testsuite/gas/mips/mips1@relax-offset.d
new file mode 100644
index 0000000..bd38410
--- /dev/null
+++ b/gas/testsuite/gas/mips/mips1@relax-offset.d
@@ -0,0 +1,30 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS PIC branch relaxation with offset
+#as: -32 -relax-branch
+#stderr: relax-offset.l
+#source: relax-offset.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 3c1c0000 lui gp,0x0
+[ ]*[0-9a-f]+: R_MIPS_HI16 _gp_disp
+[0-9a-f]+ <[^>]*> 279c0000 addiu gp,gp,0
+[ ]*[0-9a-f]+: R_MIPS_LO16 _gp_disp
+[0-9a-f]+ <[^>]*> 0399e021 addu gp,gp,t9
+[0-9a-f]+ <[^>]*> 14800005 bnez a0,00000024 <foo\+0x24>
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 8f810002 lw at,2\(gp\)
+[ ]*[0-9a-f]+: R_MIPS_GOT16 \.text
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 24210034 addiu at,at,52
+[ ]*[0-9a-f]+: R_MIPS_LO16 \.text
+[0-9a-f]+ <[^>]*> 00200008 jr at
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 03e00008 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
+[0-9a-f]+ <[^>]*> 0000000c syscall
+[0-9a-f]+ <[^>]*> 03e00008 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/r3000@relax-offset.d b/gas/testsuite/gas/mips/r3000@relax-offset.d
new file mode 100644
index 0000000..d726d32
--- /dev/null
+++ b/gas/testsuite/gas/mips/r3000@relax-offset.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS PIC branch relaxation with offset
+#as: -32 -relax-branch
+#stderr: relax-offset.l
+#source: relax-offset.s
+#dump: mips1@relax-offset.d
diff --git a/gas/testsuite/gas/mips/r3900@relax-offset.d b/gas/testsuite/gas/mips/r3900@relax-offset.d
new file mode 100644
index 0000000..d726d32
--- /dev/null
+++ b/gas/testsuite/gas/mips/r3900@relax-offset.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS PIC branch relaxation with offset
+#as: -32 -relax-branch
+#stderr: relax-offset.l
+#source: relax-offset.s
+#dump: mips1@relax-offset.d
diff --git a/gas/testsuite/gas/mips/relax-offset.d b/gas/testsuite/gas/mips/relax-offset.d
new file mode 100644
index 0000000..e7f36e2
--- /dev/null
+++ b/gas/testsuite/gas/mips/relax-offset.d
@@ -0,0 +1,28 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS PIC branch relaxation with offset
+#as: -32 -relax-branch
+#stderr: relax-offset.l
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 3c1c0000 lui gp,0x0
+[ ]*[0-9a-f]+: R_MIPS_HI16 _gp_disp
+[0-9a-f]+ <[^>]*> 279c0000 addiu gp,gp,0
+[ ]*[0-9a-f]+: R_MIPS_LO16 _gp_disp
+[0-9a-f]+ <[^>]*> 0399e021 addu gp,gp,t9
+[0-9a-f]+ <[^>]*> 14800004 bnez a0,00000020 <foo\+0x20>
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 8f810002 lw at,2\(gp\)
+[ ]*[0-9a-f]+: R_MIPS_GOT16 \.text
+[0-9a-f]+ <[^>]*> 24210034 addiu at,at,52
+[ ]*[0-9a-f]+: R_MIPS_LO16 \.text
+[0-9a-f]+ <[^>]*> 00200008 jr at
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 03e00008 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
+[0-9a-f]+ <[^>]*> 0000000c syscall
+[0-9a-f]+ <[^>]*> 03e00008 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/relax-offset.l b/gas/testsuite/gas/mips/relax-offset.l
new file mode 100644
index 0000000..570a783
--- /dev/null
+++ b/gas/testsuite/gas/mips/relax-offset.l
@@ -0,0 +1,2 @@
+.*: Assembler messages:
+.*:10: Warning: relaxed out-of-range branch into a jump
diff --git a/gas/testsuite/gas/mips/relax-offset.s b/gas/testsuite/gas/mips/relax-offset.s
new file mode 100644
index 0000000..6255322
--- /dev/null
+++ b/gas/testsuite/gas/mips/relax-offset.s
@@ -0,0 +1,23 @@
+ .abicalls
+
+ .align 4, 0
+ .globl foo
+ .ent foo
+foo:
+ .set noreorder
+ .cpload $25
+ .set reorder
+ beq $4, $0, bar + 4
+ jr $31
+
+ .space 131072
+
+ .align 4, 0
+bar:
+ syscall
+ jr $31
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .space 16
+ .align 4, 0