aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-05-19 15:11:31 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2017-05-20 00:31:39 +0100
commite5713223cbc1025f484fa2548d58f74173646b8a (patch)
tree3bc243c6e43c0f5f0f1b7724a586181a15e7c66b /bfd
parentf0681695daa9d4fd493f3ca88f194675c9affbff (diff)
downloadgdb-e5713223cbc1025f484fa2548d58f74173646b8a.zip
gdb-e5713223cbc1025f484fa2548d58f74173646b8a.tar.gz
gdb-e5713223cbc1025f484fa2548d58f74173646b8a.tar.bz2
MIPS/BFD: For n64 hold the number of internal relocs in `->reloc_count'
Revert parts of commit fee24f1c5bfe ("objdump improvements for mips elf64"), <https://sourceware.org/ml/binutils/2003-03/msg00108.html>, and make the `->reloc_count' member of `struct bfd_section' hold the actual number of internal relocations stored in its `->relocation' vector. To do so adjust `mips_elf64_slurp_one_reloc_table' to set `->reloc_count' to the actual number of internal relocations retrieved and discard `mips_elf64_canonicalize_reloc', `mips_elf64_canonicalize_dynamic_reloc' and their corresponding target macros. Contrary to the description of `mips_elf64_slurp_one_reloc_table', adjusted appropriately, this makes generic relocation processing code happy and satisfies the "merge notes section" binutils test case. Add extra binutils test cases to expand the coverage of the generic "merge notes section" test case, now passing with the n64 ABI, across the MIPS o32, n32 and n64 ABIs regardless of the default ABI selected in target configuration, and also to verify correctness of the relocations produced. Conversely, do not provide any additional test cases for the original issue addressed with the commit referred: - objdump would display only 1/3 of the total number of relocations, because it used the external relocation count, but each external relocation is brought in as 3 internal relocations. as n64 ABI relocation processing with `objdump -r' and `objdump -R' is already widely covered across the GAS and LD test suites. bfd/ * elf64-mips.c (mips_elf64_canonicalize_reloc): Remove prototype and function. (mips_elf64_canonicalize_dynamic_reloc): Likewise. (mips_elf64_slurp_one_reloc_table): Set `reloc_count' to the actual number of internal relocations retrieved. Adjust function description. (bfd_elf64_canonicalize_reloc): Remove macro. (bfd_elf64_canonicalize_dynamic_reloc): Likewise. binutils/ * testsuite/binutils-all/mips/mips-note-2.d: New test. * testsuite/binutils-all/mips/mips-note-2r.d: New test. * testsuite/binutils-all/mips/mips-note-2-n32.d: New test. * testsuite/binutils-all/mips/mips-note-2-n64.d: New test. * testsuite/binutils-all/mips/mips-note-2r-n32.d: New test. * testsuite/binutils-all/mips/mips-note-2r-n64.d: New test. * testsuite/binutils-all/mips/mips.exp: Define `has_newabi'. Run the new tests.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog11
-rw-r--r--bfd/elf64-mips.c82
2 files changed, 18 insertions, 75 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 26b96f3..38462fe 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,14 @@
+2017-05-19 Maciej W. Rozycki <macro@imgtec.com>
+
+ * elf64-mips.c (mips_elf64_canonicalize_reloc): Remove prototype
+ and function.
+ (mips_elf64_canonicalize_dynamic_reloc): Likewise.
+ (mips_elf64_slurp_one_reloc_table): Set `reloc_count' to the
+ actual number of internal relocations retrieved. Adjust
+ function description.
+ (bfd_elf64_canonicalize_reloc): Remove macro.
+ (bfd_elf64_canonicalize_dynamic_reloc): Likewise.
+
2017-05-19 Jose E. Marchesi <jose.marchesi@oracle.com>
* archures.c (bfd_mach_sparc_v9m8): Define.
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index a66c319..e95db2c 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -88,12 +88,8 @@ static void mips_elf64_info_to_howto_rela
(bfd *, arelent *, Elf_Internal_Rela *);
static long mips_elf64_get_reloc_upper_bound
(bfd *, asection *);
-static long mips_elf64_canonicalize_reloc
- (bfd *, asection *, arelent **, asymbol **);
static long mips_elf64_get_dynamic_reloc_upper_bound
(bfd *);
-static long mips_elf64_canonicalize_dynamic_reloc
- (bfd *, arelent **, asymbol **);
static bfd_boolean mips_elf64_slurp_one_reloc_table
(bfd *, asection *, Elf_Internal_Shdr *, bfd_size_type, arelent *,
asymbol **, bfd_boolean);
@@ -3663,76 +3659,14 @@ mips_elf64_get_dynamic_reloc_upper_bound (bfd *abfd)
return _bfd_elf_get_dynamic_reloc_upper_bound (abfd) * 3;
}
-/* We must also copy more relocations than the corresponding functions
- in elf.c would, so the two following functions are slightly
- modified from elf.c, that multiply the external relocation count by
- 3 to obtain the internal relocation count. */
-
-static long
-mips_elf64_canonicalize_reloc (bfd *abfd, sec_ptr section,
- arelent **relptr, asymbol **symbols)
-{
- arelent *tblptr;
- unsigned int i;
- const struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- if (! bed->s->slurp_reloc_table (abfd, section, symbols, FALSE))
- return -1;
-
- tblptr = section->relocation;
- for (i = 0; i < section->reloc_count * 3; i++)
- *relptr++ = tblptr++;
-
- *relptr = NULL;
-
- return section->reloc_count * 3;
-}
-
-static long
-mips_elf64_canonicalize_dynamic_reloc (bfd *abfd, arelent **storage,
- asymbol **syms)
-{
- bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean);
- asection *s;
- long ret;
-
- if (elf_dynsymtab (abfd) == 0)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
-
- slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
- ret = 0;
- for (s = abfd->sections; s != NULL; s = s->next)
- {
- if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
- && (elf_section_data (s)->this_hdr.sh_type == SHT_REL
- || elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
- {
- arelent *p;
- long count, i;
-
- if (! (*slurp_relocs) (abfd, s, syms, TRUE))
- return -1;
- count = s->size / elf_section_data (s)->this_hdr.sh_entsize * 3;
- p = s->relocation;
- for (i = 0; i < count; i++)
- *storage++ = p++;
- ret += count;
- }
- }
-
- *storage = NULL;
-
- return ret;
-}
-
/* Read the relocations from one reloc section. This is mostly copied
from elfcode.h, except for the changes to expand one external
- relocation to 3 internal ones. We must unfortunately set
- reloc_count to the number of external relocations, because a lot of
- generic code seems to depend on this. */
+ relocation to 3 internal ones. To reduce processing effort we
+ could discard those R_MIPS_NONE relocations that occupy the second
+ and the third entry of a triplet, as `mips_elf64_write_rel' and
+ `mips_elf64_write_rela' recreate them in output automagically,
+ however that would also remove them from `objdump -r' output,
+ breaking a long-established tradition and likely confusing people. */
static bfd_boolean
mips_elf64_slurp_one_reloc_table (bfd *abfd, asection *asect,
@@ -3885,7 +3819,7 @@ mips_elf64_slurp_one_reloc_table (bfd *abfd, asection *asect,
}
}
- asect->reloc_count += (relent - relents) / 3;
+ asect->reloc_count += relent - relents;
if (allocated != NULL)
free (allocated);
@@ -4504,9 +4438,7 @@ const struct elf_size_info mips_elf64_size_info =
_bfd_mips_elf_print_private_bfd_data
#define bfd_elf64_get_reloc_upper_bound mips_elf64_get_reloc_upper_bound
-#define bfd_elf64_canonicalize_reloc mips_elf64_canonicalize_reloc
#define bfd_elf64_get_dynamic_reloc_upper_bound mips_elf64_get_dynamic_reloc_upper_bound
-#define bfd_elf64_canonicalize_dynamic_reloc mips_elf64_canonicalize_dynamic_reloc
#define bfd_elf64_mkobject _bfd_mips_elf_mkobject
/* The SGI style (n)64 NewABI. */