public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ld -z options
@ 2011-07-13 18:20 Alan Modra
  2011-07-14  0:36 ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2011-07-13 18:20 UTC (permalink / raw)
  To: binutils

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

I found today that none of the ld -z options are available on ELF
targets that lack shared lib support (unless the target happens to
provide some target specific options, which is weird).  This patch
rearranges the option support code in elf32.em to make a few useful
options generally available, and moves a couple of x86/x86_64 options
out of the general set.  I'll commit this after running tests
overnight.

	* emultempl/elf32.em (gld${EMULATION_NAME}_add_options,
	gld${EMULATION_NAME}_handle_option, gld${EMULATION_NAME}_list_options):
	Provide --build-id, -z defs, -z muldefs, -z max-page-size,
	-z common-page-size, -z execstack, -z noexecstack for all targets.
	Add help for --exclude-libs.
	(OPTION_LD_GENERATED_UNWIND_INFO,
	OPTION_NO_LD_GENERATED_UNWIND_INFO): Move this..
	(gld${EMULATION_NAME}_handle_option): ..and code handling
	--ld-generated-unwind-info and --no-ld-generated-unwind-info..
	* emultempl/plt_unwind.em: ..to here.  New file.  Add help.
	* emulparams/elf_i386.sh (EXTRA_EM_FILE): Define.
	* emulparams/elf_x86_64.sh (EXTRA_EM_FILE): Define.

I'd normally put the patch inline but sourceware.org just rejected the
patch as spam, so trying compressed.

-- 
Alan Modra
Australia Development Lab, IBM

