From df2a1cc48b45a5493646e14bcd81eff7d684e15b Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Thu, 24 Sep 2015 09:00:22 +0000 Subject: Support PIE on Solaris gcc/testsuite: * lib/target-supports.exp (check_effective_target_pie): Check for PIE support on Solaris 11.x and 12. libgcc: * config.host (*-*-solaris2*): Add t-crtstuff-pic to tmake_file. Add crtbeginS.o, crtendS.o to extra_parts if libgcc_cv_solaris_crts. * config/sol2/gmon.c: (monstartup): Don't write trailing NUL of messages. (internal_mcount): Likewise. * config/sol2/t-sol2 (crtp.o, crtpg.o, gmon.o): Compile with crt_compile, add CRTSTUFF_T_CFLAGS_S. gcc: * configure.ac (gcc_cv_ld_pie): Check for gld >= 2.26 on Solaris. Check for ld -type pie on Solaris 11.x and 12. * configure: Regenerate. * config.in: Regenerate. * gcc.c (LD_PIE_SPEC): Allow redefinition. * config/sol2.h (STARTFILE_CRTBEGIN_SPEC): Define. (STARTFILE_SPEC): Use it. (ENDFILE_CRTEND_SPEC): Define. (ENDFILE_SPEC): Use it and ENDFILE_ARCH_SPEC. (SUBTARGET_EXTRA_SPECS): Add STARTFILE_CRTBEGIN_SPEC, ENDFILE_ARCH_SPEC, ENDFILE_CRTEND_SPEC. [HAVE_LD_PIE && HAVE_SOLARIS_CRTS] (LD_PIE_SPEC): Define. (!(HAVE_LD_PIE && HAVE_SOLARIS_CRTS)] (LINK_PIE_SPEC): Define. * config/i386/sol2.h (ENDFILE_SPEC): Remove. (ENDFILE_ARCH_SPEC): Define. * config/sparc/sol2.h (ENDFILE_ARCH_SPEC): Define. From-SVN: r228078 --- gcc/configure.ac | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'gcc/configure.ac') diff --git a/gcc/configure.ac b/gcc/configure.ac index 4f8a44e..65b5d70 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -4751,19 +4751,41 @@ AC_MSG_RESULT($gcc_cv_ld_eh_frame_ciev3) AC_MSG_CHECKING(linker position independent executable support) gcc_cv_ld_pie=no if test $in_tree_ld = yes ; then - if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 15 -o "$gcc_cv_gld_major_version" -gt 2 \ + case "$target" in + # Full PIE support on Solaris was only introduced in gld 2.26. + *-*-solaris2*) gcc_gld_pie_min_version=26 ;; + *) gcc_gld_pie_min_version=15 ;; + esac + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge "$gcc_gld_pie_min_version" -o "$gcc_cv_gld_major_version" -gt 2 \ && test $in_tree_ld_is_elf = yes; then gcc_cv_ld_pie=yes fi elif test x$gcc_cv_ld != x; then - # Check if linker supports -pie option - if $gcc_cv_ld --help 2>/dev/null | grep -- -pie > /dev/null; then - gcc_cv_ld_pie=yes + # Check if linker supports -pie option + if $gcc_cv_ld --help 2>/dev/null | grep -- -pie > /dev/null; then + gcc_cv_ld_pie=yes + case "$target" in + *-*-solaris2*) + if echo "$ld_ver" | grep GNU > /dev/null \ + && test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then + gcc_cv_ld_pie=no fi + ;; + esac + else + case "$target" in + *-*-solaris2.1[[1-9]]*) + # Solaris 11.x and Solaris 12 added PIE support. + if $gcc_cv_ld -z help 2>&1 | grep -- type.*pie > /dev/null; then + gcc_cv_ld_pie=yes + fi + ;; + esac + fi fi if test x"$gcc_cv_ld_pie" = xyes; then AC_DEFINE(HAVE_LD_PIE, 1, -[Define if your linker supports -pie option.]) +[Define if your linker supports PIE option.]) fi AC_MSG_RESULT($gcc_cv_ld_pie) -- cgit v1.1