public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [RFC] ld: add new --enable-new-dtags-only flag
@ 2012-12-25  7:29 Mike Frysinger
  2013-01-08  9:32 ` Alan Modra
                   ` (5 more replies)
  0 siblings, 6 replies; 59+ messages in thread
From: Mike Frysinger @ 2012-12-25  7:29 UTC (permalink / raw)
  To: binutils

With the --enable-new-dtags flag, you can generate DT_RUNPATH in
addition to DT_RPATH.  But the former tag isn't terribly useful
so long as the latter is still being generated.  So add a new
option to suppress that.

The proposed option name isn't great, but it's in line with the
existing --neable-new-dtags flag.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

[Being lazy on CL writing until we hammer out the proposal]
---
 bfd/elflink.c         | 14 ++++++++++----
 gold/layout.cc        |  3 ++-
 gold/options.h        |  3 +++
 include/bfdlink.h     |  3 +++
 ld/emultempl/elf32.em | 10 +++++++++-
 ld/ld.texinfo         |  8 ++++++--
 6 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 661b2eb..b70d995 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5748,13 +5748,19 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
 
 	  indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, rpath,
 				      TRUE);
-	  if (indx == (bfd_size_type) -1
-	      || !_bfd_elf_add_dynamic_entry (info, DT_RPATH, indx))
+	  if (indx == (bfd_size_type) -1)
 	    return FALSE;
 
-	  if  (info->new_dtags)
+	  if (!info->new_dtags_only)
+	    {
+	      if (!_bfd_elf_add_dynamic_entry (info, DT_RPATH, indx))
+		return FALSE;
+	    }
+
+	  if (info->new_dtags)
 	    {
-	      _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, indx);
+	      if (!info->new_dtags_only)
+		_bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, indx);
 	      if (!_bfd_elf_add_dynamic_entry (info, DT_RUNPATH, indx))
 		return FALSE;
 	    }
diff --git a/gold/layout.cc b/gold/layout.cc
index f7f0e7e..5083e24 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -4645,7 +4645,8 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
 	    }
 	}
 
-      odyn->add_string(elfcpp::DT_RPATH, rpath_val);
+      if (!parameters->options().enable_new_dtags_only())
+	odyn->add_string(elfcpp::DT_RPATH, rpath_val);
       if (parameters->options().enable_new_dtags())
 	odyn->add_string(elfcpp::DT_RUNPATH, rpath_val);
     }
diff --git a/gold/options.h b/gold/options.h
index 38f0c00..65ff03b 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -908,6 +908,9 @@ class General_options
 		N_("Enable use of DT_RUNPATH and DT_FLAGS"),
 		N_("Disable use of DT_RUNPATH and DT_FLAGS"));
 
+  DEFINE_enable(new_dtags_only, options::EXACTLY_TWO_DASHES, '\0', false,
+		N_("Skip the use of DT_RPATH"), NULL);
+
   DEFINE_bool(noinhibit_exec, options::TWO_DASHES, '\0', false,
 	      N_("Create an output file even if errors occur"), NULL);
 
diff --git a/include/bfdlink.h b/include/bfdlink.h
index bf44dee..3920d12 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -368,6 +368,9 @@ struct bfd_link_info
   /* TRUE if the new ELF dynamic tags are enabled. */
   unsigned int new_dtags: 1;
 
+  /* TRUE if only the new ELF dynamic tags are used (skips old tags).  */
+  unsigned int new_dtags_only: 1;
+
   /* FALSE if .eh_frame unwind info should be generated for PLT and other
      linker created sections, TRUE if it should be omitted.  */
   unsigned int no_ld_generated_unwind_info: 1;
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index d30a0ad..405cfc3 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -2120,7 +2120,8 @@ fragment <<EOF
 
 #define OPTION_DISABLE_NEW_DTAGS	(400)
 #define OPTION_ENABLE_NEW_DTAGS		(OPTION_DISABLE_NEW_DTAGS + 1)
-#define OPTION_GROUP			(OPTION_ENABLE_NEW_DTAGS + 1)
+#define OPTION_ENABLE_NEW_DTAGS_ONLY	(OPTION_ENABLE_NEW_DTAGS + 1)
+#define OPTION_GROUP			(OPTION_ENABLE_NEW_DTAGS_ONLY + 1)
 #define OPTION_EH_FRAME_HDR		(OPTION_GROUP + 1)
 #define OPTION_EXCLUDE_LIBS		(OPTION_EH_FRAME_HDR + 1)
 #define OPTION_HASH_STYLE		(OPTION_EXCLUDE_LIBS + 1)
