diff --git a/aclocal.m4 b/aclocal.m4 index d19a66e79a846092ab21d474fb589f5e92eb5f10..6ca398659c2bd490940362044c0f48e11ee12f72 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -472,6 +472,7 @@ AC_DEFUN([FP_SETTINGS], SettingsDllWrapCommand="/bin/false" SettingsWindresCommand="/bin/false" SettingsLibtoolCommand="libtool" + SettingsReadElfCommand="$ReadElfCmd" SettingsTouchCommand='touch' fi if test -z "$LlcCmd" @@ -501,6 +502,7 @@ AC_DEFUN([FP_SETTINGS], AC_SUBST(SettingsDllWrapCommand) AC_SUBST(SettingsWindresCommand) AC_SUBST(SettingsLibtoolCommand) + AC_SUBST(SettingsReadElfCommand) AC_SUBST(SettingsTouchCommand) AC_SUBST(SettingsLlcCommand) AC_SUBST(SettingsOptCommand) @@ -2203,6 +2205,23 @@ AC_DEFUN([FIND_GCC],[ AC_SUBST($1) ]) +# FIND_READELF() +# -------------------------------- +# Finds which `readelf` to use. This is used in both in the top level +# `configure.ac` and in `distrib/configure.ac.in` +# +# $1 = the variable to set +# +AC_DEFUN([FIND_READELF],[ + if test "$HostOS" != "mingw32"; then + FP_ARG_WITH_PATH_GNU_PROG([READELF], [readelf], [readelf]) + if test -z "$READELF"; then + AC_MSG_ERROR([cannot identify readelf tool]) + fi + $1="$READELF" + fi +]) + AC_DEFUN([MAYBE_OVERRIDE_STAGE0],[ if test ! -z "$With_$1" -a "$CrossCompiling" != "YES"; then AC_MSG_NOTICE([Not cross-compiling, so --with-$1 also sets $2]) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 78370cf6920b956f866a5ef69ba34eaeab45ff6f..42ac14ee47bdcf4135516ee6f3d2bdeb3869ebe3 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -71,7 +71,7 @@ module DynFlags ( versionedAppDir, extraGccViaCFlags, systemPackageConfig, pgm_L, pgm_P, pgm_F, pgm_c, pgm_s, pgm_a, pgm_l, pgm_dll, pgm_T, - pgm_sysman, pgm_windres, pgm_libtool, pgm_lo, pgm_lc, + pgm_sysman, pgm_windres, pgm_libtool, pgm_readelf, pgm_lo, pgm_lc, opt_L, opt_P, opt_F, opt_c, opt_a, opt_l, opt_windres, opt_lo, opt_lc, @@ -935,6 +935,7 @@ data Settings = Settings { sPgm_sysman :: String, sPgm_windres :: String, sPgm_libtool :: String, + sPgm_readelf :: String, sPgm_lo :: (String,[Option]), -- LLVM: opt llvm optimiser sPgm_lc :: (String,[Option]), -- LLVM: llc static compiler -- options for particular phases @@ -995,6 +996,8 @@ pgm_windres :: DynFlags -> String pgm_windres dflags = sPgm_windres (settings dflags) pgm_libtool :: DynFlags -> String pgm_libtool dflags = sPgm_libtool (settings dflags) +pgm_readelf :: DynFlags -> String +pgm_readelf dflags = sPgm_readelf (settings dflags) pgm_lo :: DynFlags -> (String,[Option]) pgm_lo dflags = sPgm_lo (settings dflags) pgm_lc :: DynFlags -> (String,[Option]) @@ -2308,6 +2311,8 @@ dynamic_flags = [ (hasArg (\f -> alterSettings (\s -> s { sPgm_windres = f}))) , defFlag "pgmlibtool" (hasArg (\f -> alterSettings (\s -> s { sPgm_libtool = f}))) + , defFlag "pgmreadelf" + (hasArg (\f -> alterSettings (\s -> s { sPgm_readelf = f}))) -- need to appear before -optl/-opta to be parsed as LLVM flags. , defFlag "optlo" diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs index b3a540b7bfcfcbf802144176a7f26b6477f7484f..8c3ab1a834dc731e2bd47224a809c5646d9a6fa4 100644 --- a/compiler/main/SysTools.hs +++ b/compiler/main/SysTools.hs @@ -275,6 +275,7 @@ initSysTools mbMinusB windres_path <- getSetting "windres command" libtool_path <- getSetting "libtool command" + readelf_path <- getSetting "readelf command" tmpdir <- getTemporaryDirectory @@ -346,6 +347,7 @@ initSysTools mbMinusB sPgm_sysman = top_dir ++ "/ghc/rts/parallel/SysMan", sPgm_windres = windres_path, sPgm_libtool = libtool_path, + sPgm_readelf = readelf_path, sPgm_lo = (lo_prog,[]), sPgm_lc = (lc_prog,[]), -- Hans: this isn't right in general, but you can @@ -1048,9 +1050,9 @@ copyWithHeader dflags purpose maybe_header from to = do -- | read the contents of the named section in an ELF object as a -- String. readElfSection :: DynFlags -> String -> FilePath -> IO (Maybe String) -readElfSection _dflags section exe = do +readElfSection dflags section exe = do let - prog = "readelf" + prog = pgm_readelf dflags args = [Option "-p", Option section, FileOption "" exe] -- r <- readProcessEnvWithExitCode prog (filter notNull (map showOpt args)) diff --git a/configure.ac b/configure.ac index b41a81094ca809d7aa3a7f8956fe191b17ddab2f..5b94d0702131bbf398c696eb0380d48da3d3454a 100644 --- a/configure.ac +++ b/configure.ac @@ -532,6 +532,11 @@ FP_ARG_WITH_PATH_GNU_PROG([RANLIB], [ranlib], [ranlib]) RanlibCmd="$RANLIB" RANLIB="$RanlibCmd" +dnl ** Which readelf to use? +dnl -------------------------------------------------------------- +FIND_READELF([ReadElfCmd]) +AC_SUBST([ReadElfCmd]) + # Note: we may not have objdump on OS X, and we only need it on Windows (for DLL checks) case $HostOS_CPP in diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in index 0fcd869491ea76d4aac304ce25217e91f10f9870..f1abd916cb24abe0975151468986797650e12033 100644 --- a/distrib/configure.ac.in +++ b/distrib/configure.ac.in @@ -139,6 +139,11 @@ dnl ** how to invoke `ar' and `ranlib' FP_PROG_AR_SUPPORTS_ATFILE FP_PROG_AR_NEEDS_RANLIB +dnl ** Which readelf to use? +dnl -------------------------------------------------------------- +FIND_READELF([ReadElfCmd]) +AC_SUBST([ReadElfCmd]) + FP_SETTINGS # diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml index f019854c1f90579b743df19c64f2e6daa76ffbc5..b4a76ffb371e68012391407b86481e1924a045e9 100644 --- a/docs/users_guide/flags.xml +++ b/docs/users_guide/flags.xml @@ -2780,6 +2780,13 @@ <entry>dynamic</entry> <entry>-</entry> </row> + <row> + <entry><option>-pgmreadelf</option> <replaceable>cmd</replaceable></entry> + <entry>Use <replaceable>cmd</replaceable> as the command for readelf + (part of Unix binutils)</entry> + <entry>dynamic</entry> + <entry>-</entry> + </row> </tbody> </tgroup> </informaltable> diff --git a/docs/users_guide/phases.xml b/docs/users_guide/phases.xml index 8994ffe72e747ec5441236c7763f1b626f145f14..3b7403b9ca38a11815e7a056212d65397149da07 100644 --- a/docs/users_guide/phases.xml +++ b/docs/users_guide/phases.xml @@ -148,6 +148,17 @@ (when using <option>-staticlib</option> only).</para> </listitem> </varlistentry> + + <varlistentry> + <term> + <option>-pgmreadelf</option> <replaceable>cmd</replaceable> + <indexterm><primary><option>-pgmreadelf</option></primary></indexterm> + </term> + <listitem> + <para>Use <replaceable>cmd</replaceable> as the readelf command + (part of Unix binutils).</para> + </listitem> + </varlistentry> </variablelist> </sect2> diff --git a/settings.in b/settings.in index e8cdad34f840a61af41814d851b97cd8066288ee..5f54fd99d772b9c85dd23b12aae80757631a2223 100644 --- a/settings.in +++ b/settings.in @@ -17,6 +17,7 @@ ("dllwrap command", "@SettingsDllWrapCommand@"), ("windres command", "@SettingsWindresCommand@"), ("libtool command", "@SettingsLibtoolCommand@"), + ("readelf command", "@SettingsReadElfCommand@"), ("perl command", "@SettingsPerlCommand@"), ("cross compiling", "@CrossCompiling@"), ("target os", "@HaskellTargetOs@"),