]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/x86_64/_mcount.S
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / x86_64 / _mcount.S
1 /* Machine-specific calling sequence for `mcount' profiling function. x86-64 version.
2 Copyright (C) 2002-2014 Free Software Foundation, Inc.
3 Contributed by Andreas Jaeger <aj@suse.de>.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20 /* Assembly stub to invoke _mcount(). Compiler generated code calls
21 this stub after executing a function's prologue and without saving any
22 registers. It is therefore necessary to preserve %rcx, %rdx, %rsi, %rdi,
23 %r8, %r9 as they may contain function arguments. */
24
25 #include <sysdep.h>
26
27 .globl C_SYMBOL_NAME(_mcount)
28 .type C_SYMBOL_NAME(_mcount), @function
29 .align ALIGNARG(4)
30 C_LABEL(_mcount)
31 /* Allocate space for 7 registers. */
32 subq $56,%rsp
33 movq %rax,(%rsp)
34 movq %rcx,8(%rsp)
35 movq %rdx,16(%rsp)
36 movq %rsi,24(%rsp)
37 movq %rdi,32(%rsp)
38 movq %r8,40(%rsp)
39 movq %r9,48(%rsp)
40
41 /* Setup parameter for __mcount_internal. */
42 /* selfpc is the return address on the stack. */
43 movq 56(%rsp),%rsi
44 /* Get frompc via the frame pointer. */
45 movq 8(%rbp),%rdi
46 #ifdef PIC
47 call C_SYMBOL_NAME(__mcount_internal)@PLT
48 #else
49 call C_SYMBOL_NAME(__mcount_internal)
50 #endif
51 /* Pop the saved registers. Please note that `mcount' has no
52 return value. */
53 movq 48(%rsp),%r9
54 movq 40(%rsp),%r8
55 movq 32(%rsp),%rdi
56 movq 24(%rsp),%rsi
57 movq 16(%rsp),%rdx
58 movq 8(%rsp),%rcx
59 movq (%rsp),%rax
60 addq $56,%rsp
61 ret
62
63 ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(_mcount))
64
65 #undef mcount
66 weak_alias (_mcount, mcount)
67
68 .globl C_SYMBOL_NAME(__fentry__)
69 .type C_SYMBOL_NAME(__fentry__), @function
70 .align ALIGNARG(4)
71 C_LABEL(__fentry__)
72 /* Allocate space for 7 registers. */
73 subq $64,%rsp
74 movq %rax,(%rsp)
75 movq %rcx,8(%rsp)
76 movq %rdx,16(%rsp)
77 movq %rsi,24(%rsp)
78 movq %rdi,32(%rsp)
79 movq %r8,40(%rsp)
80 movq %r9,48(%rsp)
81
82 /* Setup parameter for __mcount_internal. */
83 /* selfpc is the return address on the stack. */
84 movq 64(%rsp),%rsi
85 /* caller is the return address above it */
86 movq 72(%rsp),%rdi
87 #ifdef PIC
88 call C_SYMBOL_NAME(__mcount_internal)@PLT
89 #else
90 call C_SYMBOL_NAME(__mcount_internal)
91 #endif
92 /* Pop the saved registers. Please note that `__fentry__' has no
93 return value. */
94 movq 48(%rsp),%r9
95 movq 40(%rsp),%r8
96 movq 32(%rsp),%rdi
97 movq 24(%rsp),%rsi
98 movq 16(%rsp),%rdx
99 movq 8(%rsp),%rcx
100 movq (%rsp),%rax
101 addq $64,%rsp
102 ret
103
104 ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(__fentry__))