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 __mcount is always arm code (even if co...



details:   https://anonhg.NetBSD.org/src/rev/4da1dfec8df2
branches:  trunk
changeset: 789365:4da1dfec8df2
user:      matt <matt%NetBSD.org@localhost>
date:      Fri Aug 16 21:42:48 2013 +0000

description:
__mcount is always arm code (even if compiled -mthumb).
Add .cfi for unwind tables

diffstat:

 sys/arch/arm/include/profile.h |  69 ++++++++++++++++++-----------------------
 1 files changed, 30 insertions(+), 39 deletions(-)

diffs (111 lines):

diff -r c4c30284b8d9 -r 4da1dfec8df2 sys/arch/arm/include/profile.h
--- a/sys/arch/arm/include/profile.h    Fri Aug 16 21:04:07 2013 +0000
+++ b/sys/arch/arm/include/profile.h    Fri Aug 16 21:42:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: profile.h,v 1.9 2013/08/15 22:41:15 matt Exp $ */
+/*     $NetBSD: profile.h,v 1.10 2013/08/16 21:42:48 matt Exp $        */
 
 /*
  * Copyright (c) 2001 Ben Harris
@@ -54,10 +54,20 @@
        __asm(".type    " MCOUNT_ASM_NAME ",%function");                \
        __asm(".global  " MCOUNT_ASM_NAME);                             \
        __asm(MCOUNT_ASM_NAME ":");                                     \
+       __asm(".cfi_startproc");                                        \
+       __asm(".fnstart");                                              \
        /*                                                              \
         * Preserve registers that are trashed during mcount            \
         */                                                             \
        __asm("push     {r0-r3, ip, lr}");                              \
+       __asm(".save {r0-r3, ip, lr}");                                 \
+       __asm(".cfi_def_cfa_offset 24");                                \
+       __asm(".cfi_offset 14, -4");                                    \
+       __asm(".cfi_offset 12, -8");                                    \
+       __asm(".cfi_offset 3, -12");                                    \
+       __asm(".cfi_offset 2, -16");                                    \
+       __asm(".cfi_offset 1, -20");                                    \
+       __asm(".cfi_offset 0, -24");                                    \
        /* Check what mode we're in.  EQ => 32, NE => 26 */             \
        __asm("teq      r0, r0");                                       \
        __asm("teq      pc, r15");                                      \
@@ -81,19 +91,32 @@
        /*                                                              \
         * Restore registers that were trashed during mcount            \
         */                                                             \
-       __asm("pop      {r0-r3, lr, pc}");                              \
+       __asm("pop      {r0-r3, pc}");                                  \
+       __asm(".cfi_endproc");                                          \
+       __asm(".fnend");                                                \
        __asm(".size    " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
-#elif !defined(__thumb__) || defined(_ARM_ARCH_T2)
+#else
 #define        MCOUNT                                                          \
        __asm(".text");                                                 \
        __asm(".align   0");                                            \
        __asm(".type    " MCOUNT_ASM_NAME ",%function");                \
        __asm(".global  " MCOUNT_ASM_NAME);                             \
+       __asm(".arm");                                                  \
        __asm(MCOUNT_ASM_NAME ":");                                     \
+       __asm(".fnstart");                                              \
+       __asm(".cfi_startproc");                                        \
        /*                                                              \
         * Preserve registers that are trashed during mcount            \
         */                                                             \
-       __asm("push     {r0-r3, ip, lr}");                              \
+       __asm("push     {r0-r4, ip, lr}");                              \
+       __asm(".save {r0-r4, lr}");                                     \
+       __asm(".cfi_def_cfa_offset 24");                                \
+       __asm(".cfi_offset 14, -4");                                    \
+       __asm(".cfi_offset 4, -8");                                     \
+       __asm(".cfi_offset 3, -12");                                    \
+       __asm(".cfi_offset 2, -16");                                    \
+       __asm(".cfi_offset 1, -20");                                    \
+       __asm(".cfi_offset 0, -24");                                    \
        /*                                                              \
         * find the return address for mcount,                          \
         * and the return address for mcount's caller.                  \
@@ -112,41 +135,9 @@
        /*                                                              \
         * 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("pop      {r0-r4, lr, pc}");                              \
+       __asm(".cfi_endproc");                                          \
+       __asm(".fnend");                                                \
        __asm(".size    " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
 #endif
 



Home | Main Index | Thread Index | Old Index