https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78875

--- Comment #2 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Author: segher
Date: Tue Jan 17 22:02:42 2017
New Revision: 244556

URL: https://gcc.gnu.org/viewcvs?rev=244556&root=gcc&view=rev
Log:
-mstack-protector-guard and friends (PR78875)

Currently, on PowerPC, code compiled with -fstack-protector will load
the canary from -0x7010(13) (for -m64) or from -0x7008(2) (for -m32)
if GCC was compiled against GNU libc 2.4 or newer or some other libc
that supports -fstack-protector, and from the global variable
__stack_chk_guard otherwise.

This does not work well for Linux and other OS kernels and similar.
For such non-standard applications, this patch creates a few new
command-line options.  The relevant new use cases are:

-mstack-protector-guard=global
Use the __stack_chk_guard variable, no matter how this GCC was
configured.

-mstack-protector-guard=tls
Use the canary from TLS.  This will error out if this GCC was built
with a C library that does not support it.

-mstack-protector-guard=tls -mstack-protector-register=<reg>
-mstack-protector-offset=<offset>
Load the canary from offset <off> from base register <reg>.


        PR target/78875
        * config/rs6000/rs6000-opts.h (stack_protector_guard): New enum.
        * config/rs6000/rs6000.c (rs6000_option_override_internal): Handle
        the new options.
        * config/rs6000/rs6000.md (stack_protect_set): Handle the new more
        flexible settings.
        (stack_protect_test): Ditto.
        * config/rs6000/rs6000.opt (mstack-protector-guard=,
        mstack-protector-guard-reg=, mstack-protector-guard-offset=): New
        options.
        * doc/invoke.texi (Option Summary) [RS/6000 and PowerPC Options]:
        Add -mstack-protector-guard=, -mstack-protector-guard-reg=, and
        -mstack-protector-guard-offset=.
        (RS/6000 and PowerPC Options): Ditto.

gcc/testsuite/
        * gcc.target/powerpc/ssp-1.c: New testcase.
        * gcc.target/powerpc/ssp-2.c: New testcase.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000-opts.h
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/config/rs6000/rs6000.md
    trunk/gcc/config/rs6000/rs6000.opt
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog

Reply via email to