From bce964aa6c777d236fbd641f2bc7bb931cfe4bf3 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sun, 23 Apr 2017 11:03:34 +0930 Subject: PR 21412, get_reloc_section assumes .rel/.rela name for SHT_REL/RELA. This patch fixes an assumption made by code that runs for objcopy and strip, that SHT_REL/SHR_RELA sections are always named starting with a .rel/.rela prefix. I'm also modifying the interface for elf_backend_get_reloc_section, so any backend function just needs to handle name mapping. PR 21412 * elf-bfd.h (struct elf_backend_data ): Change parameters and comment. (_bfd_elf_get_reloc_section): Delete. (_bfd_elf_plt_get_reloc_section): Declare. * elf.c (_bfd_elf_plt_get_reloc_section, elf_get_reloc_section): New functions. Don't blindly skip over assumed .rel/.rela prefix. Extracted from.. (_bfd_elf_get_reloc_section): ..here. Delete. (assign_section_numbers): Call elf_get_reloc_section. * elf64-ppc.c (elf_backend_get_reloc_section): Define. * elfxx-target.h (elf_backend_get_reloc_section): Update. --- bfd/elf-bfd.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bfd/elf-bfd.h') diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index af377ee..4c0c9e8 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1360,8 +1360,10 @@ struct elf_backend_data bfd_size_type (*maybe_function_sym) (const asymbol *sym, asection *sec, bfd_vma *code_off); - /* Return the section which RELOC_SEC applies to. */ - asection *(*get_reloc_section) (asection *reloc_sec); + /* Given NAME, the name of a relocation section stripped of its + .rel/.rela prefix, return the section in ABFD to which the + relocations apply. */ + asection *(*get_reloc_section) (bfd *abfd, const char *name); /* Called to set the sh_flags, sh_link and sh_info fields of OSECTION which has a type >= SHT_LOOS. Returns TRUE if the fields were initialised, @@ -2448,7 +2450,7 @@ extern bfd_boolean _bfd_elf_is_function_type (unsigned int); extern bfd_size_type _bfd_elf_maybe_function_sym (const asymbol *, asection *, bfd_vma *); -extern asection *_bfd_elf_get_reloc_section (asection *); +extern asection *_bfd_elf_plt_get_reloc_section (bfd *, const char *); extern int bfd_elf_get_default_section_type (flagword); -- cgit v1.1