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