aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-08-25 01:51:39 +0930
committerAlan Modra <amodra@gmail.com>2021-01-28 11:50:36 +1030
commit0004f3b30c717314abfb741758eb383ac43730ed (patch)
treea6d0e6dd29711b4489a0491ea3ad46f8e396a364
parentPR26483, ASAN: ppc_elf_link_params elf32-ppc.c:2314 (diff)
downloadbinutils-gdb-0004f3b30c717314abfb741758eb383ac43730ed.tar.gz
binutils-gdb-0004f3b30c717314abfb741758eb383ac43730ed.tar.bz2
binutils-gdb-0004f3b30c717314abfb741758eb383ac43730ed.zip
PR26492, ASAN: ppc64_elf_before_check_relocs elf64-ppc.c:4337
PR 26492 * elf64-ppc.c (ppc_hash_table): Test is_elf_hash_table before accessing elf_hash_table_id. (cherry picked from commit 573eb292ee79dc78207cedadaa8acbb1922ab699)
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf64-ppc.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b7b23513cb..8615b08cc5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -2,6 +2,11 @@
Apply from master
2020-08-25 Alan Modra <amodra@gmail.com>
+ PR 26492
+ * elf64-ppc.c (ppc_hash_table): Test is_elf_hash_table before
+ accessing elf_hash_table_id.
+
+ 2020-08-25 Alan Modra <amodra@gmail.com>
PR 26483
* elf32-ppc.c (ppc_elf_hash_table): Test is_elf_hash_table before
accessing elf_hash_table_id.
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index ec8c85eba5..aef161c029 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -3283,8 +3283,9 @@ struct ppc_link_hash_table
/* Get the ppc64 ELF linker hash table from a link_info structure. */
#define ppc_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == PPC64_ELF_DATA ? ((struct ppc_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == PPC64_ELF_DATA) \
+ ? (struct ppc_link_hash_table *) (p)->hash : NULL)
#define ppc_stub_hash_lookup(table, string, create, copy) \
((struct ppc_stub_hash_entry *) \