]> asedeno.scripts.mit.edu Git - linux.git/blob - include/asm-generic/vmlinux.lds.h
Merge branch 'work.cramfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[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  * 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() STRUCT_ALIGN();                        \
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
256 #define READ_MOSTLY_DATA(align)                                         \
257         . = ALIGN(align);                                               \
258         *(.data..read_mostly)                                           \
259         . = ALIGN(align);
260
261 #define CACHELINE_ALIGNED_DATA(align)                                   \
262         . = ALIGN(align);                                               \
263         *(.data..cacheline_aligned)
264
265 #define INIT_TASK_DATA(align)                                           \
266         . = ALIGN(align);                                               \
267         VMLINUX_SYMBOL(__start_init_task) = .;                          \
268         *(.data..init_task)                                             \
269         VMLINUX_SYMBOL(__end_init_task) = .;
270
271 /*
272  * Allow architectures to handle ro_after_init data on their
273  * own by defining an empty RO_AFTER_INIT_DATA.
274  */
275 #ifndef RO_AFTER_INIT_DATA
276 #define RO_AFTER_INIT_DATA                                              \
277         VMLINUX_SYMBOL(__start_ro_after_init) = .;                      \
278         *(.data..ro_after_init)                                         \
279         VMLINUX_SYMBOL(__end_ro_after_init) = .;
280 #endif
281
282 /*
283  * Read only Data
284  */
285 #define RO_DATA_SECTION(align)                                          \
286         . = ALIGN((align));                                             \
287         .rodata           : AT(ADDR(.rodata) - LOAD_OFFSET) {           \
288                 VMLINUX_SYMBOL(__start_rodata) = .;                     \
289                 *(.rodata) *(.rodata.*)                                 \
290                 RO_AFTER_INIT_DATA      /* Read only after init */      \
291                 KEEP(*(__vermagic))     /* Kernel version magic */      \
292                 . = ALIGN(8);                                           \
293                 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .;         \
294                 KEEP(*(__tracepoints_ptrs)) /* Tracepoints: pointer array */ \
295                 VMLINUX_SYMBOL(__stop___tracepoints_ptrs) = .;          \
296                 *(__tracepoints_strings)/* Tracepoints: strings */      \
297         }                                                               \
298                                                                         \
299         .rodata1          : AT(ADDR(.rodata1) - LOAD_OFFSET) {          \
300                 *(.rodata1)                                             \
301         }                                                               \
302                                                                         \
303         /* PCI quirks */                                                \
304         .pci_fixup        : AT(ADDR(.pci_fixup) - LOAD_OFFSET) {        \
305                 VMLINUX_SYMBOL(__start_pci_fixups_early) = .;           \
306                 KEEP(*(.pci_fixup_early))                               \
307                 VMLINUX_SYMBOL(__end_pci_fixups_early) = .;             \
308                 VMLINUX_SYMBOL(__start_pci_fixups_header) = .;          \
309                 KEEP(*(.pci_fixup_header))                              \
310                 VMLINUX_SYMBOL(__end_pci_fixups_header) = .;            \
311                 VMLINUX_SYMBOL(__start_pci_fixups_final) = .;           \
312                 KEEP(*(.pci_fixup_final))                               \
313                 VMLINUX_SYMBOL(__end_pci_fixups_final) = .;             \
314                 VMLINUX_SYMBOL(__start_pci_fixups_enable) = .;          \
315                 KEEP(*(.pci_fixup_enable))                              \
316                 VMLINUX_SYMBOL(__end_pci_fixups_enable) = .;            \
317                 VMLINUX_SYMBOL(__start_pci_fixups_resume) = .;          \
318                 KEEP(*(.pci_fixup_resume))                              \
319                 VMLINUX_SYMBOL(__end_pci_fixups_resume) = .;            \
320                 VMLINUX_SYMBOL(__start_pci_fixups_resume_early) = .;    \
321                 KEEP(*(.pci_fixup_resume_early))                        \
322                 VMLINUX_SYMBOL(__end_pci_fixups_resume_early) = .;      \
323                 VMLINUX_SYMBOL(__start_pci_fixups_suspend) = .;         \
324                 KEEP(*(.pci_fixup_suspend))                             \
325                 VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .;           \
326                 VMLINUX_SYMBOL(__start_pci_fixups_suspend_late) = .;    \
327                 KEEP(*(.pci_fixup_suspend_late))                        \
328                 VMLINUX_SYMBOL(__end_pci_fixups_suspend_late) = .;      \
329         }                                                               \
330                                                                         \
331         /* Built-in firmware blobs */                                   \
332         .builtin_fw        : AT(ADDR(.builtin_fw) - LOAD_OFFSET) {      \
333                 VMLINUX_SYMBOL(__start_builtin_fw) = .;                 \
334                 KEEP(*(.builtin_fw))                                    \
335                 VMLINUX_SYMBOL(__end_builtin_fw) = .;                   \
336         }                                                               \
337                                                                         \
338         TRACEDATA                                                       \
339                                                                         \
340         /* Kernel symbol table: Normal symbols */                       \
341         __ksymtab         : AT(ADDR(__ksymtab) - LOAD_OFFSET) {         \
342                 VMLINUX_SYMBOL(__start___ksymtab) = .;                  \
343                 KEEP(*(SORT(___ksymtab+*)))                             \
344                 VMLINUX_SYMBOL(__stop___ksymtab) = .;                   \
345         }                                                               \
346                                                                         \
347         /* Kernel symbol table: GPL-only symbols */                     \
348         __ksymtab_gpl     : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) {     \
349                 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .;              \
350                 KEEP(*(SORT(___ksymtab_gpl+*)))                         \
351                 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .;               \
352         }                                                               \
353                                                                         \
354         /* Kernel symbol table: Normal unused symbols */                \
355         __ksymtab_unused  : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) {  \
356                 VMLINUX_SYMBOL(__start___ksymtab_unused) = .;           \
357                 KEEP(*(SORT(___ksymtab_unused+*)))                      \
358                 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .;            \
359         }                                                               \
360                                                                         \
361         /* Kernel symbol table: GPL-only unused symbols */              \
362         __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
363                 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .;       \
364                 KEEP(*(SORT(___ksymtab_unused_gpl+*)))                  \
365                 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .;        \
366         }                                                               \
367                                                                         \
368         /* Kernel symbol table: GPL-future-only symbols */              \
369         __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
370                 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .;       \
371                 KEEP(*(SORT(___ksymtab_gpl_future+*)))                  \
372                 VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .;        \
373         }                                                               \
374                                                                         \
375         /* Kernel symbol table: Normal symbols */                       \
376         __kcrctab         : AT(ADDR(__kcrctab) - LOAD_OFFSET) {         \
377                 VMLINUX_SYMBOL(__start___kcrctab) = .;                  \
378                 KEEP(*(SORT(___kcrctab+*)))                             \
379                 VMLINUX_SYMBOL(__stop___kcrctab) = .;                   \
380         }                                                               \
381                                                                         \
382         /* Kernel symbol table: GPL-only symbols */                     \
383         __kcrctab_gpl     : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) {     \
384                 VMLINUX_SYMBOL(__start___kcrctab_gpl) = .;              \
385                 KEEP(*(SORT(___kcrctab_gpl+*)))                         \
386                 VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .;               \
387         }                                                               \
388                                                                         \
389         /* Kernel symbol table: Normal unused symbols */                \
390         __kcrctab_unused  : AT(ADDR(__kcrctab_unused) - LOAD_OFFSET) {  \
391                 VMLINUX_SYMBOL(__start___kcrctab_unused) = .;           \
392                 KEEP(*(SORT(___kcrctab_unused+*)))                      \
393                 VMLINUX_SYMBOL(__stop___kcrctab_unused) = .;            \
394         }                                                               \
395                                                                         \
396         /* Kernel symbol table: GPL-only unused symbols */              \
397         __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
398                 VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .;       \
399                 KEEP(*(SORT(___kcrctab_unused_gpl+*)))                  \
400                 VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .;        \
401         }                                                               \
402                                                                         \
403         /* Kernel symbol table: GPL-future-only symbols */              \
404         __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
405                 VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .;       \
406                 KEEP(*(SORT(___kcrctab_gpl_future+*)))                  \
407                 VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .;        \
408         }                                                               \
409                                                                         \
410         /* Kernel symbol table: strings */                              \
411         __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
412                 *(__ksymtab_strings)                                    \
413         }                                                               \
414                                                                         \
415         /* __*init sections */                                          \
416         __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) {         \
417                 *(.ref.rodata)                                          \
418                 MEM_KEEP(init.rodata)                                   \
419                 MEM_KEEP(exit.rodata)                                   \
420         }                                                               \
421                                                                         \
422         /* Built-in module parameters. */                               \
423         __param : AT(ADDR(__param) - LOAD_OFFSET) {                     \
424                 VMLINUX_SYMBOL(__start___param) = .;                    \
425                 KEEP(*(__param))                                        \
426                 VMLINUX_SYMBOL(__stop___param) = .;                     \
427         }                                                               \
428                                                                         \
429         /* Built-in module versions. */                                 \
430         __modver : AT(ADDR(__modver) - LOAD_OFFSET) {                   \
431                 VMLINUX_SYMBOL(__start___modver) = .;                   \
432                 KEEP(*(__modver))                                       \
433                 VMLINUX_SYMBOL(__stop___modver) = .;                    \
434                 . = ALIGN((align));                                     \
435                 VMLINUX_SYMBOL(__end_rodata) = .;                       \
436         }                                                               \
437         . = ALIGN((align));
438
439 /* RODATA & RO_DATA provided for backward compatibility.
440  * All archs are supposed to use RO_DATA() */
441 #define RODATA          RO_DATA_SECTION(4096)
442 #define RO_DATA(align)  RO_DATA_SECTION(align)
443
444 #define SECURITY_INIT                                                   \
445         .security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \
446                 VMLINUX_SYMBOL(__security_initcall_start) = .;          \
447                 KEEP(*(.security_initcall.init))                        \
448                 VMLINUX_SYMBOL(__security_initcall_end) = .;            \
449         }
450
451 /*
452  * .text section. Map to function alignment to avoid address changes
453  * during second ld run in second ld pass when generating System.map
454  *
455  * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead
456  * code elimination is enabled, so these sections should be converted
457  * to use ".." first.
458  */
459 #define TEXT_TEXT                                                       \
460                 ALIGN_FUNCTION();                                       \
461                 *(.text.hot TEXT_MAIN .text.fixup .text.unlikely)       \
462                 *(.text..refcount)                                      \
463                 *(.ref.text)                                            \
464         MEM_KEEP(init.text)                                             \
465         MEM_KEEP(exit.text)                                             \
466
467
468 /* sched.text is aling to function alignment to secure we have same
469  * address even at second ld pass when generating System.map */
470 #define SCHED_TEXT                                                      \
471                 ALIGN_FUNCTION();                                       \
472                 VMLINUX_SYMBOL(__sched_text_start) = .;                 \
473                 *(.sched.text)                                          \
474                 VMLINUX_SYMBOL(__sched_text_end) = .;
475
476 /* spinlock.text is aling to function alignment to secure we have same
477  * address even at second ld pass when generating System.map */
478 #define LOCK_TEXT                                                       \
479                 ALIGN_FUNCTION();                                       \
480                 VMLINUX_SYMBOL(__lock_text_start) = .;                  \
481                 *(.spinlock.text)                                       \
482                 VMLINUX_SYMBOL(__lock_text_end) = .;
483
484 #define CPUIDLE_TEXT                                                    \
485                 ALIGN_FUNCTION();                                       \
486                 VMLINUX_SYMBOL(__cpuidle_text_start) = .;               \
487                 *(.cpuidle.text)                                        \
488                 VMLINUX_SYMBOL(__cpuidle_text_end) = .;
489
490 #define KPROBES_TEXT                                                    \
491                 ALIGN_FUNCTION();                                       \
492                 VMLINUX_SYMBOL(__kprobes_text_start) = .;               \
493                 *(.kprobes.text)                                        \
494                 VMLINUX_SYMBOL(__kprobes_text_end) = .;
495
496 #define ENTRY_TEXT                                                      \
497                 ALIGN_FUNCTION();                                       \
498                 VMLINUX_SYMBOL(__entry_text_start) = .;                 \
499                 *(.entry.text)                                          \
500                 VMLINUX_SYMBOL(__entry_text_end) = .;
501
502 #define IRQENTRY_TEXT                                                   \
503                 ALIGN_FUNCTION();                                       \
504                 VMLINUX_SYMBOL(__irqentry_text_start) = .;              \
505                 *(.irqentry.text)                                       \
506                 VMLINUX_SYMBOL(__irqentry_text_end) = .;
507
508 #define SOFTIRQENTRY_TEXT                                               \
509                 ALIGN_FUNCTION();                                       \
510                 VMLINUX_SYMBOL(__softirqentry_text_start) = .;          \
511                 *(.softirqentry.text)                                   \
512                 VMLINUX_SYMBOL(__softirqentry_text_end) = .;
513
514 /* Section used for early init (in .S files) */
515 #define HEAD_TEXT  *(.head.text)
516
517 #define HEAD_TEXT_SECTION                                                       \
518         .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) {               \
519                 HEAD_TEXT                                               \
520         }
521
522 /*
523  * Exception table
524  */
525 #define EXCEPTION_TABLE(align)                                          \
526         . = ALIGN(align);                                               \
527         __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {               \
528                 VMLINUX_SYMBOL(__start___ex_table) = .;                 \
529                 KEEP(*(__ex_table))                                     \
530                 VMLINUX_SYMBOL(__stop___ex_table) = .;                  \
531         }
532
533 /*
534  * Init task
535  */
536 #define INIT_TASK_DATA_SECTION(align)                                   \
537         . = ALIGN(align);                                               \
538         .data..init_task :  AT(ADDR(.data..init_task) - LOAD_OFFSET) {  \
539                 INIT_TASK_DATA(align)                                   \
540         }
541
542 #ifdef CONFIG_CONSTRUCTORS
543 #define KERNEL_CTORS()  . = ALIGN(8);                      \
544                         VMLINUX_SYMBOL(__ctors_start) = .; \
545                         KEEP(*(.ctors))                    \
546                         KEEP(*(SORT(.init_array.*)))       \
547                         KEEP(*(.init_array))               \
548                         VMLINUX_SYMBOL(__ctors_end) = .;
549 #else
550 #define KERNEL_CTORS()
551 #endif
552
553 /* init and exit section handling */
554 #define INIT_DATA                                                       \
555         KEEP(*(SORT(___kentry+*)))                                      \
556         *(.init.data)                                                   \
557         MEM_DISCARD(init.data)                                          \
558         KERNEL_CTORS()                                                  \
559         MCOUNT_REC()                                                    \
560         *(.init.rodata)                                                 \
561         FTRACE_EVENTS()                                                 \
562         TRACE_SYSCALLS()                                                \
563         KPROBE_BLACKLIST()                                              \
564         MEM_DISCARD(init.rodata)                                        \
565         CLK_OF_TABLES()                                                 \
566         RESERVEDMEM_OF_TABLES()                                         \
567         TIMER_OF_TABLES()                                               \
568         IOMMU_OF_TABLES()                                               \
569         CPU_METHOD_OF_TABLES()                                          \
570         CPUIDLE_METHOD_OF_TABLES()                                      \
571         KERNEL_DTB()                                                    \
572         IRQCHIP_OF_MATCH_TABLE()                                        \
573         ACPI_PROBE_TABLE(irqchip)                                       \
574         ACPI_PROBE_TABLE(timer)                                         \
575         ACPI_PROBE_TABLE(iort)                                          \
576         EARLYCON_TABLE()
577
578 #define INIT_TEXT                                                       \
579         *(.init.text)                                                   \
580         *(.text.startup)                                                \
581         MEM_DISCARD(init.text)
582
583 #define EXIT_DATA                                                       \
584         *(.exit.data)                                                   \
585         *(.fini_array)                                                  \
586         *(.dtors)                                                       \
587         MEM_DISCARD(exit.data)                                          \
588         MEM_DISCARD(exit.rodata)
589
590 #define EXIT_TEXT                                                       \
591         *(.exit.text)                                                   \
592         *(.text.exit)                                                   \
593         MEM_DISCARD(exit.text)
594
595 #define EXIT_CALL                                                       \
596         *(.exitcall.exit)
597
598 /*
599  * bss (Block Started by Symbol) - uninitialized data
600  * zeroed during startup
601  */
602 #define SBSS(sbss_align)                                                \
603         . = ALIGN(sbss_align);                                          \
604         .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) {                         \
605                 *(.dynsbss)                                             \
606                 *(.sbss)                                                \
607                 *(.scommon)                                             \
608         }
609
610 /*
611  * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
612  * sections to the front of bss.
613  */
614 #ifndef BSS_FIRST_SECTIONS
615 #define BSS_FIRST_SECTIONS
616 #endif
617
618 #define BSS(bss_align)                                                  \
619         . = ALIGN(bss_align);                                           \
620         .bss : AT(ADDR(.bss) - LOAD_OFFSET) {                           \
621                 BSS_FIRST_SECTIONS                                      \
622                 *(.bss..page_aligned)                                   \
623                 *(.dynbss)                                              \
624                 *(BSS_MAIN)                                             \
625                 *(COMMON)                                               \
626         }
627
628 /*
629  * DWARF debug sections.
630  * Symbols in the DWARF debugging sections are relative to
631  * the beginning of the section so we begin them at 0.
632  */
633 #define DWARF_DEBUG                                                     \
634                 /* DWARF 1 */                                           \
635                 .debug          0 : { *(.debug) }                       \
636                 .line           0 : { *(.line) }                        \
637                 /* GNU DWARF 1 extensions */                            \
638                 .debug_srcinfo  0 : { *(.debug_srcinfo) }               \
639                 .debug_sfnames  0 : { *(.debug_sfnames) }               \
640                 /* DWARF 1.1 and DWARF 2 */                             \
641                 .debug_aranges  0 : { *(.debug_aranges) }               \
642                 .debug_pubnames 0 : { *(.debug_pubnames) }              \
643                 /* DWARF 2 */                                           \
644                 .debug_info     0 : { *(.debug_info                     \
645                                 .gnu.linkonce.wi.*) }                   \
646                 .debug_abbrev   0 : { *(.debug_abbrev) }                \
647                 .debug_line     0 : { *(.debug_line) }                  \
648                 .debug_frame    0 : { *(.debug_frame) }                 \
649                 .debug_str      0 : { *(.debug_str) }                   \
650                 .debug_loc      0 : { *(.debug_loc) }                   \
651                 .debug_macinfo  0 : { *(.debug_macinfo) }               \
652                 .debug_pubtypes 0 : { *(.debug_pubtypes) }              \
653                 /* DWARF 3 */                                           \
654                 .debug_ranges   0 : { *(.debug_ranges) }                \
655                 /* SGI/MIPS DWARF 2 extensions */                       \
656                 .debug_weaknames 0 : { *(.debug_weaknames) }            \
657                 .debug_funcnames 0 : { *(.debug_funcnames) }            \
658                 .debug_typenames 0 : { *(.debug_typenames) }            \
659                 .debug_varnames  0 : { *(.debug_varnames) }             \
660                 /* GNU DWARF 2 extensions */                            \
661                 .debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) }      \
662                 .debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) }      \
663                 /* DWARF 4 */                                           \
664                 .debug_types    0 : { *(.debug_types) }                 \
665                 /* DWARF 5 */                                           \
666                 .debug_macro    0 : { *(.debug_macro) }                 \
667                 .debug_addr     0 : { *(.debug_addr) }
668
669                 /* Stabs debugging sections.  */
670 #define STABS_DEBUG                                                     \
671                 .stab 0 : { *(.stab) }                                  \
672                 .stabstr 0 : { *(.stabstr) }                            \
673                 .stab.excl 0 : { *(.stab.excl) }                        \
674                 .stab.exclstr 0 : { *(.stab.exclstr) }                  \
675                 .stab.index 0 : { *(.stab.index) }                      \
676                 .stab.indexstr 0 : { *(.stab.indexstr) }                \
677                 .comment 0 : { *(.comment) }
678
679 #ifdef CONFIG_GENERIC_BUG
680 #define BUG_TABLE                                                       \
681         . = ALIGN(8);                                                   \
682         __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) {             \
683                 VMLINUX_SYMBOL(__start___bug_table) = .;                \
684                 KEEP(*(__bug_table))                                    \
685                 VMLINUX_SYMBOL(__stop___bug_table) = .;                 \
686         }
687 #else
688 #define BUG_TABLE
689 #endif
690
691 #ifdef CONFIG_UNWINDER_ORC
692 #define ORC_UNWIND_TABLE                                                \
693         . = ALIGN(4);                                                   \
694         .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) {       \
695                 VMLINUX_SYMBOL(__start_orc_unwind_ip) = .;              \
696                 KEEP(*(.orc_unwind_ip))                                 \
697                 VMLINUX_SYMBOL(__stop_orc_unwind_ip) = .;               \
698         }                                                               \
699         . = ALIGN(6);                                                   \
700         .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) {             \
701                 VMLINUX_SYMBOL(__start_orc_unwind) = .;                 \
702                 KEEP(*(.orc_unwind))                                    \
703                 VMLINUX_SYMBOL(__stop_orc_unwind) = .;                  \
704         }                                                               \
705         . = ALIGN(4);                                                   \
706         .orc_lookup : AT(ADDR(.orc_lookup) - LOAD_OFFSET) {             \
707                 VMLINUX_SYMBOL(orc_lookup) = .;                         \
708                 . += (((SIZEOF(.text) + LOOKUP_BLOCK_SIZE - 1) /        \
709                         LOOKUP_BLOCK_SIZE) + 1) * 4;                    \
710                 VMLINUX_SYMBOL(orc_lookup_end) = .;                     \
711         }
712 #else
713 #define ORC_UNWIND_TABLE
714 #endif
715
716 #ifdef CONFIG_PM_TRACE
717 #define TRACEDATA                                                       \
718         . = ALIGN(4);                                                   \
719         .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {               \
720                 VMLINUX_SYMBOL(__tracedata_start) = .;                  \
721                 KEEP(*(.tracedata))                                     \
722                 VMLINUX_SYMBOL(__tracedata_end) = .;                    \
723         }
724 #else
725 #define TRACEDATA
726 #endif
727
728 #define NOTES                                                           \
729         .notes : AT(ADDR(.notes) - LOAD_OFFSET) {                       \
730                 VMLINUX_SYMBOL(__start_notes) = .;                      \
731                 *(.note.*)                                              \
732                 VMLINUX_SYMBOL(__stop_notes) = .;                       \
733         }
734
735 #define INIT_SETUP(initsetup_align)                                     \
736                 . = ALIGN(initsetup_align);                             \
737                 VMLINUX_SYMBOL(__setup_start) = .;                      \
738                 KEEP(*(.init.setup))                                    \
739                 VMLINUX_SYMBOL(__setup_end) = .;
740
741 #define INIT_CALLS_LEVEL(level)                                         \
742                 VMLINUX_SYMBOL(__initcall##level##_start) = .;          \
743                 KEEP(*(.initcall##level##.init))                        \
744                 KEEP(*(.initcall##level##s.init))                       \
745
746 #define INIT_CALLS                                                      \
747                 VMLINUX_SYMBOL(__initcall_start) = .;                   \
748                 KEEP(*(.initcallearly.init))                            \
749                 INIT_CALLS_LEVEL(0)                                     \
750                 INIT_CALLS_LEVEL(1)                                     \
751                 INIT_CALLS_LEVEL(2)                                     \
752                 INIT_CALLS_LEVEL(3)                                     \
753                 INIT_CALLS_LEVEL(4)                                     \
754                 INIT_CALLS_LEVEL(5)                                     \
755                 INIT_CALLS_LEVEL(rootfs)                                \
756                 INIT_CALLS_LEVEL(6)                                     \
757                 INIT_CALLS_LEVEL(7)                                     \
758                 VMLINUX_SYMBOL(__initcall_end) = .;
759
760 #define CON_INITCALL                                                    \
761                 VMLINUX_SYMBOL(__con_initcall_start) = .;               \
762                 KEEP(*(.con_initcall.init))                             \
763                 VMLINUX_SYMBOL(__con_initcall_end) = .;
764
765 #define SECURITY_INITCALL                                               \
766                 VMLINUX_SYMBOL(__security_initcall_start) = .;          \
767                 KEEP(*(.security_initcall.init))                        \
768                 VMLINUX_SYMBOL(__security_initcall_end) = .;
769
770 #ifdef CONFIG_BLK_DEV_INITRD
771 #define INIT_RAM_FS                                                     \
772         . = ALIGN(4);                                                   \
773         VMLINUX_SYMBOL(__initramfs_start) = .;                          \
774         KEEP(*(.init.ramfs))                                            \
775         . = ALIGN(8);                                                   \
776         KEEP(*(.init.ramfs.info))
777 #else
778 #define INIT_RAM_FS
779 #endif
780
781 /*
782  * Memory encryption operates on a page basis. Since we need to clear
783  * the memory encryption mask for this section, it needs to be aligned
784  * on a page boundary and be a page-size multiple in length.
785  *
786  * Note: We use a separate section so that only this section gets
787  * decrypted to avoid exposing more than we wish.
788  */
789 #ifdef CONFIG_AMD_MEM_ENCRYPT
790 #define PERCPU_DECRYPTED_SECTION                                        \
791         . = ALIGN(PAGE_SIZE);                                           \
792         *(.data..percpu..decrypted)                                     \
793         . = ALIGN(PAGE_SIZE);
794 #else
795 #define PERCPU_DECRYPTED_SECTION
796 #endif
797
798
799 /*
800  * Default discarded sections.
801  *
802  * Some archs want to discard exit text/data at runtime rather than
803  * link time due to cross-section references such as alt instructions,
804  * bug table, eh_frame, etc.  DISCARDS must be the last of output
805  * section definitions so that such archs put those in earlier section
806  * definitions.
807  */
808 #define DISCARDS                                                        \
809         /DISCARD/ : {                                                   \
810         EXIT_TEXT                                                       \
811         EXIT_DATA                                                       \
812         EXIT_CALL                                                       \
813         *(.discard)                                                     \
814         *(.discard.*)                                                   \
815         }
816
817 /**
818  * PERCPU_INPUT - the percpu input sections
819  * @cacheline: cacheline size
820  *
821  * The core percpu section names and core symbols which do not rely
822  * directly upon load addresses.
823  *
824  * @cacheline is used to align subsections to avoid false cacheline
825  * sharing between subsections for different purposes.
826  */
827 #define PERCPU_INPUT(cacheline)                                         \
828         VMLINUX_SYMBOL(__per_cpu_start) = .;                            \
829         *(.data..percpu..first)                                         \
830         . = ALIGN(PAGE_SIZE);                                           \
831         *(.data..percpu..page_aligned)                                  \
832         . = ALIGN(cacheline);                                           \
833         *(.data..percpu..read_mostly)                                   \
834         . = ALIGN(cacheline);                                           \
835         *(.data..percpu)                                                \
836         *(.data..percpu..shared_aligned)                                \
837         PERCPU_DECRYPTED_SECTION                                        \
838         VMLINUX_SYMBOL(__per_cpu_end) = .;
839
840 /**
841  * PERCPU_VADDR - define output section for percpu area
842  * @cacheline: cacheline size
843  * @vaddr: explicit base address (optional)
844  * @phdr: destination PHDR (optional)
845  *
846  * Macro which expands to output section for percpu area.
847  *
848  * @cacheline is used to align subsections to avoid false cacheline
849  * sharing between subsections for different purposes.
850  *
851  * If @vaddr is not blank, it specifies explicit base address and all
852  * percpu symbols will be offset from the given address.  If blank,
853  * @vaddr always equals @laddr + LOAD_OFFSET.
854  *
855  * @phdr defines the output PHDR to use if not blank.  Be warned that
856  * output PHDR is sticky.  If @phdr is specified, the next output
857  * section in the linker script will go there too.  @phdr should have
858  * a leading colon.
859  *
860  * Note that this macros defines __per_cpu_load as an absolute symbol.
861  * If there is no need to put the percpu section at a predetermined
862  * address, use PERCPU_SECTION.
863  */
864 #define PERCPU_VADDR(cacheline, vaddr, phdr)                            \
865         VMLINUX_SYMBOL(__per_cpu_load) = .;                             \
866         .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load)         \
867                                 - LOAD_OFFSET) {                        \
868                 PERCPU_INPUT(cacheline)                                 \
869         } phdr                                                          \
870         . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
871
872 /**
873  * PERCPU_SECTION - define output section for percpu area, simple version
874  * @cacheline: cacheline size
875  *
876  * Align to PAGE_SIZE and outputs output section for percpu area.  This
877  * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and
878  * __per_cpu_start will be identical.
879  *
880  * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,)
881  * except that __per_cpu_load is defined as a relative symbol against
882  * .data..percpu which is required for relocatable x86_32 configuration.
883  */
884 #define PERCPU_SECTION(cacheline)                                       \
885         . = ALIGN(PAGE_SIZE);                                           \
886         .data..percpu   : AT(ADDR(.data..percpu) - LOAD_OFFSET) {       \
887                 VMLINUX_SYMBOL(__per_cpu_load) = .;                     \
888                 PERCPU_INPUT(cacheline)                                 \
889         }
890
891
892 /*
893  * Definition of the high level *_SECTION macros
894  * They will fit only a subset of the architectures
895  */
896
897
898 /*
899  * Writeable data.
900  * All sections are combined in a single .data section.
901  * The sections following CONSTRUCTORS are arranged so their
902  * typical alignment matches.
903  * A cacheline is typical/always less than a PAGE_SIZE so
904  * the sections that has this restriction (or similar)
905  * is located before the ones requiring PAGE_SIZE alignment.
906  * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
907  * matches the requirement of PAGE_ALIGNED_DATA.
908  *
909  * use 0 as page_align if page_aligned data is not used */
910 #define RW_DATA_SECTION(cacheline, pagealigned, inittask)               \
911         . = ALIGN(PAGE_SIZE);                                           \
912         .data : AT(ADDR(.data) - LOAD_OFFSET) {                         \
913                 INIT_TASK_DATA(inittask)                                \
914                 NOSAVE_DATA                                             \
915                 PAGE_ALIGNED_DATA(pagealigned)                          \
916                 CACHELINE_ALIGNED_DATA(cacheline)                       \
917                 READ_MOSTLY_DATA(cacheline)                             \
918                 DATA_DATA                                               \
919                 CONSTRUCTORS                                            \
920         }                                                               \
921         BUG_TABLE                                                       \
922
923 #define INIT_TEXT_SECTION(inittext_align)                               \
924         . = ALIGN(inittext_align);                                      \
925         .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {               \
926                 VMLINUX_SYMBOL(_sinittext) = .;                         \
927                 INIT_TEXT                                               \
928                 VMLINUX_SYMBOL(_einittext) = .;                         \
929         }
930
931 #define INIT_DATA_SECTION(initsetup_align)                              \
932         .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {               \
933                 INIT_DATA                                               \
934                 INIT_SETUP(initsetup_align)                             \
935                 INIT_CALLS                                              \
936                 CON_INITCALL                                            \
937                 SECURITY_INITCALL                                       \
938                 INIT_RAM_FS                                             \
939         }
940
941 #define BSS_SECTION(sbss_align, bss_align, stop_align)                  \
942         . = ALIGN(sbss_align);                                          \
943         VMLINUX_SYMBOL(__bss_start) = .;                                \
944         SBSS(sbss_align)                                                \
945         BSS(bss_align)                                                  \
946         . = ALIGN(stop_align);                                          \
947         VMLINUX_SYMBOL(__bss_stop) = .;