This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] ld: Override default linker emulation at configure time


This commit adds a new configure option for ld that allows the default
linker emulation to be selected at configure time.  The new option is:

    --with-default-linker-emulation=NAME

where NAME is the name of a linker emulation that would otherwise be
valid for this target (as you'd pass to ld -mNAME).  The validity of
NAME is checked at configure time.

The effect of this configure option is to make NAME the new default
linker emulation.  The old default is still available in the list of
alternative emulations and can be selected with the -m option to ld.

If this new option is not used at configure time then the linker should
be unchanged.

I tested that for a couple of targets, NOT supplying the configure
option gives the same linker script as before, that supplying an
invalid emulation name gives a configure error, and that supplying a
valid emulation does change the linker script as expected.

ld/ChangeLog:

	* configure.ac: Add option --with-default-linker-emulation.
	* configure: Regenerate
	* NEWS: Add mention of new option.
---
 ld/ChangeLog    |  6 ++++++
 ld/NEWS         |  4 ++++
 ld/configure    | 39 +++++++++++++++++++++++++++++++++++++--
 ld/configure.ac | 28 ++++++++++++++++++++++++++++
 4 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/ld/NEWS b/ld/NEWS
index d43f846..7254e39 100644
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -2,6 +2,10 @@
 
 * Add support for the Texas Instruments PRU processor.
 
+* Add new configure option --with-default-linker-emulation=NAME, where NAME is
+  a valid linker emulation for the target being configured.  This allows the
+  default linker emulation to be overridden at configure time.
+
 Changes in 2.28:
 
 * The EXCLUDE_FILE linker script construct can now be applied outside of the
diff --git a/ld/configure b/ld/configure
index c238f54..3914564 100755
--- a/ld/configure
+++ b/ld/configure
@@ -793,6 +793,7 @@ enable_werror
 enable_build_warnings
 enable_nls
 enable_initfini_array
+with_default_linker_emulation
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1461,6 +1462,8 @@ Optional Packages:
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-lib-path=dir1:dir2...  set default LIB_PATH
   --with-sysroot=DIR Search for usr/lib et al within DIR.
+  --with-default-linker-emulation=NAME
+                          override default linker emulation
 
 Some influential environment variables:
   CC          C compiler command
@@ -11720,7 +11723,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11723 "configure"
+#line 11726 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11826,7 +11829,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11829 "configure"
+#line 11832 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17205,6 +17208,38 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+# Provide a configure time option to override the default linker
+# emulation.  The new default must be one of the valid emulations, and
+# the old default will be added to the list of available alternatives.
+
+# Check whether --with-default_linker_emulation was given.
+if test "${with_default_linker_emulation+set}" = set; then :
+  withval=$with_default_linker_emulation; # Action if present
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker emulation override is valid" >&5
+$as_echo_n "checking linker emulation override is valid... " >&6; }
+  ac_override_default_emulation=unset
+  if test "x$withval" != "x$EMUL"; then
+    # Not the current default, check against other known emulations
+    ac_override_extra_emuls=$EMUL
+    for i in $targ_extra_emuls; do
+       if test "x$withval" = "x$i"; then
+          ac_override_default_emulation=$withval
+       else
+          ac_override_extra_emuls="$ac_override_extra_emuls $i"
+       fi
+    done
+    if test "x$ac_override_default_emulation" = "xunset"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+      as_fn_error "unknown linker emulation '${withval}' known emulations are ${EMUL} ${targ_extra_emuls}" "$LINENO" 5
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    targ_extra_emuls=$ac_override_extra_emuls
+    EMUL=$ac_override_default_emulation
+  fi
+fi
+
 
 
 
diff --git a/ld/configure.ac b/ld/configure.ac
index fe8eff6..317e3e8 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -390,6 +390,34 @@ AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_RELRO,
   $ac_default_ld_z_relro,
   [Define to 1 if you want to enable -z relro in ELF linker by default.])
 
+# Provide a configure time option to override the default linker
+# emulation.  The new default must be one of the valid emulations, and
+# the old default will be added to the list of available alternatives.
+AC_ARG_WITH(default_linker_emulation,
+	      AS_HELP_STRING([--with-default-linker-emulation=NAME],
+	      [override default linker emulation]),
+              # Action if present
+  AC_MSG_CHECKING(linker emulation override is valid)
+  ac_override_default_emulation=unset
+  if test "x$withval" != "x$EMUL"; then
+    # Not the current default, check against other known emulations
+    ac_override_extra_emuls=$EMUL
+    for i in $targ_extra_emuls; do
+       if test "x$withval" = "x$i"; then
+          ac_override_default_emulation=$withval
+       else
+          ac_override_extra_emuls="$ac_override_extra_emuls $i"
+       fi
+    done
+    if test "x$ac_override_default_emulation" = "xunset"; then
+      AC_MSG_RESULT(no)
+      AC_MSG_ERROR(unknown linker emulation '${withval}' known emulations are ${EMUL} ${targ_extra_emuls})
+    fi
+    AC_MSG_RESULT(yes)
+    targ_extra_emuls=$ac_override_extra_emuls
+    EMUL=$ac_override_default_emulation
+  fi)dnl
+
 AC_SUBST(elf_list_options)
 AC_SUBST(elf_shlib_list_options)
 AC_SUBST(elf_plt_unwind_list_options)
-- 
2.5.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]