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