diff options
author | Maciej W. Rozycki <macro@imgtec.com> | 2016-06-28 01:23:36 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@imgtec.com> | 2016-06-28 01:29:56 +0100 |
commit | c9775dde32773c57d4eb5dfb4265eda9cb8adbe8 (patch) | |
tree | 59735930ba2df8d7a5e885c7d388b45e341ecd04 /gas/testsuite | |
parent | bac13b9c13a0169aea400335776310b1f1ff2d16 (diff) | |
download | gdb-c9775dde32773c57d4eb5dfb4265eda9cb8adbe8.zip gdb-c9775dde32773c57d4eb5dfb4265eda9cb8adbe8.tar.gz gdb-c9775dde32773c57d4eb5dfb4265eda9cb8adbe8.tar.bz2 |
MIPS16: Add R_MIPS16_PC16_S1 branch relocation support
For R_MIPS16_PC16_S1 the calculation is `(sign_extend(A) + S - P) >> 1'
and the usual MIPS16 bit shuffling applies to relocated field handling,
as per the encoding of the branch target in the extended form of the
MIPS16 B, BEQZ, BNEZ, BTEQZ and BTNEZ instructions.
include/
* elf/mips.h (R_MIPS16_PC16_S1): New relocation.
bfd/
* elf32-mips.c (elf_mips16_howto_table_rel): Add
R_MIPS16_PC16_S1.
(mips16_reloc_map): Likewise.
* elf64-mips.c (mips16_elf64_howto_table_rel): Likewise.
(mips16_elf64_howto_table_rela): Likewise.
(mips16_reloc_map): Likewise.
* elfn32-mips.c (elf_mips16_howto_table_rel): Likewise.
(elf_mips16_howto_table_rela): Likewise.
(mips16_reloc_map): Likewise.
* elfxx-mips.c (mips16_branch_reloc_p): New function.
(mips16_reloc_p): Handle R_MIPS16_PC16_S1.
(b_reloc_p): Likewise.
(mips_elf_calculate_relocation): Likewise.
(_bfd_mips_elf_check_relocs): Likewise.
* reloc.c (BFD_RELOC_MIPS16_16_PCREL_S1): New relocation.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
gas/
* config/tc-mips.c (mips16_reloc_p): Handle
BFD_RELOC_MIPS16_16_PCREL_S1.
(b_reloc_p): Likewise.
(limited_pcrel_reloc_p): Likewise.
(md_pcrel_from): Likewise.
(md_apply_fix): Likewise.
(tc_gen_reloc): Likewise.
(md_convert_frag): Likewise.
(mips_fix_adjustable): Update comment.
* testsuite/gas/mips/mips16-branch-reloc-2.d: Remove error
output, add dump patterns.
* testsuite/gas/mips/mips16-branch-reloc-3.d: Remove error
output, add dump patterns.
* testsuite/gas/mips/mips16-branch-addend-2.d: Remove error
output, add dump patterns.
* testsuite/gas/mips/mips16-branch-addend-3.d: Remove error
output, add dump patterns.
* testsuite/gas/mips/mips16-branch-absolute.d: Remove error
output, add dump patterns.
* testsuite/gas/mips/mips16-branch-reloc-2.l: Remove file.
* testsuite/gas/mips/mips16-branch-reloc-3.l: Remove file.
* testsuite/gas/mips/mips16-branch-addend-2.l: Remove file.
* testsuite/gas/mips/mips16-branch-addend-3.l: Remove file.
* testsuite/gas/mips/mips16-branch-absolute.l: Remove file.
* testsuite/gas/mips/mips16-branch-addend-2.s: Add padding.
* testsuite/gas/mips/branch-weak.s: Adjust alignment, avoid
implicit instruction padding, avoid MIPS16 JR->JRC conversion.
* testsuite/gas/mips/branch-weak-6.d: New test.
* testsuite/gas/mips/branch-weak-7.d: New test.
* testsuite/gas/mips/mips.exp: Run the new tests.
ld/
* testsuite/ld-mips-elf/mips16-branch-2.d: New test.
* testsuite/ld-mips-elf/mips16-branch-3.d: New test.
* testsuite/ld-mips-elf/mips16-branch-addend-2.d: New test.
* testsuite/ld-mips-elf/mips16-branch-addend-3.d: New test.
* testsuite/ld-mips-elf/mips16-branch.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'gas/testsuite')
-rw-r--r-- | gas/testsuite/gas/mips/branch-weak-6.d | 14 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/branch-weak-7.d | 14 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/branch-weak.s | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips.exp | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-absolute.d | 19 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-absolute.l | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-addend-2.d | 21 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-addend-2.l | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-addend-2.s | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-addend-3.d | 19 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-addend-3.l | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-reloc-2.d | 21 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-reloc-2.l | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-reloc-3.d | 19 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-branch-reloc-3.l | 6 |
15 files changed, 129 insertions, 38 deletions
diff --git a/gas/testsuite/gas/mips/branch-weak-6.d b/gas/testsuite/gas/mips/branch-weak-6.d new file mode 100644 index 0000000..e16b1b8 --- /dev/null +++ b/gas/testsuite/gas/mips/branch-weak-6.d @@ -0,0 +1,14 @@ +#objdump: -dr --prefix-addresses --show-raw-insn +#name: MIPS16 branch to a weak symbol +#as: -32 -mips16 --defsym align=12 +#source: branch-weak.s + +.*: +file format .*mips.* + +Disassembly of section \.text: +[0-9a-f]+ <[^>]*> f7ff 101e b 00000000 <foo> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 bar + \.\.\. +[0-9a-f]+ <[^>]*> e820 jr ra +[0-9a-f]+ <[^>]*> 6500 nop + \.\.\. diff --git a/gas/testsuite/gas/mips/branch-weak-7.d b/gas/testsuite/gas/mips/branch-weak-7.d new file mode 100644 index 0000000..b291289 --- /dev/null +++ b/gas/testsuite/gas/mips/branch-weak-7.d @@ -0,0 +1,14 @@ +#objdump: -dr --prefix-addresses --show-raw-insn +#name: MIPS16 short branch to a weak symbol +#as: -32 -mips16 --defsym align=4 +#source: branch-weak.s + +.*: +file format .*mips.* + +Disassembly of section \.text: +[0-9a-f]+ <[^>]*> f7ff 101e b 00000000 <foo> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 bar + \.\.\. +[0-9a-f]+ <[^>]*> e820 jr ra +[0-9a-f]+ <[^>]*> 6500 nop + \.\.\. diff --git a/gas/testsuite/gas/mips/branch-weak.s b/gas/testsuite/gas/mips/branch-weak.s index eedef7a..a2dc734 100644 --- a/gas/testsuite/gas/mips/branch-weak.s +++ b/gas/testsuite/gas/mips/branch-weak.s @@ -1,5 +1,5 @@ .text - .align 4, 0 + .align align, 0 .globl foo .ent foo foo: @@ -11,9 +11,9 @@ foo: .weak bar .ent bar bar: + nop jr $ra .end bar # Force some (non-delay-slot) zero bytes, to make 'objdump' print ... - .align 4, 0 - .space 16 + .align align, 0 diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp index d268dc0..4f5651b 100644 --- a/gas/testsuite/gas/mips/mips.exp +++ b/gas/testsuite/gas/mips/mips.exp @@ -588,6 +588,8 @@ if { [istarget mips*-*-vxworks*] } { run_dump_test "branch-weak-3" run_dump_test "branch-weak-4" run_dump_test "branch-weak-5" + run_dump_test "branch-weak-6" + run_dump_test "branch-weak-7" run_dump_test "branch-local-1" if $has_newabi { run_dump_test "branch-local-n32-1" diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute.d b/gas/testsuite/gas/mips/mips16-branch-absolute.d index 90a9ea7..3e1ec8e 100644 --- a/gas/testsuite/gas/mips/mips16-branch-absolute.d +++ b/gas/testsuite/gas/mips/mips16-branch-absolute.d @@ -1,3 +1,20 @@ +#objdump: -dr --prefix-addresses --show-raw-insn #name: MIPS16 branch to absolute expression #as: -32 -#error-output: mips16-branch-absolute.l + +.*: +file format .*mips.* + +Disassembly of section \.text: + \.\.\. +[0-9a-f]+ <[^>]*> f000 1000 b 00001004 <foo\+0x4> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\* +[0-9a-f]+ <[^>]*> f000 6000 bteqz 00001008 <foo\+0x8> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\* +[0-9a-f]+ <[^>]*> f000 6100 btnez 0000100c <foo\+0xc> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\* +[0-9a-f]+ <[^>]*> f000 2200 beqz v0,00001010 <foo\+0x10> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\* +[0-9a-f]+ <[^>]*> f000 2a00 bnez v0,00001014 <foo\+0x14> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 \*ABS\* +[0-9a-f]+ <[^>]*> 6500 nop + \.\.\. diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute.l b/gas/testsuite/gas/mips/mips16-branch-absolute.l deleted file mode 100644 index c72b8d0..0000000 --- a/gas/testsuite/gas/mips/mips16-branch-absolute.l +++ /dev/null @@ -1,6 +0,0 @@ -.*: Assembler messages: -.*:8: Error: unsupported relocation -.*:9: Error: unsupported relocation -.*:10: Error: unsupported relocation -.*:11: Error: unsupported relocation -.*:12: Error: unsupported relocation diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-2.d b/gas/testsuite/gas/mips/mips16-branch-addend-2.d index ae98546..3e61c24 100644 --- a/gas/testsuite/gas/mips/mips16-branch-addend-2.d +++ b/gas/testsuite/gas/mips/mips16-branch-addend-2.d @@ -1,3 +1,22 @@ +#objdump: -dr --prefix-addresses --show-raw-insn #name: MIPS16 branch relocation with addend 2 #as: -32 -#error-output: mips16-branch-addend-2.l + +.*: +file format .*mips.* + +Disassembly of section \.text: + \.\.\. +[0-9a-f]+ <[^>]*> f101 1018 b 00002234 <bar\+0x1204> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 bar +[0-9a-f]+ <[^>]*> f101 6018 bteqz 00002238 <bar\+0x1208> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 bar +[0-9a-f]+ <[^>]*> f101 6118 btnez 0000223c <bar\+0x120c> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 bar +[0-9a-f]+ <[^>]*> f101 2218 beqz v0,00002240 <bar\+0x1210> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 bar +[0-9a-f]+ <[^>]*> f101 2a18 bnez v0,00002244 <bar\+0x1214> +[ ]*[0-9a-f]+: R_MIPS16_PC16_S1 bar +[0-9a-f]+ <[^>]*> 6500 nop + \.\.\. +[0-9a-f]+ <[^>]*> 6500 nop + \.\.\. diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-2.l b/gas/testsuite/gas/mips/mips16-branch-addend-2.l deleted file mode 100644 index d30fd62..0000000 --- a/gas/testsuite/gas/mips/mips16-branch-addend-2.l +++ /dev/null @@ -1,6 +0,0 @@ -.*: Assembler messages: -.*:9: Error: unsupported relocation -.*:10: Error: unsupported relocation -.*:11: Error: unsupported relocation -.*:12: Error: unsupported relocation -.*:13: Error: unsupported relocation diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-2.s b/gas/testsuite/gas/mips/mips16-branch-addend-2.s index fe9e5b8..6035db8 100644 --- a/gas/testsuite/gas/mips/mips16-branch-addend-2.s +++ b/gas/testsuite/gas/mips/mips16-branch-addend-2.s @@ -26,6 +26,8 @@ bar: .set nomips16 .end bar + .space 0x1000 + # Force some (non-delay-slot) zero bytes, to make 'objdump' print ... .align 4, 0 .space 16 diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-3.d b/gas/testsuite/gas/mips/mips16-branch-addend-3.d index 165e8f1..f3ecb75 100644 --- a/gas/testsuite/gas/mips/mips16-branch-addend-3.d +++ b/gas/testsuite/gas/mips/mips16-branch-addend-3.d @@ -1,3 +1,20 @@ +#objdump: -dr --prefix-addresses --show-raw-insn #name: MIPS16 branch relocation with addend 3 #as: -32 -#error-output: mips16-branch-reloc-3.l + +.*: +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 + \.\.\. diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-3.l b/gas/testsuite/gas/mips/mips16-branch-addend-3.l deleted file mode 100644 index c72b8d0..0000000 --- a/gas/testsuite/gas/mips/mips16-branch-addend-3.l +++ /dev/null @@ -1,6 +0,0 @@ -.*: Assembler messages: -.*:8: Error: unsupported relocation -.*:9: Error: unsupported relocation -.*:10: Error: unsupported relocation -.*:11: Error: unsupported relocation -.*:12: Error: unsupported relocation diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-2.d b/gas/testsuite/gas/mips/mips16-branch-reloc-2.d index 1e6ecb4..4f920d2 100644 --- a/gas/testsuite/gas/mips/mips16-branch-reloc-2.d +++ b/gas/testsuite/gas/mips/mips16-branch-reloc-2.d @@ -1,3 +1,22 @@ +#objdump: -dr --prefix-addresses --show-raw-insn #name: MIPS16 branch relocation 2 #as: -32 -#error-output: mips16-branch-reloc-2.l + +.*: +file format .*mips.* + +Disassembly of section \.text: + \.\.\. +[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 + \.\.\. +[0-9a-f]+ <[^>]*> 6500 nop + \.\.\. diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-2.l b/gas/testsuite/gas/mips/mips16-branch-reloc-2.l deleted file mode 100644 index d30fd62..0000000 --- a/gas/testsuite/gas/mips/mips16-branch-reloc-2.l +++ /dev/null @@ -1,6 +0,0 @@ -.*: Assembler messages: -.*:9: Error: unsupported relocation -.*:10: Error: unsupported relocation -.*:11: Error: unsupported relocation -.*:12: Error: unsupported relocation -.*:13: Error: unsupported relocation diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-3.d b/gas/testsuite/gas/mips/mips16-branch-reloc-3.d index d25d42e..c8e75fb 100644 --- a/gas/testsuite/gas/mips/mips16-branch-reloc-3.d +++ b/gas/testsuite/gas/mips/mips16-branch-reloc-3.d @@ -1,3 +1,20 @@ +#objdump: -dr --prefix-addresses --show-raw-insn #name: MIPS16 branch relocation 3 #as: -32 -#error-output: mips16-branch-reloc-3.l + +.*: +file format .*mips.* + +Disassembly of section \.text: + \.\.\. +[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 + \.\.\. diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-3.l b/gas/testsuite/gas/mips/mips16-branch-reloc-3.l deleted file mode 100644 index c72b8d0..0000000 --- a/gas/testsuite/gas/mips/mips16-branch-reloc-3.l +++ /dev/null @@ -1,6 +0,0 @@ -.*: Assembler messages: -.*:8: Error: unsupported relocation -.*:9: Error: unsupported relocation -.*:10: Error: unsupported relocation -.*:11: Error: unsupported relocation -.*:12: Error: unsupported relocation |