hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/linux/linkage.h
....@@ -36,8 +36,8 @@
3636 __stringify(name))
3737 #endif
3838
39
-#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
40
-#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
39
+#define __page_aligned_data __section(".data..page_aligned") __aligned(PAGE_SIZE)
40
+#define __page_aligned_bss __section(".bss..page_aligned") __aligned(PAGE_SIZE)
4141
4242 /*
4343 * For assembly routines.
....@@ -75,25 +75,61 @@
7575
7676 #ifdef __ASSEMBLY__
7777
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
+
78102 #ifndef LINKER_SCRIPT
79103 #define ALIGN __ALIGN
80104 #define ALIGN_STR __ALIGN_STR
81105
82
-#ifndef ENTRY
83
-#define ENTRY(name) \
106
+/* === DEPRECATED annotations === */
107
+
108
+#ifndef CONFIG_ARCH_USE_SYM_ANNOTATIONS
109
+#ifndef GLOBAL
110
+/* deprecated, use SYM_DATA*, SYM_ENTRY, or similar */
111
+#define GLOBAL(name) \
84112 .globl name ASM_NL \
85
- ALIGN ASM_NL \
86113 name:
87114 #endif
115
+
116
+#ifndef ENTRY
117
+/* deprecated, use SYM_FUNC_START */
118
+#define ENTRY(name) \
119
+ SYM_FUNC_START(name)
120
+#endif
121
+#endif /* CONFIG_ARCH_USE_SYM_ANNOTATIONS */
88122 #endif /* LINKER_SCRIPT */
89123
124
+#ifndef CONFIG_ARCH_USE_SYM_ANNOTATIONS
90125 #ifndef WEAK
126
+/* deprecated, use SYM_FUNC_START_WEAK* */
91127 #define WEAK(name) \
92
- .weak name ASM_NL \
93
- name:
128
+ SYM_FUNC_START_WEAK(name)
94129 #endif
95130
96131 #ifndef END
132
+/* deprecated, use SYM_FUNC_END, SYM_DATA_END, or SYM_END */
97133 #define END(name) \
98134 .size name, .-name
99135 #endif
....@@ -103,11 +139,220 @@
103139 * static analysis tools such as stack depth analyzer.
104140 */
105141 #ifndef ENDPROC
142
+/* deprecated, use SYM_FUNC_END */
106143 #define ENDPROC(name) \
107
- .type name, @function ASM_NL \
108
- END(name)
144
+ SYM_FUNC_END(name)
145
+#endif
146
+#endif /* CONFIG_ARCH_USE_SYM_ANNOTATIONS */
147
+
148
+/* === generic annotations === */
149
+
150
+/* SYM_ENTRY -- use only if you have to for non-paired symbols */
151
+#ifndef SYM_ENTRY
152
+#define SYM_ENTRY(name, linkage, align...) \
153
+ linkage(name) ASM_NL \
154
+ align ASM_NL \
155
+ name:
109156 #endif
110157
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)
111162 #endif
112163
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
+ .size name, .-name
113169 #endif
170
+
171
+/* === code annotations === */
172
+
173
+/*
174
+ * FUNC -- C-like functions (proper stack frame etc.)
175
+ * CODE -- non-C code (e.g. irq handlers with different, special stack etc.)
176
+ *
177
+ * Objtool validates stack for FUNC, but not for CODE.
178
+ * Objtool generates debug info for both FUNC & CODE, but needs special
179
+ * annotations for each CODE's start (to describe the actual stack frame).
180
+ *
181
+ * Objtool requires that all code must be contained in an ELF symbol. Symbol
182
+ * names that have a .L prefix do not emit symbol table entries. .L
183
+ * prefixed symbols can be used within a code region, but should be avoided for
184
+ * denoting a range of code via ``SYM_*_START/END`` annotations.
185
+ *
186
+ * ALIAS -- does not generate debug info -- the aliased function will
187
+ */
188
+
189
+/* SYM_INNER_LABEL_ALIGN -- only for labels in the middle of code */
190
+#ifndef SYM_INNER_LABEL_ALIGN
191
+#define SYM_INNER_LABEL_ALIGN(name, linkage) \
192
+ .type name SYM_T_NONE ASM_NL \
193
+ SYM_ENTRY(name, linkage, SYM_A_ALIGN)
194
+#endif
195
+
196
+/* SYM_INNER_LABEL -- only for labels in the middle of code */
197
+#ifndef SYM_INNER_LABEL
198
+#define SYM_INNER_LABEL(name, linkage) \
199
+ .type name SYM_T_NONE ASM_NL \
200
+ SYM_ENTRY(name, linkage, SYM_A_NONE)
201
+#endif
202
+
203
+/*
204
+ * SYM_FUNC_START_LOCAL_ALIAS -- use where there are two local names for one
205
+ * function
206
+ */
207
+#ifndef SYM_FUNC_START_LOCAL_ALIAS
208
+#define SYM_FUNC_START_LOCAL_ALIAS(name) \
209
+ SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
210
+#endif
211
+
212
+/*
213
+ * SYM_FUNC_START_ALIAS -- use where there are two global names for one
214
+ * function
215
+ */
216
+#ifndef SYM_FUNC_START_ALIAS
217
+#define SYM_FUNC_START_ALIAS(name) \
218
+ SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
219
+#endif
220
+
221
+/* SYM_FUNC_START -- use for global functions */
222
+#ifndef SYM_FUNC_START
223
+/*
224
+ * The same as SYM_FUNC_START_ALIAS, but we will need to distinguish these two
225
+ * later.
226
+ */
227
+#define SYM_FUNC_START(name) \
228
+ SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
229
+#endif
230
+
231
+/* SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment */
232
+#ifndef SYM_FUNC_START_NOALIGN
233
+#define SYM_FUNC_START_NOALIGN(name) \
234
+ SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
235
+#endif
236
+
237
+/* SYM_FUNC_START_LOCAL -- use for local functions */
238
+#ifndef SYM_FUNC_START_LOCAL
239
+/* the same as SYM_FUNC_START_LOCAL_ALIAS, see comment near SYM_FUNC_START */
240
+#define SYM_FUNC_START_LOCAL(name) \
241
+ SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
242
+#endif
243
+
244
+/* SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o alignment */
245
+#ifndef SYM_FUNC_START_LOCAL_NOALIGN
246
+#define SYM_FUNC_START_LOCAL_NOALIGN(name) \
247
+ SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
248
+#endif
249
+
250
+/* SYM_FUNC_START_WEAK -- use for weak functions */
251
+#ifndef SYM_FUNC_START_WEAK
252
+#define SYM_FUNC_START_WEAK(name) \
253
+ SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN)
254
+#endif
255
+
256
+/* SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment */
257
+#ifndef SYM_FUNC_START_WEAK_NOALIGN
258
+#define SYM_FUNC_START_WEAK_NOALIGN(name) \
259
+ SYM_START(name, SYM_L_WEAK, SYM_A_NONE)
260
+#endif
261
+
262
+/* SYM_FUNC_END_ALIAS -- the end of LOCAL_ALIASed or ALIASed function */
263
+#ifndef SYM_FUNC_END_ALIAS
264
+#define SYM_FUNC_END_ALIAS(name) \
265
+ SYM_END(name, SYM_T_FUNC)
266
+#endif
267
+
268
+/*
269
+ * SYM_FUNC_END -- the end of SYM_FUNC_START_LOCAL, SYM_FUNC_START,
270
+ * SYM_FUNC_START_WEAK, ...
271
+ */
272
+#ifndef SYM_FUNC_END
273
+/* the same as SYM_FUNC_END_ALIAS, see comment near SYM_FUNC_START */
274
+#define SYM_FUNC_END(name) \
275
+ SYM_END(name, SYM_T_FUNC)
276
+#endif
277
+
278
+/* SYM_CODE_START -- use for non-C (special) functions */
279
+#ifndef SYM_CODE_START
280
+#define SYM_CODE_START(name) \
281
+ SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
282
+#endif
283
+
284
+/* SYM_CODE_START_NOALIGN -- use for non-C (special) functions, w/o alignment */
285
+#ifndef SYM_CODE_START_NOALIGN
286
+#define SYM_CODE_START_NOALIGN(name) \
287
+ SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
288
+#endif
289
+
290
+/* SYM_CODE_START_LOCAL -- use for local non-C (special) functions */
291
+#ifndef SYM_CODE_START_LOCAL
292
+#define SYM_CODE_START_LOCAL(name) \
293
+ SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
294
+#endif
295
+
296
+/*
297
+ * SYM_CODE_START_LOCAL_NOALIGN -- use for local non-C (special) functions,
298
+ * w/o alignment
299
+ */
300
+#ifndef SYM_CODE_START_LOCAL_NOALIGN
301
+#define SYM_CODE_START_LOCAL_NOALIGN(name) \
302
+ SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
303
+#endif
304
+
305
+/* SYM_CODE_END -- the end of SYM_CODE_START_LOCAL, SYM_CODE_START, ... */
306
+#ifndef SYM_CODE_END
307
+#define SYM_CODE_END(name) \
308
+ SYM_END(name, SYM_T_NONE)
309
+#endif
310
+
311
+/* === data annotations === */
312
+
313
+/* SYM_DATA_START -- global data symbol */
314
+#ifndef SYM_DATA_START
315
+#define SYM_DATA_START(name) \
316
+ SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
317
+#endif
318
+
319
+/* SYM_DATA_START -- local data symbol */
320
+#ifndef SYM_DATA_START_LOCAL
321
+#define SYM_DATA_START_LOCAL(name) \
322
+ SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
323
+#endif
324
+
325
+/* SYM_DATA_END -- the end of SYM_DATA_START symbol */
326
+#ifndef SYM_DATA_END
327
+#define SYM_DATA_END(name) \
328
+ SYM_END(name, SYM_T_OBJECT)
329
+#endif
330
+
331
+/* SYM_DATA_END_LABEL -- the labeled end of SYM_DATA_START symbol */
332
+#ifndef SYM_DATA_END_LABEL
333
+#define SYM_DATA_END_LABEL(name, linkage, label) \
334
+ linkage(label) ASM_NL \
335
+ .type label SYM_T_OBJECT ASM_NL \
336
+ label: \
337
+ SYM_END(name, SYM_T_OBJECT)
338
+#endif
339
+
340
+/* SYM_DATA -- start+end wrapper around simple global data */
341
+#ifndef SYM_DATA
342
+#define SYM_DATA(name, data...) \
343
+ SYM_DATA_START(name) ASM_NL \
344
+ data ASM_NL \
345
+ SYM_DATA_END(name)
346
+#endif
347
+
348
+/* SYM_DATA_LOCAL -- start+end wrapper around simple local data */
349
+#ifndef SYM_DATA_LOCAL
350
+#define SYM_DATA_LOCAL(name, data...) \
351
+ SYM_DATA_START_LOCAL(name) ASM_NL \
352
+ data ASM_NL \
353
+ SYM_DATA_END(name)
354
+#endif
355
+
356
+#endif /* __ASSEMBLY__ */
357
+
358
+#endif /* _LINUX_LINKAGE_H */