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