public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add ld_list_options
@ 2015-04-07 17:17 H.J. Lu
  2015-04-08  1:06 ` Alan Modra
  2015-04-08 16:16 ` Steve Ellcey
  0 siblings, 2 replies; 11+ messages in thread
From: H.J. Lu @ 2015-04-07 17:17 UTC (permalink / raw)
  To: binutils

This patch adds ld_list_options for ELF targets to avoid duplicated
outputs from ld --help.  Any comments, suggestions or objections?

H.J.
--
	* Makefile.am (ELF_CLFAGS): New.
	(AM_CFLAGS): Add $(ELF_CLFAGS).
	* configure.ac (elf_list_options): New.  AC_SUBST.
	(elf_shlib_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	* lexsup.c (elf_shlib_list_options): New.
	(elf_static_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	(ld_list_options): Likewise.
	(help): Call ld_list_options.
	* Makefile.in: Regenerated.
	* configure: Likewise.
	* emulparams/plt_unwind.sh (PLT_UNWIND): New.
	(PARSE_AND_LIST_OPTIONS): Removed.
	* emultempl/elf32.em (gld_list_options): New.
	(gld${EMULATION_NAME}_list_options): Define only if BNDPLT or
	PARSE_AND_LIST_OPTIONS is defined.
	(ld_${EMULATION_NAME}_emulation): Replace
	gld${EMULATION_NAME}_list_options with ${gld_list_options.
---
 ld/Makefile.am              |   5 +-
 ld/Makefile.in              |   9 +++-
 ld/configure                |  28 ++++++++--
 ld/configure.ac             |  21 +++++++-
 ld/emulparams/plt_unwind.sh |   9 +---
 ld/emultempl/elf32.em       | 112 +++-------------------------------------
 ld/lexsup.c                 | 122 ++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 187 insertions(+), 119 deletions(-)

diff --git a/ld/Makefile.am b/ld/Makefile.am
index 80c7487..99e6fb1 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -34,9 +34,12 @@ LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo @LEX@; fi`
 am__skiplex =
 am__skipyacc =
 
+ELF_CLFAGS=-DELF_LIST_OPTIONS=@elf_list_options@ \
+	   -DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
+	   -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@
 WARN_CFLAGS = @WARN_CFLAGS@
 NO_WERROR = @NO_WERROR@
-AM_CFLAGS = $(WARN_CFLAGS)
+AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
 
 # Conditionally enable the plugin interface.
 if ENABLE_PLUGINS
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 81159cb..bc874f1 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -344,6 +344,9 @@ datarootdir = @datarootdir@
 do_compare = @do_compare@
 docdir = @docdir@
 dvidir = @dvidir@
+elf_list_options = @elf_list_options@
+elf_plt_unwind_list_options = @elf_plt_unwind_list_options@
+elf_shlib_list_options = @elf_shlib_list_options@
 enable_initfini_array = @enable_initfini_array@
 exec_prefix = @exec_prefix@
 host = @host@
@@ -391,7 +394,11 @@ tooldir = $(exec_prefix)/$(target_alias)
 # maintainer mode is disabled.  Avoid this.
 am__skiplex = 
 am__skipyacc = 
-AM_CFLAGS = $(WARN_CFLAGS)
+ELF_CLFAGS = -DELF_LIST_OPTIONS=@elf_list_options@ \
+	   -DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
+	   -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@
+
+AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
 @ENABLE_PLUGINS_FALSE@PLUGIN_C = 
 
 # Conditionally enable the plugin interface.
diff --git a/ld/configure b/ld/configure
index 4a312df..44bce0e 100755
--- a/ld/configure
+++ b/ld/configure
@@ -608,6 +608,9 @@ LIB_PATH
 EMUL_EXTRA_OFILES
 EMULATION_OFILES
 EMUL
+elf_plt_unwind_list_options
+elf_shlib_list_options
+elf_list_options
 STRINGIFY
 enable_initfini_array
 ENABLE_PLUGINS_FALSE
@@ -11710,7 +11713,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11713 "configure"
+#line 11716 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11816,7 +11819,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11819 "configure"
+#line 11822 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17025,6 +17028,9 @@ _ACEOF
   fi
 fi
 
+elf_list_options=FALSE
+elf_shlib_list_options=FALSE
+elf_plt_unwind_list_options=FALSE
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
   if test "$targ_alias" = "all"; then
@@ -17055,7 +17061,20 @@ do
 
     for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
 	case " $all_emuls " in
-	*" e${i}.o "*) ;;
+	*" e${i}.o "*)
+	  case "${i}" in
+	  *elf*)
+	    elf_list_options=TRUE
+	    . ${srcdir}/emulparams/${i}.sh
+	    if test x${GENERATE_SHLIB_SCRIPT} = xyes; then
+	      elf_shlib_list_options=TRUE
+	    fi
+	    if test x${PLT_UNWIND} = xyes; then
+	      elf_plt_unwind_list_options=TRUE
+	    fi
+	    ;;
+	  esac
+	  ;;
 	*)
 	  all_emuls="$all_emuls e${i}.o"
 	  eval result=\$tdir_$i
@@ -17092,6 +17111,9 @@ done
 
 
 
+
+
+
 TDIRS=tdirs
 
 
diff --git a/ld/configure.ac b/ld/configure.ac
index a885b7b..572440c 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -281,6 +281,9 @@ if test x${want64} = xfalse; then
   fi
 fi
 
+elf_list_options=FALSE
+elf_shlib_list_options=FALSE
+elf_plt_unwind_list_options=FALSE
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
   if test "$targ_alias" = "all"; then
@@ -311,7 +314,20 @@ do
 
     for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
 	case " $all_emuls " in
-	*" e${i}.o "*) ;;
+	*" e${i}.o "*)
+	  case "${i}" in
+	  *elf*)
+	    elf_list_options=TRUE
+	    . ${srcdir}/emulparams/${i}.sh
+	    if test x${GENERATE_SHLIB_SCRIPT} = xyes; then
+	      elf_shlib_list_options=TRUE
+	    fi
+	    if test x${PLT_UNWIND} = xyes; then
+	      elf_plt_unwind_list_options=TRUE
+	    fi
+	    ;;
+	  esac
+	  ;;
 	*)
 	  all_emuls="$all_emuls e${i}.o"
 	  eval result=\$tdir_$i
@@ -346,6 +362,9 @@ do
   fi
 done
 
+AC_SUBST(elf_list_options)
+AC_SUBST(elf_shlib_list_options)
+AC_SUBST(elf_plt_unwind_list_options)
 AC_SUBST(EMUL)
 
 TDIRS=tdirs
diff --git a/ld/emulparams/plt_unwind.sh b/ld/emulparams/plt_unwind.sh
index c832570..38d7668 100644
--- a/ld/emulparams/plt_unwind.sh
+++ b/ld/emulparams/plt_unwind.sh
@@ -1,3 +1,5 @@
+PLT_UNWIND=yes
+
 PARSE_AND_LIST_PROLOGUE='
 #define OPTION_LD_GENERATED_UNWIND_INFO	301
 #define OPTION_NO_LD_GENERATED_UNWIND_INFO 302
@@ -10,13 +12,6 @@ PARSE_AND_LIST_LONGOPTS='
    OPTION_NO_LD_GENERATED_UNWIND_INFO},
 '
 
-PARSE_AND_LIST_OPTIONS='
-  fprintf (file, _("\
-  --ld-generated-unwind-info  Generate exception handling info for PLT.\n\
-  --no-ld-generated-unwind-info Don'\''t do so.\n"
-		   ));
-'
-
 PARSE_AND_LIST_ARGS_CASES='
     case OPTION_LD_GENERATED_UNWIND_INFO:
       link_info.no_ld_generated_unwind_info = FALSE;
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 4dd71ab..dc643b6 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -2366,117 +2366,14 @@ fragment <<EOF
 EOF
 
 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
+gld_list_options="gld${EMULATION_NAME}_list_options"
+if test -n "$PARSE_AND_LIST_OPTIONS" || test x"$BNDPLT" = xyes; then
 fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_list_options (FILE * file)
 {
 EOF
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  --audit=AUDITLIB            Specify a library to use for auditing\n"));
-  fprintf (file, _("\
-  -Bgroup                     Selects group name lookup rules for DSO\n"));
-EOF
-fi
-fragment <<EOF
-  fprintf (file, _("\
-  --build-id[=STYLE]          Generate build ID note\n"));
-EOF
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  -P AUDITLIB, --depaudit=AUDITLIB\n" "\
-			      Specify a library to use for auditing dependencies\n"));
-  fprintf (file, _("\
-  --disable-new-dtags         Disable new dynamic tags\n"));
-  fprintf (file, _("\
-  --enable-new-dtags          Enable new dynamic tags\n"));
-  fprintf (file, _("\
-  --eh-frame-hdr              Create .eh_frame_hdr section\n"));
-  fprintf (file, _("\
-  --exclude-libs=LIBS         Make all symbols in LIBS hidden\n"));
-  fprintf (file, _("\
-  --hash-style=STYLE          Set hash style to sysv, gnu or both\n"));
-  fprintf (file, _("\
-  -z combreloc                Merge dynamic relocs into one section and sort\n"));
-EOF
-fi
-
-fragment <<EOF
-  fprintf (file, _("\
-  -z common-page-size=SIZE    Set common page size to SIZE\n"));
-  fprintf (file, _("\
-  -z defs                     Report unresolved symbols in object files.\n"));
-  fprintf (file, _("\
-  -z execstack                Mark executable as requiring executable stack\n"));
-EOF
-
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  -z global                   Make symbols in DSO available for subsequently\n\
-			       loaded objects\n"));
-  fprintf (file, _("\
-  -z initfirst                Mark DSO to be initialized first at runtime\n"));
-  fprintf (file, _("\
-  -z interpose                Mark object to interpose all DSOs but executable\n"));
-  fprintf (file, _("\
-  -z lazy                     Mark object lazy runtime binding (default)\n"));
-  fprintf (file, _("\
-  -z loadfltr                 Mark object requiring immediate process\n"));
-EOF
-fi
-
-fragment <<EOF
-  fprintf (file, _("\
-  -z max-page-size=SIZE       Set maximum page size to SIZE\n"));
-  fprintf (file, _("\
-  -z muldefs                  Allow multiple definitions\n"));
-EOF
-
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  -z nocombreloc              Don't merge dynamic relocs into one section\n"));
-  fprintf (file, _("\
-  -z nocopyreloc              Don't create copy relocs\n"));
-  fprintf (file, _("\
-  -z nodefaultlib             Mark object not to use default search paths\n"));
-  fprintf (file, _("\
-  -z nodelete                 Mark DSO non-deletable at runtime\n"));
-  fprintf (file, _("\
-  -z nodlopen                 Mark DSO not available to dlopen\n"));
-  fprintf (file, _("\
-  -z nodump                   Mark DSO not available to dldump\n"));
-EOF
-fi
-fragment <<EOF
-  fprintf (file, _("\
-  -z noexecstack              Mark executable as not requiring executable stack\n"));
-EOF
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  -z text                     Treat DT_TEXTREL in shared object as error\n"));
-  fprintf (file, _("\
-  -z notext                   Don't treat DT_TEXTREL in shared object as error\n"));
-  fprintf (file, _("\
-  -z textoff                  Don't treat DT_TEXTREL in shared object as error\n"));
-  fprintf (file, _("\
-  -z norelro                  Don't create RELRO program header\n"));
-  fprintf (file, _("\
-  -z now                      Mark object non-lazy runtime binding\n"));
-  fprintf (file, _("\
-  -z origin                   Mark object requiring immediate \$ORIGIN\n\
-				processing at runtime\n"));
-  fprintf (file, _("\
-  -z relro                    Create RELRO program header\n"));
-  fprintf (file, _("\
-  -z stacksize=SIZE           Set size of stack segment\n"));
-EOF
-fi
 
 if test x"$BNDPLT" = xyes; then
 fragment <<EOF
@@ -2494,6 +2391,9 @@ fi
 fragment <<EOF
 }
 EOF
+else
+  gld_list_options="NULL"
+fi
 
 if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
 fragment <<EOF
@@ -2527,7 +2427,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   gld${EMULATION_NAME}_add_options,
   gld${EMULATION_NAME}_handle_option,
   ${LDEMUL_UNRECOGNIZED_FILE-NULL},
-  ${LDEMUL_LIST_OPTIONS-gld${EMULATION_NAME}_list_options},
+  ${LDEMUL_LIST_OPTIONS-${gld_list_options}},
   ${LDEMUL_RECOGNIZED_FILE-gld${EMULATION_NAME}_load_symbols},
   ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
   ${LDEMUL_NEW_VERS_PATTERN-NULL},
diff --git a/ld/lexsup.c b/ld/lexsup.c
index a30fafa..ce415b9 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -1652,6 +1652,126 @@ set_segment_start (const char *section, char *valstr)
   lang_section_start (section, exp_intop (val), seg);
 }
 
+static void
+elf_shlib_list_options (FILE *file)
+{
+  static bfd_boolean done;
+  if (done)
+    return;
+  done = TRUE;
+
+  fprintf (file, _("\
+  --audit=AUDITLIB            Specify a library to use for auditing\n"));
+  fprintf (file, _("\
+  -Bgroup                     Selects group name lookup rules for DSO\n"));
+  fprintf (file, _("\
+  --disable-new-dtags         Disable new dynamic tags\n"));
+  fprintf (file, _("\
+  --enable-new-dtags          Enable new dynamic tags\n"));
+  fprintf (file, _("\
+  --eh-frame-hdr              Create .eh_frame_hdr section\n"));
+  fprintf (file, _("\
+  --exclude-libs=LIBS         Make all symbols in LIBS hidden\n"));
+  fprintf (file, _("\
+  --hash-style=STYLE          Set hash style to sysv, gnu or both\n"));
+  fprintf (file, _("\
+  -P AUDITLIB, --depaudit=AUDITLIB\n" "\
+			      Specify a library to use for auditing dependencies\n"));
+  fprintf (file, _("\
+  -z combreloc                Merge dynamic relocs into one section and sort\n"));
+  fprintf (file, _("\
+  -z nocombreloc              Don't merge dynamic relocs into one section\n"));
+  fprintf (file, _("\
+  -z global                   Make symbols in DSO available for subsequently\n\
+			       loaded objects\n"));
+  fprintf (file, _("\
+  -z initfirst                Mark DSO to be initialized first at runtime\n"));
+  fprintf (file, _("\
+  -z interpose                Mark object to interpose all DSOs but executable\n"));
+  fprintf (file, _("\
+  -z lazy                     Mark object lazy runtime binding (default)\n"));
+  fprintf (file, _("\
+  -z loadfltr                 Mark object requiring immediate process\n"));
+  fprintf (file, _("\
+  -z nocopyreloc              Don't create copy relocs\n"));
+  fprintf (file, _("\
+  -z nodefaultlib             Mark object not to use default search paths\n"));
+  fprintf (file, _("\
+  -z nodelete                 Mark DSO non-deletable at runtime\n"));
+  fprintf (file, _("\
+  -z nodlopen                 Mark DSO not available to dlopen\n"));
+  fprintf (file, _("\
+  -z nodump                   Mark DSO not available to dldump\n"));
+  fprintf (file, _("\
+  -z now                      Mark object non-lazy runtime binding\n"));
+  fprintf (file, _("\
+  -z origin                   Mark object requiring immediate $ORIGIN\n\
+				processing at runtime\n"));
+  fprintf (file, _("\
+  -z relro                    Create RELRO program header\n"));
+  fprintf (file, _("\
+  -z norelro                  Don't create RELRO program header\n"));
+  fprintf (file, _("\
+  -z stacksize=SIZE           Set size of stack segment\n"));
+  fprintf (file, _("\
+  -z text                     Treat DT_TEXTREL in shared object as error\n"));
+  fprintf (file, _("\
+  -z notext                   Don't treat DT_TEXTREL in shared object as error\n"));
+  fprintf (file, _("\
+  -z textoff                  Don't treat DT_TEXTREL in shared object as error\n"));
+}
+
+static void
+elf_static_list_options (FILE *file)
+{
+  static bfd_boolean done;
+  if (done)
+    return;
+  done = TRUE;
+
+  fprintf (file, _("\
+  --build-id[=STYLE]          Generate build ID note\n"));
+  fprintf (file, _("\
+  -z common-page-size=SIZE    Set common page size to SIZE\n"));
+  fprintf (file, _("\
+  -z max-page-size=SIZE       Set maximum page size to SIZE\n"));
+  fprintf (file, _("\
+  -z defs                     Report unresolved symbols in object files.\n"));
+  fprintf (file, _("\
+  -z muldefs                  Allow multiple definitions\n"));
+  fprintf (file, _("\
+  -z execstack                Mark executable as requiring executable stack\n"));
+  fprintf (file, _("\
+  -z noexecstack              Mark executable as not requiring executable stack\n"));
+}
+
+static void
+elf_plt_unwind_list_options (FILE *file)
+{
+  static bfd_boolean done;
+  if (done)
+    return;
+  done = TRUE;
+
+  fprintf (file, _("\
+  --ld-generated-unwind-info  Generate exception handling info for PLT\n\
+  --no-ld-generated-unwind-info\n\
+                              Don't generate exception handling info for PLT\n"));
+}
+
+static void
+ld_list_options (FILE *file, bfd_boolean elf, bfd_boolean shlib,
+		 bfd_boolean plt_unwind)
+{
+  if (!elf)
+    return;
+  if (plt_unwind)
+    elf_plt_unwind_list_options (file);
+  elf_static_list_options (file);
+  if (shlib)
+    elf_shlib_list_options (file);
+}
+
 \f
 /* Print help messages for the options.  */
 
@@ -1764,6 +1884,8 @@ help (void)
 
   /* xgettext:c-format */
   printf (_("%s: emulation specific options:\n"), program_name);
+  ld_list_options (stdout, ELF_LIST_OPTIONS, ELF_SHLIB_LIST_OPTIONS,
+		   ELF_PLT_UNWIND_LIST_OPTIONS);
   ldemul_list_emulation_options (stdout);
   printf ("\n");
 
-- 
1.9.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Add ld_list_options
  2015-04-07 17:17 [PATCH] Add ld_list_options H.J. Lu
@ 2015-04-08  1:06 ` Alan Modra
  2015-04-08 11:57   ` H.J. Lu
  2015-04-08 16:16 ` Steve Ellcey
  1 sibling, 1 reply; 11+ messages in thread
From: Alan Modra @ 2015-04-08  1:06 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

On Tue, Apr 07, 2015 at 10:12:57AM -0700, H.J. Lu wrote:
> This patch adds ld_list_options for ELF targets to avoid duplicated
> outputs from ld --help.  Any comments, suggestions or objections?

I like the idea.  Perhaps add a heading "ELF emulations:" or something
like that?

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Add ld_list_options
  2015-04-08  1:06 ` Alan Modra
@ 2015-04-08 11:57   ` H.J. Lu
  0 siblings, 0 replies; 11+ messages in thread
From: H.J. Lu @ 2015-04-08 11:57 UTC (permalink / raw)
  To: Binutils

[-- Attachment #1: Type: text/plain, Size: 410 bytes --]

On Tue, Apr 7, 2015 at 6:05 PM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Apr 07, 2015 at 10:12:57AM -0700, H.J. Lu wrote:
>> This patch adds ld_list_options for ELF targets to avoid duplicated
>> outputs from ld --help.  Any comments, suggestions or objections?
>
> I like the idea.  Perhaps add a heading "ELF emulations:" or something
> like that?

Done.  This is what I checked in.

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-Add-ld_list_options.patch --]
[-- Type: text/x-patch, Size: 17443 bytes --]

From c58212eaf957ef39484ed71316074fd8366e9c4a Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 8 Apr 2015 04:55:07 -0700
Subject: [PATCH] Add ld_list_options

This patch adds ld_list_options for ELF targets to avoid duplicated
outputs from ld --help.

	* Makefile.am (ELF_CLFAGS): New.
	(AM_CFLAGS): Add $(ELF_CLFAGS).
	* configure.ac (elf_list_options): New.  AC_SUBST.
	(elf_shlib_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	* lexsup.c (elf_shlib_list_options): New.
	(elf_static_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	(ld_list_options): Likewise.
	(help): Call ld_list_options.
	* Makefile.in: Regenerated.
	* configure: Likewise.
	* emulparams/plt_unwind.sh (PLT_UNWIND): New.
	(PARSE_AND_LIST_OPTIONS): Removed.
	* emultempl/elf32.em (gld_list_options): New.
	(gld${EMULATION_NAME}_list_options): Define only if BNDPLT or
	PARSE_AND_LIST_OPTIONS is defined.
	(ld_${EMULATION_NAME}_emulation): Replace
	gld${EMULATION_NAME}_list_options with ${gld_list_options.
---
 ld/ChangeLog                |  22 +++++++++
 ld/Makefile.am              |   5 +-
 ld/Makefile.in              |   9 +++-
 ld/configure                |  28 +++++++++--
 ld/configure.ac             |  21 ++++++++-
 ld/emulparams/plt_unwind.sh |   9 +---
 ld/emultempl/elf32.em       | 112 +++-----------------------------------------
 ld/lexsup.c                 | 108 ++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 195 insertions(+), 119 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 4228732..a76dcb3 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,25 @@
+2015-04-08  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* Makefile.am (ELF_CLFAGS): New.
+	(AM_CFLAGS): Add $(ELF_CLFAGS).
+	* configure.ac (elf_list_options): New.  AC_SUBST.
+	(elf_shlib_list_options): Likewise.
+	(elf_plt_unwind_list_options): Likewise.
+	* lexsup.c (elf_shlib_list_options): New.
+	(elf_static_list_options): Likewise.
+	(elf_plt_unwind_list_options): Likewise.
+	(ld_list_options): Likewise.
+	(help): Call ld_list_options.
+	* Makefile.in: Regenerated.
+	* configure: Likewise.
+	* emulparams/plt_unwind.sh (PLT_UNWIND): New.
+	(PARSE_AND_LIST_OPTIONS): Removed.
+	* emultempl/elf32.em (gld_list_options): New.
+	(gld${EMULATION_NAME}_list_options): Define only if BNDPLT or
+	PARSE_AND_LIST_OPTIONS is defined.
+	(ld_${EMULATION_NAME}_emulation): Replace
+	gld${EMULATION_NAME}_list_options with ${gld_list_options.
+
 2015-04-07  Alan Modra  <amodra@gmail.com>
 
 	PR ld/18176
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 80c7487..99e6fb1 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -34,9 +34,12 @@ LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo @LEX@; fi`
 am__skiplex =
 am__skipyacc =
 
+ELF_CLFAGS=-DELF_LIST_OPTIONS=@elf_list_options@ \
+	   -DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
+	   -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@
 WARN_CFLAGS = @WARN_CFLAGS@
 NO_WERROR = @NO_WERROR@
-AM_CFLAGS = $(WARN_CFLAGS)
+AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
 
 # Conditionally enable the plugin interface.
 if ENABLE_PLUGINS
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 81159cb..bc874f1 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -344,6 +344,9 @@ datarootdir = @datarootdir@
 do_compare = @do_compare@
 docdir = @docdir@
 dvidir = @dvidir@
+elf_list_options = @elf_list_options@
+elf_plt_unwind_list_options = @elf_plt_unwind_list_options@
+elf_shlib_list_options = @elf_shlib_list_options@
 enable_initfini_array = @enable_initfini_array@
 exec_prefix = @exec_prefix@
 host = @host@
@@ -391,7 +394,11 @@ tooldir = $(exec_prefix)/$(target_alias)
 # maintainer mode is disabled.  Avoid this.
 am__skiplex = 
 am__skipyacc = 
-AM_CFLAGS = $(WARN_CFLAGS)
+ELF_CLFAGS = -DELF_LIST_OPTIONS=@elf_list_options@ \
+	   -DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
+	   -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@
+
+AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
 @ENABLE_PLUGINS_FALSE@PLUGIN_C = 
 
 # Conditionally enable the plugin interface.
diff --git a/ld/configure b/ld/configure
index 4a312df..44bce0e 100755
--- a/ld/configure
+++ b/ld/configure
@@ -608,6 +608,9 @@ LIB_PATH
 EMUL_EXTRA_OFILES
 EMULATION_OFILES
 EMUL
+elf_plt_unwind_list_options
+elf_shlib_list_options
+elf_list_options
 STRINGIFY
 enable_initfini_array
 ENABLE_PLUGINS_FALSE
@@ -11710,7 +11713,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11713 "configure"
+#line 11716 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11816,7 +11819,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11819 "configure"
+#line 11822 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17025,6 +17028,9 @@ _ACEOF
   fi
 fi
 
+elf_list_options=FALSE
+elf_shlib_list_options=FALSE
+elf_plt_unwind_list_options=FALSE
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
   if test "$targ_alias" = "all"; then
@@ -17055,7 +17061,20 @@ do
 
     for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
 	case " $all_emuls " in
-	*" e${i}.o "*) ;;
+	*" e${i}.o "*)
+	  case "${i}" in
+	  *elf*)
+	    elf_list_options=TRUE
+	    . ${srcdir}/emulparams/${i}.sh
+	    if test x${GENERATE_SHLIB_SCRIPT} = xyes; then
+	      elf_shlib_list_options=TRUE
+	    fi
+	    if test x${PLT_UNWIND} = xyes; then
+	      elf_plt_unwind_list_options=TRUE
+	    fi
+	    ;;
+	  esac
+	  ;;
 	*)
 	  all_emuls="$all_emuls e${i}.o"
 	  eval result=\$tdir_$i
@@ -17092,6 +17111,9 @@ done
 
 
 
+
+
+
 TDIRS=tdirs
 
 
diff --git a/ld/configure.ac b/ld/configure.ac
index a885b7b..572440c 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -281,6 +281,9 @@ if test x${want64} = xfalse; then
   fi
 fi
 
+elf_list_options=FALSE
+elf_shlib_list_options=FALSE
+elf_plt_unwind_list_options=FALSE
 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
   if test "$targ_alias" = "all"; then
@@ -311,7 +314,20 @@ do
 
     for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
 	case " $all_emuls " in
-	*" e${i}.o "*) ;;
+	*" e${i}.o "*)
+	  case "${i}" in
+	  *elf*)
+	    elf_list_options=TRUE
+	    . ${srcdir}/emulparams/${i}.sh
+	    if test x${GENERATE_SHLIB_SCRIPT} = xyes; then
+	      elf_shlib_list_options=TRUE
+	    fi
+	    if test x${PLT_UNWIND} = xyes; then
+	      elf_plt_unwind_list_options=TRUE
+	    fi
+	    ;;
+	  esac
+	  ;;
 	*)
 	  all_emuls="$all_emuls e${i}.o"
 	  eval result=\$tdir_$i
@@ -346,6 +362,9 @@ do
   fi
 done
 
+AC_SUBST(elf_list_options)
+AC_SUBST(elf_shlib_list_options)
+AC_SUBST(elf_plt_unwind_list_options)
 AC_SUBST(EMUL)
 
 TDIRS=tdirs
diff --git a/ld/emulparams/plt_unwind.sh b/ld/emulparams/plt_unwind.sh
index c832570..38d7668 100644
--- a/ld/emulparams/plt_unwind.sh
+++ b/ld/emulparams/plt_unwind.sh
@@ -1,3 +1,5 @@
+PLT_UNWIND=yes
+
 PARSE_AND_LIST_PROLOGUE='
 #define OPTION_LD_GENERATED_UNWIND_INFO	301
 #define OPTION_NO_LD_GENERATED_UNWIND_INFO 302
@@ -10,13 +12,6 @@ PARSE_AND_LIST_LONGOPTS='
    OPTION_NO_LD_GENERATED_UNWIND_INFO},
 '
 
-PARSE_AND_LIST_OPTIONS='
-  fprintf (file, _("\
-  --ld-generated-unwind-info  Generate exception handling info for PLT.\n\
-  --no-ld-generated-unwind-info Don'\''t do so.\n"
-		   ));
-'
-
 PARSE_AND_LIST_ARGS_CASES='
     case OPTION_LD_GENERATED_UNWIND_INFO:
       link_info.no_ld_generated_unwind_info = FALSE;
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 4dd71ab..dc643b6 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -2366,117 +2366,14 @@ fragment <<EOF
 EOF
 
 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
+gld_list_options="gld${EMULATION_NAME}_list_options"
+if test -n "$PARSE_AND_LIST_OPTIONS" || test x"$BNDPLT" = xyes; then
 fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_list_options (FILE * file)
 {
 EOF
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  --audit=AUDITLIB            Specify a library to use for auditing\n"));
-  fprintf (file, _("\
-  -Bgroup                     Selects group name lookup rules for DSO\n"));
-EOF
-fi
-fragment <<EOF
-  fprintf (file, _("\
-  --build-id[=STYLE]          Generate build ID note\n"));
-EOF
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  -P AUDITLIB, --depaudit=AUDITLIB\n" "\
-			      Specify a library to use for auditing dependencies\n"));
-  fprintf (file, _("\
-  --disable-new-dtags         Disable new dynamic tags\n"));
-  fprintf (file, _("\
-  --enable-new-dtags          Enable new dynamic tags\n"));
-  fprintf (file, _("\
-  --eh-frame-hdr              Create .eh_frame_hdr section\n"));
-  fprintf (file, _("\
-  --exclude-libs=LIBS         Make all symbols in LIBS hidden\n"));
-  fprintf (file, _("\
-  --hash-style=STYLE          Set hash style to sysv, gnu or both\n"));
-  fprintf (file, _("\
-  -z combreloc                Merge dynamic relocs into one section and sort\n"));
-EOF
-fi
-
-fragment <<EOF
-  fprintf (file, _("\
-  -z common-page-size=SIZE    Set common page size to SIZE\n"));
-  fprintf (file, _("\
-  -z defs                     Report unresolved symbols in object files.\n"));
-  fprintf (file, _("\
-  -z execstack                Mark executable as requiring executable stack\n"));
-EOF
-
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  -z global                   Make symbols in DSO available for subsequently\n\
-			       loaded objects\n"));
-  fprintf (file, _("\
-  -z initfirst                Mark DSO to be initialized first at runtime\n"));
-  fprintf (file, _("\
-  -z interpose                Mark object to interpose all DSOs but executable\n"));
-  fprintf (file, _("\
-  -z lazy                     Mark object lazy runtime binding (default)\n"));
-  fprintf (file, _("\
-  -z loadfltr                 Mark object requiring immediate process\n"));
-EOF
-fi
-
-fragment <<EOF
-  fprintf (file, _("\
-  -z max-page-size=SIZE       Set maximum page size to SIZE\n"));
-  fprintf (file, _("\
-  -z muldefs                  Allow multiple definitions\n"));
-EOF
-
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  -z nocombreloc              Don't merge dynamic relocs into one section\n"));
-  fprintf (file, _("\
-  -z nocopyreloc              Don't create copy relocs\n"));
-  fprintf (file, _("\
-  -z nodefaultlib             Mark object not to use default search paths\n"));
-  fprintf (file, _("\
-  -z nodelete                 Mark DSO non-deletable at runtime\n"));
-  fprintf (file, _("\
-  -z nodlopen                 Mark DSO not available to dlopen\n"));
-  fprintf (file, _("\
-  -z nodump                   Mark DSO not available to dldump\n"));
-EOF
-fi
-fragment <<EOF
-  fprintf (file, _("\
-  -z noexecstack              Mark executable as not requiring executable stack\n"));
-EOF
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  -z text                     Treat DT_TEXTREL in shared object as error\n"));
-  fprintf (file, _("\
-  -z notext                   Don't treat DT_TEXTREL in shared object as error\n"));
-  fprintf (file, _("\
-  -z textoff                  Don't treat DT_TEXTREL in shared object as error\n"));
-  fprintf (file, _("\
-  -z norelro                  Don't create RELRO program header\n"));
-  fprintf (file, _("\
-  -z now                      Mark object non-lazy runtime binding\n"));
-  fprintf (file, _("\
-  -z origin                   Mark object requiring immediate \$ORIGIN\n\
-				processing at runtime\n"));
-  fprintf (file, _("\
-  -z relro                    Create RELRO program header\n"));
-  fprintf (file, _("\
-  -z stacksize=SIZE           Set size of stack segment\n"));
-EOF
-fi
 
 if test x"$BNDPLT" = xyes; then
 fragment <<EOF
@@ -2494,6 +2391,9 @@ fi
 fragment <<EOF
 }
 EOF
+else
+  gld_list_options="NULL"
+fi
 
 if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
 fragment <<EOF
@@ -2527,7 +2427,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   gld${EMULATION_NAME}_add_options,
   gld${EMULATION_NAME}_handle_option,
   ${LDEMUL_UNRECOGNIZED_FILE-NULL},
-  ${LDEMUL_LIST_OPTIONS-gld${EMULATION_NAME}_list_options},
+  ${LDEMUL_LIST_OPTIONS-${gld_list_options}},
   ${LDEMUL_RECOGNIZED_FILE-gld${EMULATION_NAME}_load_symbols},
   ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
   ${LDEMUL_NEW_VERS_PATTERN-NULL},
diff --git a/ld/lexsup.c b/ld/lexsup.c
index a30fafa..4a71ba4 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -1652,6 +1652,112 @@ set_segment_start (const char *section, char *valstr)
   lang_section_start (section, exp_intop (val), seg);
 }
 
+static void
+elf_shlib_list_options (FILE *file)
+{
+  fprintf (file, _("\
+  --audit=AUDITLIB            Specify a library to use for auditing\n"));
+  fprintf (file, _("\
+  -Bgroup                     Selects group name lookup rules for DSO\n"));
+  fprintf (file, _("\
+  --disable-new-dtags         Disable new dynamic tags\n"));
+  fprintf (file, _("\
+  --enable-new-dtags          Enable new dynamic tags\n"));
+  fprintf (file, _("\
+  --eh-frame-hdr              Create .eh_frame_hdr section\n"));
+  fprintf (file, _("\
+  --exclude-libs=LIBS         Make all symbols in LIBS hidden\n"));
+  fprintf (file, _("\
+  --hash-style=STYLE          Set hash style to sysv, gnu or both\n"));
+  fprintf (file, _("\
+  -P AUDITLIB, --depaudit=AUDITLIB\n" "\
+			      Specify a library to use for auditing dependencies\n"));
+  fprintf (file, _("\
+  -z combreloc                Merge dynamic relocs into one section and sort\n"));
+  fprintf (file, _("\
+  -z nocombreloc              Don't merge dynamic relocs into one section\n"));
+  fprintf (file, _("\
+  -z global                   Make symbols in DSO available for subsequently\n\
+			       loaded objects\n"));
+  fprintf (file, _("\
+  -z initfirst                Mark DSO to be initialized first at runtime\n"));
+  fprintf (file, _("\
+  -z interpose                Mark object to interpose all DSOs but executable\n"));
+  fprintf (file, _("\
+  -z lazy                     Mark object lazy runtime binding (default)\n"));
+  fprintf (file, _("\
+  -z loadfltr                 Mark object requiring immediate process\n"));
+  fprintf (file, _("\
+  -z nocopyreloc              Don't create copy relocs\n"));
+  fprintf (file, _("\
+  -z nodefaultlib             Mark object not to use default search paths\n"));
+  fprintf (file, _("\
+  -z nodelete                 Mark DSO non-deletable at runtime\n"));
+  fprintf (file, _("\
+  -z nodlopen                 Mark DSO not available to dlopen\n"));
+  fprintf (file, _("\
+  -z nodump                   Mark DSO not available to dldump\n"));
+  fprintf (file, _("\
+  -z now                      Mark object non-lazy runtime binding\n"));
+  fprintf (file, _("\
+  -z origin                   Mark object requiring immediate $ORIGIN\n\
+				processing at runtime\n"));
+  fprintf (file, _("\
+  -z relro                    Create RELRO program header\n"));
+  fprintf (file, _("\
+  -z norelro                  Don't create RELRO program header\n"));
+  fprintf (file, _("\
+  -z stacksize=SIZE           Set size of stack segment\n"));
+  fprintf (file, _("\
+  -z text                     Treat DT_TEXTREL in shared object as error\n"));
+  fprintf (file, _("\
+  -z notext                   Don't treat DT_TEXTREL in shared object as error\n"));
+  fprintf (file, _("\
+  -z textoff                  Don't treat DT_TEXTREL in shared object as error\n"));
+}
+
+static void
+elf_static_list_options (FILE *file)
+{
+  fprintf (file, _("\
+  --build-id[=STYLE]          Generate build ID note\n"));
+  fprintf (file, _("\
+  -z common-page-size=SIZE    Set common page size to SIZE\n"));
+  fprintf (file, _("\
+  -z max-page-size=SIZE       Set maximum page size to SIZE\n"));
+  fprintf (file, _("\
+  -z defs                     Report unresolved symbols in object files.\n"));
+  fprintf (file, _("\
+  -z muldefs                  Allow multiple definitions\n"));
+  fprintf (file, _("\
+  -z execstack                Mark executable as requiring executable stack\n"));
+  fprintf (file, _("\
+  -z noexecstack              Mark executable as not requiring executable stack\n"));
+}
+
+static void
+elf_plt_unwind_list_options (FILE *file)
+{
+  fprintf (file, _("\
+  --ld-generated-unwind-info  Generate exception handling info for PLT\n\
+  --no-ld-generated-unwind-info\n\
+                              Don't generate exception handling info for PLT\n"));
+}
+
+static void
+ld_list_options (FILE *file, bfd_boolean elf, bfd_boolean shlib,
+		 bfd_boolean plt_unwind)
+{
+  if (!elf)
+    return;
+  printf (_("ELF emulations:\n"));
+  if (plt_unwind)
+    elf_plt_unwind_list_options (file);
+  elf_static_list_options (file);
+  if (shlib)
+    elf_shlib_list_options (file);
+}
+
 \f
 /* Print help messages for the options.  */
 
@@ -1764,6 +1870,8 @@ help (void)
 
   /* xgettext:c-format */
   printf (_("%s: emulation specific options:\n"), program_name);
+  ld_list_options (stdout, ELF_LIST_OPTIONS, ELF_SHLIB_LIST_OPTIONS,
+		   ELF_PLT_UNWIND_LIST_OPTIONS);
   ldemul_list_emulation_options (stdout);
   printf ("\n");
 
-- 
2.1.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Add ld_list_options
  2015-04-07 17:17 [PATCH] Add ld_list_options H.J. Lu
  2015-04-08  1:06 ` Alan Modra
@ 2015-04-08 16:16 ` Steve Ellcey
  2015-04-08 16:32   ` Steve Ellcey
  1 sibling, 1 reply; 11+ messages in thread
From: Steve Ellcey @ 2015-04-08 16:16 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

On Tue, 2015-04-07 at 10:12 -0700, H.J. Lu wrote:
> This patch adds ld_list_options for ELF targets to avoid duplicated
> outputs from ld --help.  Any comments, suggestions or objections?
> 
> H.J.
> --
> 	* Makefile.am (ELF_CLFAGS): New.
> 	(AM_CFLAGS): Add $(ELF_CLFAGS).
> 	* configure.ac (elf_list_options): New.  AC_SUBST.
> 	(elf_shlib_list_options): Likewise.
> 	(elf_plt_unwind_list_options): Likewise.
> 	* lexsup.c (elf_shlib_list_options): New.
> 	(elf_static_list_options): Likewise.
> 	(elf_plt_unwind_list_options): Likewise.
> 	(ld_list_options): Likewise.
> 	(help): Call ld_list_options.
> 	* Makefile.in: Regenerated.
> 	* configure: Likewise.
> 	* emulparams/plt_unwind.sh (PLT_UNWIND): New.
> 	(PARSE_AND_LIST_OPTIONS): Removed.
> 	* emultempl/elf32.em (gld_list_options): New.
> 	(gld${EMULATION_NAME}_list_options): Define only if BNDPLT or
> 	PARSE_AND_LIST_OPTIONS is defined.
> 	(ld_${EMULATION_NAME}_emulation): Replace
> 	gld${EMULATION_NAME}_list_options with ${gld_list_options.

I am not entirely sure this patch is at fault (I will double check) but
this morning when I tried to build a cross linker (running on x86 linux
and targetting mips-mti-linux-gnu) I got this failure during the ld
configure:


checking whether ANSI C string concatenation works... yes
checking size of void *... 8
/scratch/sellcey/repos/sim-bug/src/binutils/ld/configure: unhandled
emulation
make: *** [configure-ld] Error 1
Error: Make command failed, stopping build.


Has anyone else seen this?

Steve Ellcey
sellcey@imgtec.com


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Add ld_list_options
  2015-04-08 16:16 ` Steve Ellcey
@ 2015-04-08 16:32   ` Steve Ellcey
  2015-04-08 16:49     ` H.J. Lu
  0 siblings, 1 reply; 11+ messages in thread
From: Steve Ellcey @ 2015-04-08 16:32 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

I have verified that this is the checkin where my linker configure
started failing.

Steve Ellcey
sellcey@imgtec.com

On Wed, 2015-04-08 at 09:15 -0700, Steve Ellcey wrote:
> On Tue, 2015-04-07 at 10:12 -0700, H.J. Lu wrote:
> > This patch adds ld_list_options for ELF targets to avoid duplicated
> > outputs from ld --help.  Any comments, suggestions or objections?
> > 
> > H.J.
> > --
> > 	* Makefile.am (ELF_CLFAGS): New.
> > 	(AM_CFLAGS): Add $(ELF_CLFAGS).
> > 	* configure.ac (elf_list_options): New.  AC_SUBST.
> > 	(elf_shlib_list_options): Likewise.
> > 	(elf_plt_unwind_list_options): Likewise.
> > 	* lexsup.c (elf_shlib_list_options): New.
> > 	(elf_static_list_options): Likewise.
> > 	(elf_plt_unwind_list_options): Likewise.
> > 	(ld_list_options): Likewise.
> > 	(help): Call ld_list_options.
> > 	* Makefile.in: Regenerated.
> > 	* configure: Likewise.
> > 	* emulparams/plt_unwind.sh (PLT_UNWIND): New.
> > 	(PARSE_AND_LIST_OPTIONS): Removed.
> > 	* emultempl/elf32.em (gld_list_options): New.
> > 	(gld${EMULATION_NAME}_list_options): Define only if BNDPLT or
> > 	PARSE_AND_LIST_OPTIONS is defined.
> > 	(ld_${EMULATION_NAME}_emulation): Replace
> > 	gld${EMULATION_NAME}_list_options with ${gld_list_options.
> 
> I am not entirely sure this patch is at fault (I will double check) but
> this morning when I tried to build a cross linker (running on x86 linux
> and targetting mips-mti-linux-gnu) I got this failure during the ld
> configure:
> 
> 
> checking whether ANSI C string concatenation works... yes
> checking size of void *... 8
> /scratch/sellcey/repos/sim-bug/src/binutils/ld/configure: unhandled
> emulation
> make: *** [configure-ld] Error 1
> Error: Make command failed, stopping build.
> 
> 
> Has anyone else seen this?
> 
> Steve Ellcey
> sellcey@imgtec.com
> 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Add ld_list_options
  2015-04-08 16:32   ` Steve Ellcey
@ 2015-04-08 16:49     ` H.J. Lu
  2015-04-08 16:58       ` Steve Ellcey
  2015-04-08 23:31       ` Alan Modra
  0 siblings, 2 replies; 11+ messages in thread
From: H.J. Lu @ 2015-04-08 16:49 UTC (permalink / raw)
  To: sellcey; +Cc: Binutils

On Wed, Apr 8, 2015 at 9:32 AM, Steve Ellcey <sellcey@imgtec.com> wrote:
> I have verified that this is the checkin where my linker configure
> started failing.
>

I checked in this patch to fix mips buid.

-- 
H.J.
--
    Skip empty EMULATION_NAME

    * emulparams/elf32bmipn32-defs.sh: Skip empty EMULATION_NAME.

diff --git a/ld/ChangeLog b/ld/ChangeLog
index a76dcb3..b83c11e 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,9 @@
 2015-04-08  H.J. Lu  <hongjiu.lu@intel.com>

+ * emulparams/elf32bmipn32-defs.sh: Skip empty EMULATION_NAME.
+
+2015-04-08  H.J. Lu  <hongjiu.lu@intel.com>
+
  * Makefile.am (ELF_CLFAGS): New.
  (AM_CFLAGS): Add $(ELF_CLFAGS).
  * configure.ac (elf_list_options): New.  AC_SUBST.
diff --git a/ld/emulparams/elf32bmipn32-defs.sh
b/ld/emulparams/elf32bmipn32-defs.sh
index 723eac8..af8f01d 100644
--- a/ld/emulparams/elf32bmipn32-defs.sh
+++ b/ld/emulparams/elf32bmipn32-defs.sh
@@ -13,9 +13,10 @@ LITTLE_OUTPUT_FORMAT="elf32-littlemips"
 TEMPLATE_NAME=elf32
 EXTRA_EM_FILE=mipself

-case "$EMULATION_NAME" in
-elf32*n32*) ELFSIZE=32 ;;
-elf64*) ELFSIZE=64 ;;
+case x"$EMULATION_NAME" in
+xelf32*n32*) ELFSIZE=32 ;;
+xelf64*) ELFSIZE=64 ;;
+x) ;;
 *) echo $0: unhandled emulation $EMULATION_NAME >&2; exit 1 ;;
 esac

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Add ld_list_options
  2015-04-08 16:49     ` H.J. Lu
@ 2015-04-08 16:58       ` Steve Ellcey
  2015-04-08 23:31       ` Alan Modra
  1 sibling, 0 replies; 11+ messages in thread
From: Steve Ellcey @ 2015-04-08 16:58 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

On Wed, 2015-04-08 at 09:48 -0700, H.J. Lu wrote:
> On Wed, Apr 8, 2015 at 9:32 AM, Steve Ellcey <sellcey@imgtec.com> wrote:
> > I have verified that this is the checkin where my linker configure
> > started failing.
> >
> 
> I checked in this patch to fix mips build.
> 

    Skip empty EMULATION_NAME

    * emulparams/elf32bmipn32-defs.sh: Skip empty EMULATION_NAME.

This patch fixed my build.  Thanks.

Steve Ellcey
sellcey@imgtec.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Add ld_list_options
  2015-04-08 16:49     ` H.J. Lu
  2015-04-08 16:58       ` Steve Ellcey
@ 2015-04-08 23:31       ` Alan Modra
  2015-04-09  0:10         ` H.J. Lu
  1 sibling, 1 reply; 11+ messages in thread
From: Alan Modra @ 2015-04-08 23:31 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

On Wed, Apr 08, 2015 at 09:48:56AM -0700, H.J. Lu wrote:
> I checked in this patch to fix mips buid.

Another thing, you ought to set elf_list_options et al to TRUE for
--enable-targets=all, to cover building for a non-ELF host.

Also, please make use of EXTRA_EM_FILE to move the BNDPLT code out of
elf32.em.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Add ld_list_options
  2015-04-08 23:31       ` Alan Modra
@ 2015-04-09  0:10         ` H.J. Lu
  2015-04-09  0:22           ` H.J. Lu
  0 siblings, 1 reply; 11+ messages in thread
From: H.J. Lu @ 2015-04-09  0:10 UTC (permalink / raw)
  To: Binutils

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]

On Wed, Apr 8, 2015 at 4:31 PM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, Apr 08, 2015 at 09:48:56AM -0700, H.J. Lu wrote:
>> I checked in this patch to fix mips buid.
>
> Another thing, you ought to set elf_list_options et al to TRUE for
> --enable-targets=all, to cover building for a non-ELF host.

This is what I checked in.

> Also, please make use of EXTRA_EM_FILE to move the BNDPLT code out of
> elf32.em.
>

I will take care of it tomorrow.


-- 
H.J.

[-- Attachment #2: 0001-Enable-ELF-ld_list_options-for-enable-targets-all.patch --]
[-- Type: text/x-patch, Size: 2101 bytes --]

From 82d8e420ab39cf227aa8e0869a54fb0a29b0a00d Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 8 Apr 2015 17:05:54 -0700
Subject: [PATCH] Enable ELF ld_list_options for --enable-targets=all

When --enable-targets=all is used with non-ELF target, we should enable
ELF ld_list_options.

	* configure.ac (elf_list_options): Set to TRUE for
	--enable-targets=all.
	(elf_shlib_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	* configure: Regenerated.
---
 ld/ChangeLog    | 8 ++++++++
 ld/configure    | 3 +++
 ld/configure.ac | 3 +++
 3 files changed, 14 insertions(+)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index b83c11e..9807eab 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,13 @@
 2015-04-08  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* configure.ac (elf_list_options): Set to TRUE for
+	--enable-targets=all.
+	(elf_shlib_list_options): Likewise.
+	(elf_plt_unwind_list_options): Likewise.
+	* configure: Regenerated.
+
+2015-04-08  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* emulparams/elf32bmipn32-defs.sh: Skip empty EMULATION_NAME.
 
 2015-04-08  H.J. Lu  <hongjiu.lu@intel.com>
diff --git a/ld/configure b/ld/configure
index 44bce0e..b528f74 100755
--- a/ld/configure
+++ b/ld/configure
@@ -17035,6 +17035,9 @@ for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
   if test "$targ_alias" = "all"; then
     all_targets=true
+    elf_list_options=TRUE
+    elf_shlib_list_options=TRUE
+    elf_plt_unwind_list_options=TRUE
   else
     # Canonicalize the secondary target names.
     result=`$ac_config_sub $targ_alias 2>/dev/null`
diff --git a/ld/configure.ac b/ld/configure.ac
index 572440c..ac3c14f 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -288,6 +288,9 @@ for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
 do
   if test "$targ_alias" = "all"; then
     all_targets=true
+    elf_list_options=TRUE
+    elf_shlib_list_options=TRUE
+    elf_plt_unwind_list_options=TRUE
   else
     # Canonicalize the secondary target names.
     result=`$ac_config_sub $targ_alias 2>/dev/null`
-- 
1.9.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Add ld_list_options
  2015-04-09  0:10         ` H.J. Lu
@ 2015-04-09  0:22           ` H.J. Lu
  2015-04-09  1:07             ` Alan Modra
  0 siblings, 1 reply; 11+ messages in thread
From: H.J. Lu @ 2015-04-09  0:22 UTC (permalink / raw)
  To: Binutils

[-- Attachment #1: Type: text/plain, Size: 240 bytes --]

On Wed, Apr 8, 2015 at 5:10 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> Also, please make use of EXTRA_EM_FILE to move the BNDPLT code out of
>> elf32.em.
>>
>
> I will take care of it tomorrow.
>

I will check in this tomorrow.


-- 
H.J.

[-- Attachment #2: bndplt.patch --]
[-- Type: text/x-patch, Size: 1880 bytes --]

diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh
index aa26a1b..984e5e9 100644
--- a/ld/emulparams/elf_x86_64.sh
+++ b/ld/emulparams/elf_x86_64.sh
@@ -36,7 +36,14 @@ case "$target" in
     case "$EMULATION_NAME" in
       *64*)
         LIBPATH_SUFFIX=64
-        BNDPLT=yes
+	PARSE_AND_LIST_OPTIONS='
+  fprintf (file, _("\
+  -z bndplt                   Always generate BND prefix in PLT entries\n"));
+'
+	PARSE_AND_LIST_ARGS_CASE_Z='
+      else if (strcmp (optarg, "bndplt") == 0)
+	link_info.bndplt = TRUE;
+'
         ;;
     esac
     ;;
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index dc643b6..5db5a93 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -2286,13 +2286,6 @@ fragment <<EOF
 	}
 EOF
 
-if test x"$BNDPLT" = xyes; then
-fragment <<EOF
-      else if (strcmp (optarg, "bndplt") == 0)
-	link_info.bndplt = TRUE;
-EOF
-fi
-
 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
 fragment <<EOF
       else if (strcmp (optarg, "global") == 0)
@@ -2345,6 +2338,12 @@ fragment <<EOF
 EOF
 fi
 
+if test -n "$PARSE_AND_LIST_ARGS_CASE_Z" ; then
+fragment <<EOF
+ $PARSE_AND_LIST_ARGS_CASE_Z
+EOF
+fi
+
 fragment <<EOF
       else
 	einfo (_("%P: warning: -z %s ignored.\n"), optarg);
@@ -2367,7 +2366,7 @@ EOF
 
 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
 gld_list_options="gld${EMULATION_NAME}_list_options"
-if test -n "$PARSE_AND_LIST_OPTIONS" || test x"$BNDPLT" = xyes; then
+if test -n "$PARSE_AND_LIST_OPTIONS"; then
 fragment <<EOF
 
 static void
@@ -2375,13 +2374,6 @@ gld${EMULATION_NAME}_list_options (FILE * file)
 {
 EOF
 
-if test x"$BNDPLT" = xyes; then
-fragment <<EOF
-  fprintf (file, _("\
-  -z bndplt                   Always generate BND prefix in PLT entries\n"));
-EOF
-fi
-
 if test -n "$PARSE_AND_LIST_OPTIONS" ; then
 fragment <<EOF
  $PARSE_AND_LIST_OPTIONS

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Add ld_list_options
  2015-04-09  0:22           ` H.J. Lu
@ 2015-04-09  1:07             ` Alan Modra
  0 siblings, 0 replies; 11+ messages in thread
From: Alan Modra @ 2015-04-09  1:07 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

On Wed, Apr 08, 2015 at 05:22:10PM -0700, H.J. Lu wrote:
> On Wed, Apr 8, 2015 at 5:10 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> >> Also, please make use of EXTRA_EM_FILE to move the BNDPLT code out of
> >> elf32.em.
> >>
> >
> > I will take care of it tomorrow.
> >
> 
> I will check in this tomorrow.

Thanks, that looks a lot tidier.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-04-09  1:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 17:17 [PATCH] Add ld_list_options H.J. Lu
2015-04-08  1:06 ` Alan Modra
2015-04-08 11:57   ` H.J. Lu
2015-04-08 16:16 ` Steve Ellcey
2015-04-08 16:32   ` Steve Ellcey
2015-04-08 16:49     ` H.J. Lu
2015-04-08 16:58       ` Steve Ellcey
2015-04-08 23:31       ` Alan Modra
2015-04-09  0:10         ` H.J. Lu
2015-04-09  0:22           ` H.J. Lu
2015-04-09  1:07             ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).