public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch][GCC] Document and fix -r (partial linking)
@ 2018-08-01 16:14 Allan Sandfeld Jensen
  2018-08-01 16:32 ` Joseph Myers
  2018-08-01 16:39 ` Rainer Orth
  0 siblings, 2 replies; 16+ messages in thread
From: Allan Sandfeld Jensen @ 2018-08-01 16:14 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

The option has existed and been working for years,
make sure it implies the right extra options, and list
it in the documentation.

2018-08-01 Allan Sandfeld Jensen <allan.jensen@qt.io>

gcc/doc

    * invoke.texi: Document -r

gcc/
    * gcc.c: Correct default specs for -r
---
 gcc/doc/invoke.texi | 7 ++++++-
 gcc/gcc.c           | 6 +++---
 2 files changed, 9 insertions(+), 4 deletions(-)

[-- Attachment #2: 0001-Fix-and-document-r-option.patch --]
[-- Type: text/x-patch, Size: 2878 bytes --]

From 638966e6c7e072ca46c6af0664fbd57bedbfff80 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Wed, 1 Aug 2018 18:07:05 +0200
Subject: [PATCH] Fix and document -r option

The option has existed and been working for years,
make sure it implies the right extra options, and list
it in the documentation.

2018-07-29 Allan Sandfeld Jensen <allan.jensen@qt.io>

gcc/doc

    * invoke.texi: Document -r

gcc/
    * gcc.c: Correct default specs for -r
---
 gcc/doc/invoke.texi | 7 ++++++-
 gcc/gcc.c           | 6 +++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 6047d82065a..7da30bd9d99 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -518,7 +518,7 @@ Objective-C and Objective-C++ Dialects}.
 @xref{Link Options,,Options for Linking}.
 @gccoptlist{@var{object-file-name}  -fuse-ld=@var{linker}  -l@var{library} @gol
 -nostartfiles  -nodefaultlibs  -nolibc  -nostdlib @gol
--pie  -pthread  -rdynamic @gol
+-pie  -pthread  -r  -rdynamic @gol
 -s  -static -static-pie -static-libgcc  -static-libstdc++ @gol
 -static-libasan  -static-libtsan  -static-liblsan  -static-libubsan @gol
 -shared  -shared-libgcc  -symbolic @gol
@@ -12444,6 +12444,11 @@ x86 Cygwin and MinGW targets.  On some targets this option also sets
 flags for the preprocessor, so it should be used consistently for both
 compilation and linking.
 
+@item -r
+@opindex r
+Produce a relocatable object as output. This is also known as partial
+linking.
+
 @item -rdynamic
 @opindex rdynamic
 Pass the flag @option{-export-dynamic} to the ELF linker, on targets
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 780d4859ef3..858a5600c14 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -675,7 +675,7 @@ proper position among the other output files.  */
 
 /* config.h can define LIB_SPEC to override the default libraries.  */
 #ifndef LIB_SPEC
-#define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
+#define LIB_SPEC "%{!shared|!r:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
 #endif
 
 /* When using -fsplit-stack we need to wrap pthread_create, in order
@@ -797,7 +797,7 @@ proper position among the other output files.  */
 /* config.h can define STARTFILE_SPEC to override the default crt0 files.  */
 #ifndef STARTFILE_SPEC
 #define STARTFILE_SPEC  \
-  "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}"
+  "%{!shared|!r:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}"
 #endif
 
 /* config.h can define ENDFILE_SPEC to override the default crtn files.  */
@@ -936,7 +936,7 @@ proper position among the other output files.  */
 #else
 #define LD_PIE_SPEC ""
 #endif
-#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
+#define LINK_PIE_SPEC "%{static|shared|r|ar:;" PIE_SPEC ":" LD_PIE_SPEC "} "
 #endif
 
 #ifndef LINK_BUILDID_SPEC
-- 
2.17.0


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

end of thread, other threads:[~2018-09-20 19:38 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01 16:14 [Patch][GCC] Document and fix -r (partial linking) Allan Sandfeld Jensen
2018-08-01 16:32 ` Joseph Myers
2018-08-01 17:12   ` Allan Sandfeld Jensen
2018-08-03 11:56   ` Allan Sandfeld Jensen
2018-08-03 13:27     ` Iain Sandoe
2018-08-11  9:05     ` Allan Sandfeld Jensen
2018-08-20 22:39     ` Joseph Myers
2018-08-23  7:47       ` Iain Sandoe
2018-08-23 21:24         ` Joseph Myers
2018-08-26 18:17           ` Allan Sandfeld Jensen
2018-08-27 13:37             ` Joseph Myers
2018-09-01 10:57               ` Allan Sandfeld Jensen
2018-09-01 11:05               ` Allan Sandfeld Jensen
2018-09-20 20:02                 ` Joseph Myers
2018-08-26 10:34       ` Allan Sandfeld Jensen
2018-08-01 16:39 ` Rainer Orth

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