Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/include Add an EABI ARM version of MCOUNT that ...



details:   https://anonhg.NetBSD.org/src/rev/b51f3b7264f6
branches:  trunk
changeset: 789351:b51f3b7264f6
user:      matt <matt%NetBSD.org@localhost>
date:      Thu Aug 15 22:41:15 2013 +0000

description:
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

diffstat:

 sys/arch/arm/include/profile.h |  78 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 73 insertions(+), 5 deletions(-)

diffs (106 lines):

diff -r 6079c918ed09 -r b51f3b7264f6 sys/arch/arm/include/profile.h
--- a/sys/arch/arm/include/profile.h    Thu Aug 15 22:38:25 2013 +0000
+++ b/sys/arch/arm/include/profile.h    Thu Aug 15 22:41:15 2013 +0000
@@ -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



Home | Main Index | Thread Index | Old Index