]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/s390/s390-64/s390x-mcount.S
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / s390 / s390-64 / s390x-mcount.S
1 /* 64 bit S/390-specific implemetation of profiling support.
2 Copyright (C) 2001-2014 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com)
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 #include <sysdep.h>
21
22 /* How profiling works on 64 bit S/390:
23 On the start of each function _mcount is called with the address of a
24 data word in %r1 (initialized to 0, used for counting). The compiler
25 with the option -p generates code of the form:
26
27 STM 6,15,24(15)
28 BRAS 13,.LTN0_0
29 .LT0_0:
30 .LC13: .long .LP0
31 .data
32 .align 4
33 .LP0: .long 0
34 .text
35 # function profiler
36 stg 14,4(15)
37 lg 1,.LC13-.LT0_0(13)
38 brasl 14,_mcount
39 lg 14,4(15)
40
41 The _mcount implementation now has to call __mcount_internal with the
42 address of .LP0 as first parameter and the return address as second
43 parameter. &.LP0 was loaded to %r1 and the return address is in %r14.
44 _mcount may not modify any register. */
45
46 .globl C_SYMBOL_NAME(_mcount)
47 .type C_SYMBOL_NAME(_mcount), @function
48 cfi_startproc
49 .align ALIGNARG(4)
50 C_LABEL(_mcount)
51 /* Save the caller-clobbered registers. */
52 aghi %r15,-224
53 cfi_adjust_cfa_offset (224)
54 stmg %r14,%r5,160(%r15)
55 cfi_offset (r14, 0)
56 cfi_offset (r15, 8)
57 lg %r2,232(%r15) # callers address = first parameter
58 la %r2,0(%r2) # clear bit 0
59 la %r3,0(%r14) # callees address = second parameter
60
61 #ifdef PIC
62 brasl %r14,__mcount_internal@PLT
63 #else
64 brasl %r14,__mcount_internal
65 #endif
66
67 /* Pop the saved registers. Please note that `mcount' has no
68 return value. */
69 lmg %r14,%r5,160(%r15)
70 aghi %r15,224
71 cfi_adjust_cfa_offset (-224)
72 br %r14
73 cfi_endproc
74 ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(_mcount))
75
76 #undef mcount
77 weak_alias (_mcount, mcount)