Cheng Shao pushed to branch wip/symbolizer at Glasgow Haskell Compiler / GHC
Commits:
-
237b7508
by Cheng Shao at 2025-07-04T21:04:36+00:00
9 changed files:
- configure.ac
- hadrian/cfg/system.config.in
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Settings/Packages.hs
- − m4/fp_bfd_support.m4
- rts/Printer.c
- rts/configure.ac
- rts/include/rts/Config.h
- rts/rts.cabal
Changes:
| ... | ... | @@ -868,9 +868,6 @@ AC_SUBST([UseLibm]) |
| 868 | 868 | TargetHasLibm=$UseLibm
|
| 869 | 869 | AC_SUBST(TargetHasLibm)
|
| 870 | 870 | |
| 871 | -FP_BFD_FLAG
|
|
| 872 | -AC_SUBST([UseLibbfd])
|
|
| 873 | - |
|
| 874 | 871 | dnl ################################################################
|
| 875 | 872 | dnl Check for libraries
|
| 876 | 873 | dnl ################################################################
|
| ... | ... | @@ -120,7 +120,6 @@ use-lib-numa = @UseLibNuma@ |
| 120 | 120 | use-lib-m = @UseLibm@
|
| 121 | 121 | use-lib-rt = @UseLibrt@
|
| 122 | 122 | use-lib-dl = @UseLibdl@
|
| 123 | -use-lib-bfd = @UseLibbfd@
|
|
| 124 | 123 | use-lib-pthread = @UseLibpthread@
|
| 125 | 124 | need-libatomic = @NeedLibatomic@
|
| 126 | 125 |
| ... | ... | @@ -37,7 +37,6 @@ data Flag = CrossCompiling |
| 37 | 37 | | UseLibm
|
| 38 | 38 | | UseLibrt
|
| 39 | 39 | | UseLibdl
|
| 40 | - | UseLibbfd
|
|
| 41 | 40 | | UseLibpthread
|
| 42 | 41 | | NeedLibatomic
|
| 43 | 42 | | UseGhcToolchain
|
| ... | ... | @@ -61,7 +60,6 @@ flag f = do |
| 61 | 60 | UseLibm -> "use-lib-m"
|
| 62 | 61 | UseLibrt -> "use-lib-rt"
|
| 63 | 62 | UseLibdl -> "use-lib-dl"
|
| 64 | - UseLibbfd -> "use-lib-bfd"
|
|
| 65 | 63 | UseLibpthread -> "use-lib-pthread"
|
| 66 | 64 | NeedLibatomic -> "need-libatomic"
|
| 67 | 65 | UseGhcToolchain -> "use-ghc-toolchain"
|
| ... | ... | @@ -440,7 +440,6 @@ rtsPackageArgs = package rts ? do |
| 440 | 440 | , useSystemFfi `cabalFlag` "use-system-libffi"
|
| 441 | 441 | , useLibffiForAdjustors `cabalFlag` "libffi-adjustors"
|
| 442 | 442 | , flag UseLibpthread `cabalFlag` "need-pthread"
|
| 443 | - , flag UseLibbfd `cabalFlag` "libbfd"
|
|
| 444 | 443 | , flag NeedLibatomic `cabalFlag` "need-atomic"
|
| 445 | 444 | , flag UseLibdw `cabalFlag` "libdw"
|
| 446 | 445 | , flag UseLibnuma `cabalFlag` "libnuma"
|
| 1 | -# FP_BFD_SUPPORT()
|
|
| 2 | -# ----------------------
|
|
| 3 | -# Whether to use libbfd for debugging RTS
|
|
| 4 | -#
|
|
| 5 | -# Sets:
|
|
| 6 | -# UseLibbfd: [YES|NO]
|
|
| 7 | -AC_DEFUN([FP_BFD_FLAG], [
|
|
| 8 | - UseLibbfd=NO
|
|
| 9 | - AC_ARG_ENABLE(bfd-debug,
|
|
| 10 | - [AS_HELP_STRING([--enable-bfd-debug],
|
|
| 11 | - [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])],
|
|
| 12 | - [UseLibbfd=YES],
|
|
| 13 | - [UseLibbfd=NO])
|
|
| 14 | -])
|
|
| 15 | - |
|
| 16 | -# FP_WHEN_ENABLED_BFD
|
|
| 17 | -# ----------------------
|
|
| 18 | -# Checks for libraries in the default way, which will define various
|
|
| 19 | -# `HAVE_*` macros.
|
|
| 20 | -AC_DEFUN([FP_WHEN_ENABLED_BFD], [
|
|
| 21 | - # don't pollute general LIBS environment
|
|
| 22 | - save_LIBS="$LIBS"
|
|
| 23 | - AC_CHECK_HEADERS([bfd.h])
|
|
| 24 | - dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
|
|
| 25 | - dnl the order of these tests matters: bfd needs libiberty
|
|
| 26 | - AC_CHECK_LIB(iberty, xmalloc)
|
|
| 27 | - dnl 'bfd_init' is a rare non-macro in libbfd
|
|
| 28 | - AC_CHECK_LIB(bfd, bfd_init)
|
|
| 29 | - |
|
| 30 | - AC_LINK_IFELSE(
|
|
| 31 | - [AC_LANG_PROGRAM(
|
|
| 32 | - [[#include <bfd.h>]],
|
|
| 33 | - [[
|
|
| 34 | - /* mimic our rts/Printer.c */
|
|
| 35 | - bfd* abfd;
|
|
| 36 | - const char * name;
|
|
| 37 | - char **matching;
|
|
| 38 | - |
|
| 39 | - name = "some.executable";
|
|
| 40 | - bfd_init();
|
|
| 41 | - abfd = bfd_openr(name, "default");
|
|
| 42 | - bfd_check_format_matches (abfd, bfd_object, &matching);
|
|
| 43 | - {
|
|
| 44 | - long storage_needed;
|
|
| 45 | - storage_needed = bfd_get_symtab_upper_bound (abfd);
|
|
| 46 | - }
|
|
| 47 | - {
|
|
| 48 | - asymbol **symbol_table;
|
|
| 49 | - long number_of_symbols;
|
|
| 50 | - symbol_info info;
|
|
| 51 | - |
|
| 52 | - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
|
|
| 53 | - bfd_get_symbol_info(abfd,symbol_table[0],&info);
|
|
| 54 | - }
|
|
| 55 | - ]])],
|
|
| 56 | - [], dnl bfd seems to work
|
|
| 57 | - [AC_MSG_ERROR([can't use 'bfd' library])])
|
|
| 58 | - LIBS="$save_LIBS"
|
|
| 59 | -]) |
| ... | ... | @@ -872,110 +872,11 @@ const char *lookupGHCName( void *addr ) |
| 872 | 872 | * Symbol table loading
|
| 873 | 873 | * ------------------------------------------------------------------------*/
|
| 874 | 874 | |
| 875 | -/* Causing linking trouble on Win32 plats, so I'm
|
|
| 876 | - disabling this for now.
|
|
| 877 | -*/
|
|
| 878 | -#if defined(USING_LIBBFD)
|
|
| 879 | -# define PACKAGE 1
|
|
| 880 | -# define PACKAGE_VERSION 1
|
|
| 881 | -/* Those PACKAGE_* defines are workarounds for bfd:
|
|
| 882 | - * https://sourceware.org/bugzilla/show_bug.cgi?id=14243
|
|
| 883 | - * ghc's build system filter PACKAGE_* values out specifically to avoid clashes
|
|
| 884 | - * with user's autoconf-based Cabal packages.
|
|
| 885 | - * It's a shame <bfd.h> checks for unrelated fields instead of actually used
|
|
| 886 | - * macros.
|
|
| 887 | - */
|
|
| 888 | -# include <bfd.h>
|
|
| 889 | - |
|
| 890 | -/* Fairly ad-hoc piece of code that seems to filter out a lot of
|
|
| 891 | - * rubbish like the obj-splitting symbols
|
|
| 892 | - */
|
|
| 893 | - |
|
| 894 | -static bool isReal( flagword flags STG_UNUSED, const char *name )
|
|
| 895 | -{
|
|
| 896 | -#if 0
|
|
| 897 | - /* ToDo: make this work on BFD */
|
|
| 898 | - int tp = type & N_TYPE;
|
|
| 899 | - if (tp == N_TEXT || tp == N_DATA) {
|
|
| 900 | - return (name[0] == '_' && name[1] != '_');
|
|
| 901 | - } else {
|
|
| 902 | - return false;
|
|
| 903 | - }
|
|
| 904 | -#else
|
|
| 905 | - if (*name == '\0' ||
|
|
| 906 | - (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') ||
|
|
| 907 | - (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) {
|
|
| 908 | - return false;
|
|
| 909 | - }
|
|
| 910 | - return true;
|
|
| 911 | -#endif
|
|
| 912 | -}
|
|
| 913 | - |
|
| 914 | -extern void DEBUG_LoadSymbols( const char *name )
|
|
| 915 | -{
|
|
| 916 | - bfd* abfd;
|
|
| 917 | - char **matching;
|
|
| 918 | - |
|
| 919 | - bfd_init();
|
|
| 920 | - abfd = bfd_openr(name, "default");
|
|
| 921 | - if (abfd == NULL) {
|
|
| 922 | - barf("can't open executable %s to get symbol table", name);
|
|
| 923 | - }
|
|
| 924 | - if (!bfd_check_format_matches (abfd, bfd_object, &matching)) {
|
|
| 925 | - barf("mismatch");
|
|
| 926 | - }
|
|
| 927 | - |
|
| 928 | - {
|
|
| 929 | - long storage_needed;
|
|
| 930 | - asymbol **symbol_table;
|
|
| 931 | - long number_of_symbols;
|
|
| 932 | - long num_real_syms = 0;
|
|
| 933 | - long i;
|
|
| 934 | - |
|
| 935 | - storage_needed = bfd_get_symtab_upper_bound (abfd);
|
|
| 936 | - |
|
| 937 | - if (storage_needed < 0) {
|
|
| 938 | - barf("can't read symbol table");
|
|
| 939 | - }
|
|
| 940 | - symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols");
|
|
| 941 | - |
|
| 942 | - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
|
|
| 943 | - |
|
| 944 | - if (number_of_symbols < 0) {
|
|
| 945 | - barf("can't canonicalise symbol table");
|
|
| 946 | - }
|
|
| 947 | - |
|
| 948 | - if (add_to_fname_table == NULL)
|
|
| 949 | - add_to_fname_table = allocHashTable();
|
|
| 950 | - |
|
| 951 | - for( i = 0; i != number_of_symbols; ++i ) {
|
|
| 952 | - symbol_info info;
|
|
| 953 | - bfd_get_symbol_info(abfd,symbol_table[i],&info);
|
|
| 954 | - if (isReal(info.type, info.name)) {
|
|
| 955 | - insertHashTable(add_to_fname_table,
|
|
| 956 | - info.value, (void*)info.name);
|
|
| 957 | - num_real_syms += 1;
|
|
| 958 | - }
|
|
| 959 | - }
|
|
| 960 | - |
|
| 961 | - IF_DEBUG(interpreter,
|
|
| 962 | - debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n",
|
|
| 963 | - number_of_symbols, num_real_syms)
|
|
| 964 | - );
|
|
| 965 | - |
|
| 966 | - stgFree(symbol_table);
|
|
| 967 | - }
|
|
| 968 | -}
|
|
| 969 | - |
|
| 970 | -#else /* USING_LIBBFD */
|
|
| 971 | - |
|
| 972 | 875 | extern void DEBUG_LoadSymbols( const char *name STG_UNUSED )
|
| 973 | 876 | {
|
| 974 | 877 | /* nothing, yet */
|
| 975 | 878 | }
|
| 976 | 879 | |
| 977 | -#endif /* USING_LIBBFD */
|
|
| 978 | - |
|
| 979 | 880 | void findPtr(P_ p, int); /* keep gcc -Wall happy */
|
| 980 | 881 | |
| 981 | 882 | int searched = 0;
|
| ... | ... | @@ -171,8 +171,6 @@ AS_IF( |
| 171 | 171 | [test "$CABAL_FLAG_libm" = 1],
|
| 172 | 172 | [AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])])
|
| 173 | 173 | |
| 174 | -AS_IF([test "$CABAL_FLAG_libbfd" = 1], [FP_WHEN_ENABLED_BFD])
|
|
| 175 | - |
|
| 176 | 174 | dnl ################################################################
|
| 177 | 175 | dnl Check for libraries
|
| 178 | 176 | dnl ################################################################
|
| ... | ... | @@ -19,13 +19,6 @@ |
| 19 | 19 | #error TICKY_TICKY is incompatible with THREADED_RTS
|
| 20 | 20 | #endif
|
| 21 | 21 | |
| 22 | -/*
|
|
| 23 | - * Whether the runtime system will use libbfd for debugging purposes.
|
|
| 24 | - */
|
|
| 25 | -#if defined(DEBUG) && defined(HAVE_BFD_H) && defined(HAVE_LIBBFD) && !defined(_WIN32)
|
|
| 26 | -#define USING_LIBBFD 1
|
|
| 27 | -#endif
|
|
| 28 | - |
|
| 29 | 22 | /*
|
| 30 | 23 | * We previously only offer the eventlog in a subset of RTS ways; we now
|
| 31 | 24 | * enable it unconditionally to simplify packaging. See #18948.
|
| ... | ... | @@ -101,4 +94,3 @@ code. |
| 101 | 94 | #else
|
| 102 | 95 | #define CACHELINE_SIZE 64
|
| 103 | 96 | #endif |
| 104 | - |
| ... | ... | @@ -46,9 +46,6 @@ flag libffi-adjustors |
| 46 | 46 | flag need-pthread
|
| 47 | 47 | default: False
|
| 48 | 48 | manual: True
|
| 49 | -flag libbfd
|
|
| 50 | - default: False
|
|
| 51 | - manual: True
|
|
| 52 | 49 | flag need-atomic
|
| 53 | 50 | default: False
|
| 54 | 51 | manual: True
|
| ... | ... | @@ -250,9 +247,6 @@ library |
| 250 | 247 | if flag(need-atomic)
|
| 251 | 248 | -- for sub-word-sized atomic operations (#19119)
|
| 252 | 249 | extra-libraries: atomic
|
| 253 | - if flag(libbfd)
|
|
| 254 | - -- for debugging
|
|
| 255 | - extra-libraries: bfd iberty
|
|
| 256 | 250 | if flag(libdw)
|
| 257 | 251 | -- for backtraces
|
| 258 | 252 | extra-libraries: elf dw
|