aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/sol2.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/config/sol2.h')
-rw-r--r--gcc/config/sol2.h51
1 files changed, 41 insertions, 10 deletions
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
index d31a251..f444e48 100644
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -154,6 +154,14 @@ along with GCC; see the file COPYING3. If not see
#define STARTFILE_ARCH_SPEC "%{ansi:values-Xc.o%s} \
%{!ansi:values-Xa.o%s}"
+#if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
+#define STARTFILE_CRTBEGIN_SPEC "%{shared:crtbeginS.o%s} \
+ %{" PIE_SPEC ":crtbeginS.o%s} \
+ %{" NO_PIE_SPEC ":crtbegin.o%s}"
+#else
+#define STARTFILE_CRTBEGIN_SPEC "crtbegin.o%s"
+#endif
+
/* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */
#undef STARTFILE_SPEC
#ifdef HAVE_SOLARIS_CRTS
@@ -164,21 +172,27 @@ along with GCC; see the file COPYING3. If not see
%{p:%e-p is not supported; \
pg:crtpg.o%s gmon.o%s; \
:crtp.o%s}}} \
- crti.o%s %(startfile_arch) \
- crtbegin.o%s"
+ crti.o%s %(startfile_arch) %(startfile_crtbegin)"
#else
#define STARTFILE_SPEC "%{!shared:%{!symbolic: \
%{p:mcrt1.o%s; \
pg:gcrt1.o%s gmon.o%s; \
:crt1.o%s}}} \
- crti.o%s %(startfile_arch) \
- crtbegin.o%s"
+ crti.o%s %(startfile_arch) %(startfile_crtbegin)"
+#endif
+
+#if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
+#define ENDFILE_CRTEND_SPEC "%{shared:crtendS.o%s;: \
+ %{" PIE_SPEC ":crtendS.o%s} \
+ %{" NO_PIE_SPEC ":crtend.o%s}}"
+#else
+#define ENDFILE_CRTEND_SPEC "crtend.o%s"
#endif
#undef ENDFILE_SPEC
#define ENDFILE_SPEC \
"%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
- crtend.o%s crtn.o%s"
+ %(endfile_arch) %(endfile_crtend) crtn.o%s"
#undef LINK_ARCH32_SPEC_BASE
#define LINK_ARCH32_SPEC_BASE \
@@ -251,11 +265,14 @@ along with GCC; see the file COPYING3. If not see
#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
- { "startfile_arch", STARTFILE_ARCH_SPEC }, \
- { "link_arch32", LINK_ARCH32_SPEC }, \
- { "link_arch64", LINK_ARCH64_SPEC }, \
- { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
- { "link_arch", LINK_ARCH_SPEC }, \
+ { "startfile_arch", STARTFILE_ARCH_SPEC }, \
+ { "startfile_crtbegin", STARTFILE_CRTBEGIN_SPEC }, \
+ { "link_arch32", LINK_ARCH32_SPEC }, \
+ { "link_arch64", LINK_ARCH64_SPEC }, \
+ { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
+ { "link_arch", LINK_ARCH_SPEC }, \
+ { "endfile_arch", ENDFILE_ARCH_SPEC }, \
+ { "endfile_crtend", ENDFILE_CRTEND_SPEC }, \
SUBTARGET_CPU_EXTRA_SPECS
/* C++11 programs need -lrt for nanosleep. */
@@ -310,6 +327,20 @@ along with GCC; see the file COPYING3. If not see
#endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */
#endif
+#if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
+#ifdef USE_GLD
+/* Assert -z text by default to match Solaris ld. */
+#define LD_PIE_SPEC "-pie %{!mimpure-text:-z text}"
+#else
+/* Solaris ld needs -z type=pie instead of -pie. */
+#define LD_PIE_SPEC "-z type=pie %{mimpure-text:-z textoff}"
+#endif
+#else
+/* Error out if some part of PIE support is missing. */
+#define LINK_PIE_SPEC \
+ "%{no-pie:} %{pie:%e-pie is not supported in this configuration} "
+#endif
+
/* collect2.c can only parse GNU nm -n output. Solaris nm needs -png to
produce the same format. */
#define NM_FLAGS "-png"