Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Oct 2008 12:45:18 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r183818 - in stable/7/sys: . i386/include
Message-ID:  <200810131245.m9DCjIsR076490@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810131245.m9DCjIsR076490>