]>
Commit | Line | Data |
---|---|---|
847b055c | 1 | /* Assembler macros for s390. |
04277e02 | 2 | Copyright (C) 2000-2019 Free Software Foundation, Inc. |
847b055c AJ |
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 | |
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 <sysdeps/generic/sysdep.h> | |
21 | ||
22 | #ifdef __ASSEMBLER__ | |
23 | ||
24 | /* Syntactic details of assembler. */ | |
25 | ||
847b055c AJ |
26 | /* ELF uses byte-counts for .align, most others use log2 of count of bytes. */ |
27 | #define ALIGNARG(log2) 1<<log2 | |
847b055c AJ |
28 | #define ASM_SIZE_DIRECTIVE(name) .size name,.-name; |
29 | ||
847b055c AJ |
30 | |
31 | /* Define an entry point visible from C. */ | |
32 | #define ENTRY(name) \ | |
b67e9372 MP |
33 | .globl C_SYMBOL_NAME(name); \ |
34 | .type C_SYMBOL_NAME(name),@function; \ | |
ce6ddae0 | 35 | .align ALIGNARG(4); \ |
847b055c | 36 | C_LABEL(name) \ |
844a34a2 | 37 | cfi_startproc; \ |
847b055c AJ |
38 | CALL_MCOUNT |
39 | ||
40 | #undef END | |
41 | #define END(name) \ | |
844a34a2 | 42 | cfi_endproc; \ |
847b055c AJ |
43 | ASM_SIZE_DIRECTIVE(name) \ |
44 | ||
45 | /* If compiled for profiling, call `mcount' at the start of each function. */ | |
46 | #ifdef PROF | |
47 | #ifdef PIC | |
48 | #define CALL_MCOUNT \ | |
49 | lr 0,14 ; bras 14,.+12 ; .long _GLOBAL_OFFSET_TABLE_ - . ; .long 0f-. ; \ | |
50 | lr 1,14 ; al 1,4(14) ; al 14,0(14) ; l 14,_mcount@GOT(14) ; \ | |
51 | basr 14,14 ; lr 14,0 ; .data ; .align 4 ; 0: .long 0 ; .text ; | |
52 | #else | |
53 | #define CALL_MCOUNT \ | |
54 | lr 0,14 ; bras 14,.+12 ; .long _mcount ; .long 0f ; \ | |
55 | l 1,4(14) ; l 14,0(14) ; basr 14,14 ; lr 14,0 ; \ | |
56 | .data ; .align 4 ; 0: .long 0 ; .text ; | |
57 | #endif | |
58 | #else | |
59 | #define CALL_MCOUNT /* Do nothing. */ | |
60 | #endif | |
61 | ||
847b055c AJ |
62 | /* Since C identifiers are not normally prefixed with an underscore |
63 | on this system, the asm identifier `syscall_error' intrudes on the | |
64 | C name space. Make sure we use an innocuous name. */ | |
65 | #define syscall_error __syscall_error | |
66 | #define mcount _mcount | |
847b055c | 67 | |
24116fcd | 68 | #undef PSEUDO |
db0a052c UD |
69 | #define PSEUDO(name, syscall_name, args) \ |
70 | lose: SYSCALL_PIC_SETUP \ | |
71 | basr %r1,0; \ | |
72 | 0: al %r1,1f-0b(%r1); \ | |
73 | br %r1; \ | |
74 | 1: .long JUMPTARGET(syscall_error) - 0b; \ | |
75 | .globl syscall_error; \ | |
76 | ENTRY (name) \ | |
77 | DO_CALL (syscall_name, args); \ | |
78 | jm lose | |
847b055c AJ |
79 | |
80 | #undef PSEUDO_END | |
81 | #define PSEUDO_END(name) \ | |
82 | END (name) | |
83 | ||
29d9a17d | 84 | #undef JUMPTARGET |
5e5b3b88 | 85 | #ifdef SHARED |
db0a052c | 86 | #define JUMPTARGET(name) name##@PLT |
847b055c | 87 | #define SYSCALL_PIC_SETUP \ |
5e5b3b88 SL |
88 | bras %r12,1f; \ |
89 | 0: .long _GLOBAL_OFFSET_TABLE_-0b; \ | |
847b055c AJ |
90 | 1: al %r12,0(%r12) |
91 | #else | |
5e5b3b88 | 92 | #define JUMPTARGET(name) name |
847b055c AJ |
93 | #define SYSCALL_PIC_SETUP /* Nothing. */ |
94 | #endif | |
95 | ||
96 | /* Local label name for asm code. */ | |
97 | #ifndef L | |
8addbe04 | 98 | #define L(name) .L##name |
847b055c AJ |
99 | #endif |
100 | ||
101 | #endif /* __ASSEMBLER__ */ |