From: Maciej W. Rozycki Date: Tue, 26 Jul 2016 16:45:00 +0000 (+0100) Subject: MIPS/BFD: Handle branches in PLT compression selection X-Git-Tag: gdb-7.12-release~156 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54806ffa85643c3a1ee721d5c3f5586d32f86ee1;p=external%2Fbinutils.git MIPS/BFD: Handle branches in PLT compression selection Complement: commit 1bbce132647e6d72aaa065cce5c1d5dd6585c2b2 Author: Maciej W. Rozycki Date: Mon Jun 24 23:55:46 2013 +0000 , ("MIPS: Compressed PLT/stubs support"), and also choose between regular and compressed PLT entries as appropriate for any branches referring. bfd/ * elfxx-mips.c (mips_elf_calculate_relocation): Handle branches in PLT compression selection. (_bfd_mips_elf_check_relocs): Likewise. ld/ * testsuite/ld-mips-elf/compressed-plt-1.s: Add branch support. * testsuite/ld-mips-elf/compressed-plt-1a.s: Likewise. * testsuite/ld-mips-elf/compressed-plt-1b.s: Likewise. * testsuite/ld-mips-elf/compressed-plt-1-o32-branch.od: New test. * testsuite/ld-mips-elf/compressed-plt-1-o32-branch.rd: New test. * testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.od: New test. * testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.rd: New test. * testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.od: New test. * testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.rd: New test. * testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.od: New test. * testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.rd: New test. * testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.od: New test. * testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.rd: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index ab92c6c..0779178 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2016-07-26 Maciej W. Rozycki + + * elfxx-mips.c (mips_elf_calculate_relocation): Handle branches + in PLT compression selection. + (_bfd_mips_elf_check_relocs): Likewise. + 2016-07-22 Cupertino Miranda * arc-got.h (relocate_fix_got_relocs_for_got_info): Handle the diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 5dcbcf9..cdc5d96 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -5585,7 +5585,8 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, case the symbol will have been set by mips_elf_set_plt_sym_value to point to the standard PLT entry, so redirect to the compressed one. */ - else if ((r_type == R_MIPS16_26 || r_type == R_MICROMIPS_26_S1) + else if ((mips16_branch_reloc_p (r_type) + || micromips_branch_reloc_p (r_type)) && !bfd_link_relocatable (info) && h != NULL && h->use_plt_entry @@ -8795,7 +8796,9 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, a PLT entry is not created because the symbol is satisfied locally. */ if (h != NULL - && jal_reloc_p (r_type) + && (branch_reloc_p (r_type) + || mips16_branch_reloc_p (r_type) + || micromips_branch_reloc_p (r_type)) && !SYMBOL_CALLS_LOCAL (info, h)) { if (h->plt.plist == NULL) @@ -8803,7 +8806,7 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if (h->plt.plist == NULL) return FALSE; - if (r_type == R_MIPS_26) + if (branch_reloc_p (r_type)) h->plt.plist->need_mips = TRUE; else h->plt.plist->need_comp = TRUE; diff --git a/ld/ChangeLog b/ld/ChangeLog index e0e9d32..5765509 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,30 @@ +2016-07-26 Maciej W. Rozycki + + * testsuite/ld-mips-elf/compressed-plt-1.s: Add branch support. + * testsuite/ld-mips-elf/compressed-plt-1a.s: Likewise. + * testsuite/ld-mips-elf/compressed-plt-1b.s: Likewise. + * testsuite/ld-mips-elf/compressed-plt-1-o32-branch.od: New + test. + * testsuite/ld-mips-elf/compressed-plt-1-o32-branch.rd: New + test. + * testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.od: + New test. + * testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.rd: + New test. + * testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.od: + New test. + * testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.rd: + New test. + * testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.od: + New test. + * testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.rd: + New test. + * testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.od: + New test. + * testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.rd: + New test. + * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests. + 2016-07-26 Igor Kudrin * ldbuildid.c: Changes for MinGW32: diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-branch.od b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-branch.od new file mode 100644 index 0000000..d88dbcc --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-branch.od @@ -0,0 +1,30 @@ + +.* file format .* + + +Disassembly of section \.plt: + +10100000 <_PROCEDURE_LINKAGE_TABLE_>: +.*: 3c1c1020 lui \$28,0x1020 +.*: 8f990000 lw \$25,0\(\$28\) +.*: 279c0000 addiu \$28,\$28,0 +.*: 031cc023 subu \$24,\$24,\$28 +.*: 03e07825 move \$15,\$31 +.*: 0018c082 srl \$24,\$24,0x2 +.*: 0320f809 jalr \$25 +.*: 2718fffe addiu \$24,\$24,-2 + +10100020 : +.*: 3c0f1020 lui \$15,0x1020 +.*: 8df90008 lw \$25,8\(\$15\) +.*: 03200008 jr \$25 +.*: 25f80008 addiu \$24,\$15,8 + +Disassembly of section \.text\.b: + +10101000 : +.*: 0411fc07 bal 10100020 +.*: 00000000 nop +.*: 1000fc05 b 10100020 +.*: 00000000 nop +.*: 03e00008 jr \$31 diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-branch.rd b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-branch.rd new file mode 100644 index 0000000..372db52 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-branch.rd @@ -0,0 +1,44 @@ + +Dynamic section .* +#... + 0x00000003 \(PLTGOT\) 0x10201000 +#... + 0x70000013 \(MIPS_GOTSYM\) 0x4 + 0x00000014 \(PLTREL\) REL + 0x00000017 \(JMPREL\) 0x10004000 + 0x00000002 \(PLTRELSZ\) 8 \(bytes\) + 0x70000032 \(MIPS_PLTGOT\) 0x10200000 +#... +Relocation section '\.rel\.plt' .* + Offset Info Type Sym\.Value Sym\. Name +10200008 [^ ]+ R_MIPS_JUMP_SLOT 00000000 f_bu + +Symbol table '\.dynsym' .* + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND +#... + .*: 00000000 0 FUNC GLOBAL DEFAULT UND f_bu + +Symbol table '\.symtab' .* +#... +Primary GOT: + Canonical gp value: 10208ff0 + + Reserved entries: + Address Access Initial Purpose + 10201000 -32752\(gp\) 00000000 Lazy resolver + 10201004 -32748\(gp\) 80000000 Module pointer \(GNU extension\) + + +PLT GOT: + + Reserved entries: + Address Initial Purpose + 10200000 00000000 PLT lazy resolver + 10200004 00000000 Module pointer + + Entries: + Address Initial Sym\.Val\. Type Ndx Name + 10200008 10100000 00000000 FUNC UND f_bu + + diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.od b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.od new file mode 100644 index 0000000..f195b93 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.od @@ -0,0 +1,69 @@ + +.* file format .* + + +Disassembly of section \.plt: + +# Only _bc (branch from compressed code) functions should have a +# MIPS16 PLT. +10100000 <_PROCEDURE_LINKAGE_TABLE_>: +.*: 3c1c1020 lui \$28,0x1020 +.*: 8f990000 lw \$25,0\(\$28\) +.*: 279c0000 addiu \$28,\$28,0 +.*: 031cc023 subu \$24,\$24,\$28 +.*: 03e07825 move \$15,\$31 +.*: 0018c082 srl \$24,\$24,0x2 +.*: 0320f809 jalr \$25 +.*: 2718fffe addiu \$24,\$24,-2 + +10100020 : +.*: 3c0f1020 lui \$15,0x1020 +.*: 8df90008 lw \$25,8\(\$15\) +.*: 03200008 jr \$25 +.*: 25f80008 addiu \$24,\$15,8 + +10100030 : +.*: 3c0f1020 lui \$15,0x1020 +.*: 8df9000c lw \$25,12\(\$15\) +.*: 03200008 jr \$25 +.*: 25f8000c addiu \$24,\$15,12 + +10100040 : +.*: b203 lw \$2,1010004c +.*: 9a60 lw \$3,0\(\$2\) +.*: 651a move \$24,\$2 +.*: eb00 jr \$3 +.*: 653b move \$25,\$3 +.*: 6500 nop +.*: .... .... \.word 0x10200008 + +10100050 : +.*: b203 lw \$2,1010005c +.*: 9a60 lw \$3,0\(\$2\) +.*: 651a move \$24,\$2 +.*: eb00 jr \$3 +.*: 653b move \$25,\$3 +.*: 6500 nop +.*: .... .... \.word 0x10200010 + +Disassembly of section \.text\.a: + +10101000 : +.*: f03f 1006 b 10100050 +.*: 6500 nop +.*: f01f 101b b 10100040 +.*: 6500 nop +.*: e820 jr \$31 + +Disassembly of section \.text\.b: + +10102000 : +.*: 0411f80b bal 10100030 +.*: 00000000 nop +.*: 1000f809 b 10100030 +.*: 00000000 nop +.*: 0411f803 bal 10100020 +.*: 00000000 nop +.*: 1000f801 b 10100020 +.*: 00000000 nop +.*: 03e00008 jr \$31 diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.rd b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.rd new file mode 100644 index 0000000..86cc3c8 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.rd @@ -0,0 +1,49 @@ + +Dynamic section .* +#... + 0x00000003 \(PLTGOT\) 0x10201000 +#... + 0x70000013 \(MIPS_GOTSYM\) 0x6 + 0x00000014 \(PLTREL\) REL + 0x00000017 \(JMPREL\) 0x10004000 + 0x00000002 \(PLTRELSZ\) 24 \(bytes\) + 0x70000032 \(MIPS_PLTGOT\) 0x10200000 +#... +Relocation section '\.rel\.plt' .* + Offset Info Type Sym\.Value Sym\. Name +10200008 [^ ]+ R_MIPS_JUMP_SLOT 00000000 f_bu_bc +1020000c [^ ]+ R_MIPS_JUMP_SLOT 00000000 f_bu +10200010 [^ ]+ R_MIPS_JUMP_SLOT 00000000 f_bc + +Symbol table '\.dynsym' .* + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND +#... + .*: 00000000 0 FUNC GLOBAL DEFAULT UND f_bu_bc + .*: 00000000 0 FUNC GLOBAL DEFAULT UND f_bu + .*: 00000000 0 FUNC GLOBAL DEFAULT UND f_bc + +Symbol table '\.symtab' .* +#... +Primary GOT: + Canonical gp value: 10208ff0 + + Reserved entries: + Address Access Initial Purpose + 10201000 -32752\(gp\) 00000000 Lazy resolver + 10201004 -32748\(gp\) 80000000 Module pointer \(GNU extension\) + + +PLT GOT: + + Reserved entries: + Address Initial Purpose + 10200000 00000000 PLT lazy resolver + 10200004 00000000 Module pointer + + Entries: + Address Initial Sym\.Val\. Type Ndx Name + 10200008 10100000 00000000 FUNC UND f_bu_bc + 1020000c 10100000 00000000 FUNC UND f_bu + 10200010 10100000 00000000 FUNC UND f_bc + diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.od b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.od new file mode 100644 index 0000000..4022a19 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.od @@ -0,0 +1,32 @@ + +.* file format .* + + +Disassembly of section \.plt: + +# Direct branches must have a MIPS16 PLT. +10100000 <_PROCEDURE_LINKAGE_TABLE_>: +.*: 3c1c1020 lui \$28,0x1020 +.*: 8f990000 lw \$25,0\(\$28\) +.*: 279c0000 addiu \$28,\$28,0 +.*: 031cc023 subu \$24,\$24,\$28 +.*: 03e07825 move \$15,\$31 +.*: 0018c082 srl \$24,\$24,0x2 +.*: 0320f809 jalr \$25 +.*: 2718fffe addiu \$24,\$24,-2 + +10100020 : +.*: b203 lw \$2,1010002c +.*: 9a60 lw \$3,0\(\$2\) +.*: 651a move \$24,\$2 +.*: eb00 jr \$3 +.*: 653b move \$25,\$3 +.*: 6500 nop +.*: .... .... \.word 0x10200008 + +Disassembly of section \.text\.a: + +10101000 : +.*: f01f 100e b 10100020 +.*: 6500 nop +.*: e820 jr \$31 diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.rd b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.rd new file mode 100644 index 0000000..648159e --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.rd @@ -0,0 +1,43 @@ + +Dynamic section .* +#... + 0x00000003 \(PLTGOT\) 0x10201000 +#... + 0x70000013 \(MIPS_GOTSYM\) 0x4 + 0x00000014 \(PLTREL\) REL + 0x00000017 \(JMPREL\) 0x10004000 + 0x00000002 \(PLTRELSZ\) 8 \(bytes\) + 0x70000032 \(MIPS_PLTGOT\) 0x10200000 +#... +Relocation section '\.rel\.plt' .* + Offset Info Type Sym\.Value Sym\. Name +10200008 [^ ]+ R_MIPS_JUMP_SLOT 00000000 f_bc + +Symbol table '\.dynsym' .* + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND +#... + .*: 00000000 0 FUNC GLOBAL DEFAULT UND f_bc + +Symbol table '\.symtab' contains 34 entries: +#... +Primary GOT: + Canonical gp value: 10208ff0 + + Reserved entries: + Address Access Initial Purpose + 10201000 -32752\(gp\) 00000000 Lazy resolver + 10201004 -32748\(gp\) 80000000 Module pointer \(GNU extension\) + + +PLT GOT: + + Reserved entries: + Address Initial Purpose + 10200000 00000000 PLT lazy resolver + 10200004 00000000 Module pointer + + Entries: + Address Initial Sym\.Val\. Type Ndx Name + 10200008 10100000 00000000 FUNC UND f_bc + diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.od b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.od new file mode 100644 index 0000000..5fa5e7d --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.od @@ -0,0 +1,69 @@ + +.* file format .* + + +Disassembly of section \.plt: + +# Only _bc (branch from compressed code) functions should have a +# microMIPS PLT. +10100000 <_PROCEDURE_LINKAGE_TABLE_>: +.*: 3c1c1020 lui \$28,0x1020 +.*: 8f990000 lw \$25,0\(\$28\) +.*: 279c0000 addiu \$28,\$28,0 +.*: 031cc023 subu \$24,\$24,\$28 +.*: 03e07825 move \$15,\$31 +.*: 0018c082 srl \$24,\$24,0x2 +.*: 0320f809 jalr \$25 +.*: 2718fffe addiu \$24,\$24,-2 + +10100020 : +.*: 3c0f1020 lui \$15,0x1020 +.*: 8df90008 lw \$25,8\(\$15\) +.*: 03200008 jr \$25 +.*: 25f80008 addiu \$24,\$15,8 + +10100030 : +.*: 3c0f1020 lui \$15,0x1020 +.*: 8df9000c lw \$25,12\(\$15\) +.*: 03200008 jr \$25 +.*: 25f8000c addiu \$24,\$15,12 + +10100040 : +.*: 7903 fff2 addiu \$2,\$pc,1048520 +# ^ 0x10200008 +.*: ff22 0000 lw \$25,0\(\$2\) +.*: 4599 jr \$25 +.*: 0f02 move \$24,\$2 + +1010004c : +.*: 7903 fff1 addiu \$2,\$pc,1048516 +# ^ 0x10200010 +.*: ff22 0000 lw \$25,0\(\$2\) +.*: 4599 jr \$25 +.*: 0f02 move \$24,\$2 + +Disassembly of section \.text\.a: + +10101000 : +.*: 4060 f824 bal 1010004c +.*: 0000 0000 nop +.*: 9400 f820 b 1010004c +.*: 0c00 nop +.*: 4060 f817 bal 10100040 +.*: 0000 0000 nop +.*: 9400 f813 b 10100040 +.*: 0c00 nop +.*: 459f jr \$31 + +Disassembly of section \.text\.b: + +10102000 : +.*: 0411f80b bal 10100030 +.*: 00000000 nop +.*: 1000f809 b 10100030 +.*: 00000000 nop +.*: 0411f803 bal 10100020 +.*: 00000000 nop +.*: 1000f801 b 10100020 +.*: 00000000 nop +.*: 03e00008 jr \$31 diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.rd b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.rd new file mode 100644 index 0000000..86cc3c8 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.rd @@ -0,0 +1,49 @@ + +Dynamic section .* +#... + 0x00000003 \(PLTGOT\) 0x10201000 +#... + 0x70000013 \(MIPS_GOTSYM\) 0x6 + 0x00000014 \(PLTREL\) REL + 0x00000017 \(JMPREL\) 0x10004000 + 0x00000002 \(PLTRELSZ\) 24 \(bytes\) + 0x70000032 \(MIPS_PLTGOT\) 0x10200000 +#... +Relocation section '\.rel\.plt' .* + Offset Info Type Sym\.Value Sym\. Name +10200008 [^ ]+ R_MIPS_JUMP_SLOT 00000000 f_bu_bc +1020000c [^ ]+ R_MIPS_JUMP_SLOT 00000000 f_bu +10200010 [^ ]+ R_MIPS_JUMP_SLOT 00000000 f_bc + +Symbol table '\.dynsym' .* + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND +#... + .*: 00000000 0 FUNC GLOBAL DEFAULT UND f_bu_bc + .*: 00000000 0 FUNC GLOBAL DEFAULT UND f_bu + .*: 00000000 0 FUNC GLOBAL DEFAULT UND f_bc + +Symbol table '\.symtab' .* +#... +Primary GOT: + Canonical gp value: 10208ff0 + + Reserved entries: + Address Access Initial Purpose + 10201000 -32752\(gp\) 00000000 Lazy resolver + 10201004 -32748\(gp\) 80000000 Module pointer \(GNU extension\) + + +PLT GOT: + + Reserved entries: + Address Initial Purpose + 10200000 00000000 PLT lazy resolver + 10200004 00000000 Module pointer + + Entries: + Address Initial Sym\.Val\. Type Ndx Name + 10200008 10100000 00000000 FUNC UND f_bu_bc + 1020000c 10100000 00000000 FUNC UND f_bu + 10200010 10100000 00000000 FUNC UND f_bc + diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.od b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.od new file mode 100644 index 0000000..2290852 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.od @@ -0,0 +1,33 @@ + +.* file format .* + + +Disassembly of section \.plt: + +# All entries must be microMIPS. +10100000 <_PROCEDURE_LINKAGE_TABLE_>: +.*: 7984 0000 addiu \$3,\$pc,1048576 +.*: ff23 0000 lw \$25,0\(\$3\) +.*: 0535 subu \$2,\$2,\$3 +.*: 2525 srl \$2,\$2,2 +.*: 3302 fffe addiu \$24,\$2,-2 +.*: 0dff move \$15,\$31 +.*: 45f9 jalrs \$25 +.*: 0f83 move \$28,\$3 +.*: 0c00 nop + +10100018 : +.*: 7903 fffc addiu \$2,\$pc,1048560 +# ^ 0x10200008 +.*: ff22 0000 lw \$25,0\(\$2\) +.*: 4599 jr \$25 +.*: 0f02 move \$24,\$2 + +Disassembly of section \.text\.a: + +10101000 : +.*: 4060 f80a bal 10100018 +.*: 0000 0000 nop +.*: 9400 f806 b 10100018 +.*: 0c00 nop +.*: 459f jr \$31 diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.rd b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.rd new file mode 100644 index 0000000..9b02330 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.rd @@ -0,0 +1,43 @@ + +Dynamic section .* +#... + 0x00000003 \(PLTGOT\) 0x10201000 +#... + 0x70000013 \(MIPS_GOTSYM\) 0x4 + 0x00000014 \(PLTREL\) REL + 0x00000017 \(JMPREL\) 0x10004000 + 0x00000002 \(PLTRELSZ\) 8 \(bytes\) + 0x70000032 \(MIPS_PLTGOT\) 0x10200000 +#... +Relocation section '\.rel\.plt' .* + Offset Info Type Sym\.Value Sym\. Name +10200008 [^ ]+ R_MIPS_JUMP_SLOT 00000000 f_bc + +Symbol table '\.dynsym' .* + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND +#... + .*: 00000000 0 FUNC GLOBAL DEFAULT UND f_bc + +Symbol table '\.symtab' .* +#... +Primary GOT: + Canonical gp value: 10208ff0 + + Reserved entries: + Address Access Initial Purpose + 10201000 -32752\(gp\) 00000000 Lazy resolver + 10201004 -32748\(gp\) 80000000 Module pointer \(GNU extension\) + + +PLT GOT: + + Reserved entries: + Address Initial Purpose + 10200000 00000000 PLT lazy resolver + 10200004 00000000 Module pointer + + Entries: + Address Initial Sym\.Val\. Type Ndx Name + 10200008 10100001 00000000 FUNC UND f_bc + diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1.s b/ld/testsuite/ld-mips-elf/compressed-plt-1.s index aa0b497..7e7bdaa 100644 --- a/ld/testsuite/ld-mips-elf/compressed-plt-1.s +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1.s @@ -13,10 +13,12 @@ __call_stub_\name: # Flags to specify how a particular function is referenced .equ DC, 1 # Direct call from "compressed" code - .equ IC, 2 # Indirect call from "compressed" code - .equ DU, 4 # Direct call from "uncompressed" code - .equ IU, 8 # Indirect call from "uncompressed" code - .equ LO, 16 # Direct address reference (%lo) + .equ BC, 2 # Branch from "compressed" code + .equ IC, 4 # Indirect call from "compressed" code + .equ DU, 8 # Direct call from "uncompressed" code + .equ BU, 16 # Branch from "uncompressed" code + .equ IU, 32 # Indirect call from "uncompressed" code + .equ LO, 64 # Direct address reference (%lo) # A wrapper around a macro called test_one, which is defined by # the file that includes this one. NAME is the name of a function @@ -35,9 +37,14 @@ __call_stub_\name: test_filter \name\()_dc, (\flags | DC) .endm - .macro test_all_ic, name, flags + .macro test_all_bc, name, flags test_all_dc \name, \flags - test_all_dc \name\()_ic, (\flags | IC) + test_all_dc \name\()_bc, (\flags | BC) + .endm + + .macro test_all_ic, name, flags + test_all_bc \name, \flags + test_all_bc \name\()_ic, (\flags | IC) .endm .macro test_all_du, name, flags @@ -45,9 +52,14 @@ __call_stub_\name: test_all_ic \name\()_du, (\flags | DU) .endm - .macro test_all_iu, name, flags + .macro test_all_bu, name, flags test_all_du \name, \flags - test_all_du \name\()_iu, (\flags | IU) + test_all_du \name\()_bu, (\flags | BU) + .endm + + .macro test_all_iu, name, flags + test_all_bu \name, \flags + test_all_bu \name\()_iu, (\flags | IU) .endm .macro test_all_lo, name, flags diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1a.s b/ld/testsuite/ld-mips-elf/compressed-plt-1a.s index d5c6b4f..ad2ae79 100644 --- a/ld/testsuite/ld-mips-elf/compressed-plt-1a.s +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1a.s @@ -1,4 +1,4 @@ -# Define a function with all "compressed" (dc and ic) references. +# Define a function with all "compressed" (dc, bc and ic) references. .abicalls .option pic0 @@ -16,6 +16,16 @@ .endif .endif .endif + .if (\types) & BC + .if micromips + bal \name + nop + .endif + .ifdef o32 + b \name + nop + .endif + .endif .if (\types) & IC lw $2, %call16(\name)($3) .endif diff --git a/ld/testsuite/ld-mips-elf/compressed-plt-1b.s b/ld/testsuite/ld-mips-elf/compressed-plt-1b.s index 33deccb..5a3f454 100644 --- a/ld/testsuite/ld-mips-elf/compressed-plt-1b.s +++ b/ld/testsuite/ld-mips-elf/compressed-plt-1b.s @@ -1,4 +1,4 @@ -# Define a function with all "uncompressed" (du and iu) references. +# Define a function with all "uncompressed" (du, bu and iu) references. .abicalls .option pic0 @@ -12,6 +12,12 @@ j \name nop .endif + .if (\types) & BU + bal \name + nop + b \name + nop + .endif .if (\types) & IU lw $2, %call16(\name)($3) .endif diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 10a4339..731f419 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -974,13 +974,13 @@ proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } { set ld_flags "$abi_ldflags($abi) -T compressed-plt-1.ld" set dynobj "tmpdir/compressed-plt-1-${abi}-dyn.so" set files [list] - if { $filter & 3 } { + if { $filter & 7 } { lappend files compressed-plt-1a.s } - if { $filter & 12 } { + if { $filter & 56 } { lappend files compressed-plt-1b.s } - if { $filter & 16 } { + if { $filter & 64 } { lappend files compressed-plt-1c.s } eval [list lappend files] $extra @@ -1000,28 +1000,35 @@ proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } { if { $linux_gnu } { build_mips_plt_lib o32 - run_mips_plt_test "o32 PLTs for standard encoding" o32 28 0 se - run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 19 0 mips16-only - run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 19 1 umips-only + run_mips_plt_test "o32 PLTs for standard encoding" o32 104 0 se + run_mips_plt_test "o32 PLTs for standard branches" o32 16 0 branch + run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 69 0 mips16-only + run_mips_plt_test "o32 PLTs for MIPS16 branches" o32 2 0 mips16-bronly + run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 69 1 umips-only + run_mips_plt_test "o32 PLTs for microMIPS branches" o32 2 1 umips-bronly run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16" \ - o32 -1 0 mips16 + o32 109 0 mips16 + run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 branches" \ + o32 18 0 mips16-branch run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with %got" \ - o32 -1 0 mips16-got compressed-plt-1d.s + o32 109 0 mips16-got compressed-plt-1d.s run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with .word" \ - o32 -1 0 mips16-word compressed-plt-1e.s + o32 109 0 mips16-word compressed-plt-1e.s run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS" \ - o32 -1 1 umips + o32 109 1 umips + run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS branches" \ + o32 18 1 umips-branch run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with %got" \ - o32 -1 1 umips-got compressed-plt-1d.s + o32 109 1 umips-got compressed-plt-1d.s run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with .word" \ - o32 -1 1 umips-word compressed-plt-1e.s + o32 109 1 umips-word compressed-plt-1e.s if $has_newabi { build_mips_plt_lib n32 run_mips_plt_test "n32 PLTs for mixed MIPS and MIPS16" \ - n32 -1 0 mips16 + n32 109 0 mips16 run_mips_plt_test "n32 PLTs for mixed MIPS and microMIPS" \ - n32 -1 1 umips + n32 109 1 umips } }