This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] ia64 -fstack-protector support


Hi!

Tested with make check and
make check RUNTESTFLAGS=--target_board=unix/-fstack-protector
Ok to commit?

2005-07-04  Jakub Jelinek  <jakub@redhat.com>

	* config/ia64/ia64.h (FRAME_GROWS_DOWNWARD): Define to 1 if
	-fstack-protect.
	* config/ia64/ia64.c (ia64_compute_frame_size): Make sure
	size is a multiple of 16 if FRAME_GROWS_DOWNWARD.
	(ia64_initial_elimination_offset): Support FRAME_GROWS_DOWNWARD
	layout.

--- gcc/config/ia64/ia64.h.jj	2005-07-02 02:28:14.000000000 +0200
+++ gcc/config/ia64/ia64.h	2005-07-04 12:17:46.000000000 +0200
@@ -951,7 +951,7 @@ enum reg_class
 
 /* Define this macro to non-zero if the addresses of local variable slots
    are at negative offsets from the frame pointer.  */
-#define FRAME_GROWS_DOWNWARD 0
+#define FRAME_GROWS_DOWNWARD (flag_stack_protect != 0)
 
 /* Offset from the frame pointer to the first local variable slot to
    be allocated.  */
--- gcc/config/ia64/ia64.c.jj	2005-07-03 13:53:07.000000000 +0200
+++ gcc/config/ia64/ia64.c	2005-07-04 12:29:03.000000000 +0200
@@ -2367,6 +2367,9 @@ ia64_compute_frame_size (HOST_WIDE_INT s
   else
     pretend_args_size = current_function_pretend_args_size;
 
+  if (FRAME_GROWS_DOWNWARD)
+    size = IA64_STACK_ALIGN (size);
+
   total_size = (spill_size + extra_spill_size + size + pretend_args_size
 		+ current_function_outgoing_args_size);
   total_size = IA64_STACK_ALIGN (total_size);
@@ -2391,27 +2394,22 @@ ia64_compute_frame_size (HOST_WIDE_INT s
 HOST_WIDE_INT
 ia64_initial_elimination_offset (int from, int to)
 {
-  HOST_WIDE_INT offset;
+  HOST_WIDE_INT offset, size;
 
-  ia64_compute_frame_size (get_frame_size ());
+  ia64_compute_frame_size (size = get_frame_size ());
   switch (from)
     {
     case FRAME_POINTER_REGNUM:
+      offset = FRAME_GROWS_DOWNWARD ? IA64_STACK_ALIGN (size) : 0;
+      if (!current_function_is_leaf)
+	offset += 16 + current_function_outgoing_args_size;
       switch (to)
 	{
 	case HARD_FRAME_POINTER_REGNUM:
-	  if (current_function_is_leaf)
-	    offset = -current_frame_info.total_size;
-	  else
-	    offset = -(current_frame_info.total_size
-		       - current_function_outgoing_args_size - 16);
+	  offset -= current_frame_info.total_size;
 	  break;
 
 	case STACK_POINTER_REGNUM:
-	  if (current_function_is_leaf)
-	    offset = 0;
-	  else
-	    offset = 16 + current_function_outgoing_args_size;
 	  break;
 
 	default:

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]