aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-10-30 10:20:29 +1030
committerAlan Modra <amodra@gmail.com>2017-10-30 11:03:50 +1030
commit81742b83e9f25895eaaf3a07ac1651a4e9a68251 (patch)
treece6ef2cdab6327ca8f8a795454c4d37f08a00579
parentd336fa6d820f50235c271ea327fadbf4ff6e1edd (diff)
downloadgdb-81742b83e9f25895eaaf3a07ac1651a4e9a68251.zip
gdb-81742b83e9f25895eaaf3a07ac1651a4e9a68251.tar.gz
gdb-81742b83e9f25895eaaf3a07ac1651a4e9a68251.tar.bz2
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.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c2
2 files changed, 8 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c56e1cf..7cf5b32 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
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
* elf32-hppa.c (elf32_hppa_check_relocs): Move SEC_ALLOC test to
ensure non_got_ref is not set due to debug references.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 9f2d63b..122549c 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -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;