aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-mips.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-06-06 01:24:06 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2017-06-06 01:34:23 +0100
commit056bafd472efccfb2d7f44f6469dfa08cdf7414b (patch)
tree28decf9ca961e8679145223fe87d66b4be673d18 /bfd/elfxx-mips.c
parent61756f84eedc470c975f8bafe6ddf10acaca6942 (diff)
downloadgdb-056bafd472efccfb2d7f44f6469dfa08cdf7414b.zip
gdb-056bafd472efccfb2d7f44f6469dfa08cdf7414b.tar.gz
gdb-056bafd472efccfb2d7f44f6469dfa08cdf7414b.tar.bz2
ELF/BFD: Hold the number of internal static relocs in `->reloc_count'
Correct a commit e5713223cbc1 ("MIPS/BFD: For n64 hold the number of internal relocs in `->reloc_count'") regression and change internal relocation handling in the generic ELF BFD linker code such that, except in the presence of R_SPARC_OLO10 relocations, a section's `reloc_count' holds the number of internal rather than external relocations, making the handling more consistent between GAS, which sets `->reloc_count' with a call to `bfd_set_reloc', and LD, which sets `->reloc_count' as it reads input sections. The handling of dynamic relocations remains unchanged and they continue holding the number of external relocations in `->reloc_count'; they are also not converted to the internal form except in `elf_link_sort_relocs' (which does not handle the general, i.e. non-n64-MIPS case of composed relocations correctly as per the ELF gABI, though it does not seem to matter for the targets we currently support). The n64 MIPS backend is the only one with `int_rels_per_ext_rel' set to non-one, and consequently the change is trivial for all the remaining backends and targets. bfd/ * elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Subtract `count' from `reloc_count' rather than decrementing it. * elf.c (bfd_section_from_shdr): Multiply the adjustment to `reloc_count' by `int_rels_per_ext_rel'. * elf32-score.c (score_elf_final_link_relocate): Do not multiply `reloc_count' by `int_rels_per_ext_rel' for last relocation entry determination. (s3_bfd_score_elf_check_relocs): Likewise. * elf32-score7.c (score_elf_final_link_relocate): Likewise. (s7_bfd_score_elf_relocate_section): Likewise. (s7_bfd_score_elf_check_relocs): Likewise. * elf64-mips.c (mips_elf64_get_reloc_upper_bound): Remove prototype and function. (mips_elf64_slurp_one_reloc_table): Do not update `reloc_count'. (mips_elf64_slurp_reloc_table): Assert that `reloc_count' is triple rather than once the sum of REL and RELA relocation entry counts. (bfd_elf64_get_reloc_upper_bound): Remove macro. * elflink.c (_bfd_elf_link_read_relocs): Do not multiply `reloc_count' by `int_rels_per_ext_rel' for internal relocation storage allocation size determination. (elf_link_input_bfd): Multiply `.ctors' and `.dtors' section's size by `int_rels_per_ext_rel'. Do not multiply `reloc_count' by `int_rels_per_ext_rel' for last relocation entry determination. (bfd_elf_final_link): Do not multiply `reloc_count' by `int_rels_per_ext_rel' for internal relocation storage allocation size determination. (init_reloc_cookie_rels): Do not multiply `reloc_count' by `int_rels_per_ext_rel' for last relocation entry determination. (elf_gc_smash_unused_vtentry_relocs): Likewise. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise. (_bfd_mips_elf_relocate_section): Likewise.
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r--bfd/elfxx-mips.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index cbf39c0..1ef27f6 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -8102,7 +8102,7 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
bed = get_elf_backend_data (abfd);
- rel_end = relocs + sec->reloc_count * bed->s->int_rels_per_ext_rel;
+ rel_end = relocs + sec->reloc_count;
/* Check for the mips16 stub sections. */
@@ -10034,7 +10034,7 @@ _bfd_mips_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
const struct elf_backend_data *bed;
bed = get_elf_backend_data (output_bfd);
- relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
+ relend = relocs + input_section->reloc_count;
for (rel = relocs; rel < relend; ++rel)
{
const char *name;