diff options
author | Alan Modra <amodra@gmail.com> | 2021-04-11 23:34:21 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-04-12 11:57:03 +0930 |
commit | fc304b889106f6d1bd720e969b95615992bf1961 (patch) | |
tree | af9f6df2ab9282409587e4b8ba784e813e2c6f5c /ld/ldlang.c | |
parent | e601909a3287bf541c6a7d82214bb387d2c76d82 (diff) | |
download | gdb-fc304b889106f6d1bd720e969b95615992bf1961.zip gdb-fc304b889106f6d1bd720e969b95615992bf1961.tar.gz gdb-fc304b889106f6d1bd720e969b95615992bf1961.tar.bz2 |
PR27719, lang_mark_undefineds trashes memory
It's not enough to test that the output is ELF before casting
bfd_link_hash_entry to elf_link_hash_entry. Some ELF targets (d30v,
dlx, pj, s12z, xgate) use the generic linker support in bfd/linker.c
and thus their symbols are of type generic_link_hash_entry.
Not all of the places this patch touches can result in wrong accesses,
but I thought it worth ensuring that all occurrences of
elf_link_hash_entry in ld/ were obviously correct.
PR 27719
* ldlang.c (lang_mark_undefineds, undef_start_stop): Test that
the symbol hash table is the correct type before accessing
elf_link_hash_entry symbols.
* plugin.c (is_visible_from_outside): Likewise.
* emultempl/armelf.em (ld${EMULATION_NAME}_finish): Likewise.
* emultempl/solaris2.em (elf_solaris2_before_allocation): Likewise.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index 8910899..37b64c8 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -4009,7 +4009,7 @@ lang_mark_undefineds (void) { ldlang_undef_chain_list_type *ptr; - if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour) + if (is_elf_hash_table (link_info.hash)) for (ptr = ldlang_undef_chain_list_head; ptr != NULL; ptr = ptr->next) { struct elf_link_hash_entry *h = (struct elf_link_hash_entry *) @@ -6822,7 +6822,7 @@ undef_start_stop (struct bfd_link_hash_entry *h) } h->type = bfd_link_hash_undefined; h->u.undef.abfd = NULL; - if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour) + if (is_elf_hash_table (link_info.hash)) { const struct elf_backend_data *bed; struct elf_link_hash_entry *eh = (struct elf_link_hash_entry *) h; |