From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 37AC9139694 for ; Thu, 15 Jun 2017 14:37:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0B97B21C073; Thu, 15 Jun 2017 14:37:39 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A13DE21C043 for ; Thu, 15 Jun 2017 14:37:38 +0000 (UTC) Received: from [10.98.191.124] (public-gprs386236.centertel.pl [37.47.139.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id A42D2341833; Thu, 15 Jun 2017 14:37:35 +0000 (UTC) Date: Thu, 15 Jun 2017 16:37:29 +0200 User-Agent: K-9 Mail for Android In-Reply-To: <20170615134510.5219-2-tamiko@gentoo.org> References: <1497514281.1807.2.camel@gentoo.org> <20170615134510.5219-1-tamiko@gentoo.org> <20170615134510.5219-2-tamiko@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [gentoo-dev] [PATCH 01/05] toolchain-funcs.eclass: Add functions for detection of PIE / SSP in way compatible with GCC >=6. To: gentoo-dev@lists.gentoo.org,Matthias Maier CC: toolchain@gentoo.org,embedded@gentoo.org From: =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= Message-ID: <76B379FB-3055-4D85-8E51-3CF6D658F9C3@gentoo.org> X-Archives-Salt: c3ae70d1-ccce-4b7d-9401-4a2eb3802dd3 X-Archives-Hash: a3acc86b90c94e94c8ef7405811aa93f Dnia 15 czerwca 2017 15:45:10 CEST, Matthias Maier na= pisa=C5=82(a): >From: Arfrever Frehtes Taifersar Arahesis > >Newly added tc-enables-pie(), tc-enables-ssp(), tc-enables-ssp-strong() >and tc-enables-ssp-all() check macros instead of specs=2E >This solution also works with older GCC and with Clang=2E > >Signed-off-by: Matthias Maier >--- >eclass/toolchain-funcs=2Eeclass | 67 >+++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 67 insertions(+) > >diff --git a/eclass/toolchain-funcs=2Eeclass >b/eclass/toolchain-funcs=2Eeclass >index a0c359a950=2E=2E8cfe329a96 100644 >--- a/eclass/toolchain-funcs=2Eeclass >+++ b/eclass/toolchain-funcs=2Eeclass >@@ -792,6 +792,73 @@ gcc-specs-stack-check() { > } >=20 >=20 >+# @FUNCTION: tc-enables-pie >+# @RETURN: Truth if the current compiler generates >position-independent code (PIC) which can be linked into executables >+# @DESCRIPTION: >+# Return truth if the current compiler generates position-independent >code (PIC) >+# which can be linked into executables=2E >+tc-enables-pie() { >+ local ret=3D"$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> >/dev/null >+ #if defined(__PIE__) >+ true >+ #endif >+ EOF >+ )" >+ [ "${ret}" =3D "true" ] [[ ${ret} =3D=3D true ]] Would be the canonical bash way=2E >+} >+ >+# @FUNCTION: tc-enables-ssp >+# @RETURN: Truth if the current compiler enables stack smashing >protection (SSP) on at least minimal level >+# @DESCRIPTION: >+# Return truth if the current compiler enables stack smashing >protection (SSP) >+# on level corresponding to any of the following options: >+# -fstack-protector >+# -fstack-protector-strong >+# -fstack-protector-all >+tc-enables-ssp() { >+ local ret=3D"$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> >/dev/null >+ #if defined(__SSP__) || defined(__SSP_STRONG__) || >defined(__SSP_ALL__) >+ true >+ #endif >+ EOF >+ )" >+ [ "${ret}" =3D "true" ] >+} >+ >+# @FUNCTION: tc-enables-ssp-strong >+# @RETURN: Truth if the current compiler enables stack smashing >protection (SSP) on at least middle level >+# @DESCRIPTION: >+# Return truth if the current compiler enables stack smashing >protection (SSP) >+# on level corresponding to any of the following options: >+# -fstack-protector-strong >+# -fstack-protector-all >+tc-enables-ssp-strong() { >+ local ret=3D"$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> >/dev/null >+ #if defined(__SSP_STRONG__) || defined(__SSP_ALL__) >+ true >+ #endif >+ EOF >+ )" >+ [ "${ret}" =3D "true" ] >+} >+ >+# @FUNCTION: tc-enables-ssp-all >+# @RETURN: Truth if the current compiler enables stack smashing >protection (SSP) on maximal level >+# @DESCRIPTION: >+# Return truth if the current compiler enables stack smashing >protection (SSP) >+# on level corresponding to any of the following options: >+# -fstack-protector-all >+tc-enables-ssp-all() { >+ local ret=3D"$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> >/dev/null >+ #if defined(__SSP_ALL__) >+ true >+ #endif >+ EOF >+ )" >+ [ "${ret}" =3D "true" ] >+} >+ >+ > # @FUNCTION: gen_usr_ldscript > # @USAGE: [-a] > # @DESCRIPTION: --=20 Best regards, Micha=C5=82 G=C3=B3rny (by phone)