This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
x86 android: change -fstack-protector guard default to TLS
- From: Than McIntosh <thanm at google dot com>
- To: gcc at gcc dot gnu dot org
- Cc: Than McIntosh <thanm at google dot com>, David Li <davidxl at google dot com>, Elliott Hughes <enh at google dot com>
- Date: Wed, 11 Nov 2015 10:16:09 -0500
- Subject: x86 android: change -fstack-protector guard default to TLS
- Authentication-results: sourceware.org; auth=none
Hi,
The current implementation of -fstack-protector for x86 defaults to
using a TLS guard, unless the target in question is Android, in which
case it falls back on using a global guard. Code from
config/i386/i386.c line 5512 or thereabouts:
/* Handle stack protector */
if (!opts_set->x_ix86_stack_protector_guard)
opts->x_ix86_stack_protector_guard
= TARGET_HAS_BIONIC ? SSP_GLOBAL : SSP_TLS;
The rationale for the current behavior is described here:
https://gcc.gnu.org/ml/gcc-patches/2013-04/msg00764.html
e.g. the decision to default to a global guard was motivated by the
desire to promote compatibility at the time with older versions of
Android (pre Jelly Bean).
This default for Android no longer makes sense given Bionic has had
TLS guard support for quite some time now; platform developers and
kernel developers have complained about the current behavior and have
been lobbying for changing the default. Folks that are compiling
native code for pre-4.2 Android will most likely be using older
versions of the Android NDK in any case.
I would like to propose removing the Bionic exception, e.g. changing
the code to read:
/* Handle stack protector */
if (!opts_set->x_ix86_stack_protector_guard)
opts->x_ix86_stack_protector_guard = SSP_TLS;
Any comments, questions, etc. would be appreciated.
Thanks, Than