This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix 23221
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 3 Aug 2005 21:01:06 -0700
- Subject: fix 23221
Here we simply need to emit a stack-protect epilogue before
invoking a tail call. Existing code in stack_protect_epilogue
will make sure that block-reordering moves the __stack_chk_fail
call out of line. Existing code in cross-jumping will unify
multiple calls to __stack_chk_fail in the case there are
multiple tail calls in the function.
Tested on x86_64-linux.
r~
* function.c (stack_protect_epilogue): Export.
* tree.h (stack_protect_epilogue): Declare.
* calls.c (expand_call): Call it.
Index: calls.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/calls.c,v
retrieving revision 1.398
diff -u -p -d -r1.398 calls.c
--- calls.c 26 Jul 2005 13:53:48 -0000 1.398
+++ calls.c 4 Aug 2005 03:55:40 -0000
@@ -2247,6 +2247,9 @@ expand_call (tree exp, rtx target, int i
if (pass && (flags & (ECF_LIBCALL_BLOCK | ECF_MALLOC)))
start_sequence ();
+ if (pass == 0 && cfun->stack_protect_guard)
+ stack_protect_epilogue ();
+
adjusted_args_size = args_size;
/* Compute the actual size of the argument block required. The variable
and constant sizes must be combined, the size may have to be rounded,
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.639
diff -u -p -d -r1.639 function.c
--- function.c 3 Aug 2005 21:50:13 -0000 1.639
+++ function.c 4 Aug 2005 03:55:41 -0000
@@ -4013,7 +4013,7 @@ stack_protect_prologue (void)
# define gen_stack_protect_test(x, y, z) (gcc_unreachable (), NULL_RTX)
#endif
-static void
+void
stack_protect_epilogue (void)
{
tree guard_decl = targetm.stack_protect_guard ();
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.750
diff -u -p -d -r1.750 tree.h
--- tree.h 26 Jul 2005 02:56:44 -0000 1.750
+++ tree.h 4 Aug 2005 03:55:42 -0000
@@ -3908,6 +3908,7 @@ extern void dump_tree_statistics (void);
extern void expand_function_end (void);
extern void expand_function_start (tree);
extern void stack_protect_prologue (void);
+extern void stack_protect_epilogue (void);
extern void recompute_tree_invarant_for_addr_expr (tree);
extern bool is_global_var (tree t);
extern bool needs_to_live_in_memory (tree);