mailing list of musl libc
 help / color / mirror / code / Atom feed
* fixing -fPIE + -fstack-protector-all
@ 2014-11-05 15:25 John Spencer
  2014-11-05 15:43 ` Rich Felker
  2014-11-05 16:01 ` Timo Teras
  0 siblings, 2 replies; 16+ messages in thread
From: John Spencer @ 2014-11-05 15:25 UTC (permalink / raw)
  To: musl; +Cc: Gregor Richards

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


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-11-07 12:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-05 15:25 fixing -fPIE + -fstack-protector-all John Spencer
2014-11-05 15:43 ` Rich Felker
2014-11-05 16:01   ` John Spencer
2014-11-05 16:20     ` Rich Felker
2014-11-06  1:34   ` Andy Lutomirski
2014-11-06  1:44     ` Rich Felker
2014-11-06 11:45   ` Anthony G. Basile
2014-11-06 12:36     ` John Spencer
2014-11-07 12:25       ` Anthony G. Basile
2014-11-07  2:10     ` Andy Lutomirski
2014-11-07 12:16       ` Anthony G. Basile
2014-11-05 16:01 ` Timo Teras
2014-11-06 12:11   ` Anthony G. Basile
2014-11-06 15:43     ` Rich Felker
2014-11-06 12:40   ` John Spencer
2014-11-06 12:47     ` Timo Teras

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).