]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/s390/s390-64/s390x-mcount.h
1 /* 64 bit S/390-specific implementation of profiling support.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com)
4 This file is part of the GNU C Library.
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.
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.
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 <https://www.gnu.org/licenses/>. */
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:
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.
46 Alternatively, at the start of each function __fentry__ is called using a
52 instruction. In this case %r0 points to the callee, and %r14 points to the
53 caller. These values need to be passed to __mcount_internal using the same
54 sequence as for _mcount, so the code below is shared between both functions.
55 The only major difference is that __fentry__ cannot return through %r0, in
56 which the return address is located, because br instruction is a no-op with
57 this register. Therefore %r1, which is clobbered by the PLT anyway, is
60 #define xglue(x, y) x ## y
61 #define glue(x, y) xglue(x, y)
63 .globl
C_SYMBOL_NAME(MCOUNT_SYMBOL
)
64 .type
C_SYMBOL_NAME(MCOUNT_SYMBOL
), @function
67 C_LABEL(MCOUNT_SYMBOL
)
68 cfi_return_column (glue(r
, MCOUNT_CALLEE_REG
))
69 /* Save the caller-clobbered registers. */
71 cfi_adjust_cfa_offset (224)
72 /* binutils 2.28+: .cfi_val_offset r15, -160 */
74 /* DW_CFA_val_offset */ 0x14, \
76 /* scaled offset */ 0x14
77 stmg
%r14
,%r5
,160(%r15
)
78 cfi_offset (r14
, -224)
79 cfi_offset (r0
, -224+16)
80 lg
%r2
,MCOUNT_CALLER_OFF(%r15
) # callers address = 1st param
81 lgr
%r3
,glue(%r
, MCOUNT_CALLEE_REG
) # callees address = 2nd param
84 brasl
%r14
,__mcount_internal@PLT
86 brasl
%r14
,__mcount_internal
89 /* Pop the saved registers. Please note that `mcount' has no
91 lmg
%r14
,%r5
,160(%r15
)
93 cfi_adjust_cfa_offset (-224)
94 #if MCOUNT_RETURN_REG != MCOUNT_CALLEE_REG
95 lgr
glue(%r
, MCOUNT_RETURN_REG
),glue(%r
, MCOUNT_CALLEE_REG
)
97 br
glue(%r
, MCOUNT_RETURN_REG
)
99 ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(MCOUNT_SYMBOL
))