public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5845] Darwin: Amend pie options when linking mdynamic-no-pic.
@ 2021-12-08 19:47 Iain D Sandoe
0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2021-12-08 19:47 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1c1563fb8ff227590eb5ab0fc3d22f3b0a57c241
commit r12-5845-g1c1563fb8ff227590eb5ab0fc3d22f3b0a57c241
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Mon Dec 6 13:17:10 2021 +0000
Darwin: Amend pie options when linking mdynamic-no-pic.
On i686 Darwin from macOS 10.7 onwards the default is to
link executables as PIE, which conflicts with code generated
using mdynamic-no-pic. Rather than warn about this and then
get the user to add -Wl,-no_pie, we can inject this in the
link specs.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:
* config/darwin.h (DARWIN_PIE_SPEC): Add -no_pie when
linking mdynamic-no-pic code on macOS > 10.7.
Diff:
---
gcc/config/darwin.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 9895e7f99ec..0ce13207ad6 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -288,13 +288,17 @@ extern GTY(()) int darwin_ms_struct;
#define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}"
#endif
-/* FIXME: we should check that the linker supports the -pie and -no_pie.
+/* Code built with mdynamic-no-pic does not support PIE/PIC, so we disallow
+ these combinations; we also ensure that the no_pie option is passed to
+ ld64 on system versions that default to PIE when mdynamic-no-pic is given.
+ FIXME: we should check that the linker supports the -pie and -no_pie.
options. */
#define DARWIN_PIE_SPEC \
"%{pie|fpie|fPIE:\
%{mdynamic-no-pic: \
%n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \
- :%:version-compare(>= 10.5 mmacosx-version-min= -pie) }} "
+ :%:version-compare(>= 10.5 mmacosx-version-min= -pie) }; \
+ mdynamic-no-pic:%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } "
#define DARWIN_NOPIE_SPEC \
"%{no-pie|fno-pie|fno-PIE: \
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-08 19:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 19:47 [gcc r12-5845] Darwin: Amend pie options when linking mdynamic-no-pic Iain D Sandoe
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).