relocs_compatible test for gc-sections
authorAlan Modra <amodra@gmail.com>
Sun, 29 Oct 2017 23:50:29 +0000 (10:20 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 30 Oct 2017 00:33:50 +0000 (11:03 +1030)
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.

bfd/ChangeLog
bfd/elflink.c

index c56e1cf66b3cd7137623c18dcff128b808fb9fdc..7cf5b3270c002f4dda6bf39c859a58ba1662c595 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-30  Alan Modra  <amodra@gmail.com>
+
+       * elflink.c (elf_gc_sweep): Test elf_object_id in addition to
+       relocs_compatible.
+       (bfd_elf_gc_sections): Likewise.
+
 2017-10-30  Alan Modra  <amodra@gmail.com>
 
        PR 22269
index 9f2d63b2805e4ddfe1fb5272c83b49574021b0c6..122549c594b1034553383200abe225f1146cf95d 100644 (file)
@@ -13034,6 +13034,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;
@@ -13335,6 +13336,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;
 
This page took 0.030847 seconds and 4 git commands to generate.