aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf-bfd.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-04-12 18:33:45 +0930
committerAlan Modra <amodra@gmail.com>2021-04-13 00:35:44 +0930
commit43e05cd4f48b550023819d823fec02abf54e26d3 (patch)
tree8db8be01bef7bae060fcfef55b7d6d0843731274 /bfd/elf-bfd.h
parent04977957ecfc723bc4f57460e8e4eed7e6b69f32 (diff)
downloadgdb-43e05cd4f48b550023819d823fec02abf54e26d3.zip
gdb-43e05cd4f48b550023819d823fec02abf54e26d3.tar.gz
gdb-43e05cd4f48b550023819d823fec02abf54e26d3.tar.bz2
ENABLE_CHECKING in bfd, opcodes, binutils, ld
gas already has this. Here it enables checking hash table type passed to elf_link_hash_lookup and elf_link_hash_traverse. bfd/ * elf-bfd.h (ENABLE_CHECKING): Define. (elf_link_hash_lookup): Abort if wrong type of hash table. (elf_link_hash_traverse): Likewise. * configure.ac (--enable-checking): Add support. * config.in: Regenerate. * configure: Regenerate. binutils/ * configure.ac (--enable-checking): Add support. * config.in: Regenerate. * configure: Regenerate. ld/ * configure.ac (--enable-checking): Add support. * config.in: Regenerate. * configure: Regenerate. opcodes/ * configure.ac (--enable-checking): Add support. * config.in: Regenerate. * configure: Regenerate.
Diffstat (limited to 'bfd/elf-bfd.h')
-rw-r--r--bfd/elf-bfd.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index e0b7e57..5a2f642 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -27,6 +27,10 @@
#include "elf/internal.h"
#include "bfdlink.h"
+#ifndef ENABLE_CHECKING
+#define ENABLE_CHECKING 0
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -721,6 +725,8 @@ static inline struct elf_link_hash_entry *
elf_link_hash_lookup (struct elf_link_hash_table *table, const char *string,
bool create, bool copy, bool follow)
{
+ if (ENABLE_CHECKING && !is_elf_hash_table (&table->root))
+ abort ();
return (struct elf_link_hash_entry *)
bfd_link_hash_lookup (&table->root, string, create, copy, follow);
}
@@ -732,6 +738,8 @@ elf_link_hash_traverse (struct elf_link_hash_table *table,
bool (*f) (struct elf_link_hash_entry *, void *),
void *info)
{
+ if (ENABLE_CHECKING && !is_elf_hash_table (&table->root))
+ abort ();
bfd_link_hash_traverse (&table->root,
(bool (*) (struct bfd_link_hash_entry *, void *)) f,
info);