]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - include/asm-generic/vmlinux.lds.h
tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values
[karo-tx-linux.git] / include / asm-generic / vmlinux.lds.h
1 /*
2  * Helper macros to support writing architecture specific
3  * linker scripts.
4  *
5  * A minimal linker scripts has following content:
6  * [This is a sample, architectures may have special requiriements]
7  *
8  * OUTPUT_FORMAT(...)
9  * OUTPUT_ARCH(...)
10  * ENTRY(...)
11  * SECTIONS
12  * {
13  *      . = START;
14  *      __init_begin = .;
15  *      HEAD_TEXT_SECTION
16  *      INIT_TEXT_SECTION(PAGE_SIZE)
17  *      INIT_DATA_SECTION(...)
18  *      PERCPU_SECTION(CACHELINE_SIZE)
19  *      __init_end = .;
20  *
21  *      _stext = .;
22  *      TEXT_SECTION = 0
23  *      _etext = .;
24  *
25  *      _sdata = .;
26  *      RO_DATA_SECTION(PAGE_SIZE)
27  *      RW_DATA_SECTION(...)
28  *      _edata = .;
29  *
30  *      EXCEPTION_TABLE(...)
31  *      NOTES
32  *
33  *      BSS_SECTION(0, 0, 0)
34  *      _end = .;
35  *
36  *      STABS_DEBUG
37  *      DWARF_DEBUG
38  *
39  *      DISCARDS                // must be the last
40  * }
41  *
42  * [__init_begin, __init_end] is the init section that may be freed after init
43  *      // __init_begin and __init_end should be page aligned, so that we can
44  *      // free the whole .init memory
45  * [_stext, _etext] is the text section
46  * [_sdata, _edata] is the data section
47  *
48  * Some of the included output section have their own set of constants.
49  * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
50  *               [__nosave_begin, __nosave_end] for the nosave data
51  */
52
53 #ifndef LOAD_OFFSET
54 #define LOAD_OFFSET 0
55 #endif
56
57 #include <linux/export.h>
58
59 /* Align . to a 8 byte boundary equals to maximum function alignment. */
60 #define ALIGN_FUNCTION()  . = ALIGN(8)
61
62 /*
63  * Align to a 32 byte boundary equal to the
64  * alignment gcc 4.5 uses for a struct
65  */
66 #define STRUCT_ALIGNMENT 32
67 #define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)
68
69 /* The actual configuration determine if the init/exit sections
70  * are handled as text/data or they can be discarded (which
71  * often happens at runtime)
72  */
73 #ifdef CONFIG_HOTPLUG_CPU
74 #define CPU_KEEP(sec)    *(.cpu##sec)
75 #define CPU_DISCARD(sec)
76 #else
77 #define CPU_KEEP(sec)
78 #define CPU_DISCARD(sec) *(.cpu##sec)
79 #endif
80
81 #if defined(CONFIG_MEMORY_HOTPLUG)
82 #define MEM_KEEP(sec)    *(.mem##sec)
83 #define MEM_DISCARD(sec)
84 #else
85 #define MEM_KEEP(sec)
86 #define MEM_DISCARD(sec) *(.mem##sec)
87 #endif
88
89 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
90 #define MCOUNT_REC()    . = ALIGN(8);                           \
91                         VMLINUX_SYMBOL(__start_mcount_loc) = .; \
92                         *(__mcount_loc)                         \
93                         VMLINUX_SYMBOL(__stop_mcount_loc) = .;
94 #else
95 #define MCOUNT_REC()
96 #endif
97
98 #ifdef CONFIG_TRACE_BRANCH_PROFILING
99 #define LIKELY_PROFILE()        VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \
100                                 *(_ftrace_annotated_branch)                           \
101                                 VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .;
102 #else
103 #define LIKELY_PROFILE()
104 #endif
105
106 #ifdef CONFIG_PROFILE_ALL_BRANCHES
107 #define BRANCH_PROFILE()        VMLINUX_SYMBOL(__start_branch_profile) = .;   \
108                                 *(_ftrace_branch)                             \
109                                 VMLINUX_SYMBOL(__stop_branch_profile) = .;
110 #else
111 #define BRANCH_PROFILE()
112 #endif
113
114 #ifdef CONFIG_KPROBES
115 #define KPROBE_BLACKLIST()      . = ALIGN(8);                                 \
116                                 VMLINUX_SYMBOL(__start_kprobe_blacklist) = .; \
117                                 *(_kprobe_blacklist)                          \
118                                 VMLINUX_SYMBOL(__stop_kprobe_blacklist) = .;
119 #else
120 #define KPROBE_BLACKLIST()
121 #endif
122
123 #ifdef CONFIG_EVENT_TRACING
124 #define FTRACE_EVENTS() . = ALIGN(8);                                   \
125                         VMLINUX_SYMBOL(__start_ftrace_events) = .;      \
126                         *(_ftrace_events)                               \
127                         VMLINUX_SYMBOL(__stop_ftrace_events) = .;       \
128                         VMLINUX_SYMBOL(__start_ftrace_enum_maps) = .;   \
129                         *(_ftrace_enum_map)                             \
130                         VMLINUX_SYMBOL(__stop_ftrace_enum_maps) = .;
131 #else
132 #define FTRACE_EVENTS()
133 #endif
134
135 #ifdef CONFIG_TRACING
136 #define TRACE_PRINTKS() VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .;      \
137                          *(__trace_printk_fmt) /* Trace_printk fmt' pointer */ \
138                          VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .;
139 #define TRACEPOINT_STR() VMLINUX_SYMBOL(__start___tracepoint_str) = .;  \
140                          *(__tracepoint_str) /* Trace_printk fmt' pointer */ \
141                          VMLINUX_SYMBOL(__stop___tracepoint_str) = .;
142 #else
143 #define TRACE_PRINTKS()
144 #define TRACEPOINT_STR()
145 #endif
146
147 #ifdef CONFIG_FTRACE_SYSCALLS
148 #define TRACE_SYSCALLS() . = ALIGN(8);                                  \
149                          VMLINUX_SYMBOL(__start_syscalls_metadata) = .; \
150                          *(__syscalls_metadata)                         \
151                          VMLINUX_SYMBOL(__stop_syscalls_metadata) = .;
152 #else
153 #define TRACE_SYSCALLS()
154 #endif
155
156
157 #define ___OF_TABLE(cfg, name)  _OF_TABLE_##cfg(name)
158 #define __OF_TABLE(cfg, name)   ___OF_TABLE(cfg, name)
159 #define OF_TABLE(cfg, name)     __OF_TABLE(config_enabled(cfg), name)
160 #define _OF_TABLE_0(name)
161 #define _OF_TABLE_1(name)                                               \
162         . = ALIGN(8);                                                   \
163         VMLINUX_SYMBOL(__##name##_of_table) = .;                        \
164         *(__##name##_of_table)                                          \
165         *(__##name##_of_table_end)
166
167 #define CLKSRC_OF_TABLES()      OF_TABLE(CONFIG_CLKSRC_OF, clksrc)
168 #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
169 #define CLK_OF_TABLES()         OF_TABLE(CONFIG_COMMON_CLK, clk)
170 #define IOMMU_OF_TABLES()       OF_TABLE(CONFIG_OF_IOMMU, iommu)
171 #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
172 #define CPU_METHOD_OF_TABLES()  OF_TABLE(CONFIG_SMP, cpu_method)
173 #define EARLYCON_OF_TABLES()    OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)
174
175 #define KERNEL_DTB()                                                    \
176         STRUCT_ALIGN();                                                 \
177         VMLINUX_SYMBOL(__dtb_start) = .;                                \
178         *(.dtb.init.rodata)                                             \
179         VMLINUX_SYMBOL(__dtb_end) = .;
180
181 /* .data section */
182 #define DATA_DATA                                                       \
183         *(.data)                                                        \
184         *(.ref.data)                                                    \
185         *(.data..shared_aligned) /* percpu related */                   \
186         MEM_KEEP(init.data)                                             \
187         MEM_KEEP(exit.data)                                             \
188         *(.data.unlikely)                                               \
189         STRUCT_ALIGN();                                                 \
190         *(__tracepoints)                                                \
191         /* implement dynamic printk debug */                            \
192         . = ALIGN(8);                                                   \
193         VMLINUX_SYMBOL(__start___jump_table) = .;                       \
194         *(__jump_table)                                                 \
195         VMLINUX_SYMBOL(__stop___jump_table) = .;                        \
196         . = ALIGN(8);                                                   \
197         VMLINUX_SYMBOL(__start___verbose) = .;                          \
198         *(__verbose)                                                    \
199         VMLINUX_SYMBOL(__stop___verbose) = .;                           \
200         LIKELY_PROFILE()                                                \
201         BRANCH_PROFILE()                                                \
202         TRACE_PRINTKS()                                                 \
203         TRACEPOINT_STR()
204
205 /*
206  * Data section helpers
207  */
208 #define NOSAVE_DATA                                                     \
209         . = ALIGN(PAGE_SIZE);                                           \
210         VMLINUX_SYMBOL(__nosave_begin) = .;                             \
211         *(.data..nosave)                                                \
212         . = ALIGN(PAGE_SIZE);                                           \
213         VMLINUX_SYMBOL(__nosave_end) = .;
214
215 #define PAGE_ALIGNED_DATA(page_align)                                   \
216         . = ALIGN(page_align);                                          \
217         *(.data..page_aligned)
218
219 #define READ_MOSTLY_DATA(align)                                         \
220         . = ALIGN(align);                                               \
221         *(.data..read_mostly)                                           \
222         . = ALIGN(align);
223
224 #define CACHELINE_ALIGNED_DATA(align)                                   \
225         . = ALIGN(align);                                               \
226         *(.data..cacheline_aligned)
227
228 #define INIT_TASK_DATA(align)                                           \
229         . = ALIGN(align);                                               \
230         *(.data..init_task)
231
232 /*
233  * Read only Data
234  */
235 #define RO_DATA_SECTION(align)                                          \
236         . = ALIGN((align));                                             \
237         .rodata           : AT(ADDR(.rodata) - LOAD_OFFSET) {           \
238                 VMLINUX_SYMBOL(__start_rodata) = .;                     \
239                 *(.rodata) *(.rodata.*)                                 \
240                 *(__vermagic)           /* Kernel version magic */      \
241                 . = ALIGN(8);                                           \
242                 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .;         \
243                 *(__tracepoints_ptrs)   /* Tracepoints: pointer array */\
244                 VMLINUX_SYMBOL(__stop___tracepoints_ptrs) = .;          \
245                 *(__tracepoints_strings)/* Tracepoints: strings */      \
246         }                                                               \
247                                                                         \
248         .rodata1          : AT(ADDR(.rodata1) - LOAD_OFFSET) {          \
249                 *(.rodata1)                                             \
250         }                                                               \
251                                                                         \
252         BUG_TABLE                                                       \
253                                                                         \
254         /* PCI quirks */                                                \
255         .pci_fixup        : AT(ADDR(.pci_fixup) - LOAD_OFFSET) {        \
256                 VMLINUX_SYMBOL(__start_pci_fixups_early) = .;           \
257                 *(.pci_fixup_early)                                     \
258                 VMLINUX_SYMBOL(__end_pci_fixups_early) = .;             \
259                 VMLINUX_SYMBOL(__start_pci_fixups_header) = .;          \
260                 *(.pci_fixup_header)                                    \
261                 VMLINUX_SYMBOL(__end_pci_fixups_header) = .;            \
262                 VMLINUX_SYMBOL(__start_pci_fixups_final) = .;           \
263                 *(.pci_fixup_final)                                     \
264                 VMLINUX_SYMBOL(__end_pci_fixups_final) = .;             \
265                 VMLINUX_SYMBOL(__start_pci_fixups_enable) = .;          \
266                 *(.pci_fixup_enable)                                    \
267                 VMLINUX_SYMBOL(__end_pci_fixups_enable) = .;            \
268                 VMLINUX_SYMBOL(__start_pci_fixups_resume) = .;          \
269                 *(.pci_fixup_resume)                                    \
270                 VMLINUX_SYMBOL(__end_pci_fixups_resume) = .;            \
271                 VMLINUX_SYMBOL(__start_pci_fixups_resume_early) = .;    \
272                 *(.pci_fixup_resume_early)                              \
273                 VMLINUX_SYMBOL(__end_pci_fixups_resume_early) = .;      \
274                 VMLINUX_SYMBOL(__start_pci_fixups_suspend) = .;         \
275                 *(.pci_fixup_suspend)                                   \
276                 VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .;           \
277                 VMLINUX_SYMBOL(__start_pci_fixups_suspend_late) = .;    \
278                 *(.pci_fixup_suspend_late)                              \
279                 VMLINUX_SYMBOL(__end_pci_fixups_suspend_late) = .;      \
280         }                                                               \
281                                                                         \
282         /* Built-in firmware blobs */                                   \
283         .builtin_fw        : AT(ADDR(.builtin_fw) - LOAD_OFFSET) {      \
284                 VMLINUX_SYMBOL(__start_builtin_fw) = .;                 \
285                 *(.builtin_fw)                                          \
286                 VMLINUX_SYMBOL(__end_builtin_fw) = .;                   \
287         }                                                               \
288                                                                         \
289         TRACEDATA                                                       \
290                                                                         \
291         /* Kernel symbol table: Normal symbols */                       \
292         __ksymtab         : AT(ADDR(__ksymtab) - LOAD_OFFSET) {         \
293                 VMLINUX_SYMBOL(__start___ksymtab) = .;                  \
294                 *(SORT(___ksymtab+*))                                   \
295                 VMLINUX_SYMBOL(__stop___ksymtab) = .;                   \
296         }                                                               \
297                                                                         \
298         /* Kernel symbol table: GPL-only symbols */                     \
299         __ksymtab_gpl     : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) {     \
300                 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .;              \
301                 *(SORT(___ksymtab_gpl+*))                               \
302                 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .;               \
303         }                                                               \
304                                                                         \
305         /* Kernel symbol table: Normal unused symbols */                \
306         __ksymtab_unused  : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) {  \
307                 VMLINUX_SYMBOL(__start___ksymtab_unused) = .;           \
308                 *(SORT(___ksymtab_unused+*))                            \
309                 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .;            \
310         }                                                               \
311                                                                         \
312         /* Kernel symbol table: GPL-only unused symbols */              \
313         __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
314                 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .;       \
315                 *(SORT(___ksymtab_unused_gpl+*))                        \
316                 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .;        \
317         }                                                               \
318                                                                         \
319         /* Kernel symbol table: GPL-future-only symbols */              \
320         __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
321                 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .;       \
322                 *(SORT(___ksymtab_gpl_future+*))                        \
323                 VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .;        \
324         }                                                               \
325                                                                         \
326         /* Kernel symbol table: Normal symbols */                       \
327         __kcrctab         : AT(ADDR(__kcrctab) - LOAD_OFFSET) {         \
328                 VMLINUX_SYMBOL(__start___kcrctab) = .;                  \
329                 *(SORT(___kcrctab+*))                                   \
330                 VMLINUX_SYMBOL(__stop___kcrctab) = .;                   \
331         }                                                               \
332                                                                         \
333         /* Kernel symbol table: GPL-only symbols */                     \
334         __kcrctab_gpl     : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) {     \
335                 VMLINUX_SYMBOL(__start___kcrctab_gpl) = .;              \
336                 *(SORT(___kcrctab_gpl+*))                               \
337                 VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .;               \
338         }                                                               \
339                                                                         \
340         /* Kernel symbol table: Normal unused symbols */                \
341         __kcrctab_unused  : AT(ADDR(__kcrctab_unused) - LOAD_OFFSET) {  \
342                 VMLINUX_SYMBOL(__start___kcrctab_unused) = .;           \
343                 *(SORT(___kcrctab_unused+*))                            \
344                 VMLINUX_SYMBOL(__stop___kcrctab_unused) = .;            \
345         }                                                               \
346                                                                         \
347         /* Kernel symbol table: GPL-only unused symbols */              \
348         __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
349                 VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .;       \
350                 *(SORT(___kcrctab_unused_gpl+*))                        \
351                 VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .;        \
352         }                                                               \
353                                                                         \
354         /* Kernel symbol table: GPL-future-only symbols */              \
355         __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
356                 VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .;       \
357                 *(SORT(___kcrctab_gpl_future+*))                        \
358                 VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .;        \
359         }                                                               \
360                                                                         \
361         /* Kernel symbol table: strings */                              \
362         __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
363                 *(__ksymtab_strings)                                    \
364         }                                                               \
365                                                                         \
366         /* __*init sections */                                          \
367         __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) {         \
368                 *(.ref.rodata)                                          \
369                 MEM_KEEP(init.rodata)                                   \
370                 MEM_KEEP(exit.rodata)                                   \
371         }                                                               \
372                                                                         \
373         /* Built-in module parameters. */                               \
374         __param : AT(ADDR(__param) - LOAD_OFFSET) {                     \
375                 VMLINUX_SYMBOL(__start___param) = .;                    \
376                 *(__param)                                              \
377                 VMLINUX_SYMBOL(__stop___param) = .;                     \
378         }                                                               \
379                                                                         \
380         /* Built-in module versions. */                                 \
381         __modver : AT(ADDR(__modver) - LOAD_OFFSET) {                   \
382                 VMLINUX_SYMBOL(__start___modver) = .;                   \
383                 *(__modver)                                             \
384                 VMLINUX_SYMBOL(__stop___modver) = .;                    \
385                 . = ALIGN((align));                                     \
386                 VMLINUX_SYMBOL(__end_rodata) = .;                       \
387         }                                                               \
388         . = ALIGN((align));
389
390 /* RODATA & RO_DATA provided for backward compatibility.
391  * All archs are supposed to use RO_DATA() */
392 #define RODATA          RO_DATA_SECTION(4096)
393 #define RO_DATA(align)  RO_DATA_SECTION(align)
394
395 #define SECURITY_INIT                                                   \
396         .security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \
397                 VMLINUX_SYMBOL(__security_initcall_start) = .;          \
398                 *(.security_initcall.init)                              \
399                 VMLINUX_SYMBOL(__security_initcall_end) = .;            \
400         }
401
402 /* .text section. Map to function alignment to avoid address changes
403  * during second ld run in second ld pass when generating System.map */
404 #define TEXT_TEXT                                                       \
405                 ALIGN_FUNCTION();                                       \
406                 *(.text.hot)                                            \
407                 *(.text)                                                \
408                 *(.ref.text)                                            \
409         MEM_KEEP(init.text)                                             \
410         MEM_KEEP(exit.text)                                             \
411                 *(.text.unlikely)
412
413
414 /* sched.text is aling to function alignment to secure we have same
415  * address even at second ld pass when generating System.map */
416 #define SCHED_TEXT                                                      \
417                 ALIGN_FUNCTION();                                       \
418                 VMLINUX_SYMBOL(__sched_text_start) = .;                 \
419                 *(.sched.text)                                          \
420                 VMLINUX_SYMBOL(__sched_text_end) = .;
421
422 /* spinlock.text is aling to function alignment to secure we have same
423  * address even at second ld pass when generating System.map */
424 #define LOCK_TEXT                                                       \
425                 ALIGN_FUNCTION();                                       \
426                 VMLINUX_SYMBOL(__lock_text_start) = .;                  \
427                 *(.spinlock.text)                                       \
428                 VMLINUX_SYMBOL(__lock_text_end) = .;
429
430 #define KPROBES_TEXT                                                    \
431                 ALIGN_FUNCTION();                                       \
432                 VMLINUX_SYMBOL(__kprobes_text_start) = .;               \
433                 *(.kprobes.text)                                        \
434                 VMLINUX_SYMBOL(__kprobes_text_end) = .;
435
436 #define ENTRY_TEXT                                                      \
437                 ALIGN_FUNCTION();                                       \
438                 VMLINUX_SYMBOL(__entry_text_start) = .;                 \
439                 *(.entry.text)                                          \
440                 VMLINUX_SYMBOL(__entry_text_end) = .;
441
442 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
443 #define IRQENTRY_TEXT                                                   \
444                 ALIGN_FUNCTION();                                       \
445                 VMLINUX_SYMBOL(__irqentry_text_start) = .;              \
446                 *(.irqentry.text)                                       \
447                 VMLINUX_SYMBOL(__irqentry_text_end) = .;
448 #else
449 #define IRQENTRY_TEXT
450 #endif
451
452 /* Section used for early init (in .S files) */
453 #define HEAD_TEXT  *(.head.text)
454
455 #define HEAD_TEXT_SECTION                                                       \
456         .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) {               \
457                 HEAD_TEXT                                               \
458         }
459
460 /*
461  * Exception table
462  */
463 #define EXCEPTION_TABLE(align)                                          \
464         . = ALIGN(align);                                               \
465         __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {               \
466                 VMLINUX_SYMBOL(__start___ex_table) = .;                 \
467                 *(__ex_table)                                           \
468                 VMLINUX_SYMBOL(__stop___ex_table) = .;                  \
469         }
470
471 /*
472  * Init task
473  */
474 #define INIT_TASK_DATA_SECTION(align)                                   \
475         . = ALIGN(align);                                               \
476         .data..init_task :  AT(ADDR(.data..init_task) - LOAD_OFFSET) {  \
477                 INIT_TASK_DATA(align)                                   \
478         }
479
480 #ifdef CONFIG_CONSTRUCTORS
481 #define KERNEL_CTORS()  . = ALIGN(8);                      \
482                         VMLINUX_SYMBOL(__ctors_start) = .; \
483                         *(.ctors)                          \
484                         *(SORT(.init_array.*))             \
485                         *(.init_array)                     \
486                         VMLINUX_SYMBOL(__ctors_end) = .;
487 #else
488 #define KERNEL_CTORS()
489 #endif
490
491 /* init and exit section handling */
492 #define INIT_DATA                                                       \
493         *(.init.data)                                                   \
494         MEM_DISCARD(init.data)                                          \
495         KERNEL_CTORS()                                                  \
496         MCOUNT_REC()                                                    \
497         *(.init.rodata)                                                 \
498         FTRACE_EVENTS()                                                 \
499         TRACE_SYSCALLS()                                                \
500         KPROBE_BLACKLIST()                                              \
501         MEM_DISCARD(init.rodata)                                        \
502         CLK_OF_TABLES()                                                 \
503         RESERVEDMEM_OF_TABLES()                                         \
504         CLKSRC_OF_TABLES()                                              \
505         IOMMU_OF_TABLES()                                               \
506         CPU_METHOD_OF_TABLES()                                          \
507         KERNEL_DTB()                                                    \
508         IRQCHIP_OF_MATCH_TABLE()                                        \
509         EARLYCON_OF_TABLES()
510
511 #define INIT_TEXT                                                       \
512         *(.init.text)                                                   \
513         MEM_DISCARD(init.text)
514
515 #define EXIT_DATA                                                       \
516         *(.exit.data)                                                   \
517         MEM_DISCARD(exit.data)                                          \
518         MEM_DISCARD(exit.rodata)
519
520 #define EXIT_TEXT                                                       \
521         *(.exit.text)                                                   \
522         MEM_DISCARD(exit.text)
523
524 #define EXIT_CALL                                                       \
525         *(.exitcall.exit)
526
527 /*
528  * bss (Block Started by Symbol) - uninitialized data
529  * zeroed during startup
530  */
531 #define SBSS(sbss_align)                                                \
532         . = ALIGN(sbss_align);                                          \
533         .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) {                         \
534                 *(.sbss)                                                \
535                 *(.scommon)                                             \
536         }
537
538 /*
539  * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
540  * sections to the front of bss.
541  */
542 #ifndef BSS_FIRST_SECTIONS
543 #define BSS_FIRST_SECTIONS
544 #endif
545
546 #define BSS(bss_align)                                                  \
547         . = ALIGN(bss_align);                                           \
548         .bss : AT(ADDR(.bss) - LOAD_OFFSET) {                           \
549                 BSS_FIRST_SECTIONS                                      \
550                 *(.bss..page_aligned)                                   \
551                 *(.dynbss)                                              \
552                 *(.bss)                                                 \
553                 *(COMMON)                                               \
554         }
555
556 /*
557  * DWARF debug sections.
558  * Symbols in the DWARF debugging sections are relative to
559  * the beginning of the section so we begin them at 0.
560  */
561 #define DWARF_DEBUG                                                     \
562                 /* DWARF 1 */                                           \
563                 .debug          0 : { *(.debug) }                       \
564                 .line           0 : { *(.line) }                        \
565                 /* GNU DWARF 1 extensions */                            \
566                 .debug_srcinfo  0 : { *(.debug_srcinfo) }               \
567                 .debug_sfnames  0 : { *(.debug_sfnames) }               \
568                 /* DWARF 1.1 and DWARF 2 */                             \
569                 .debug_aranges  0 : { *(.debug_aranges) }               \
570                 .debug_pubnames 0 : { *(.debug_pubnames) }              \
571                 /* DWARF 2 */                                           \
572                 .debug_info     0 : { *(.debug_info                     \
573                                 .gnu.linkonce.wi.*) }                   \
574                 .debug_abbrev   0 : { *(.debug_abbrev) }                \
575                 .debug_line     0 : { *(.debug_line) }                  \
576                 .debug_frame    0 : { *(.debug_frame) }                 \
577                 .debug_str      0 : { *(.debug_str) }                   \
578                 .debug_loc      0 : { *(.debug_loc) }                   \
579                 .debug_macinfo  0 : { *(.debug_macinfo) }               \
580                 /* SGI/MIPS DWARF 2 extensions */                       \
581                 .debug_weaknames 0 : { *(.debug_weaknames) }            \
582                 .debug_funcnames 0 : { *(.debug_funcnames) }            \
583                 .debug_typenames 0 : { *(.debug_typenames) }            \
584                 .debug_varnames  0 : { *(.debug_varnames) }             \
585
586                 /* Stabs debugging sections.  */
587 #define STABS_DEBUG                                                     \
588                 .stab 0 : { *(.stab) }                                  \
589                 .stabstr 0 : { *(.stabstr) }                            \
590                 .stab.excl 0 : { *(.stab.excl) }                        \
591                 .stab.exclstr 0 : { *(.stab.exclstr) }                  \
592                 .stab.index 0 : { *(.stab.index) }                      \
593                 .stab.indexstr 0 : { *(.stab.indexstr) }                \
594                 .comment 0 : { *(.comment) }
595
596 #ifdef CONFIG_GENERIC_BUG
597 #define BUG_TABLE                                                       \
598         . = ALIGN(8);                                                   \
599         __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) {             \
600                 VMLINUX_SYMBOL(__start___bug_table) = .;                \
601                 *(__bug_table)                                          \
602                 VMLINUX_SYMBOL(__stop___bug_table) = .;                 \
603         }
604 #else
605 #define BUG_TABLE
606 #endif
607
608 #ifdef CONFIG_PM_TRACE
609 #define TRACEDATA                                                       \
610         . = ALIGN(4);                                                   \
611         .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {               \
612                 VMLINUX_SYMBOL(__tracedata_start) = .;                  \
613                 *(.tracedata)                                           \
614                 VMLINUX_SYMBOL(__tracedata_end) = .;                    \
615         }
616 #else
617 #define TRACEDATA
618 #endif
619
620 #define NOTES                                                           \
621         .notes : AT(ADDR(.notes) - LOAD_OFFSET) {                       \
622                 VMLINUX_SYMBOL(__start_notes) = .;                      \
623                 *(.note.*)                                              \
624                 VMLINUX_SYMBOL(__stop_notes) = .;                       \
625         }
626
627 #define INIT_SETUP(initsetup_align)                                     \
628                 . = ALIGN(initsetup_align);                             \
629                 VMLINUX_SYMBOL(__setup_start) = .;                      \
630                 *(.init.setup)                                          \
631                 VMLINUX_SYMBOL(__setup_end) = .;
632
633 #define INIT_CALLS_LEVEL(level)                                         \
634                 VMLINUX_SYMBOL(__initcall##level##_start) = .;          \
635                 *(.initcall##level##.init)                              \
636                 *(.initcall##level##s.init)                             \
637
638 #define INIT_CALLS                                                      \
639                 VMLINUX_SYMBOL(__initcall_start) = .;                   \
640                 *(.initcallearly.init)                                  \
641                 INIT_CALLS_LEVEL(0)                                     \
642                 INIT_CALLS_LEVEL(1)                                     \
643                 INIT_CALLS_LEVEL(2)                                     \
644                 INIT_CALLS_LEVEL(3)                                     \
645                 INIT_CALLS_LEVEL(4)                                     \
646                 INIT_CALLS_LEVEL(5)                                     \
647                 INIT_CALLS_LEVEL(rootfs)                                \
648                 INIT_CALLS_LEVEL(6)                                     \
649                 INIT_CALLS_LEVEL(7)                                     \
650                 VMLINUX_SYMBOL(__initcall_end) = .;
651
652 #define CON_INITCALL                                                    \
653                 VMLINUX_SYMBOL(__con_initcall_start) = .;               \
654                 *(.con_initcall.init)                                   \
655                 VMLINUX_SYMBOL(__con_initcall_end) = .;
656
657 #define SECURITY_INITCALL                                               \
658                 VMLINUX_SYMBOL(__security_initcall_start) = .;          \
659                 *(.security_initcall.init)                              \
660                 VMLINUX_SYMBOL(__security_initcall_end) = .;
661
662 #ifdef CONFIG_BLK_DEV_INITRD
663 #define INIT_RAM_FS                                                     \
664         . = ALIGN(4);                                                   \
665         VMLINUX_SYMBOL(__initramfs_start) = .;                          \
666         *(.init.ramfs)                                                  \
667         . = ALIGN(8);                                                   \
668         *(.init.ramfs.info)
669 #else
670 #define INIT_RAM_FS
671 #endif
672
673 /*
674  * Default discarded sections.
675  *
676  * Some archs want to discard exit text/data at runtime rather than
677  * link time due to cross-section references such as alt instructions,
678  * bug table, eh_frame, etc.  DISCARDS must be the last of output
679  * section definitions so that such archs put those in earlier section
680  * definitions.
681  */
682 #define DISCARDS                                                        \
683         /DISCARD/ : {                                                   \
684         EXIT_TEXT                                                       \
685         EXIT_DATA                                                       \
686         EXIT_CALL                                                       \
687         *(.discard)                                                     \
688         *(.discard.*)                                                   \
689         }
690
691 /**
692  * PERCPU_INPUT - the percpu input sections
693  * @cacheline: cacheline size
694  *
695  * The core percpu section names and core symbols which do not rely
696  * directly upon load addresses.
697  *
698  * @cacheline is used to align subsections to avoid false cacheline
699  * sharing between subsections for different purposes.
700  */
701 #define PERCPU_INPUT(cacheline)                                         \
702         VMLINUX_SYMBOL(__per_cpu_start) = .;                            \
703         *(.data..percpu..first)                                         \
704         . = ALIGN(PAGE_SIZE);                                           \
705         *(.data..percpu..page_aligned)                                  \
706         . = ALIGN(cacheline);                                           \
707         *(.data..percpu..read_mostly)                                   \
708         . = ALIGN(cacheline);                                           \
709         *(.data..percpu)                                                \
710         *(.data..percpu..shared_aligned)                                \
711         VMLINUX_SYMBOL(__per_cpu_end) = .;
712
713 /**
714  * PERCPU_VADDR - define output section for percpu area
715  * @cacheline: cacheline size
716  * @vaddr: explicit base address (optional)
717  * @phdr: destination PHDR (optional)
718  *
719  * Macro which expands to output section for percpu area.
720  *
721  * @cacheline is used to align subsections to avoid false cacheline
722  * sharing between subsections for different purposes.
723  *
724  * If @vaddr is not blank, it specifies explicit base address and all
725  * percpu symbols will be offset from the given address.  If blank,
726  * @vaddr always equals @laddr + LOAD_OFFSET.
727  *
728  * @phdr defines the output PHDR to use if not blank.  Be warned that
729  * output PHDR is sticky.  If @phdr is specified, the next output
730  * section in the linker script will go there too.  @phdr should have
731  * a leading colon.
732  *
733  * Note that this macros defines __per_cpu_load as an absolute symbol.
734  * If there is no need to put the percpu section at a predetermined
735  * address, use PERCPU_SECTION.
736  */
737 #define PERCPU_VADDR(cacheline, vaddr, phdr)                            \
738         VMLINUX_SYMBOL(__per_cpu_load) = .;                             \
739         .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load)         \
740                                 - LOAD_OFFSET) {                        \
741                 PERCPU_INPUT(cacheline)                                 \
742         } phdr                                                          \
743         . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
744
745 /**
746  * PERCPU_SECTION - define output section for percpu area, simple version
747  * @cacheline: cacheline size
748  *
749  * Align to PAGE_SIZE and outputs output section for percpu area.  This
750  * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and
751  * __per_cpu_start will be identical.
752  *
753  * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,)
754  * except that __per_cpu_load is defined as a relative symbol against
755  * .data..percpu which is required for relocatable x86_32 configuration.
756  */
757 #define PERCPU_SECTION(cacheline)                                       \
758         . = ALIGN(PAGE_SIZE);                                           \
759         .data..percpu   : AT(ADDR(.data..percpu) - LOAD_OFFSET) {       \
760                 VMLINUX_SYMBOL(__per_cpu_load) = .;                     \
761                 PERCPU_INPUT(cacheline)                                 \
762         }
763
764
765 /*
766  * Definition of the high level *_SECTION macros
767  * They will fit only a subset of the architectures
768  */
769
770
771 /*
772  * Writeable data.
773  * All sections are combined in a single .data section.
774  * The sections following CONSTRUCTORS are arranged so their
775  * typical alignment matches.
776  * A cacheline is typical/always less than a PAGE_SIZE so
777  * the sections that has this restriction (or similar)
778  * is located before the ones requiring PAGE_SIZE alignment.
779  * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
780  * matches the requirement of PAGE_ALIGNED_DATA.
781  *
782  * use 0 as page_align if page_aligned data is not used */
783 #define RW_DATA_SECTION(cacheline, pagealigned, inittask)               \
784         . = ALIGN(PAGE_SIZE);                                           \
785         .data : AT(ADDR(.data) - LOAD_OFFSET) {                         \
786                 INIT_TASK_DATA(inittask)                                \
787                 NOSAVE_DATA                                             \
788                 PAGE_ALIGNED_DATA(pagealigned)                          \
789                 CACHELINE_ALIGNED_DATA(cacheline)                       \
790                 READ_MOSTLY_DATA(cacheline)                             \
791                 DATA_DATA                                               \
792                 CONSTRUCTORS                                            \
793         }
794
795 #define INIT_TEXT_SECTION(inittext_align)                               \
796         . = ALIGN(inittext_align);                                      \
797         .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {               \
798                 VMLINUX_SYMBOL(_sinittext) = .;                         \
799                 INIT_TEXT                                               \
800                 VMLINUX_SYMBOL(_einittext) = .;                         \
801         }
802
803 #define INIT_DATA_SECTION(initsetup_align)                              \
804         .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {               \
805                 INIT_DATA                                               \
806                 INIT_SETUP(initsetup_align)                             \
807                 INIT_CALLS                                              \
808                 CON_INITCALL                                            \
809                 SECURITY_INITCALL                                       \
810                 INIT_RAM_FS                                             \
811         }
812
813 #define BSS_SECTION(sbss_align, bss_align, stop_align)                  \
814         . = ALIGN(sbss_align);                                          \
815         VMLINUX_SYMBOL(__bss_start) = .;                                \
816         SBSS(sbss_align)                                                \
817         BSS(bss_align)                                                  \
818         . = ALIGN(stop_align);                                          \
819         VMLINUX_SYMBOL(__bss_stop) = .;