diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-06-27 10:03:26 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2005-06-27 10:03:26 +0200 |
commit | 7ce918c59e949e79c05c730c8720feea0442b4d9 (patch) | |
tree | b8b719d2e127252b7a6819c53db9212636451351 /gcc | |
parent | 7d69de618e732d343228a07d797a30e39a6363f4 (diff) | |
download | gcc-7ce918c59e949e79c05c730c8720feea0442b4d9.zip gcc-7ce918c59e949e79c05c730c8720feea0442b4d9.tar.gz gcc-7ce918c59e949e79c05c730c8720feea0442b4d9.tar.bz2 |
targhooks.c (default_hidden_stack_protect_fail): Fall back to default_external_stack_protect_fail if...
* targhooks.c (default_hidden_stack_protect_fail): Fall back to
default_external_stack_protect_fail if visibility is not supported
or not flag_pic.
* config/i386/i386.c (ix86_stack_protect_fail): New function.
(TARGET_STACK_PROTECT_FAIL): Define.
* config/i386/i386.md (stack_protect_si): Change CLOBBER into
SET to zero.
(stack_protect_di): Likewise. Use %k2 instead of %2 to avoid
invalid instruction xorl %rax, %rax.
From-SVN: r101349
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 16 | ||||
-rw-r--r-- | gcc/config/i386/i386.md | 6 | ||||
-rw-r--r-- | gcc/targhooks.c | 9 |
4 files changed, 38 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index efa4b6e..dde7e57 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2005-06-27 Jakub Jelinek <jakub@redhat.com> + + * targhooks.c (default_hidden_stack_protect_fail): Fall back to + default_external_stack_protect_fail if visibility is not supported + or not flag_pic. + * config/i386/i386.c (ix86_stack_protect_fail): New function. + (TARGET_STACK_PROTECT_FAIL): Define. + * config/i386/i386.md (stack_protect_si): Change CLOBBER into + SET to zero. + (stack_protect_di): Likewise. Use %k2 instead of %2 to avoid + invalid instruction xorl %rax, %rax. + 2005-06-27 Richard Henderson <rth@redhat.com> * c-cppbuiltin.c (c_cpp_builtins): Add __SSP_ALL__ and __SSP__. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 0f487c4..620d862 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -906,6 +906,7 @@ static bool ix86_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode, static void ix86_init_builtins (void); static rtx ix86_expand_builtin (tree, rtx, rtx, enum machine_mode, int); static const char *ix86_mangle_fundamental_type (tree); +static tree ix86_stack_protect_fail (void); /* This function is only used on Solaris. */ static void i386_solaris_elf_named_section (const char *, unsigned int, tree) @@ -1082,7 +1083,7 @@ static void init_ext_80387_constants (void); #define TARGET_MANGLE_FUNDAMENTAL_TYPE ix86_mangle_fundamental_type #undef TARGET_STACK_PROTECT_FAIL -#define TARGET_STACK_PROTECT_FAIL default_hidden_stack_protect_fail +#define TARGET_STACK_PROTECT_FAIL ix86_stack_protect_fail struct gcc_target targetm = TARGET_INITIALIZER; @@ -17564,4 +17565,17 @@ ix86_mangle_fundamental_type (tree type) } } +/* For 32-bit code we can save PIC register setup by using + __stack_chk_fail_local hidden function instead of calling + __stack_chk_fail directly. 64-bit code doesn't need to setup any PIC + register, so it is better to call __stack_chk_fail directly. */ + +static tree +ix86_stack_protect_fail (void) +{ + return TARGET_64BIT + ? default_external_stack_protect_fail () + : default_hidden_stack_protect_fail (); +} + #include "gt-i386.h" diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 8aaad7b..e8af640 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -19613,7 +19613,7 @@ (define_insn "stack_protect_set_si" [(set (match_operand:SI 0 "memory_operand" "=m") (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET)) - (clobber (match_scratch:SI 2 "=r")) + (set (match_scratch:SI 2 "=&r") (const_int 0)) (clobber (reg:CC FLAGS_REG))] "" "mov{l}\t{%1, %2|%2, %1}\;mov{l}\t{%2, %0|%0, %2}\;xor{l}\t%2, %2" @@ -19622,10 +19622,10 @@ (define_insn "stack_protect_set_di" [(set (match_operand:DI 0 "memory_operand" "=m") (unspec:DI [(match_operand:DI 1 "memory_operand" "m")] UNSPEC_SP_SET)) - (clobber (match_scratch:DI 2 "=r")) + (set (match_scratch:DI 2 "=&r") (const_int 0)) (clobber (reg:CC FLAGS_REG))] "TARGET_64BIT" - "mov{q}\t{%1, %2|%2, %1}\;mov{q}\t{%2, %0|%0, %2}\;xor{l}\t%2, %2" + "mov{q}\t{%1, %2|%2, %1}\;mov{q}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2" [(set_attr "type" "multi")]) (define_expand "stack_protect_test" diff --git a/gcc/targhooks.c b/gcc/targhooks.c index ec374c6..0664f2c 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -380,9 +380,15 @@ default_external_stack_protect_fail (void) tree default_hidden_stack_protect_fail (void) { +#ifndef HAVE_GAS_HIDDEN + return default_external_stack_protect_fail (); +#else tree t = stack_chk_fail_decl; - if (stack_chk_fail_decl == NULL_TREE) + if (!flag_pic) + return default_external_stack_protect_fail (); + + if (t == NULL_TREE) { t = build_function_type_list (void_type_node, NULL_TREE); t = build_decl (FUNCTION_DECL, @@ -402,6 +408,7 @@ default_hidden_stack_protect_fail (void) } return build_function_call_expr (t, NULL_TREE); +#endif } #include "gt-targhooks.h" |