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.
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 <http://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 .globl C_SYMBOL_NAME(_mcount)
47 .type C_SYMBOL_NAME(_mcount), @function
51 /* Save the caller-clobbered registers. */
53 cfi_adjust_cfa_offset (224)
54 stmg %r14,%r5,160(%r15)
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
62 brasl %r14,__mcount_internal@PLT
64 brasl %r14,__mcount_internal
67 /* Pop the saved registers. Please note that `mcount' has no
69 lmg %r14,%r5,160(%r15)
71 cfi_adjust_cfa_offset (-224)
74 ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(_mcount))
77 weak_alias (_mcount, mcount)