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