summaryrefslogtreecommitdiff
path: root/m4/fp_bfd_support.m4
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-04-02 11:52:47 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-05 05:42:38 -0400
commit7ffbdc3fa603c6411249ba9b758cf8f109c5fb30 (patch)
tree8a05d6e03ce2790e6e59651c824e569fee088d33 /m4/fp_bfd_support.m4
parent6acadb79afe685c635fd255f90551a0fbfcbe3dc (diff)
downloadhaskell-7ffbdc3fa603c6411249ba9b758cf8f109c5fb30.tar.gz
Break up aclocal.m4
Diffstat (limited to 'm4/fp_bfd_support.m4')
-rw-r--r--m4/fp_bfd_support.m448
1 files changed, 48 insertions, 0 deletions
diff --git a/m4/fp_bfd_support.m4 b/m4/fp_bfd_support.m4
new file mode 100644
index 0000000000..89c051253f
--- /dev/null
+++ b/m4/fp_bfd_support.m4
@@ -0,0 +1,48 @@
+# FP_BFD_SUPPORT()
+# ----------------------
+# whether to use libbfd for debugging RTS
+AC_DEFUN([FP_BFD_SUPPORT], [
+ AC_SUBST([CabalHaveLibbfd], [False])
+ AC_ARG_ENABLE(bfd-debug,
+ [AS_HELP_STRING([--enable-bfd-debug],
+ [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])],
+ [
+ # don't pollute general LIBS environment
+ save_LIBS="$LIBS"
+ AC_CHECK_HEADERS([bfd.h])
+ dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
+ dnl the order of these tests matters: bfd needs libiberty
+ AC_CHECK_LIB(iberty, xmalloc)
+ dnl 'bfd_init' is a rare non-macro in libbfd
+ AC_CHECK_LIB(bfd, bfd_init)
+
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <bfd.h>]],
+ [[
+ /* mimic our rts/Printer.c */
+ bfd* abfd;
+ const char * name;
+ char **matching;
+
+ name = "some.executable";
+ bfd_init();
+ abfd = bfd_openr(name, "default");
+ bfd_check_format_matches (abfd, bfd_object, &matching);
+ {
+ long storage_needed;
+ storage_needed = bfd_get_symtab_upper_bound (abfd);
+ }
+ {
+ asymbol **symbol_table;
+ long number_of_symbols;
+ symbol_info info;
+
+ number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
+ bfd_get_symbol_info(abfd,symbol_table[0],&info);
+ }
+ ]])],
+ [AC_SUBST([CabalHaveLibbfd], [True])],dnl bfd seems to work
+ [AC_MSG_ERROR([can't use 'bfd' library])])
+ LIBS="$save_LIBS"
+ ]
+ )
+])