This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 1/2 v3] ld: add new --{dis,en}able-new-dtags-only flag
- From: Mike Frysinger <vapier at gentoo dot org>
- To: binutils at sourceware dot org
- Date: Sat, 12 Jan 2013 01:32:54 -0500
- Subject: [PATCH 1/2 v3] ld: add new --{dis,en}able-new-dtags-only flag
- References: <1356420600-11507-1-git-send-email-vapier@gentoo.org>
With the --enable-new-dtags flag, you can generate DT_RUNPATH in
addition to DT_RPATH. But the latter tag isn't useful while the
former tag is being generated on systems, and DT_RUNPATH has been
around for at least 14 years, so it's probably about time we stop
assuming it's "new".
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
bfd/:
2013-01-12 Mike Frysinger <vapier@gentoo.org>
* elflink.c (bfd_elf_size_dynamic_sections): Add DT_RPATH entry
when new_dtags_only is false. Add DT_RUNPATH when new_dtags is
true.
gold/:
2013-01-12 Mike Frysinger <vapier@gentoo.org>
* layout.cc (Layout::finish_dynamic_section): Add DT_RPATH entry
when enable_new_dtags_only is false. Add DT_RUNPATH when
enable_new_dtags or enable_new_dtags_only is true.
* options.h (General_options): Add new_dtags_only option.
include/:
2013-01-12 Mike Frysinger <vapier@gentoo.org>
* bfdlink.h (struct bfd_link_info): Add new_dtags_only field.
ld/:
2013-01-12 Mike Frysinger <vapier@gentoo.org>
* emultempl/elf32.em (OPTION_ENABLE_NEW_DTAGS_ONLY): Define.
(OPTION_DISABLE_NEW_DTAGS_ONLY): Likewise.
(OPTION_GROUP): Define based on OPTION_DISABLE_NEW_DTAGS_ONLY.
(xtra_long): Add disable-new-dtags-only and enable-new-dtags-only.
(_handle_option): Handle OPTION_DISABLE_NEW_DTAGS_ONLY and
OPTION_ENABLE_NEW_DTAGS_ONLY.
(_list_options): Add --disable-new-dtags-only and
--enable-new-dtags-only.
* ld.texinfo (Options): Document --disable-new-dtags-only and
--enable-new-dtags-only.
---
v3
- add --disable-new-dtags-only
- fix up commit message
- add changelog
bfd/elflink.c | 14 ++++++++++----
gold/layout.cc | 6 ++++--
gold/options.h | 4 ++++
include/bfdlink.h | 3 +++
ld/emultempl/elf32.em | 18 +++++++++++++++++-
ld/ld.texinfo | 11 +++++++++--
6 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 7861946..58d0caa 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5751,13 +5751,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..4e3b0a5 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -4645,8 +4645,10 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
}
}
- odyn->add_string(elfcpp::DT_RPATH, rpath_val);
- if (parameters->options().enable_new_dtags())
+ if (!parameters->options().enable_new_dtags_only())
+ odyn->add_string(elfcpp::DT_RPATH, rpath_val);
+ if (parameters->options().enable_new_dtags()
+ || parameters->options().enable_new_dtags_only())
odyn->add_string(elfcpp::DT_RUNPATH, rpath_val);
}
diff --git a/gold/options.h b/gold/options.h
index 1eb2da2..ec3f823 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -908,6 +908,10 @@ 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"),
+ N_("Do not skip the use of DT_RPATH"));
+
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 53d4e24..7ddd7a3 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -2121,7 +2121,9 @@ 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_DISABLE_NEW_DTAGS_ONLY (OPTION_ENABLE_NEW_DTAGS_ONLY + 1)
+#define OPTION_GROUP (OPTION_DISABLE_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)
@@ -2160,6 +2162,8 @@ 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},
+ {"disable-new-dtags-only", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS_ONLY},
+ {"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},
@@ -2219,6 +2223,14 @@ fragment <<EOF
link_info.new_dtags = FALSE;
break;
+ case OPTION_DISABLE_NEW_DTAGS_ONLY:
+ link_info.new_dtags_only = FALSE;
+ break;
+
+ case OPTION_ENABLE_NEW_DTAGS_ONLY:
+ link_info.new_dtags_only = TRUE;
+ /* Fall through. */
+
case OPTION_ENABLE_NEW_DTAGS:
link_info.new_dtags = TRUE;
break;
@@ -2403,6 +2415,10 @@ fragment <<EOF
fprintf (file, _("\
--enable-new-dtags Enable new dynamic tags\n"));
fprintf (file, _("\
+ --disable-new-dtags-only Use new and old 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 4777ad5..414ccff 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -2101,15 +2101,22 @@ 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
+@kindex --disable-new-dtags-only
@item --enable-new-dtags
+@itemx --enable-new-dtags-only
@itemx --disable-new-dtags
+@itemx --disable-new-dtags-only
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}, then older
+dynamic tags will be omitted when new dynamic tags replace them
+(and @option{--disable-new-dtags-only} can disable that behavior). 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.2