]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/arm/eabi/machine-gmon.h
Update MIPS bits/poll.h for POSIX 2008.
[thirdparty/glibc.git] / sysdeps / arm / eabi / machine-gmon.h
CommitLineData
5f1d477b
DJ
1/* Machine-dependent definitions for profiling support. ARM EABI version.
2 Copyright (C) 2008 Free Software Foundation, Inc.
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/* GCC for the ARM cannot compile __builtin_return_address(N) for N != 0,
21 so we must use an assembly stub. */
22
23#include <sysdep.h>
24static void mcount_internal (u_long frompc, u_long selfpc) __attribute_used__;
25
26#define _MCOUNT_DECL(frompc, selfpc) \
27static void mcount_internal (u_long frompc, u_long selfpc)
28
29/* Use an assembly stub with a special ABI. The calling lr has been
30 pushed to the stack (which will be misaligned). We should preserve
31 all registers except ip and pop a word off the stack.
32
33 NOTE: This assumes mcount_internal does not clobber any non-core
34 (coprocessor) registers. Currently this is true, but may require
35 additional attention in the future.
36
37 The calling sequence looks something like:
38func:
39 push {lr}
40 bl __gnu_mount_nc
41 <function body>
42 */
43
44
45#define MCOUNT \
46void __attribute__((__naked__)) __gnu_mcount_nc(void) \
47{ \
48 asm ("push {r0, r1, r2, r3, lr}\n\t" \
49 "bic r1, lr, #1\n\t" \
50 "ldr r0, [sp, #20]\n\t" \
51 "bl mcount_internal\n\t" \
52 "pop {r0, r1, r2, r3, ip, lr}\n\t" \
53 "bx ip"); \
54} \
55OLD_MCOUNT
56
57/* Provide old mcount for backwards compatibility. This requires
58 code be compiled with APCS frame pointers. */
59
60#ifndef NO_UNDERSCORES
61/* The asm symbols for C functions are `_function'.
62 The canonical name for the counter function is `mcount', no _. */
63void _mcount (void) asm ("mcount");
64#else
65/* The canonical name for the function is `_mcount' in both C and asm,
66 but some old asm code might assume it's `mcount'. */
67void _mcount (void);
68weak_alias (_mcount, mcount)
69#endif
70
71#ifdef __thumb2__
72
73#define OLD_MCOUNT \
74void __attribute__((__naked__)) _mcount (void) \
75{ \
76 __asm__("push {r0, r1, r2, r3, fp, lr};" \
77 "movs r0, fp;" \
78 "ittt ne;" \
79 "ldrne r0, [r0, #-4];" \
80 "movsne r1, lr;" \
81 "blne mcount_internal;" \
82 "pop {r0, r1, r2, r3, fp, pc}"); \
83}
84
85#else
86
87#define OLD_MCOUNT \
88void __attribute__((__naked__)) _mcount (void) \
89{ \
90 __asm__("stmdb sp!, {r0, r1, r2, r3, fp, lr};" \
91 "movs fp, fp;" \
92 "ldrne r0, [fp, #-4];" \
93 "movnes r1, lr;" \
94 "blne mcount_internal;" \
95 "ldmia sp!, {r0, r1, r2, r3, fp, lr};" \
96 "bx lr"); \
97}
98
99#endif