[-- Attachment #2: elf32.diff.gz --]
[-- Type: application/octet-stream, Size: 4082 bytes --]

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

* Re: ld -z options
  2011-07-13 18:20 ld -z options Alan Modra
@ 2011-07-14  0:36 ` Ian Lance Taylor
  2011-07-14  3:29   ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2011-07-14  0:36 UTC (permalink / raw)
  To: binutils

Alan Modra <amodra@gmail.com> writes:

> I found today that none of the ld -z options are available on ELF
> targets that lack shared lib support (unless the target happens to
> provide some target specific options, which is weird).  This patch
> rearranges the option support code in elf32.em to make a few useful
> options generally available, and moves a couple of x86/x86_64 options
> out of the general set.  I'll commit this after running tests
> overnight.

While you're looking at this, how would you feel about making the linker
give a warning or error when an unrecognized -z option is used?

(I've had various gold bug reports about unrecognized -z options for
options which GNU ld doesn't recognize either.)

Ian

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

* Re: ld -z options
  2011-07-14  0:36 ` Ian Lance Taylor
@ 2011-07-14  3:29   ` Alan Modra
  2011-07-14  8:06     ` Hans-Peter Nilsson
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2011-07-14  3:29 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

On Wed, Jul 13, 2011 at 04:07:35PM -0700, Ian Lance Taylor wrote:
> Alan Modra <amodra@gmail.com> writes:
> 
> > I found today that none of the ld -z options are available on ELF
> > targets that lack shared lib support (unless the target happens to
> > provide some target specific options, which is weird).  This patch
> > rearranges the option support code in elf32.em to make a few useful
> > options generally available, and moves a couple of x86/x86_64 options
> > out of the general set.  I'll commit this after running tests
> > overnight.
> 
> While you're looking at this, how would you feel about making the linker
> give a warning or error when an unrecognized -z option is used?

Done.  A warning seems reasonable.  I've also taken out the
"-z KEYWORD Ignored for Solaris compatibility" help message, and moved
emultempl/plt_unwind.em to emulparams/plt_unwind.sh so that it doesn't
conflict with other uses of EXTRA_EM_FILE.

	* emultempl/elf32.em (gld${EMULATION_NAME}_add_options,
	gld${EMULATION_NAME}_handle_option, gld${EMULATION_NAME}_list_options):
	Provide --build-id, -z defs, -z muldefs, -z max-page-size,
	-z common-page-size, -z execstack, -z noexecstack for all targets.
	Add help for --exclude-libs.
	(OPTION_LD_GENERATED_UNWIND_INFO,
	OPTION_NO_LD_GENERATED_UNWIND_INFO): Move this..
	(gld${EMULATION_NAME}_handle_option): ..and code handling
	--ld-generated-unwind-info and --no-ld-generated-unwind-info..
	* emulparams/plt_unwind.sh: ..to here.  New file.  Add help.
	* emulparams/elf32_x86_64.sh: Include plt_unwind.sh.
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_i386_chaos.sh: Likewise.
	* emulparams/elf_i386_ldso.sh: Likewise.
	* emulparams/elf_l1om.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.

Index: ld/emulparams/elf32_x86_64.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf32_x86_64.sh,v
retrieving revision 1.2
diff -u -p -r1.2 elf32_x86_64.sh
--- ld/emulparams/elf32_x86_64.sh	16 Feb 2011 19:14:41 -0000	1.2
+++ ld/emulparams/elf32_x86_64.sh	14 Jul 2011 02:12:01 -0000
@@ -1,3 +1,4 @@
+. ${srcdir}/emulparams/plt_unwind.sh
 SCRIPT_NAME=elf
 ELFSIZE=32
 OUTPUT_FORMAT="elf32-x86-64"
Index: ld/emulparams/elf_i386.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_i386.sh,v
retrieving revision 1.10
diff -u -p -r1.10 elf_i386.sh
--- ld/emulparams/elf_i386.sh	29 Jul 2009 14:59:23 -0000	1.10
+++ ld/emulparams/elf_i386.sh	14 Jul 2011 02:12:01 -0000
@@ -1,3 +1,4 @@
+. ${srcdir}/emulparams/plt_unwind.sh
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386"
 NO_RELA_RELOCS=yes
Index: ld/emulparams/elf_i386_chaos.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_i386_chaos.sh,v
retrieving revision 1.6
diff -u -p -r1.6 elf_i386_chaos.sh
--- ld/emulparams/elf_i386_chaos.sh	9 Aug 2007 11:02:24 -0000	1.6
+++ ld/emulparams/elf_i386_chaos.sh	14 Jul 2011 02:12:01 -0000
@@ -1,3 +1,4 @@
+. ${srcdir}/emulparams/plt_unwind.sh
 SCRIPT_NAME=elf_chaos
 OUTPUT_FORMAT="elf32-i386"
 TEXT_START_ADDR=0x40000000
Index: ld/emulparams/elf_i386_ldso.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_i386_ldso.sh,v
retrieving revision 1.6
diff -u -p -r1.6 elf_i386_ldso.sh
--- ld/emulparams/elf_i386_ldso.sh	22 Oct 2008 05:20:44 -0000	1.6
+++ ld/emulparams/elf_i386_ldso.sh	14 Jul 2011 02:12:01 -0000
@@ -1,3 +1,4 @@
+. ${srcdir}/emulparams/plt_unwind.sh
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386"
 NO_RELA_RELOCS=yes
Index: ld/emulparams/elf_l1om.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_l1om.sh,v
retrieving revision 1.2
diff -u -p -r1.2 elf_l1om.sh
--- ld/emulparams/elf_l1om.sh	31 Mar 2011 22:23:09 -0000	1.2
+++ ld/emulparams/elf_l1om.sh	14 Jul 2011 02:12:01 -0000
@@ -1,3 +1,4 @@
+. ${srcdir}/emulparams/plt_unwind.sh
 SCRIPT_NAME=elf
 ELFSIZE=64
 OUTPUT_FORMAT="elf64-l1om"
Index: ld/emulparams/elf_x86_64.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_x86_64.sh,v
retrieving revision 1.22
diff -u -p -r1.22 elf_x86_64.sh
--- ld/emulparams/elf_x86_64.sh	29 Jul 2009 14:59:23 -0000	1.22
+++ ld/emulparams/elf_x86_64.sh	14 Jul 2011 02:12:01 -0000
@@ -1,3 +1,4 @@
+. ${srcdir}/emulparams/plt_unwind.sh
 SCRIPT_NAME=elf
 ELFSIZE=64
 OUTPUT_FORMAT="elf64-x86-64"
Index: ld/emulparams/plt_unwind.sh
===================================================================
RCS file: ld/emulparams/plt_unwind.sh
diff -N ld/emulparams/plt_unwind.sh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/emulparams/plt_unwind.sh	14 Jul 2011 02:34:57 -0000
@@ -0,0 +1,28 @@
+PARSE_AND_LIST_PROLOGUE='
+#define OPTION_LD_GENERATED_UNWIND_INFO	301
+#define OPTION_NO_LD_GENERATED_UNWIND_INFO 302
+'
+
+PARSE_AND_LIST_LONGOPTS='
+  {"ld-generated-unwind-info", no_argument, NULL,
+   OPTION_LD_GENERATED_UNWIND_INFO},
+  {"no-ld-generated-unwind-info", no_argument, NULL,
+   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;
+      break;
+
+    case OPTION_NO_LD_GENERATED_UNWIND_INFO:
+      link_info.no_ld_generated_unwind_info = TRUE;
+      break;
+'
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.220
diff -u -p -r1.220 elf32.em
--- ld/emultempl/elf32.em	20 Jun 2011 13:18:48 -0000	1.220
+++ ld/emultempl/elf32.em	14 Jul 2011 02:12:02 -0000
@@ -2106,8 +2106,6 @@ EOF
 fi
 fi
 
-if test -n "$PARSE_AND_LIST_ARGS_CASES" -o x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-
 if test -n "$PARSE_AND_LIST_PROLOGUE" ; then
 fragment <<EOF
  $PARSE_AND_LIST_PROLOGUE
@@ -2124,42 +2122,49 @@ fragment <<EOF
 #define OPTION_HASH_STYLE		(OPTION_EXCLUDE_LIBS + 1)
 #define OPTION_BUILD_ID			(OPTION_HASH_STYLE + 1)
 #define OPTION_AUDIT			(OPTION_BUILD_ID + 1)
-#define OPTION_LD_GENERATED_UNWIND_INFO	(OPTION_AUDIT + 1)
-#define OPTION_NO_LD_GENERATED_UNWIND_INFO (OPTION_LD_GENERATED_UNWIND_INFO + 1)
 
 static void
 gld${EMULATION_NAME}_add_options
   (int ns, char **shortopts, int nl, struct option **longopts,
    int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED)
 {
+EOF
+if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
+fragment <<EOF
   static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:P:";
+EOF
+else
+fragment <<EOF
+  static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:";
+EOF
+fi
+fragment <<EOF
   static const struct option xtra_long[] = {
-    {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
+EOF
+if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
+fragment <<EOF
     {"audit", required_argument, NULL, OPTION_AUDIT},
-    {"depaudit", required_argument, NULL, 'P'},
+    {"Bgroup", no_argument, NULL, OPTION_GROUP},
+EOF
+fi
+fragment <<EOF
+    {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
 EOF
-
 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
 fragment <<EOF
+    {"depaudit", required_argument, NULL, 'P'},
     {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
     {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
     {"eh-frame-hdr", no_argument, NULL, OPTION_EH_FRAME_HDR},
     {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
     {"hash-style", required_argument, NULL, OPTION_HASH_STYLE},
-    {"ld-generated-unwind-info", no_argument, NULL,
-      OPTION_LD_GENERATED_UNWIND_INFO},
-    {"no-ld-generated-unwind-info", no_argument, NULL,
-      OPTION_NO_LD_GENERATED_UNWIND_INFO},
-    {"Bgroup", no_argument, NULL, OPTION_GROUP},
 EOF
 fi
-
 if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
 fragment <<EOF
     $PARSE_AND_LIST_LONGOPTS
 EOF
 fi
-
 fragment <<EOF
     {NULL, no_argument, NULL, 0}
   };
@@ -2192,17 +2197,19 @@ gld${EMULATION_NAME}_handle_option (int 
       if (strcmp (optarg, "none"))
 	link_info.emit_note_gnu_build_id = xstrdup (optarg);
       break;
+
+EOF
+
+if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
+fragment <<EOF
     case OPTION_AUDIT:
   	gld${EMULATION_NAME}_append_to_separated_string (&audit, optarg); 
 	break;
+
     case 'P':
 	gld${EMULATION_NAME}_append_to_separated_string (&depaudit, optarg);
 	break;
 
-EOF
-
-if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-fragment <<EOF
     case OPTION_DISABLE_NEW_DTAGS:
       link_info.new_dtags = FALSE;
       break;
@@ -2215,14 +2222,6 @@ fragment <<EOF
       link_info.eh_frame_hdr = TRUE;
       break;
 
-    case OPTION_LD_GENERATED_UNWIND_INFO:
-      link_info.no_ld_generated_unwind_info = FALSE;
-      break;
-
-    case OPTION_NO_LD_GENERATED_UNWIND_INFO:
-      link_info.no_ld_generated_unwind_info = TRUE;
-      break;
-
     case OPTION_GROUP:
       link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
       /* Groups must be self-contained.  */
@@ -2250,8 +2249,46 @@ fragment <<EOF
 	einfo (_("%P%F: invalid hash style \`%s'\n"), optarg);
       break;
 
+EOF
+fi
+fragment <<EOF
     case 'z':
-      if (strcmp (optarg, "initfirst") == 0)
+      if (strcmp (optarg, "defs") == 0)
+	link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
+      else if (strcmp (optarg, "muldefs") == 0)
+	link_info.allow_multiple_definition = TRUE;
+      else if (CONST_STRNEQ (optarg, "max-page-size="))
+	{
+	  char *end;
+
+	  config.maxpagesize = strtoul (optarg + 14, &end, 0);
+	  if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
+	    einfo (_("%P%F: invalid maxium page size \`%s'\n"),
+		   optarg + 14);
+	}
+      else if (CONST_STRNEQ (optarg, "common-page-size="))
+	{
+	  char *end;
+	  config.commonpagesize = strtoul (optarg + 17, &end, 0);
+	  if (*end
+	      || (config.commonpagesize & (config.commonpagesize - 1)) != 0)
+	    einfo (_("%P%F: invalid common page size \`%s'\n"),
+		   optarg + 17);
+	}
+      else if (strcmp (optarg, "execstack") == 0)
+	{
+	  link_info.execstack = TRUE;
+	  link_info.noexecstack = FALSE;
+	}
+      else if (strcmp (optarg, "noexecstack") == 0)
+	{
+	  link_info.noexecstack = TRUE;
+	  link_info.execstack = FALSE;
+	}
+EOF
+if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
+fragment <<EOF
+      else if (strcmp (optarg, "initfirst") == 0)
 	link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
       else if (strcmp (optarg, "interpose") == 0)
 	link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE;
@@ -2280,26 +2317,12 @@ fragment <<EOF
 	  link_info.flags |= (bfd_vma) DF_ORIGIN;
 	  link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
 	}
-      else if (strcmp (optarg, "defs") == 0)
-	link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
-      else if (strcmp (optarg, "muldefs") == 0)
-	link_info.allow_multiple_definition = TRUE;
       else if (strcmp (optarg, "combreloc") == 0)
 	link_info.combreloc = TRUE;
       else if (strcmp (optarg, "nocombreloc") == 0)
 	link_info.combreloc = FALSE;
       else if (strcmp (optarg, "nocopyreloc") == 0)
 	link_info.nocopyreloc = TRUE;
-      else if (strcmp (optarg, "execstack") == 0)
-	{
-	  link_info.execstack = TRUE;
-	  link_info.noexecstack = FALSE;
-	}
-      else if (strcmp (optarg, "noexecstack") == 0)
-	{
-	  link_info.noexecstack = TRUE;
-	  link_info.execstack = FALSE;
-	}
 EOF
 
   if test -n "$COMMONPAGESIZE"; then
@@ -2310,30 +2333,13 @@ fragment <<EOF
 	link_info.relro = FALSE;
 EOF
   fi
+fi
 
 fragment <<EOF
-      else if (CONST_STRNEQ (optarg, "max-page-size="))
-	{
-	  char *end;
-
-	  config.maxpagesize = strtoul (optarg + 14, &end, 0);
-	  if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
-	    einfo (_("%P%F: invalid maxium page size \`%s'\n"),
-		   optarg + 14);
-	}
-      else if (CONST_STRNEQ (optarg, "common-page-size="))
-	{
-	  char *end;
-	  config.commonpagesize = strtoul (optarg + 17, &end, 0);
-	  if (*end
-	      || (config.commonpagesize & (config.commonpagesize - 1)) != 0)
-	    einfo (_("%P%F: invalid common page size \`%s'\n"),
-		   optarg + 17);
-	}
-      /* What about the other Solaris -z options? FIXME.  */
+      else
+	einfo (_("%P: warning: -z %s ignored.\n"), optarg);
       break;
 EOF
-fi
 
 if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
 fragment <<EOF
@@ -2355,19 +2361,24 @@ fragment <<EOF
 static void
 gld${EMULATION_NAME}_list_options (FILE * file)
 {
-  fprintf (file, _("\
-  --build-id[=STYLE]          Generate build ID note\n"));
+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, _("\
-  -P AUDITLIB, --depaudit=AUDITLIB\n" "\
-                              Specify a library to use for auditing dependencies\n"));
+  -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, _("\
-  -Bgroup                     Selects group name lookup rules for DSO\n"));
+  -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, _("\
@@ -2375,13 +2386,25 @@ fragment <<EOF
   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 initfirst                Mark DSO to be initialized first at runtime\n"));
   fprintf (file, _("\
@@ -2390,8 +2413,18 @@ fragment <<EOF
   -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, _("\
@@ -2404,10 +2437,13 @@ fragment <<EOF
   -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
   if test -n "$COMMONPAGESIZE"; then
 fragment <<EOF
   fprintf (file, _("\
@@ -2429,15 +2465,6 @@ fragment <<EOF
   -z relro                    Create RELRO program header\n"));
 EOF
   fi
-
-fragment <<EOF
-  fprintf (file, _("\
-  -z max-page-size=SIZE       Set maximum page size to SIZE\n"));
-  fprintf (file, _("\
-  -z common-page-size=SIZE    Set common page size to SIZE\n"));
-  fprintf (file, _("\
-  -z KEYWORD                  Ignored for Solaris compatibility\n"));
-EOF
 fi
 
 if test -n "$PARSE_AND_LIST_OPTIONS" ; then
@@ -2456,17 +2483,6 @@ fragment <<EOF
 EOF
 fi
 fi
-else
-fragment <<EOF
-#define gld${EMULATION_NAME}_add_options NULL
-#define gld${EMULATION_NAME}_handle_option NULL
-EOF
-if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
-fragment <<EOF
-#define gld${EMULATION_NAME}_list_options NULL
-EOF
-fi
-fi
 
 fragment <<EOF
 


-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: ld -z options
  2011-07-14  3:29   ` Alan Modra
@ 2011-07-14  8:06     ` Hans-Peter Nilsson
  2011-07-14 11:14       ` Hans-Peter Nilsson
  2011-07-14 11:38       ` Alan Modra
  0 siblings, 2 replies; 8+ messages in thread
From: Hans-Peter Nilsson @ 2011-07-14  8:06 UTC (permalink / raw)
  To: Alan Modra; +Cc: Ian Lance Taylor, binutils

On Thu, 14 Jul 2011, Alan Modra wrote:
> On Wed, Jul 13, 2011 at 04:07:35PM -0700, Ian Lance Taylor wrote:
> > While you're looking at this, how would you feel about making the linker
> > give a warning or error when an unrecognized -z option is used?
>
> Done.  A warning seems reasonable.  I've also taken out the
> "-z KEYWORD Ignored for Solaris compatibility" help message, and moved
> emultempl/plt_unwind.em to emulparams/plt_unwind.sh so that it doesn't
> conflict with other uses of EXTRA_EM_FILE.
>
> 	* emultempl/elf32.em (gld${EMULATION_NAME}_add_options,
> 	gld${EMULATION_NAME}_handle_option, gld${EMULATION_NAME}_list_options):
> 	Provide --build-id, -z defs, -z muldefs, -z max-page-size,
> 	-z common-page-size, -z execstack, -z noexecstack for all targets.
> 	Add help for --exclude-libs.
> 	(OPTION_LD_GENERATED_UNWIND_INFO,
> 	OPTION_NO_LD_GENERATED_UNWIND_INFO): Move this..
> 	(gld${EMULATION_NAME}_handle_option): ..and code handling
> 	--ld-generated-unwind-info and --no-ld-generated-unwind-info..
> 	* emulparams/plt_unwind.sh: ..to here.  New file.  Add help.
> 	* emulparams/elf32_x86_64.sh: Include plt_unwind.sh.
> 	* emulparams/elf_i386.sh: Likewise.
> 	* emulparams/elf_i386_chaos.sh: Likewise.
> 	* emulparams/elf_i386_ldso.sh: Likewise.
> 	* emulparams/elf_l1om.sh: Likewise.
> 	* emulparams/elf_x86_64.sh: Likewise.

This caused several test-cases to go from PASS to UNRESOLVED for
cris-axis-linux-gnu and at a glance in ld.log wrongly so:

+UNRESOLVED: strip -z relro (relro1)
+UNRESOLVED: strip -z relro -shared (relro1)
+UNRESOLVED: objcopy -z relro (relro1)
+UNRESOLVED: objcopy -z relro -shared (relro1)
+UNRESOLVED: objcopy -z relro (tdata1)
+UNRESOLVED: objcopy -shared -z relro (tdata1)
+UNRESOLVED: objcopy -z relro (tdata2)
+UNRESOLVED: objcopy -shared -z relro (tdata2)
+UNRESOLVED: objcopy -z relro (tdata3)
+UNRESOLVED: objcopy -shared -z relro (tdata3)
+UNRESOLVED: objcopy -z relro (tbss1)
+UNRESOLVED: objcopy -shared -z relro (tbss1)
+UNRESOLVED: objcopy -z relro (tbss2)
+UNRESOLVED: objcopy -shared -z relro (tbss2)
+UNRESOLVED: objcopy -z relro (tbss3)
+UNRESOLVED: objcopy -shared -z relro (tbss3)

All preceded by a linker warning ".../ld-new: warning: -z relro
ignored." in ld.log.  The UNRESOLVED status then cause the
check-ld to return error.  According to the dejagnu docs, the
UNRESOLVED is an indication of an error in the testsuite (likely
the unexpected warning).  But why the warning?  Didn't -z relro
work before; did the tests accidentally pass before your changes
and I missed something in the port or what's up?

Hm, at a second glance many other ports set
COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" which for some reason
triggers the recognition of e.g. "-z relro" but why would I have
to set that when there's just one page-size?  Can we default to
that instead?  And aren't the tests not really testing -z relro
if they passed anyway?  (Ok, it became the default, but then
there's a missing "-z norelro" test IMHO.)

brgds, H-P

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

* Re: ld -z options
  2011-07-14  8:06     ` Hans-Peter Nilsson
@ 2011-07-14 11:14       ` Hans-Peter Nilsson
  2011-07-14 12:41         ` Alan Modra
  2011-07-14 11:38       ` Alan Modra
  1 sibling, 1 reply; 8+ messages in thread
From: Hans-Peter Nilsson @ 2011-07-14 11:14 UTC (permalink / raw)
  To: binutils

Talking to myself...

On Thu, 14 Jul 2011, Hans-Peter Nilsson wrote:
> This caused several test-cases to go from PASS to UNRESOLVED for
> cris-axis-linux-gnu

It seems this would happen for e.g. ia64-*-linux-gnu too.

> All preceded by a linker warning ".../ld-new: warning: -z relro
> ignored." in ld.log.  The UNRESOLVED status then cause the
> check-ld to return error.  According to the dejagnu docs, the
> UNRESOLVED is an indication of an error in the testsuite (likely
> the unexpected warning).

That's a bug in ld-elf/binutils.exp or the new warning message;
binutils.exp tests [string match "*not supported*" $link_output]
             || [string match "*unrecognized option*" $link_output]
which doesn't match "warning: -z relro ignored.".

Which one should be adjusted?

> Hm, at a second glance many other ports set
> COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" which for some reason
> triggers the recognition of e.g. "-z relro" but why would I have
> to set that when there's just one page-size?

This seems the wrong default, and emulparams/elf64_ia64.sh
should set something to disable -z relro instead of everyone
else setting some vaguely related variable.  Or is that's too
linux-centric?  Maybe create a ${srcdir}/emulparams/linux-common.sh
for emulparams/*.sh to include?

> And aren't the tests not really testing -z relro
> if they passed anyway?

Doh, they aren't testing that option, that's just a combination
tested for objcopy/strip/whatever producing the same result
with/without that option.

brgds, H-P

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

* Re: ld -z options
  2011-07-14  8:06     ` Hans-Peter Nilsson
  2011-07-14 11:14       ` Hans-Peter Nilsson
@ 2011-07-14 11:38       ` Alan Modra
  1 sibling, 0 replies; 8+ messages in thread
From: Alan Modra @ 2011-07-14 11:38 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: Ian Lance Taylor, binutils

On Thu, Jul 14, 2011 at 03:12:21AM -0400, Hans-Peter Nilsson wrote:
> Hm, at a second glance many other ports set
> COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" which for some reason
> triggers the recognition of e.g. "-z relro" but why would I have
> to set that when there's just one page-size?

I think the test enabling -z relro only when COMMONPAGESIZE is defined
is bogus.  Also, all ELF targets should be using the CONSTANT
maxpagesize and commonpagesize, but changing over requires someone to
check that the relevant bfd backend defines ELF_MAXPAGESIZE and
ELF_COMMONPAGESIZE in agreement with their ld couterparts.  Right now
I've run out of enthusiasm for that sort of cleanup work.

	* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option,
	gld${EMULATION_NAME}_list_options): Don't condition -z relro
	and -z norelro on COMMONPAGESIZE being defined.

Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.221
diff -u -p -r1.221 elf32.em
--- ld/emultempl/elf32.em	14 Jul 2011 02:38:43 -0000	1.221
+++ ld/emultempl/elf32.em	14 Jul 2011 10:46:00 -0000
@@ -2323,16 +2323,11 @@ fragment <<EOF
 	link_info.combreloc = FALSE;
       else if (strcmp (optarg, "nocopyreloc") == 0)
 	link_info.nocopyreloc = TRUE;
-EOF
-
-  if test -n "$COMMONPAGESIZE"; then
-fragment <<EOF
       else if (strcmp (optarg, "relro") == 0)
 	link_info.relro = TRUE;
       else if (strcmp (optarg, "norelro") == 0)
 	link_info.relro = FALSE;
 EOF
-  fi
 fi
 
 fragment <<EOF
@@ -2444,27 +2439,17 @@ fragment <<EOF
   -z noexecstack              Mark executable as not requiring executable stack\n"));
 EOF
 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-  if test -n "$COMMONPAGESIZE"; then
 fragment <<EOF
   fprintf (file, _("\
   -z norelro                  Don't create RELRO program header\n"));
-EOF
-  fi
-
-fragment <<EOF
   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"));
-EOF
-
-  if test -n "$COMMONPAGESIZE"; then
-fragment <<EOF
   fprintf (file, _("\
   -z relro                    Create RELRO program header\n"));
 EOF
-  fi
 fi
 
 if test -n "$PARSE_AND_LIST_OPTIONS" ; then

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: ld -z options
  2011-07-14 11:14       ` Hans-Peter Nilsson
@ 2011-07-14 12:41         ` Alan Modra
  2011-07-14 17:16           ` H.J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2011-07-14 12:41 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

On Thu, Jul 14, 2011 at 04:06:03AM -0400, Hans-Peter Nilsson wrote:
> Talking to myself...
> 
> On Thu, 14 Jul 2011, Hans-Peter Nilsson wrote:
> > This caused several test-cases to go from PASS to UNRESOLVED for
> > cris-axis-linux-gnu
> 
> It seems this would happen for e.g. ia64-*-linux-gnu too.

Yes.

> > All preceded by a linker warning ".../ld-new: warning: -z relro
> > ignored." in ld.log.  The UNRESOLVED status then cause the
> > check-ld to return error.  According to the dejagnu docs, the
> > UNRESOLVED is an indication of an error in the testsuite (likely
> > the unexpected warning).
> 
> That's a bug in ld-elf/binutils.exp or the new warning message;
> binutils.exp tests [string match "*not supported*" $link_output]
>              || [string match "*unrecognized option*" $link_output]
> which doesn't match "warning: -z relro ignored.".
> 
> Which one should be adjusted?

Probably the new one.  Patch preapproved if you'd like to do it.

> > Hm, at a second glance many other ports set
> > COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" which for some reason
> > triggers the recognition of e.g. "-z relro" but why would I have
> > to set that when there's just one page-size?
> 
> This seems the wrong default, and emulparams/elf64_ia64.sh
> should set something to disable -z relro instead of everyone
> else setting some vaguely related variable.  Or is that's too
> linux-centric?  Maybe create a ${srcdir}/emulparams/linux-common.sh
> for emulparams/*.sh to include?

I had the same idea, but see my other mail about bfd backend and ld
needing to agree.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: ld -z options
  2011-07-14 12:41         ` Alan Modra
@ 2011-07-14 17:16           ` H.J. Lu
  0 siblings, 0 replies; 8+ messages in thread
From: H.J. Lu @ 2011-07-14 17:16 UTC (permalink / raw)
  To: Hans-Peter Nilsson, binutils

On Thu, Jul 14, 2011 at 4:18 AM, Alan Modra <amodra@gmail.com> wrote:
> On Thu, Jul 14, 2011 at 04:06:03AM -0400, Hans-Peter Nilsson wrote:
>> Talking to myself...
>>
>> On Thu, 14 Jul 2011, Hans-Peter Nilsson wrote:
>> > This caused several test-cases to go from PASS to UNRESOLVED for
>> > cris-axis-linux-gnu
>>
>> It seems this would happen for e.g. ia64-*-linux-gnu too.
>
> Yes.
>
>> > All preceded by a linker warning ".../ld-new: warning: -z relro
>> > ignored." in ld.log.  The UNRESOLVED status then cause the
>> > check-ld to return error.  According to the dejagnu docs, the
>> > UNRESOLVED is an indication of an error in the testsuite (likely
>> > the unexpected warning).
>>
>> That's a bug in ld-elf/binutils.exp or the new warning message;
>> binutils.exp tests [string match "*not supported*" $link_output]
>>              || [string match "*unrecognized option*" $link_output]
>> which doesn't match "warning: -z relro ignored.".
>>
>> Which one should be adjusted?
>
> Probably the new one.  Patch preapproved if you'd like to do it.

I checked in this:

diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index ee6987f..bc01d77 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-07-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* ld-elf/binutils.exp (binutils_test): Also check ignored
+	"-z relro".
+
 2011-07-14  Alan Modra  <amodra@gmail.com>

 	* ld-scripts/section-flags.exp: Pass --local-store 0:0 for
diff --git a/ld/testsuite/ld-elf/binutils.exp b/ld/testsuite/ld-elf/binutils.exp
index 380bd26..382d50f 100644
--- a/ld/testsuite/ld-elf/binutils.exp
+++ b/ld/testsuite/ld-elf/binutils.exp
@@ -53,7 +53,8 @@ proc binutils_test { prog_name ld_options test } {

     if { ![ld_simple_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } {
 	if { [string match "*not supported*" $link_output]
-	     || [string match "*unrecognized option*" $link_output] } {
+	     || [string match "*unrecognized option*" $link_output]
+	     || [string match "*-z relro ignored*" $link_output] } {
 	    unsupported "$ld_options is not supported by this target"
 	} else {
 	    unresolved "$test_name"


-- 
H.J.

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

end of thread, other threads:[~2011-07-14 14:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13 18:20 ld -z options Alan Modra
2011-07-14  0:36 ` Ian Lance Taylor
2011-07-14  3:29   ` Alan Modra
2011-07-14  8:06     ` Hans-Peter Nilsson
2011-07-14 11:14       ` Hans-Peter Nilsson
2011-07-14 12:41         ` Alan Modra
2011-07-14 17:16           ` H.J. Lu
2011-07-14 11:38       ` 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).