From patchwork Tue Nov 10 18:16:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andris_Pav=C4=93nis?= X-Patchwork-Id: 542554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A850A141567 for ; Wed, 11 Nov 2015 05:16:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=du/GXHDt; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Mor4gPZdFUVPFQg0gnBtOyKejhxAz9/TatCjI2L51xJa6fBF4U xUU0ClruTsawx3dazgH6RLTVuMw24ZX6B8dsNQsgq4SWqedLikehORfS6ZbjRBZT IhU1juq+z/BmZFTb+1GKd7GsJ5R4DFNZLkgN2zYBpvjRqAgwycowp+DKE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=b2qZjBZat1Pjo6FDJlb3A4g/dxg=; b=du/GXHDtrtywIMwIXk36 HGaGYhMdjxGhJ2ucL13Y8SLQbwqNFOsMhuOPiLlGitZl57X2hZD6e4q/3h+ra4II 2Nhpd1tkSlxPE2PQVEvcwbXpy2MH4L0ixOFouVpt/v14WCZkA/iUzWXfd1hmCyhV oljDlU9sI/n2+l/cUCQ/mcQ= Received: (qmail 45793 invoked by alias); 10 Nov 2015 18:16:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 44726 invoked by uid 89); 10 Nov 2015 18:16:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, SPF_NEUTRAL autolearn=no version=3.3.2 X-HELO: julia1.inet.fi Received: from mta-out1.inet.fi (HELO julia1.inet.fi) (62.71.2.232) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Nov 2015 18:16:12 +0000 Received: from ap.localhost.localdomain (84.249.219.59) by julia1.inet.fi (9.0.002.03-2-gbe5d057) (authenticated as pavean-2) id 5613C7B100DF87A0; Tue, 10 Nov 2015 20:14:46 +0200 To: GCC Patches , DJ Delorie From: Andris Pavenis Subject: [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking Message-ID: <56423464.20506@iki.fi> Date: Tue, 10 Nov 2015 20:16:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 One may need to execute extra steps after linking program. This is required for example for DJGPP to run stubify.exe on file generated by linker. The only way how to achieve was to use LINK_COMMAND_SPEC. It would be much easier and less error prone to use new macro POST_LINK_SPEC introduced in this patch. Andris ChangeLog entry 2015 Nov 10 Andris Pavenis * gcc.c: new macro POST_LINK_SPEC * doc/tm.texi.in: document POST_LINK_SPEC * doc/tm.texi: regenerate From 2b50898ca2340aa43ce756bd605862b947cf1e7d Mon Sep 17 00:00:00 2001 From: Andris Pavenis Date: Tue, 10 Nov 2015 19:52:57 +0200 Subject: [PATCH] New macro POST_LINK_SPEC for additional steps after rinning linker --- gcc/doc/tm.texi | 5 +++++ gcc/doc/tm.texi.in | 5 +++++ gcc/gcc.c | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index f394db7..fe4e7f0 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -375,6 +375,11 @@ The sequence in which libgcc and libc are specified to the linker. By default this is @code{%G %L %G}. @end defmac +@defmac POST_LINK_SPEC +Define this macro to add additional steps to be executed after linker. +The default value of this macro is empty string. +@end defmac + @defmac LINK_COMMAND_SPEC A C string constant giving the complete command line need to execute the linker. When you do this, you will need to update your port each time a diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index d188c57..8c9c1b2 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -375,6 +375,11 @@ The sequence in which libgcc and libc are specified to the linker. By default this is @code{%G %L %G}. @end defmac +@defmac POST_LINK_SPEC +Define this macro to add additional steps to be executed after linker. +The default value of this macro is empty string. +@end defmac + @defmac LINK_COMMAND_SPEC A C string constant giving the complete command line need to execute the linker. When you do this, you will need to update your port each time a diff --git a/gcc/gcc.c b/gcc/gcc.c index bbc9b23..45d6089 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -979,6 +979,10 @@ proper position among the other output files. */ %{%:sanitize(leak):" LIBLSAN_SPEC "}}}" #endif +#ifndef POST_LINK_SPEC +#define POST_LINK_SPEC "" +#endif + /* This is the spec to use, once the code for creating the vtable verification runtime library, libvtv.so, has been created. Currently the vtable verification runtime functions are in libstdc++, so we use @@ -1021,7 +1025,7 @@ proper position among the other output files. */ %(mflib) " STACK_SPLIT_SPEC "\ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \ %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ - %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}" + %{!nostdlib:%{!nostartfiles:%E}} %{T*} \n%(post_link) }}}}}}" #endif #ifndef LINK_LIBGCC_SPEC @@ -1063,6 +1067,7 @@ static const char *linker_name_spec = LINKER_NAME; static const char *linker_plugin_file_spec = ""; static const char *lto_wrapper_spec = ""; static const char *lto_gcc_spec = ""; +static const char *post_link_spec = POST_LINK_SPEC; static const char *link_command_spec = LINK_COMMAND_SPEC; static const char *link_libgcc_spec = LINK_LIBGCC_SPEC; static const char *startfile_prefix_spec = STARTFILE_PREFIX_SPEC; @@ -1571,6 +1576,7 @@ static struct spec_list static_specs[] = INIT_STATIC_SPEC ("linker_plugin_file", &linker_plugin_file_spec), INIT_STATIC_SPEC ("lto_wrapper", <o_wrapper_spec), INIT_STATIC_SPEC ("lto_gcc", <o_gcc_spec), + INIT_STATIC_SPEC ("post_link", &post_link_spec), INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec), INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix), INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix), -- 2.4.3