]>
Commit | Line | Data |
---|---|---|
12f1ae05 | 1 | /* S/390-specific implementation of profiling support. |
d614a753 | 2 | Copyright (C) 2000-2020 Free Software Foundation, Inc. |
847b055c AJ |
3 | This file is part of the GNU C Library. |
4 | Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com) | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
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. | |
847b055c AJ |
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 | |
41bdb6e2 | 14 | Lesser General Public License for more details. |
847b055c | 15 | |
41bdb6e2 | 16 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 17 | License along with the GNU C Library; if not, see |
5a82c748 | 18 | <https://www.gnu.org/licenses/>. */ |
847b055c AJ |
19 | |
20 | #include <sysdep.h> | |
21 | ||
22 | /* | |
23 | * How profiling works on S/390: | |
24 | * On the start of each function _mcount is called with the address of a | |
25 | * data word in %r1 (initialized to 0, used for counting). The compiler | |
26 | * with the option -p generates code of the form: | |
27 | * | |
28 | * STM 6,15,24(15) | |
29 | * BRAS 13,.LTN0_0 | |
30 | * .LT0_0: | |
31 | * .LC12: .long _mcount | |
32 | * .LC13: .long .LP0 | |
33 | * .data | |
34 | * .align 4 | |
35 | * .LP0: .long 0 | |
36 | * .text | |
37 | * # function profiler | |
38 | * st 14,4(15) | |
39 | * l 14,.LC12-.LT0_0(13) | |
40 | * l 1,.LC13-.LT0_0(13) | |
41 | * basr 14,14 | |
42 | * l 14,4(15) | |
43 | * | |
44 | * The _mcount implementation now has to call __mcount_internal with the | |
45 | * address of .LP0 as first parameter and the return address as second | |
46 | * parameter. &.LP0 was loaded to %r1 and the return address is in %r14. | |
47 | * _mcount may not modify any register. | |
48 | */ | |
49 | ||
7b8e0d49 | 50 | .globl C_SYMBOL_NAME(_mcount) |
b67e9372 | 51 | .type C_SYMBOL_NAME(_mcount), @function |
406300d2 | 52 | cfi_startproc |
847b055c AJ |
53 | .align ALIGNARG(4) |
54 | C_LABEL(_mcount) | |
55 | /* Save the caller-clobbered registers. */ | |
56 | ahi %r15,-128 | |
406300d2 | 57 | cfi_adjust_cfa_offset (128) |
8f135efc IL |
58 | /* binutils 2.28+: .cfi_val_offset r15, -96 */ |
59 | .cfi_escape \ | |
60 | /* DW_CFA_val_offset */ 0x14, \ | |
61 | /* r15 */ 0x0f, \ | |
62 | /* scaled offset */ 0x18 | |
847b055c | 63 | stm %r14,%r5,96(%r15) |
8f135efc | 64 | cfi_offset (r14, -128) |
847b055c AJ |
65 | l %r2,132(%r15) # callers address = first parameter |
66 | la %r2,0(%r2) # clear bit 0 | |
67 | la %r3,0(%r14) # callees address = second parameter | |
68 | ||
69 | #ifdef PIC | |
70 | bras %r14,0f | |
71 | .long _GLOBAL_OFFSET_TABLE_-. | |
72 | 0: al %r14,0(%r14) | |
73 | l %r14,__mcount_internal@GOT(%r14) | |
74 | #else | |
75 | bras %r14,0f | |
76 | .long __mcount_internal | |
77 | 0: l %r14,0(%r14) | |
78 | #endif | |
79 | basr %r14,%r14 | |
80 | ||
81 | /* | |
82 | * Pop the saved registers. Please note that `mcount' has no | |
83 | * return value. | |
84 | */ | |
85 | lm %r14,%r5,96(%r15) | |
86 | ahi %r15,128 | |
406300d2 | 87 | cfi_adjust_cfa_offset (-128) |
847b055c | 88 | br %r14 |
406300d2 | 89 | cfi_endproc |
847b055c AJ |
90 | ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(_mcount)) |
91 | ||
92 | #undef mcount | |
1ab18a5b | 93 | weak_alias (_mcount, mcount) |