Module Name:    src
Committed By:   matt
Date:           Thu Aug 15 22:41:15 UTC 2013

Modified Files:
        src/sys/arch/arm/include: profile.h

Log Message:
Add an EABI ARM version of MCOUNT that doesn't do ARM26 compat.
Add an EABI Thumb version of MCOUNT (doesn't do ARM26 compat either).
Add .size to all MCOUNT


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/include/profile.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/include/profile.h
diff -u src/sys/arch/arm/include/profile.h:1.8 src/sys/arch/arm/include/profile.h:1.9
--- src/sys/arch/arm/include/profile.h:1.8	Fri Aug 29 19:08:29 2008
+++ src/sys/arch/arm/include/profile.h	Thu Aug 15 22:41:15 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: profile.h,v 1.8 2008/08/29 19:08:29 matt Exp $	*/
+/*	$NetBSD: profile.h,v 1.9 2013/08/15 22:41:15 matt Exp $	*/
 
 /*
  * Copyright (c) 2001 Ben Harris
@@ -47,16 +47,17 @@
 #define	PLTSYM
 #endif
 
+#if !defined(__thumb__) && !defined(__ARM_EABI__)
 #define	MCOUNT								\
-	__asm(".text");						\
+	__asm(".text");							\
 	__asm(".align	0");						\
 	__asm(".type	" MCOUNT_ASM_NAME ",%function");		\
-	__asm(".global	" MCOUNT_ASM_NAME);			\
+	__asm(".global	" MCOUNT_ASM_NAME);				\
 	__asm(MCOUNT_ASM_NAME ":");					\
 	/*								\
 	 * Preserve registers that are trashed during mcount		\
 	 */								\
-	__asm("stmfd	sp!, {r0-r3, ip, lr}");				\
+	__asm("push	{r0-r3, ip, lr}");				\
 	/* Check what mode we're in.  EQ => 32, NE => 26 */		\
 	__asm("teq	r0, r0");					\
 	__asm("teq	pc, r15");					\
@@ -80,7 +81,74 @@
 	/*								\
 	 * Restore registers that were trashed during mcount		\
 	 */								\
-	__asm("ldmfd	sp!, {r0-r3, lr, pc}");
+	__asm("pop	{r0-r3, lr, pc}");				\
+	__asm(".size	" MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
+#elif !defined(__thumb__) || defined(_ARM_ARCH_T2)
+#define	MCOUNT								\
+	__asm(".text");							\
+	__asm(".align	0");						\
+	__asm(".type	" MCOUNT_ASM_NAME ",%function");		\
+	__asm(".global	" MCOUNT_ASM_NAME);				\
+	__asm(MCOUNT_ASM_NAME ":");					\
+	/*								\
+	 * Preserve registers that are trashed during mcount		\
+	 */								\
+	__asm("push	{r0-r3, ip, lr}");				\
+	/*								\
+	 * find the return address for mcount,				\
+	 * and the return address for mcount's caller.			\
+	 *								\
+	 * frompcindex = pc pushed by call into self.			\
+	 */								\
+	__asm("mov	r0, ip");					\
+	/*								\
+	 * selfpc = pc pushed by mcount call				\
+	 */								\
+	__asm("mov	r1, lr");					\
+	/*								\
+	 * Call the real mcount code					\
+	 */								\
+	__asm("bl	" ___STRING(_C_LABEL(_mcount)) PLTSYM);		\
+	/*								\
+	 * Restore registers that were trashed during mcount		\
+	 */								\
+	__asm("pop	{r0-r3, lr, pc}");				\
+	__asm(".size	" MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
+#else
+#define	MCOUNT								\
+	__asm(".text");							\
+	__asm(".align	0");						\
+	__asm(".thumb_func");						\
+	__asm(".type	" MCOUNT_ASM_NAME ",%function");		\
+	__asm(".global	" MCOUNT_ASM_NAME);				\
+	__asm(MCOUNT_ASM_NAME ":");					\
+	/*								\
+	 * Preserve registers that are trashed during mcount		\
+	 */								\
+	__asm("push	{r0-r4,lr}");					\
+	__asm("mov	r4, ip");					\
+	/*								\
+	 * find the return address for mcount,				\
+	 * and the return address for mcount's caller.			\
+	 *								\
+	 * frompcindex = pc pushed by call into self.			\
+	 */								\
+	__asm("mov	r0, ip");					\
+	/*								\
+	 * selfpc = pc pushed by mcount call				\
+	 */								\
+	__asm("mov	r1, lr");					\
+	/*								\
+	 * Call the real mcount code					\
+	 */								\
+	__asm("bl	" ___STRING(_C_LABEL(_mcount)) PLTSYM);		\
+	/*								\
+	 * Restore registers that were trashed during mcount		\
+	 */								\
+	__asm("mov	lr, r4");					\
+	__asm("pop	{r0-r4, pc}");					\
+	__asm(".size	" MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
+#endif
 
 #ifdef _KERNEL
 #ifdef __PROG26

Reply via email to