From 54806ffa85643c3a1ee721d5c3f5586d32f86ee1 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Tue, 26 Jul 2016 17:45:00 +0100 Subject: 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. --- bfd/ChangeLog | 6 ++++++ bfd/elfxx-mips.c | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'bfd') 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; -- cgit v1.1