From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6439 Path: news.gmane.org!not-for-mail From: John Spencer Newsgroups: gmane.linux.lib.musl.general Subject: fixing -fPIE + -fstack-protector-all Date: Wed, 05 Nov 2014 16:25:03 +0100 Message-ID: <545A414F.8000407@barfooze.de> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1415201199 18805 80.91.229.3 (5 Nov 2014 15:26:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Nov 2014 15:26:39 +0000 (UTC) Cc: Gregor Richards To: musl@lists.openwall.com Original-X-From: musl-return-6452-gllmg-musl=m.gmane.org@lists.openwall.com Wed Nov 05 16:26:33 2014 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Xm2Tg-0000pn-KE for gllmg-musl@m.gmane.org; Wed, 05 Nov 2014 16:26:32 +0100 Original-Received: (qmail 20094 invoked by uid 550); 5 Nov 2014 15:26:31 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 20079 invoked from network); 5 Nov 2014 15:26:30 -0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 Xref: news.gmane.org gmane.linux.lib.musl.general:6439 Archived-At: using -fPIE + -fstack-protector-all is currently broken for a number of architectures (most notably i386) in the default gcc setup (including the musl-cross patches), as it depends on a libssp_nonshared.a which provides __stack_chk_fail_local(). even when gcc's version is built from ssp-local.c and installed via `make install-target-libssp`, gcc won't use it to link programs compiled with -fstack-protector[-all]. the reason is that (since we provide the rest of the ssp functionality in musl) we set gcc_cv_libc_provides_ssp=yes, which, contrary to our earlier expectations means: "libc provides ssp *and* ssp_nonshared": (from gcc/gcc.c) #ifdef TARGET_LIBC_PROVIDES_SSP #define LINK_SSP_SPEC "%{fstack-protector:}" #else #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}" #endif so my conclusion is that in order to fix this issue cleanly and get musl support into upstream, we need to either (on the gcc side) define a new gcc_cv_libc_provides_ssp_but_not_ssp_nonshared conditional and an install target that installs only libssp_nonshared but not libssp, and links only to libssp_nonshared if ssp was used, or somehow get that symbol (__stack_chk_fail_local()) into musl and linked to binaries in a way that doesn't require additional library flags on the linker command line. in the former case, the above snippet would look like #ifdef TARGET_LIBC_PROVIDES_SSP #define LINK_SSP_SPEC "%{fstack-protector:}" #elif TARGET_LIBC_PROVIDES_SSP_BUT_NOT_SSP_NONSHARED #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared}" #else #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}" #endif --JS