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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101349
138bc75d-0d04-0410-961f-
82ee72b054a4
+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__.
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)
#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;
}
}
+/* 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"
(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"
(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"
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,
}
return build_function_call_expr (t, NULL_TREE);
+#endif
}
#include "gt-targhooks.h"