]> asedeno.scripts.mit.edu Git - linux.git/blob - include/linux/linkage.h
x86/asm/32: Change all ENTRY+END to SYM_CODE_*
[linux.git] / include / linux / linkage.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_LINKAGE_H
3 #define _LINUX_LINKAGE_H
4
5 #include <linux/compiler_types.h>
6 #include <linux/stringify.h>
7 #include <linux/export.h>
8 #include <asm/linkage.h>
9
10 /* Some toolchains use other characters (e.g. '`') to mark new line in macro */
11 #ifndef ASM_NL
12 #define ASM_NL           ;
13 #endif
14
15 #ifdef __cplusplus
16 #define CPP_ASMLINKAGE extern "C"
17 #else
18 #define CPP_ASMLINKAGE
19 #endif
20
21 #ifndef asmlinkage
22 #define asmlinkage CPP_ASMLINKAGE
23 #endif
24
25 #ifndef cond_syscall
26 #define cond_syscall(x) asm(                            \
27         ".weak " __stringify(x) "\n\t"                  \
28         ".set  " __stringify(x) ","                     \
29                  __stringify(sys_ni_syscall))
30 #endif
31
32 #ifndef SYSCALL_ALIAS
33 #define SYSCALL_ALIAS(alias, name) asm(                 \
34         ".globl " __stringify(alias) "\n\t"             \
35         ".set   " __stringify(alias) ","                \
36                   __stringify(name))
37 #endif
38
39 #define __page_aligned_data     __section(.data..page_aligned) __aligned(PAGE_SIZE)
40 #define __page_aligned_bss      __section(.bss..page_aligned) __aligned(PAGE_SIZE)
41
42 /*
43  * For assembly routines.
44  *
45  * Note when using these that you must specify the appropriate
46  * alignment directives yourself
47  */
48 #define __PAGE_ALIGNED_DATA     .section ".data..page_aligned", "aw"
49 #define __PAGE_ALIGNED_BSS      .section ".bss..page_aligned", "aw"
50
51 /*
52  * This is used by architectures to keep arguments on the stack
53  * untouched by the compiler by keeping them live until the end.
54  * The argument stack may be owned by the assembly-language
55  * caller, not the callee, and gcc doesn't always understand
56  * that.
57  *
58  * We have the return value, and a maximum of six arguments.
59  *
60  * This should always be followed by a "return ret" for the
61  * protection to work (ie no more work that the compiler might
62  * end up needing stack temporaries for).
63  */
64 /* Assembly files may be compiled with -traditional .. */
65 #ifndef __ASSEMBLY__
66 #ifndef asmlinkage_protect
67 # define asmlinkage_protect(n, ret, args...)    do { } while (0)
68 #endif
69 #endif
70
71 #ifndef __ALIGN
72 #define __ALIGN         .align 4,0x90
73 #define __ALIGN_STR     ".align 4,0x90"
74 #endif
75
76 #ifdef __ASSEMBLY__
77
78 /* SYM_T_FUNC -- type used by assembler to mark functions */
79 #ifndef SYM_T_FUNC
80 #define SYM_T_FUNC                              STT_FUNC
81 #endif
82
83 /* SYM_T_OBJECT -- type used by assembler to mark data */
84 #ifndef SYM_T_OBJECT
85 #define SYM_T_OBJECT                            STT_OBJECT
86 #endif
87
88 /* SYM_T_NONE -- type used by assembler to mark entries of unknown type */
89 #ifndef SYM_T_NONE
90 #define SYM_T_NONE                              STT_NOTYPE
91 #endif
92
93 /* SYM_A_* -- align the symbol? */
94 #define SYM_A_ALIGN                             ALIGN
95 #define SYM_A_NONE                              /* nothing */
96
97 /* SYM_L_* -- linkage of symbols */
98 #define SYM_L_GLOBAL(name)                      .globl name
99 #define SYM_L_WEAK(name)                        .weak name
100 #define SYM_L_LOCAL(name)                       /* nothing */
101
102 #ifndef LINKER_SCRIPT
103 #define ALIGN __ALIGN
104 #define ALIGN_STR __ALIGN_STR
105
106 /* === DEPRECATED annotations === */
107
108 #ifndef CONFIG_X86
109 #ifndef GLOBAL
110 /* deprecated, use SYM_DATA*, SYM_ENTRY, or similar */
111 #define GLOBAL(name) \
112         .globl name ASM_NL \
113         name:
114 #endif
115 #endif
116
117 #ifndef CONFIG_X86_64
118 #ifndef ENTRY
119 /* deprecated, use SYM_FUNC_START */
120 #define ENTRY(name) \
121         SYM_FUNC_START(name)
122 #endif
123 #endif /* CONFIG_X86_64 */
124 #endif /* LINKER_SCRIPT */
125
126 #ifndef WEAK
127 /* deprecated, use SYM_FUNC_START_WEAK* */
128 #define WEAK(name)         \
129         SYM_FUNC_START_WEAK(name)
130 #endif
131
132 #ifndef CONFIG_X86
133 #ifndef END
134 /* deprecated, use SYM_FUNC_END, SYM_DATA_END, or SYM_END */
135 #define END(name) \
136         .size name, .-name
137 #endif
138 #endif /* CONFIG_X86 */
139
140 #ifndef CONFIG_X86_64
141 /* If symbol 'name' is treated as a subroutine (gets called, and returns)
142  * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of
143  * static analysis tools such as stack depth analyzer.
144  */
145 #ifndef ENDPROC
146 /* deprecated, use SYM_FUNC_END */
147 #define ENDPROC(name) \
148         SYM_FUNC_END(name)
149 #endif
150 #endif /* CONFIG_X86_64 */
151
152 /* === generic annotations === */
153
154 /* SYM_ENTRY -- use only if you have to for non-paired symbols */
155 #ifndef SYM_ENTRY
156 #define SYM_ENTRY(name, linkage, align...)              \
157         linkage(name) ASM_NL                            \
158         align ASM_NL                                    \
159         name:
160 #endif
161
162 /* SYM_START -- use only if you have to */
163 #ifndef SYM_START
164 #define SYM_START(name, linkage, align...)              \
165         SYM_ENTRY(name, linkage, align)
166 #endif
167
168 /* SYM_END -- use only if you have to */
169 #ifndef SYM_END
170 #define SYM_END(name, sym_type)                         \
171         .type name sym_type ASM_NL                      \
172         .size name, .-name
173 #endif
174
175 /* === code annotations === */
176
177 /*
178  * FUNC -- C-like functions (proper stack frame etc.)
179  * CODE -- non-C code (e.g. irq handlers with different, special stack etc.)
180  *
181  * Objtool validates stack for FUNC, but not for CODE.
182  * Objtool generates debug info for both FUNC & CODE, but needs special
183  * annotations for each CODE's start (to describe the actual stack frame).
184  *
185  * ALIAS -- does not generate debug info -- the aliased function will
186  */
187
188 /* SYM_INNER_LABEL_ALIGN -- only for labels in the middle of code */
189 #ifndef SYM_INNER_LABEL_ALIGN
190 #define SYM_INNER_LABEL_ALIGN(name, linkage)    \
191         .type name SYM_T_NONE ASM_NL                    \
192         SYM_ENTRY(name, linkage, SYM_A_ALIGN)
193 #endif
194
195 /* SYM_INNER_LABEL -- only for labels in the middle of code */
196 #ifndef SYM_INNER_LABEL
197 #define SYM_INNER_LABEL(name, linkage)          \
198         .type name SYM_T_NONE ASM_NL                    \
199         SYM_ENTRY(name, linkage, SYM_A_NONE)
200 #endif
201
202 /*
203  * SYM_FUNC_START_LOCAL_ALIAS -- use where there are two local names for one
204  * function
205  */
206 #ifndef SYM_FUNC_START_LOCAL_ALIAS
207 #define SYM_FUNC_START_LOCAL_ALIAS(name)                \
208         SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
209 #endif
210
211 /*
212  * SYM_FUNC_START_ALIAS -- use where there are two global names for one
213  * function
214  */
215 #ifndef SYM_FUNC_START_ALIAS
216 #define SYM_FUNC_START_ALIAS(name)                      \
217         SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
218 #endif
219
220 /* SYM_FUNC_START -- use for global functions */
221 #ifndef SYM_FUNC_START
222 /*
223  * The same as SYM_FUNC_START_ALIAS, but we will need to distinguish these two
224  * later.
225  */
226 #define SYM_FUNC_START(name)                            \
227         SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
228 #endif
229
230 /* SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment */
231 #ifndef SYM_FUNC_START_NOALIGN
232 #define SYM_FUNC_START_NOALIGN(name)                    \
233         SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
234 #endif
235
236 /* SYM_FUNC_START_LOCAL -- use for local functions */
237 #ifndef SYM_FUNC_START_LOCAL
238 /* the same as SYM_FUNC_START_LOCAL_ALIAS, see comment near SYM_FUNC_START */
239 #define SYM_FUNC_START_LOCAL(name)                      \
240         SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
241 #endif
242
243 /* SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o alignment */
244 #ifndef SYM_FUNC_START_LOCAL_NOALIGN
245 #define SYM_FUNC_START_LOCAL_NOALIGN(name)              \
246         SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
247 #endif
248
249 /* SYM_FUNC_START_WEAK -- use for weak functions */
250 #ifndef SYM_FUNC_START_WEAK
251 #define SYM_FUNC_START_WEAK(name)                       \
252         SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN)
253 #endif
254
255 /* SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment */
256 #ifndef SYM_FUNC_START_WEAK_NOALIGN
257 #define SYM_FUNC_START_WEAK_NOALIGN(name)               \
258         SYM_START(name, SYM_L_WEAK, SYM_A_NONE)
259 #endif
260
261 /* SYM_FUNC_END_ALIAS -- the end of LOCAL_ALIASed or ALIASed function */
262 #ifndef SYM_FUNC_END_ALIAS
263 #define SYM_FUNC_END_ALIAS(name)                        \
264         SYM_END(name, SYM_T_FUNC)
265 #endif
266
267 /*
268  * SYM_FUNC_END -- the end of SYM_FUNC_START_LOCAL, SYM_FUNC_START,
269  * SYM_FUNC_START_WEAK, ...
270  */
271 #ifndef SYM_FUNC_END
272 /* the same as SYM_FUNC_END_ALIAS, see comment near SYM_FUNC_START */
273 #define SYM_FUNC_END(name)                              \
274         SYM_END(name, SYM_T_FUNC)
275 #endif
276
277 /* SYM_CODE_START -- use for non-C (special) functions */
278 #ifndef SYM_CODE_START
279 #define SYM_CODE_START(name)                            \
280         SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
281 #endif
282
283 /* SYM_CODE_START_NOALIGN -- use for non-C (special) functions, w/o alignment */
284 #ifndef SYM_CODE_START_NOALIGN
285 #define SYM_CODE_START_NOALIGN(name)                    \
286         SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
287 #endif
288
289 /* SYM_CODE_START_LOCAL -- use for local non-C (special) functions */
290 #ifndef SYM_CODE_START_LOCAL
291 #define SYM_CODE_START_LOCAL(name)                      \
292         SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
293 #endif
294
295 /*
296  * SYM_CODE_START_LOCAL_NOALIGN -- use for local non-C (special) functions,
297  * w/o alignment
298  */
299 #ifndef SYM_CODE_START_LOCAL_NOALIGN
300 #define SYM_CODE_START_LOCAL_NOALIGN(name)              \
301         SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
302 #endif
303
304 /* SYM_CODE_END -- the end of SYM_CODE_START_LOCAL, SYM_CODE_START, ... */
305 #ifndef SYM_CODE_END
306 #define SYM_CODE_END(name)                              \
307         SYM_END(name, SYM_T_NONE)
308 #endif
309
310 /* === data annotations === */
311
312 /* SYM_DATA_START -- global data symbol */
313 #ifndef SYM_DATA_START
314 #define SYM_DATA_START(name)                            \
315         SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
316 #endif
317
318 /* SYM_DATA_START -- local data symbol */
319 #ifndef SYM_DATA_START_LOCAL
320 #define SYM_DATA_START_LOCAL(name)                      \
321         SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
322 #endif
323
324 /* SYM_DATA_END -- the end of SYM_DATA_START symbol */
325 #ifndef SYM_DATA_END
326 #define SYM_DATA_END(name)                              \
327         SYM_END(name, SYM_T_OBJECT)
328 #endif
329
330 /* SYM_DATA_END_LABEL -- the labeled end of SYM_DATA_START symbol */
331 #ifndef SYM_DATA_END_LABEL
332 #define SYM_DATA_END_LABEL(name, linkage, label)        \
333         linkage(label) ASM_NL                           \
334         .type label SYM_T_OBJECT ASM_NL                 \
335         label:                                          \
336         SYM_END(name, SYM_T_OBJECT)
337 #endif
338
339 /* SYM_DATA -- start+end wrapper around simple global data */
340 #ifndef SYM_DATA
341 #define SYM_DATA(name, data...)                         \
342         SYM_DATA_START(name) ASM_NL                             \
343         data ASM_NL                                             \
344         SYM_DATA_END(name)
345 #endif
346
347 /* SYM_DATA_LOCAL -- start+end wrapper around simple local data */
348 #ifndef SYM_DATA_LOCAL
349 #define SYM_DATA_LOCAL(name, data...)                   \
350         SYM_DATA_START_LOCAL(name) ASM_NL                       \
351         data ASM_NL                                             \
352         SYM_DATA_END(name)
353 #endif
354
355 #endif /* __ASSEMBLY__ */
356
357 #endif /* _LINUX_LINKAGE_H */