diff options
author | Alan Modra <amodra@gmail.com> | 2021-04-12 18:33:45 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-04-13 00:35:44 +0930 |
commit | 43e05cd4f48b550023819d823fec02abf54e26d3 (patch) | |
tree | 8db8be01bef7bae060fcfef55b7d6d0843731274 /bfd | |
parent | 04977957ecfc723bc4f57460e8e4eed7e6b69f32 (diff) | |
download | gdb-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')
-rw-r--r-- | bfd/ChangeLog | 8 | ||||
-rw-r--r-- | bfd/config.in | 3 | ||||
-rwxr-xr-x | bfd/configure | 22 | ||||
-rw-r--r-- | bfd/configure.ac | 13 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 8 |
5 files changed, 52 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 84f16fc..fa7e649 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,13 @@ 2021-04-12 Alan Modra <amodra@gmail.com> + * elf-bfd.h (ENABLE_CHECKING): Define. + (elf_link_hash_lookup): Abort if wrong type of hash table. + * configure.ac (--enable-checking): Add support. + * config.in: Regenerate. + * configure: Regenerate. + +2021-04-12 Alan Modra <amodra@gmail.com> + * elf-bfd.h (is_elf_hash_table): Convert macro to inline function. (elf_link_hash_lookup, elf_link_hash_traverse): Likewise. (elf_hash_table, elf_hash_table_id): Likewise. diff --git a/bfd/config.in b/bfd/config.in index ba5ce68..6d46ea7 100644 --- a/bfd/config.in +++ b/bfd/config.in @@ -14,6 +14,9 @@ default. */ #undef DEFAULT_LD_Z_SEPARATE_CODE +/* Define if you want run-time sanity checks. */ +#undef ENABLE_CHECKING + /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS diff --git a/bfd/configure b/bfd/configure index adddec1..d98e330 100755 --- a/bfd/configure +++ b/bfd/configure @@ -826,6 +826,7 @@ with_gnu_ld enable_libtool_lock enable_plugins enable_largefile +enable_checking enable_64_bit_bfd enable_targets enable_64_bit_archive @@ -1484,6 +1485,7 @@ Optional Features: --disable-libtool-lock avoid locking (might break parallel builds) --enable-plugins Enable support for plugins --disable-largefile omit support for large files + --enable-checking enable run-time checks --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes) --enable-targets alternative target configurations --enable-64-bit-archive force 64-bit archives @@ -11042,7 +11044,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11045 "configure" +#line 11047 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11148,7 +11150,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11151 "configure" +#line 11153 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11788,6 +11790,22 @@ else fi +ac_checking= +. ${srcdir}/development.sh +test "$development" = true && ac_checking=yes +# Check whether --enable-checking was given. +if test "${enable_checking+set}" = set; then : + enableval=$enable_checking; case "${enableval}" in + no|none) ac_checking= ;; + *) ac_checking=yes ;; +esac +fi +if test x$ac_checking != x ; then + +$as_echo "#define ENABLE_CHECKING 1" >>confdefs.h + +fi + # Check whether --enable-64-bit-bfd was given. if test "${enable_64_bit_bfd+set}" = set; then : enableval=$enable_64_bit_bfd; case "${enableval}" in diff --git a/bfd/configure.ac b/bfd/configure.ac index c016fd0..07a75ed 100644 --- a/bfd/configure.ac +++ b/bfd/configure.ac @@ -69,6 +69,19 @@ esac AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes") +ac_checking= +. ${srcdir}/development.sh +test "$development" = true && ac_checking=yes +AC_ARG_ENABLE(checking, +[ --enable-checking enable run-time checks], +[case "${enableval}" in + no|none) ac_checking= ;; + *) ac_checking=yes ;; +esac])dnl +if test x$ac_checking != x ; then + AC_DEFINE(ENABLE_CHECKING, 1, [Define if you want run-time sanity checks.]) +fi + AC_ARG_ENABLE(64-bit-bfd, [ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)], [case "${enableval}" in 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); |