From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4777 invoked by alias); 11 Jan 2013 06:03:01 -0000 Received: (qmail 4761 invoked by uid 22791); 11 Jan 2013 06:02:58 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Jan 2013 06:02:51 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 7E0E333D99E for ; Fri, 11 Jan 2013 06:02:50 +0000 (UTC) From: Mike Frysinger To: binutils@sourceware.org Subject: [PATCH v2] ld: add new --enable-new-dtags-only flag Date: Fri, 11 Jan 2013 06:03:00 -0000 Message-Id: <1357884334-12598-1-git-send-email-vapier@gentoo.org> In-Reply-To: <1356420600-11507-1-git-send-email-vapier@gentoo.org> References: <1356420600-11507-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00159.txt.bz2 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 [Being lazy on CL writing until we hammer out the proposal] --- v2 - allow --enable-new-dtags-only to imply --enable-new-dtags bfd/elflink.c | 14 ++++++++++---- gold/layout.cc | 6 ++++-- gold/options.h | 3 +++ include/bfdlink.h | 3 +++ ld/emultempl/elf32.em | 10 +++++++++- ld/ld.texinfo | 8 ++++++-- 6 files changed, 35 insertions(+), 9 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..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 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..5de2b21 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -2120,7 +2120,8 @@ fragment <