[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patches] ARM mcount fix



The ARM _mcount implementation assumes that functions with a frame pointer 
also save the link register.  Recent gcc generate optimized stack frames, so 
this is no longer true.  The attached patch adds explicit clobbers to fix 
this.

Tested on arm-linux-gnueabi.

I don't have svn write access, so please apply if OK.  The patch should be 
applicable to all active branches.

Paul

2008-03-27  Paul Brook  <paul@xxxxxxxxxxxxxxxx>

	* sysdeps/arm/machine-gmon.h (_mcount): Clobber lr.
Index: sysdeps/arm/machine-gmon.h
===================================================================
--- sysdeps/arm/machine-gmon.h	(revision 197781)
+++ sysdeps/arm/machine-gmon.h	(working copy)
@@ -67,7 +67,8 @@ void _mcount (void)							\
 	  "movs		r0, r0;"					\
 	  "it		ne;"						\
 	  "blne		mcount_internal;"				\
-	  "pop		{r0, r1, r2, r3}");				\
+	  "pop		{r0, r1, r2, r3}"				\
+	  ::: "ip", "lr");						\
 }
 
 #else
@@ -84,7 +85,8 @@ void _mcount (void)							\
 	  "ldrne	r0, [r0, $-4];"					\
 	  "movs		r0, r0;"					\
 	  "blne		mcount_internal;"				\
-	  "ldmia	sp!, {r0, r1, r2, r3}");			\
+	  "ldmia	sp!, {r0, r1, r2, r3}"				\
+	  ::: "ip", "lr");						\
 }
 
 #endif