@@ -2159,6 +2160,7 @@ 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},
+    {"enable-new-dtags-only", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS_ONLY},
     {"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},
@@ -2222,6 +2224,10 @@ fragment <<EOF
       link_info.new_dtags = TRUE;
       break;
 
+    case OPTION_ENABLE_NEW_DTAGS_ONLY:
+      link_info.new_dtags_only = TRUE;
+      break;
+
     case OPTION_EH_FRAME_HDR:
       link_info.eh_frame_hdr = TRUE;
       break;
@@ -2402,6 +2408,8 @@ fragment <<EOF
   fprintf (file, _("\
   --enable-new-dtags          Enable new dynamic tags\n"));
   fprintf (file, _("\
+  --enable-new-dtags-only     Only use new dynamic tags (omit old 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"));
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index c7ae2a5..bdab407 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -2099,15 +2099,19 @@ generated code sections like PLT.  This option is on by default
 if linker generated unwind info is supported.
 
 @kindex --enable-new-dtags
+@kindex --enable-new-dtags-only
 @kindex --disable-new-dtags
 @item --enable-new-dtags
+@itemx --enable-new-dtags-only
 @itemx --disable-new-dtags
 This linker can create the new dynamic tags in ELF. But the older ELF
 systems may not understand them. If you specify
 @option{--enable-new-dtags}, the dynamic tags will be created as needed.
 If you specify @option{--disable-new-dtags}, no new dynamic tags will be
-created. By default, the new dynamic tags are not created. Note that
-those options are only available for ELF systems.
+created. If you specify @option{--enable-new-dtags-only} in conjunction
+with @option{--enable-new-dtags}, then older dynamic tags will be omitted
+when new dynamic tags replace them. By default, the new dynamic tags are
+not created. Note that those options are only available for ELF systems.
 
 @kindex --hash-size=@var{number}
 @item --hash-size=@var{number}
-- 
1.8.0

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

end of thread, other threads:[~2014-02-05 17:01 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-25  7:29 [PATCH] [RFC] ld: add new --enable-new-dtags-only flag Mike Frysinger
2013-01-08  9:32 ` Alan Modra
2013-01-08 11:25   ` Mike Frysinger
2013-01-11  6:03 ` [PATCH v2] " Mike Frysinger
2013-01-11  9:22   ` John Marino
2013-01-11 16:34     ` Mike Frysinger
2013-01-12  6:30 ` [PATCH 1/2 v3] ld: add new --{dis,en}able-new-dtags-only flag Mike Frysinger
2013-01-12  6:30   ` [PATCH 2/2] gold: enable new dtags by default Mike Frysinger
2013-01-15 14:47     ` Ian Lance Taylor
2013-01-15 17:37       ` Mike Frysinger
2013-01-15 19:06         ` Ian Lance Taylor
2013-01-15 19:32           ` Mike Frysinger
2013-01-15 20:02             ` Ian Lance Taylor
2013-01-15 21:06               ` Mike Frysinger
2013-01-17  3:42               ` Alan Modra
2013-01-17  4:09                 ` Mike Frysinger
2013-01-17  4:42                   ` Alan Modra
2013-01-17 13:10                     ` Michael Matz
2013-01-17 19:19                     ` Mike Frysinger
2013-01-17 22:19                       ` Alan Modra
2013-01-17 19:19 ` [PATCH 1/2 v4] ld: change --enable-new-dtags to only generate new dtags Mike Frysinger
2013-01-17 19:18   ` [PATCH 2/2 v4] gold: enable new dtags by default Mike Frysinger
2013-01-17 21:33   ` [PATCH 1/2 v4] ld: change --enable-new-dtags to only generate new dtags Alan Modra
2013-01-17 22:26     ` Mike Frysinger
2013-01-18  4:23 ` [PATCH 1/2 v5] " Mike Frysinger
2013-01-18  4:23   ` [PATCH 2/2 v5] gold: enable new dtags by default Mike Frysinger
2013-01-18  6:24     ` Ian Lance Taylor
2013-02-05  1:44       ` H.J. Lu
2013-02-05  5:43         ` Ian Lance Taylor
2013-02-05  9:39           ` Alan Modra
2013-02-05 14:19             ` Ian Lance Taylor
2013-02-05 21:50               ` Alan Modra
2013-02-06 16:24                 ` H.J. Lu
2013-02-05 14:20             ` Ian Lance Taylor
2013-02-05 16:33               ` H.J. Lu
2013-02-05 21:57                 ` Alan Modra
2013-02-06  8:24                   ` Andreas Schwab
2013-02-06 16:37                     ` H.J. Lu
2013-02-06 16:28                   ` H.J. Lu
2013-02-06 21:44                     ` Alan Modra
2013-02-05 16:47             ` H.J. Lu
2013-02-05 17:41               ` H.J. Lu
2013-02-20  6:15           ` Mike Frysinger
2013-02-20 17:17             ` H.J. Lu
2013-02-20 18:40               ` Mike Frysinger
2014-02-05  0:12                 ` Cary Coutant
2014-02-05  2:29                   ` Joseph S. Myers
2014-02-05 16:53                     ` Cary Coutant
2014-02-05 17:01                       ` Joseph S. Myers
2013-01-18 14:00   ` [PATCH 1/2 v5] ld: change --enable-new-dtags to only generate new dtags Alan Modra
2013-01-18 21:02 ` [PATCH] ld: enable new dtags by default for linux/gnu targets Mike Frysinger
2013-01-19  6:42   ` Alan Modra
2013-01-19  8:40   ` Andreas Schwab
2013-01-19 16:12     ` Mike Frysinger
2013-01-21  8:26       ` Mike Frysinger
2013-01-31  0:47   ` Hans-Peter Nilsson
2013-01-31  0:58     ` Hans-Peter Nilsson
2013-01-31  9:58       ` Hans-Peter Nilsson
2013-02-04 18:15   ` H.J. Lu

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).