]> The Tcpdump Group git mirrors - tcpdump/blobdiff - configure
autoconf: Add an option to help debugging (--enable-instrument-functions)
[tcpdump] / configure
index 3071a3daa2d198ad063e350cf6fbe256c04e8c87..d35f29abbf551967c99fbd91175dfc76e1225406 100755 (executable)
--- a/configure
+++ b/configure
@@ -701,6 +701,7 @@ enable_option_checking
 with_gcc
 enable_universal
 with_smi
+enable_instrument_functions
 enable_smb
 with_user
 with_chroot
@@ -1332,6 +1333,8 @@ Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --disable-universal     don't build universal on macOS
+  --enable-instrument-functions
+                          enable instrument functions code [default=no]
   --enable-smb            enable possibly-buggy SMB printer [default=no]
   --disable-local-libpcap don't look for a local libpcap [default=check for a
                           local libpcap]
@@ -4345,6 +4348,76 @@ fi
 
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable the instrument functions code" >&5
+$as_echo_n "checking whether to enable the instrument functions code... " >&6; }
+# Check whether --enable-instrument-functions was given.
+if test "${enable_instrument_functions+set}" = set; then :
+  enableval=$enable_instrument_functions;
+else
+  enableval=no
+fi
+
+case "$enableval" in
+yes)   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_init in -lbfd" >&5
+$as_echo_n "checking for bfd_init in -lbfd... " >&6; }
+if ${ac_cv_lib_bfd_bfd_init+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbfd  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char bfd_init ();
+int
+main ()
+{
+return bfd_init ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_bfd_bfd_init=yes
+else
+  ac_cv_lib_bfd_bfd_init=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_init" >&5
+$as_echo "$ac_cv_lib_bfd_bfd_init" >&6; }
+if test "x$ac_cv_lib_bfd_bfd_init" = xyes; then :
+  true
+else
+  as_fn_error $? "--enable-instrument-functions was given, but test for library libbfd failed. Please install the 'binutils-dev' package." "$LINENO" 5
+fi
+
+
+$as_echo "#define ENABLE_INSTRUMENT_FUNCTIONS 1" >>confdefs.h
+
+       LOCALSRC="$LOCALSRC instrument-functions.c"
+       # Add '-finstrument-functions' instrumentation option to generate
+       # instrumentation calls for entry and exit to functions.
+       # Try to avoid Address Space Layout Randomization (ALSR).
+       CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions -fno-stack-protector -fno-pic"
+       LDFLAGS="$LDFLAGS -O0 -ggdb -fno-stack-protector -no-pie"
+       LIBS="$LIBS -lbfd"
+       ;;
+*)     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+       ;;
+esac
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable the possibly-buggy SMB printer" >&5
 $as_echo_n "checking whether to enable the possibly-buggy SMB printer... " >&6; }
 # Check whether --enable-smb was given.