From: Alan Modra Date: Sun, 29 Oct 2017 23:50:29 +0000 (+1030) Subject: relocs_compatible test for gc-sections X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e769a82c35d580ed81a52e6fbd072841530d3f6;p=thirdparty%2Fbinutils-gdb.git relocs_compatible test for gc-sections I noticed when looking at pr22300 that before calling check_relocs we have an elf_object_id test (added for pr11933) as well as the relocs_compatible test. I believe backend gc_mark_hook and gc_sweep_hook ought to be protected similarly from being confused by unexpected relocations (for example, both elf64-ppc.c and elf32-ppc.c use _bfd_elf_relocs_compatible, so I think it would be possible for the ppc64 gc_mark_hook to be presented with a ppc32 relocatable object). * elflink.c (elf_gc_sweep): Test elf_object_id in addition to relocs_compatible. (bfd_elf_gc_sections): Likewise. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index ea035e76ff4..a86ad613ea9 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,6 +1,11 @@ 2017-11-01 Alan Modra Apply from master + 2017-10-30 Alan Modra + * elflink.c (elf_gc_sweep): Test elf_object_id in addition to + relocs_compatible. + (bfd_elf_gc_sections): Likewise. + 2017-10-28 Alan Modra PR 22300 * elflink.c (_bfd_elf_merge_symbol): Remove relocs_compatible check. diff --git a/bfd/elflink.c b/bfd/elflink.c index 245d89c6f4f..9e0c1bb2c73 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -13023,6 +13023,7 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info) asection *o; if (bfd_get_flavour (sub) != bfd_target_elf_flavour + || elf_object_id (sub) != elf_hash_table_id (elf_hash_table (info)) || !(*bed->relocs_compatible) (sub->xvec, abfd->xvec)) continue; o = sub->sections; @@ -13351,6 +13352,7 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info) asection *o; if (bfd_get_flavour (sub) != bfd_target_elf_flavour + || elf_object_id (sub) != elf_hash_table_id (htab) || !(*bed->relocs_compatible) (sub->xvec, abfd->xvec)) continue;