svn commit: r183818 - in stable/7/sys: . i386/include

Konstantin Belousov kib at FreeBSD.org
Mon Oct 13 12:45:19 UTC 2008


Author: kib
Date: Mon Oct 13 12:45:18 2008
New Revision: 183818
URL: http://svn.freebsd.org/changeset/base/183818

Log:
  MFC r180756 (by luoqi):
  Unbreak cc -pg support on i386 by changing mcount() to always preserve %ecx.
  
  Approved by:	re (kensmith)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/i386/include/profile.h

Modified: stable/7/sys/i386/include/profile.h
==============================================================================
--- stable/7/sys/i386/include/profile.h	Mon Oct 13 12:28:33 2008	(r183817)
+++ stable/7/sys/i386/include/profile.h	Mon Oct 13 12:45:18 2008	(r183818)
@@ -115,7 +115,15 @@ void user(void);
 void									\
 mcount()								\
 {									\
-	uintfptr_t selfpc, frompc;					\
+	uintfptr_t selfpc, frompc, ecx;					\
+	/*								\
+	 * In gcc 4.2, ecx might be used in the caller as the arg	\
+	 * pointer if the stack realignment option is set (-mstackrealign) \
+	 * or if the caller has the force_align_arg_pointer attribute	\
+	 * (stack realignment is ALWAYS on for main).  Preserve ecx	\
+	 * here.							\
+	 */								\
+	__asm("" : "=c" (ecx));						\
 	/*								\
 	 * Find the return address for mcount,				\
 	 * and the return address for mcount's caller.			\
@@ -132,6 +140,7 @@ mcount()								\
 	__asm("movl (%%ebp),%0" : "=r" (frompc));			\
 	frompc = ((uintfptr_t *)frompc)[1];				\
 	_mcount(frompc, selfpc);					\
+	__asm("" : : "c" (ecx));					\
 }
 #else /* !__GNUCLIKE_ASM */
 #define	MCOUNT


More information about the svn-src-all mailing list