]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/arm/eabi/arm-mcount.S
MIPS: replace bits/socket.h with bits/socket_type.h.
[thirdparty/glibc.git] / sysdeps / arm / eabi / arm-mcount.S
CommitLineData
2423dc24 1/* Implementation of profiling support. ARM EABI version.
01b32e73 2 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
2423dc24
TS
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20/* Don't call mcount when calling mcount... */
21#undef PROF
22
23#include <sysdep.h>
24
25
26#ifdef __thumb2__
27 .thumb
28 .syntax unified
29#endif
30
31
32/* Use an assembly stub with a special ABI. The calling lr has been
33 pushed to the stack (which will be misaligned). We should preserve
34 all registers except ip and pop a word off the stack.
35
36 NOTE: This assumes mcount_internal does not clobber any non-core
37 (coprocessor) registers. Currently this is true, but may require
38 additional attention in the future.
39
40 The calling sequence looks something like:
41func:
42 push {lr}
43 bl __gnu_mount_nc
44 <function body>
45*/
46
47ENTRY(__gnu_mcount_nc)
48 push {r0, r1, r2, r3, lr}
01b32e73
TS
49 cfi_adjust_cfa_offset (20)
50 cfi_rel_offset (r0, 0)
51 cfi_rel_offset (r1, 4)
52 cfi_rel_offset (r2, 8)
53 cfi_rel_offset (r3, 12)
54 cfi_rel_offset (lr, 16)
2423dc24
TS
55 bic r1, lr, #1
56 ldr r0, [sp, #20]
57 bl __mcount_internal
58 pop {r0, r1, r2, r3, ip, lr}
01b32e73
TS
59 cfi_adjust_cfa_offset (-24)
60 cfi_restore (r0)
61 cfi_restore (r1)
62 cfi_restore (r2)
63 cfi_restore (r3)
64 cfi_register (lr, ip)
2423dc24
TS
65 bx ip
66END(__gnu_mcount_nc)
67
68
69/* Provide old mcount for backwards compatibility. This requires
70 code be compiled with APCS frame pointers. */
71
72ENTRY(_mcount)
73 stmdb sp!, {r0, r1, r2, r3, fp, lr}
01b32e73
TS
74 cfi_adjust_cfa_offset (24)
75 cfi_rel_offset (r0, 0)
76 cfi_rel_offset (r1, 4)
77 cfi_rel_offset (r2, 8)
78 cfi_rel_offset (r3, 12)
79 cfi_rel_offset (fp, 16)
80 cfi_rel_offset (lr, 20)
2423dc24
TS
81#ifdef __thumb2__
82 movs r0, fp
83 ittt ne
84 ldrne r0, [r0, #-4]
85#else
86 movs fp, fp
87 ldrne r0, [fp, #-4]
88#endif
89 movnes r1, lr
90 blne __mcount_internal
91#ifdef __thumb2__
92 ldmia sp!, {r0, r1, r2, r3, fp, pc}
93#else
94 ldmia sp!, {r0, r1, r2, r3, fp, lr}
01b32e73
TS
95 cfi_adjust_cfa_offset (-24)
96 cfi_restore (r0)
97 cfi_restore (r1)
98 cfi_restore (r2)
99 cfi_restore (r3)
100 cfi_restore (fp)
101 cfi_restore (lr)
2423dc24
TS
102 bx lr
103#endif
104END(_mcount)
105
106/* The canonical name for the function is `_mcount' in both C and asm,
107 but some old asm code might assume it's `mcount'. */
108#undef mcount
109weak_alias (_mcount, mcount)