diff options
author | Maciej W. Rozycki <macro@imgtec.com> | 2017-07-01 00:42:19 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@imgtec.com> | 2017-07-01 00:42:19 +0100 |
commit | 9f00292e69635d48623372c7a3e390dc5d159a8f (patch) | |
tree | d625f865ccb7101eea8a9e3b46f4deb0c4c55d93 /ld/testsuite | |
parent | 32f76c677333510350f21a40db062a8d17995c53 (diff) | |
download | gdb-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 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-mips-elf/mips-elf.exp | 34 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/relax-offset-umips.dd | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/relax-offset-umips.gd | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/relax-offset.dd | 19 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/relax-offset.gd | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/relax-offset.ld | 16 |
6 files changed, 106 insertions, 0 deletions
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 66b2ae4..4360b83 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -1179,3 +1179,37 @@ run_ld_link_tests [list \ # Check that the ISA level is consistently II for the LSI 4010. run_dump_test "lsi-4010-isa" [list [list ld $abi_ldflags(o32)]] + +# PIC branch relaxation with offset tests. We need to use our version +# of `prune_warnings' to get rid of GAS branch relaxation noise. +rename prune_warnings mips_old_prune_warnings +proc prune_warnings { msg } { + set msg1 "Assembler messages:" + set msg2 "Warning: relaxed out-of-range branch into a jump" + set msgx "(?:$msg1|$msg2)" + regsub -all "(^|\[\n\r\]*)\[^\n\r\]*: $msgx\[\n\r\]*" $msg "\\1" msg + return [mips_old_prune_warnings $msg] +} +run_ld_link_tests [list \ + [list \ + "MIPS link PIC branch relaxation with offset" \ + "$abi_ldflags(o32) -shared -T relax-offset.ld" "" \ + "$abi_asflags(o32) -relax-branch -mips2" \ + {../../../gas/testsuite/gas/mips/relax-offset.s} \ + {{objdump \ + {-d --prefix-addresses --show-raw-insn} \ + relax-offset.dd} \ + {readelf -A relax-offset.gd}} \ + "relax-offset"] \ + [list \ + "microMIPS link PIC branch relaxation with offset" \ + "$abi_ldflags(o32) -shared -T relax-offset.ld" "" \ + "$abi_asflags(o32) -relax-branch -mmicromips" \ + {../../../gas/testsuite/gas/mips/relax-offset.s} \ + {{objdump \ + {-d --prefix-addresses --show-raw-insn} \ + relax-offset-umips.dd} \ + {readelf -A relax-offset-umips.gd}} \ + "relax-offset-umips"]] +rename prune_warnings "" +rename mips_old_prune_warnings prune_warnings diff --git a/ld/testsuite/ld-mips-elf/relax-offset-umips.dd b/ld/testsuite/ld-mips-elf/relax-offset-umips.dd new file mode 100644 index 0000000..8e23931 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/relax-offset-umips.dd @@ -0,0 +1,15 @@ +.*: +file format .*mips.* + +Disassembly of section \.text: +00000000 <.*> 41bc 0003 lui gp,0x3 +00000004 <.*> 339c 802f addiu gp,gp,-32721 +00000008 <.*> 033c e150 addu gp,gp,t9 +0000000c <.*> 40a4 0005 bnezc a0,0000001a <.*> +00000010 <.*> fc3c 8018 lw at,-32744\(gp\) +00000014 <.*> 3021 0025 addiu at,at,37 +00000018 <.*> 45a1 jrc at +0000001a <.*> 45bf jrc ra + \.\.\. +00020020 <.*> 0000 8b7c syscall +00020024 <.*> 45bf jrc ra + \.\.\. diff --git a/ld/testsuite/ld-mips-elf/relax-offset-umips.gd b/ld/testsuite/ld-mips-elf/relax-offset-umips.gd new file mode 100644 index 0000000..119667f --- /dev/null +++ b/ld/testsuite/ld-mips-elf/relax-offset-umips.gd @@ -0,0 +1,11 @@ +Primary GOT: + Canonical gp value: 00028030 + + Reserved entries: + Address Access Initial Purpose + 00020040 -32752\(gp\) 00000000 Lazy resolver + 00020044 -32748\(gp\) 80000000 Module pointer \(GNU extension\) + + Local entries: + Address Access Initial + 00020048 -32744\(gp\) 00020000 diff --git a/ld/testsuite/ld-mips-elf/relax-offset.dd b/ld/testsuite/ld-mips-elf/relax-offset.dd new file mode 100644 index 0000000..322a0c9 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/relax-offset.dd @@ -0,0 +1,19 @@ +.*: +file format .*mips.* + +Disassembly of section \.text: +00000000 <.*> 3c1c0003 lui gp,0x3 +00000004 <.*> 279c8040 addiu gp,gp,-32704 +00000008 <.*> 0399e021 addu gp,gp,t9 +0000000c <.*> 14800004 bnez a0,00000020 <.*> +00000010 <.*> 00000000 nop +00000014 <.*> 8f818018 lw at,-32744\(gp\) +00000018 <.*> 24210034 addiu at,at,52 +0000001c <.*> 00200008 jr at +00000020 <.*> 00000000 nop +00000024 <.*> 03e00008 jr ra +00000028 <.*> 00000000 nop + \.\.\. +00020030 <.*> 0000000c syscall +00020034 <.*> 03e00008 jr ra +00020038 <.*> 00000000 nop + \.\.\. diff --git a/ld/testsuite/ld-mips-elf/relax-offset.gd b/ld/testsuite/ld-mips-elf/relax-offset.gd new file mode 100644 index 0000000..41f4af9 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/relax-offset.gd @@ -0,0 +1,11 @@ +Primary GOT: + Canonical gp value: 00028040 + + Reserved entries: + Address Access Initial Purpose + 00020050 -32752\(gp\) 00000000 Lazy resolver + 00020054 -32748\(gp\) 80000000 Module pointer \(GNU extension\) + + Local entries: + Address Access Initial + 00020058 -32744\(gp\) 00020000 diff --git a/ld/testsuite/ld-mips-elf/relax-offset.ld b/ld/testsuite/ld-mips-elf/relax-offset.ld new file mode 100644 index 0000000..39f6367 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/relax-offset.ld @@ -0,0 +1,16 @@ +ENTRY (foo); +SECTIONS +{ + .text : { *(.text) } + HIDDEN (_gp = ALIGN(16) + 0x7ff0); + .got : { *(.got) } + .dynamic : { *(.dynamic) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .pdr : { *(.pdr) } + .shstrtab : { *(.shstrtab) } + .symtab : { *(.symtab) } + .strtab : { *(.strtab) } + /DISCARD/ : { *(*) } +} |