From: Andris Pavenis <andris.pavenis@iki.fi>
To: GCC Patches <gcc-patches@gcc.gnu.org>, DJ Delorie <dj@delorie.com>
Subject: [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking
Date: Tue, 10 Nov 2015 18:16:00 -0000 [thread overview]
Message-ID: <56423464.20506@iki.fi> (raw)
[-- Attachment #1: Type: text/plain, Size: 504 bytes --]
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 <andris.pavenis@iki.fi>
* gcc.c: new macro POST_LINK_SPEC
* doc/tm.texi.in: document POST_LINK_SPEC
* doc/tm.texi: regenerate
[-- Attachment #2: 0001-New-macro-POST_LINK_SPEC.patch --]
[-- Type: text/x-patch, Size: 3437 bytes --]
From 2b50898ca2340aa43ce756bd605862b947cf1e7d Mon Sep 17 00:00:00 2001
From: Andris Pavenis <andris.pavenis@iki.fi>
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
next reply other threads:[~2015-11-10 18:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 18:16 Andris Pavenis [this message]
2015-11-10 21:20 ` Jeff Law
2015-11-11 4:30 ` Andris Pavenis
2015-11-13 6:41 ` Jeff Law
2015-11-13 6:40 ` Jeff Law
2015-11-15 8:28 ` Andris Pavenis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56423464.20506@iki.fi \
--to=andris.pavenis@iki.fi \
--cc=dj@delorie.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).