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]

An Eh patch


Hi,

I have verified that the following patch works for x86, sparc and
alpha. It fixes the problem when the return address is stored in a
register.


-- 
H.J. Lu (hjl@gnu.org)
----
Sun Sep  6 20:40:36 1998  H.J. Lu  (hjl@gnu.org)

	* libgcc2.c (put_reg): Fix REG_SAVED_REG.
	(get_return_addr, get_reg): Remove the last argument.
	(__throw): Call put_return_addr () if != REG_UNSAVED instead of
	== REG_SAVED_OFFSET.

	* expr.c (expand_builtin) [BUILT_IN_FP]: Return the hard fp.

--- /home/work/misc/gnu/import/egcs/gcc/expr.c	Sat Aug 15 13:01:09 1998
+++ expr.c	Sun Sep  6 18:58:20 1998
@@ -9225,7 +9225,7 @@ expand_builtin (exp, target, subtarget, 
       expand_builtin_unwind_init ();
       return const0_rtx;
     case BUILT_IN_FP:
-      return frame_pointer_rtx;
+      return hard_frame_pointer_rtx;
     case BUILT_IN_SP:
       return stack_pointer_rtx;
 #ifdef DWARF2_UNWIND_INFO
--- /home/work/misc/gnu/import/egcs/gcc/libgcc2.c	Thu Sep  3 16:40:23 1998
+++ libgcc2.c	Sun Sep  6 18:58:20 1998
@@ -3481,13 +3481,13 @@ typedef int ptr_type __attribute__ ((mod
    frame called by UDATA or 0.  */
 
 static void*
-get_reg (unsigned reg, frame_state *udata, frame_state *sub_udata)
+get_reg (unsigned reg, frame_state *udata)
 {
   if (udata->saved[reg] == REG_SAVED_OFFSET)
     return (void *)(ptr_type)
       *(word_type *)(udata->cfa + udata->reg_or_offset[reg]);
-  else if (udata->saved[reg] == REG_SAVED_REG && sub_udata)
-    return get_reg (udata->reg_or_offset[reg], sub_udata, 0);
+  else if (udata->saved[reg] == REG_SAVED_REG)
+    return get_reg (udata->reg_or_offset[reg], udata);
   else
     abort ();
 }
@@ -3500,6 +3500,8 @@ put_reg (unsigned reg, void *val, frame_
   if (udata->saved[reg] == REG_SAVED_OFFSET)
     *(word_type *)(udata->cfa + udata->reg_or_offset[reg])
       = (word_type)(ptr_type) val;
+  else if (udata->saved[reg] == REG_SAVED_REG)
+    put_reg (udata->reg_or_offset[reg], val, udata);
   else
     abort ();
 }
@@ -3520,14 +3522,13 @@ copy_reg (unsigned reg, frame_state *uda
     abort ();
 }
 
-/* Retrieve the return address for frame UDATA, where SUB_UDATA is a
-   frame called by UDATA or 0.  */
+/* Retrieve the return address for frame UDATA. */
 
 static inline void *
-get_return_addr (frame_state *udata, frame_state *sub_udata)
+get_return_addr (frame_state *udata)
 {
   return __builtin_extract_return_addr
-    (get_reg (udata->retaddr_column, udata, sub_udata));
+    (get_reg (udata->retaddr_column, udata));
 }
 
 /* Overwrite the return address for frame UDATA with VAL.  */
@@ -3553,7 +3554,7 @@ next_stack_level (void *pc, frame_state 
      was saved in our stack frame, restore it; otherwise, assume the CFA
      register is SP and restore it to our CFA value.  */
   if (udata->saved[caller_udata->cfa_reg])
-    caller_udata->cfa = get_reg (caller_udata->cfa_reg, udata, 0);
+    caller_udata->cfa = get_reg (caller_udata->cfa_reg, udata);
   else
     caller_udata->cfa = udata->cfa;
   caller_udata->cfa += caller_udata->cfa_offset;
@@ -3661,7 +3662,7 @@ label:
 
       /* Otherwise, we continue searching.  We subtract 1 from PC to avoid
 	 hitting the beginning of the next region.  */
-      pc = get_return_addr (udata, sub_udata) - 1;
+      pc = get_return_addr (udata) - 1;
     }
 
   /* If we haven't found a handler by now, this is an unhandled
@@ -3710,7 +3711,7 @@ label:
 		copy_reg (i, udata, my_udata);
 	      }
 
-	  pc = get_return_addr (udata, sub_udata) - 1;
+	  pc = get_return_addr (udata) - 1;
 	}
 
 #ifdef INCOMING_REGNO
@@ -3734,7 +3735,7 @@ label:
     retaddr =  __builtin_eh_stub_old ();
 
   /* And then set our return address to point to the stub.  */
-  if (my_udata->saved[my_udata->retaddr_column] == REG_SAVED_OFFSET)
+  if (my_udata->saved[my_udata->retaddr_column] != REG_UNSAVED)
     put_return_addr (retaddr, my_udata);
   else
     __builtin_set_return_addr_reg (retaddr);


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