PCI: Fix pci_slot_release() NULL pointer dereference
[linux/fpc-iii.git] / include / asm-generic / vmlinux.lds.h
blob4fdb1d98484443db8894da6bb0dde23ef13f9a7b
1 /*
2 * Helper macros to support writing architecture specific
3 * linker scripts.
5 * A minimal linker scripts has following content:
6 * [This is a sample, architectures may have special requiriements]
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 = .;
21 * _stext = .;
22 * TEXT_SECTION = 0
23 * _etext = .;
25 * _sdata = .;
26 * RO_DATA_SECTION(PAGE_SIZE)
27 * RW_DATA_SECTION(...)
28 * _edata = .;
30 * EXCEPTION_TABLE(...)
31 * NOTES
33 * BSS_SECTION(0, 0, 0)
34 * _end = .;
36 * STABS_DEBUG
37 * DWARF_DEBUG
39 * DISCARDS // must be the last
40 * }
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
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
53 #ifndef LOAD_OFFSET
54 #define LOAD_OFFSET 0
55 #endif
57 #include <linux/export.h>
59 /* Align . to a 8 byte boundary equals to maximum function alignment. */
60 #define ALIGN_FUNCTION() . = ALIGN(8)
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.
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
79 * Align to a 32 byte boundary equal to the
80 * alignment gcc 4.5 uses for a struct
82 #define STRUCT_ALIGNMENT 32
83 #define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)
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)
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
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
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
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
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
130 #ifdef CONFIG_KPROBES
131 #define KPROBE_BLACKLIST() . = ALIGN(8); \
132 VMLINUX_SYMBOL(__start_kprobe_blacklist) = .; \
133 *(_kprobe_blacklist) \
134 VMLINUX_SYMBOL(__stop_kprobe_blacklist) = .;
135 #else
136 #define KPROBE_BLACKLIST()
137 #endif
139 #ifdef CONFIG_EVENT_TRACING
140 #define FTRACE_EVENTS() . = ALIGN(8); \
141 VMLINUX_SYMBOL(__start_ftrace_events) = .; \
142 *(_ftrace_events) \
143 VMLINUX_SYMBOL(__stop_ftrace_events) = .; \
144 VMLINUX_SYMBOL(__start_ftrace_enum_maps) = .; \
145 *(_ftrace_enum_map) \
146 VMLINUX_SYMBOL(__stop_ftrace_enum_maps) = .;
147 #else
148 #define FTRACE_EVENTS()
149 #endif
151 #ifdef CONFIG_TRACING
152 #define TRACE_PRINTKS() VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .; \
153 *(__trace_printk_fmt) /* Trace_printk fmt' pointer */ \
154 VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .;
155 #define TRACEPOINT_STR() VMLINUX_SYMBOL(__start___tracepoint_str) = .; \
156 *(__tracepoint_str) /* Trace_printk fmt' pointer */ \
157 VMLINUX_SYMBOL(__stop___tracepoint_str) = .;
158 #else
159 #define TRACE_PRINTKS()
160 #define TRACEPOINT_STR()
161 #endif
163 #ifdef CONFIG_FTRACE_SYSCALLS
164 #define TRACE_SYSCALLS() . = ALIGN(8); \
165 VMLINUX_SYMBOL(__start_syscalls_metadata) = .; \
166 *(__syscalls_metadata) \
167 VMLINUX_SYMBOL(__stop_syscalls_metadata) = .;
168 #else
169 #define TRACE_SYSCALLS()
170 #endif
172 #ifdef CONFIG_SERIAL_EARLYCON
173 #define EARLYCON_TABLE() . = ALIGN(8); \
174 VMLINUX_SYMBOL(__earlycon_table) = .; \
175 *(__earlycon_table) \
176 VMLINUX_SYMBOL(__earlycon_table_end) = .;
177 #else
178 #define EARLYCON_TABLE()
179 #endif
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 *(__##name##_of_table) \
189 *(__##name##_of_table_end)
191 #define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc)
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)
199 #ifdef CONFIG_ACPI
200 #define ACPI_PROBE_TABLE(name) \
201 . = ALIGN(8); \
202 VMLINUX_SYMBOL(__##name##_acpi_probe_table) = .; \
203 *(__##name##_acpi_probe_table) \
204 VMLINUX_SYMBOL(__##name##_acpi_probe_table_end) = .;
205 #else
206 #define ACPI_PROBE_TABLE(name)
207 #endif
209 #define KERNEL_DTB() \
210 STRUCT_ALIGN(); \
211 VMLINUX_SYMBOL(__dtb_start) = .; \
212 *(.dtb.init.rodata) \
213 VMLINUX_SYMBOL(__dtb_end) = .;
216 * .data section
218 #define DATA_DATA \
219 *(DATA_MAIN) \
220 *(.ref.data) \
221 *(.data..shared_aligned) /* percpu related */ \
222 MEM_KEEP(init.data) \
223 MEM_KEEP(exit.data) \
224 *(.data.unlikely) \
225 STRUCT_ALIGN(); \
226 *(__tracepoints) \
227 /* implement dynamic printk debug */ \
228 . = ALIGN(8); \
229 VMLINUX_SYMBOL(__start___jump_table) = .; \
230 *(__jump_table) \
231 VMLINUX_SYMBOL(__stop___jump_table) = .; \
232 . = ALIGN(8); \
233 VMLINUX_SYMBOL(__start___verbose) = .; \
234 *(__verbose) \
235 VMLINUX_SYMBOL(__stop___verbose) = .; \
236 LIKELY_PROFILE() \
237 BRANCH_PROFILE() \
238 TRACE_PRINTKS() \
239 TRACEPOINT_STR()
242 * Data section helpers
244 #define NOSAVE_DATA \
245 . = ALIGN(PAGE_SIZE); \
246 VMLINUX_SYMBOL(__nosave_begin) = .; \
247 *(.data..nosave) \
248 . = ALIGN(PAGE_SIZE); \
249 VMLINUX_SYMBOL(__nosave_end) = .;
251 #define PAGE_ALIGNED_DATA(page_align) \
252 . = ALIGN(page_align); \
253 *(.data..page_aligned) \
254 . = ALIGN(page_align);
256 #define READ_MOSTLY_DATA(align) \
257 . = ALIGN(align); \
258 *(.data..read_mostly) \
259 . = ALIGN(align);
261 #define CACHELINE_ALIGNED_DATA(align) \
262 . = ALIGN(align); \
263 *(.data..cacheline_aligned)
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) = .;
272 * Allow architectures to handle ro_after_init data on their
273 * own by defining an empty RO_AFTER_INIT_DATA.
275 #ifndef RO_AFTER_INIT_DATA
276 #define RO_AFTER_INIT_DATA \
277 __start_data_ro_after_init = .; \
278 *(.data..ro_after_init) \
279 __end_data_ro_after_init = .;
280 #endif
283 * Read only Data
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 *(__vermagic) /* Kernel version magic */ \
292 . = ALIGN(8); \
293 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
294 *(__tracepoints_ptrs) /* Tracepoints: pointer array */\
295 VMLINUX_SYMBOL(__stop___tracepoints_ptrs) = .; \
296 *(__tracepoints_strings)/* Tracepoints: strings */ \
299 .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
300 *(.rodata1) \
303 BUG_TABLE \
305 /* PCI quirks */ \
306 .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
307 VMLINUX_SYMBOL(__start_pci_fixups_early) = .; \
308 *(.pci_fixup_early) \
309 VMLINUX_SYMBOL(__end_pci_fixups_early) = .; \
310 VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
311 *(.pci_fixup_header) \
312 VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
313 VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \
314 *(.pci_fixup_final) \
315 VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \
316 VMLINUX_SYMBOL(__start_pci_fixups_enable) = .; \
317 *(.pci_fixup_enable) \
318 VMLINUX_SYMBOL(__end_pci_fixups_enable) = .; \
319 VMLINUX_SYMBOL(__start_pci_fixups_resume) = .; \
320 *(.pci_fixup_resume) \
321 VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \
322 VMLINUX_SYMBOL(__start_pci_fixups_resume_early) = .; \
323 *(.pci_fixup_resume_early) \
324 VMLINUX_SYMBOL(__end_pci_fixups_resume_early) = .; \
325 VMLINUX_SYMBOL(__start_pci_fixups_suspend) = .; \
326 *(.pci_fixup_suspend) \
327 VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .; \
328 VMLINUX_SYMBOL(__start_pci_fixups_suspend_late) = .; \
329 *(.pci_fixup_suspend_late) \
330 VMLINUX_SYMBOL(__end_pci_fixups_suspend_late) = .; \
333 /* Built-in firmware blobs */ \
334 .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \
335 VMLINUX_SYMBOL(__start_builtin_fw) = .; \
336 *(.builtin_fw) \
337 VMLINUX_SYMBOL(__end_builtin_fw) = .; \
340 TRACEDATA \
342 /* Kernel symbol table: Normal symbols */ \
343 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
344 VMLINUX_SYMBOL(__start___ksymtab) = .; \
345 KEEP(*(SORT(___ksymtab+*))) \
346 VMLINUX_SYMBOL(__stop___ksymtab) = .; \
349 /* Kernel symbol table: GPL-only symbols */ \
350 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
351 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
352 KEEP(*(SORT(___ksymtab_gpl+*))) \
353 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
356 /* Kernel symbol table: Normal unused symbols */ \
357 __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \
358 VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \
359 KEEP(*(SORT(___ksymtab_unused+*))) \
360 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \
363 /* Kernel symbol table: GPL-only unused symbols */ \
364 __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
365 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \
366 KEEP(*(SORT(___ksymtab_unused_gpl+*))) \
367 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \
370 /* Kernel symbol table: GPL-future-only symbols */ \
371 __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
372 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \
373 KEEP(*(SORT(___ksymtab_gpl_future+*))) \
374 VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \
377 /* Kernel symbol table: Normal symbols */ \
378 __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
379 VMLINUX_SYMBOL(__start___kcrctab) = .; \
380 KEEP(*(SORT(___kcrctab+*))) \
381 VMLINUX_SYMBOL(__stop___kcrctab) = .; \
384 /* Kernel symbol table: GPL-only symbols */ \
385 __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
386 VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \
387 KEEP(*(SORT(___kcrctab_gpl+*))) \
388 VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
391 /* Kernel symbol table: Normal unused symbols */ \
392 __kcrctab_unused : AT(ADDR(__kcrctab_unused) - LOAD_OFFSET) { \
393 VMLINUX_SYMBOL(__start___kcrctab_unused) = .; \
394 KEEP(*(SORT(___kcrctab_unused+*))) \
395 VMLINUX_SYMBOL(__stop___kcrctab_unused) = .; \
398 /* Kernel symbol table: GPL-only unused symbols */ \
399 __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
400 VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .; \
401 KEEP(*(SORT(___kcrctab_unused_gpl+*))) \
402 VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .; \
405 /* Kernel symbol table: GPL-future-only symbols */ \
406 __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
407 VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \
408 KEEP(*(SORT(___kcrctab_gpl_future+*))) \
409 VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .; \
412 /* Kernel symbol table: strings */ \
413 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
414 KEEP(*(__ksymtab_strings)) \
417 /* __*init sections */ \
418 __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
419 *(.ref.rodata) \
420 MEM_KEEP(init.rodata) \
421 MEM_KEEP(exit.rodata) \
424 /* Built-in module parameters. */ \
425 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
426 VMLINUX_SYMBOL(__start___param) = .; \
427 *(__param) \
428 VMLINUX_SYMBOL(__stop___param) = .; \
431 /* Built-in module versions. */ \
432 __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
433 VMLINUX_SYMBOL(__start___modver) = .; \
434 *(__modver) \
435 VMLINUX_SYMBOL(__stop___modver) = .; \
436 . = ALIGN((align)); \
437 VMLINUX_SYMBOL(__end_rodata) = .; \
439 . = ALIGN((align));
441 /* RODATA & RO_DATA provided for backward compatibility.
442 * All archs are supposed to use RO_DATA() */
443 #define RODATA RO_DATA_SECTION(4096)
444 #define RO_DATA(align) RO_DATA_SECTION(align)
446 #define SECURITY_INIT \
447 .security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \
448 VMLINUX_SYMBOL(__security_initcall_start) = .; \
449 KEEP(*(.security_initcall.init)) \
450 VMLINUX_SYMBOL(__security_initcall_end) = .; \
454 * .text section. Map to function alignment to avoid address changes
455 * during second ld run in second ld pass when generating System.map
457 * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead
458 * code elimination is enabled, so these sections should be converted
459 * to use ".." first.
461 #define TEXT_TEXT \
462 ALIGN_FUNCTION(); \
463 *(.text.hot TEXT_MAIN .text.fixup .text.unlikely) \
464 *(.ref.text) \
465 MEM_KEEP(init.text) \
466 MEM_KEEP(exit.text) \
469 /* sched.text is aling to function alignment to secure we have same
470 * address even at second ld pass when generating System.map */
471 #define SCHED_TEXT \
472 ALIGN_FUNCTION(); \
473 VMLINUX_SYMBOL(__sched_text_start) = .; \
474 *(.sched.text) \
475 VMLINUX_SYMBOL(__sched_text_end) = .;
477 /* spinlock.text is aling to function alignment to secure we have same
478 * address even at second ld pass when generating System.map */
479 #define LOCK_TEXT \
480 ALIGN_FUNCTION(); \
481 VMLINUX_SYMBOL(__lock_text_start) = .; \
482 *(.spinlock.text) \
483 VMLINUX_SYMBOL(__lock_text_end) = .;
485 #define CPUIDLE_TEXT \
486 ALIGN_FUNCTION(); \
487 VMLINUX_SYMBOL(__cpuidle_text_start) = .; \
488 *(.cpuidle.text) \
489 VMLINUX_SYMBOL(__cpuidle_text_end) = .;
491 #define KPROBES_TEXT \
492 ALIGN_FUNCTION(); \
493 VMLINUX_SYMBOL(__kprobes_text_start) = .; \
494 *(.kprobes.text) \
495 VMLINUX_SYMBOL(__kprobes_text_end) = .;
497 #define ENTRY_TEXT \
498 ALIGN_FUNCTION(); \
499 VMLINUX_SYMBOL(__entry_text_start) = .; \
500 *(.entry.text) \
501 VMLINUX_SYMBOL(__entry_text_end) = .;
503 #if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN)
504 #define IRQENTRY_TEXT \
505 ALIGN_FUNCTION(); \
506 VMLINUX_SYMBOL(__irqentry_text_start) = .; \
507 *(.irqentry.text) \
508 VMLINUX_SYMBOL(__irqentry_text_end) = .;
509 #else
510 #define IRQENTRY_TEXT
511 #endif
513 #if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN)
514 #define SOFTIRQENTRY_TEXT \
515 ALIGN_FUNCTION(); \
516 VMLINUX_SYMBOL(__softirqentry_text_start) = .; \
517 *(.softirqentry.text) \
518 VMLINUX_SYMBOL(__softirqentry_text_end) = .;
519 #else
520 #define SOFTIRQENTRY_TEXT
521 #endif
523 /* Section used for early init (in .S files) */
524 #define HEAD_TEXT *(.head.text)
526 #define HEAD_TEXT_SECTION \
527 .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { \
528 HEAD_TEXT \
532 * Exception table
534 #define EXCEPTION_TABLE(align) \
535 . = ALIGN(align); \
536 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \
537 VMLINUX_SYMBOL(__start___ex_table) = .; \
538 *(__ex_table) \
539 VMLINUX_SYMBOL(__stop___ex_table) = .; \
543 * Init task
545 #define INIT_TASK_DATA_SECTION(align) \
546 . = ALIGN(align); \
547 .data..init_task : AT(ADDR(.data..init_task) - LOAD_OFFSET) { \
548 INIT_TASK_DATA(align) \
551 #ifdef CONFIG_CONSTRUCTORS
552 #define KERNEL_CTORS() . = ALIGN(8); \
553 VMLINUX_SYMBOL(__ctors_start) = .; \
554 *(.ctors) \
555 *(SORT(.init_array.*)) \
556 *(.init_array) \
557 VMLINUX_SYMBOL(__ctors_end) = .;
558 #else
559 #define KERNEL_CTORS()
560 #endif
562 /* init and exit section handling */
563 #define INIT_DATA \
564 KEEP(*(SORT(___kentry+*))) \
565 *(.init.data) \
566 MEM_DISCARD(init.data) \
567 KERNEL_CTORS() \
568 MCOUNT_REC() \
569 *(.init.rodata) \
570 FTRACE_EVENTS() \
571 TRACE_SYSCALLS() \
572 KPROBE_BLACKLIST() \
573 MEM_DISCARD(init.rodata) \
574 CLK_OF_TABLES() \
575 RESERVEDMEM_OF_TABLES() \
576 CLKSRC_OF_TABLES() \
577 IOMMU_OF_TABLES() \
578 CPU_METHOD_OF_TABLES() \
579 CPUIDLE_METHOD_OF_TABLES() \
580 KERNEL_DTB() \
581 IRQCHIP_OF_MATCH_TABLE() \
582 ACPI_PROBE_TABLE(irqchip) \
583 ACPI_PROBE_TABLE(clksrc) \
584 EARLYCON_TABLE()
586 #define INIT_TEXT \
587 *(.init.text) \
588 *(.text.startup) \
589 MEM_DISCARD(init.text)
591 #define EXIT_DATA \
592 *(.exit.data) \
593 *(.fini_array) \
594 *(.dtors) \
595 MEM_DISCARD(exit.data) \
596 MEM_DISCARD(exit.rodata)
598 #define EXIT_TEXT \
599 *(.exit.text) \
600 *(.text.exit) \
601 MEM_DISCARD(exit.text)
603 #define EXIT_CALL \
604 *(.exitcall.exit)
607 * bss (Block Started by Symbol) - uninitialized data
608 * zeroed during startup
610 #define SBSS(sbss_align) \
611 . = ALIGN(sbss_align); \
612 .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
613 *(.sbss) \
614 *(.scommon) \
618 * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
619 * sections to the front of bss.
621 #ifndef BSS_FIRST_SECTIONS
622 #define BSS_FIRST_SECTIONS
623 #endif
625 #define BSS(bss_align) \
626 . = ALIGN(bss_align); \
627 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \
628 BSS_FIRST_SECTIONS \
629 . = ALIGN(PAGE_SIZE); \
630 *(.bss..page_aligned) \
631 . = ALIGN(PAGE_SIZE); \
632 *(.dynbss) \
633 *(BSS_MAIN) \
634 *(COMMON) \
638 * DWARF debug sections.
639 * Symbols in the DWARF debugging sections are relative to
640 * the beginning of the section so we begin them at 0.
642 #define DWARF_DEBUG \
643 /* DWARF 1 */ \
644 .debug 0 : { *(.debug) } \
645 .line 0 : { *(.line) } \
646 /* GNU DWARF 1 extensions */ \
647 .debug_srcinfo 0 : { *(.debug_srcinfo) } \
648 .debug_sfnames 0 : { *(.debug_sfnames) } \
649 /* DWARF 1.1 and DWARF 2 */ \
650 .debug_aranges 0 : { *(.debug_aranges) } \
651 .debug_pubnames 0 : { *(.debug_pubnames) } \
652 /* DWARF 2 */ \
653 .debug_info 0 : { *(.debug_info \
654 .gnu.linkonce.wi.*) } \
655 .debug_abbrev 0 : { *(.debug_abbrev) } \
656 .debug_line 0 : { *(.debug_line) } \
657 .debug_frame 0 : { *(.debug_frame) } \
658 .debug_str 0 : { *(.debug_str) } \
659 .debug_loc 0 : { *(.debug_loc) } \
660 .debug_macinfo 0 : { *(.debug_macinfo) } \
661 /* SGI/MIPS DWARF 2 extensions */ \
662 .debug_weaknames 0 : { *(.debug_weaknames) } \
663 .debug_funcnames 0 : { *(.debug_funcnames) } \
664 .debug_typenames 0 : { *(.debug_typenames) } \
665 .debug_varnames 0 : { *(.debug_varnames) } \
667 /* Stabs debugging sections. */
668 #define STABS_DEBUG \
669 .stab 0 : { *(.stab) } \
670 .stabstr 0 : { *(.stabstr) } \
671 .stab.excl 0 : { *(.stab.excl) } \
672 .stab.exclstr 0 : { *(.stab.exclstr) } \
673 .stab.index 0 : { *(.stab.index) } \
674 .stab.indexstr 0 : { *(.stab.indexstr) } \
675 .comment 0 : { *(.comment) }
677 #ifdef CONFIG_GENERIC_BUG
678 #define BUG_TABLE \
679 . = ALIGN(8); \
680 __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \
681 VMLINUX_SYMBOL(__start___bug_table) = .; \
682 *(__bug_table) \
683 VMLINUX_SYMBOL(__stop___bug_table) = .; \
685 #else
686 #define BUG_TABLE
687 #endif
689 #ifdef CONFIG_PM_TRACE
690 #define TRACEDATA \
691 . = ALIGN(4); \
692 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \
693 VMLINUX_SYMBOL(__tracedata_start) = .; \
694 *(.tracedata) \
695 VMLINUX_SYMBOL(__tracedata_end) = .; \
697 #else
698 #define TRACEDATA
699 #endif
701 #define NOTES \
702 .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
703 VMLINUX_SYMBOL(__start_notes) = .; \
704 *(.note.*) \
705 VMLINUX_SYMBOL(__stop_notes) = .; \
708 #define INIT_SETUP(initsetup_align) \
709 . = ALIGN(initsetup_align); \
710 VMLINUX_SYMBOL(__setup_start) = .; \
711 *(.init.setup) \
712 VMLINUX_SYMBOL(__setup_end) = .;
714 #define INIT_CALLS_LEVEL(level) \
715 VMLINUX_SYMBOL(__initcall##level##_start) = .; \
716 KEEP(*(.initcall##level##.init)) \
717 KEEP(*(.initcall##level##s.init)) \
719 #define INIT_CALLS \
720 VMLINUX_SYMBOL(__initcall_start) = .; \
721 KEEP(*(.initcallearly.init)) \
722 INIT_CALLS_LEVEL(0) \
723 INIT_CALLS_LEVEL(1) \
724 INIT_CALLS_LEVEL(2) \
725 INIT_CALLS_LEVEL(3) \
726 INIT_CALLS_LEVEL(4) \
727 INIT_CALLS_LEVEL(5) \
728 INIT_CALLS_LEVEL(rootfs) \
729 INIT_CALLS_LEVEL(6) \
730 INIT_CALLS_LEVEL(7) \
731 VMLINUX_SYMBOL(__initcall_end) = .;
733 #define CON_INITCALL \
734 VMLINUX_SYMBOL(__con_initcall_start) = .; \
735 KEEP(*(.con_initcall.init)) \
736 VMLINUX_SYMBOL(__con_initcall_end) = .;
738 #define SECURITY_INITCALL \
739 VMLINUX_SYMBOL(__security_initcall_start) = .; \
740 KEEP(*(.security_initcall.init)) \
741 VMLINUX_SYMBOL(__security_initcall_end) = .;
743 #ifdef CONFIG_BLK_DEV_INITRD
744 #define INIT_RAM_FS \
745 . = ALIGN(4); \
746 VMLINUX_SYMBOL(__initramfs_start) = .; \
747 KEEP(*(.init.ramfs)) \
748 . = ALIGN(8); \
749 KEEP(*(.init.ramfs.info))
750 #else
751 #define INIT_RAM_FS
752 #endif
755 * Default discarded sections.
757 * Some archs want to discard exit text/data at runtime rather than
758 * link time due to cross-section references such as alt instructions,
759 * bug table, eh_frame, etc. DISCARDS must be the last of output
760 * section definitions so that such archs put those in earlier section
761 * definitions.
763 #define DISCARDS \
764 /DISCARD/ : { \
765 EXIT_TEXT \
766 EXIT_DATA \
767 EXIT_CALL \
768 *(.discard) \
769 *(.discard.*) \
773 * PERCPU_INPUT - the percpu input sections
774 * @cacheline: cacheline size
776 * The core percpu section names and core symbols which do not rely
777 * directly upon load addresses.
779 * @cacheline is used to align subsections to avoid false cacheline
780 * sharing between subsections for different purposes.
782 #define PERCPU_INPUT(cacheline) \
783 VMLINUX_SYMBOL(__per_cpu_start) = .; \
784 VMLINUX_SYMBOL(__per_cpu_user_mapped_start) = .; \
785 *(.data..percpu..first) \
786 . = ALIGN(cacheline); \
787 *(.data..percpu..user_mapped) \
788 *(.data..percpu..user_mapped..shared_aligned) \
789 . = ALIGN(PAGE_SIZE); \
790 *(.data..percpu..user_mapped..page_aligned) \
791 VMLINUX_SYMBOL(__per_cpu_user_mapped_end) = .; \
792 . = ALIGN(PAGE_SIZE); \
793 *(.data..percpu..page_aligned) \
794 . = ALIGN(cacheline); \
795 *(.data..percpu..read_mostly) \
796 . = ALIGN(cacheline); \
797 *(.data..percpu) \
798 *(.data..percpu..shared_aligned) \
799 VMLINUX_SYMBOL(__per_cpu_end) = .;
802 * PERCPU_VADDR - define output section for percpu area
803 * @cacheline: cacheline size
804 * @vaddr: explicit base address (optional)
805 * @phdr: destination PHDR (optional)
807 * Macro which expands to output section for percpu area.
809 * @cacheline is used to align subsections to avoid false cacheline
810 * sharing between subsections for different purposes.
812 * If @vaddr is not blank, it specifies explicit base address and all
813 * percpu symbols will be offset from the given address. If blank,
814 * @vaddr always equals @laddr + LOAD_OFFSET.
816 * @phdr defines the output PHDR to use if not blank. Be warned that
817 * output PHDR is sticky. If @phdr is specified, the next output
818 * section in the linker script will go there too. @phdr should have
819 * a leading colon.
821 * Note that this macros defines __per_cpu_load as an absolute symbol.
822 * If there is no need to put the percpu section at a predetermined
823 * address, use PERCPU_SECTION.
825 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
826 VMLINUX_SYMBOL(__per_cpu_load) = .; \
827 .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
828 - LOAD_OFFSET) { \
829 PERCPU_INPUT(cacheline) \
830 } phdr \
831 . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
834 * PERCPU_SECTION - define output section for percpu area, simple version
835 * @cacheline: cacheline size
837 * Align to PAGE_SIZE and outputs output section for percpu area. This
838 * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and
839 * __per_cpu_start will be identical.
841 * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,)
842 * except that __per_cpu_load is defined as a relative symbol against
843 * .data..percpu which is required for relocatable x86_32 configuration.
845 #define PERCPU_SECTION(cacheline) \
846 . = ALIGN(PAGE_SIZE); \
847 .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \
848 VMLINUX_SYMBOL(__per_cpu_load) = .; \
849 PERCPU_INPUT(cacheline) \
854 * Definition of the high level *_SECTION macros
855 * They will fit only a subset of the architectures
860 * Writeable data.
861 * All sections are combined in a single .data section.
862 * The sections following CONSTRUCTORS are arranged so their
863 * typical alignment matches.
864 * A cacheline is typical/always less than a PAGE_SIZE so
865 * the sections that has this restriction (or similar)
866 * is located before the ones requiring PAGE_SIZE alignment.
867 * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
868 * matches the requirement of PAGE_ALIGNED_DATA.
870 * use 0 as page_align if page_aligned data is not used */
871 #define RW_DATA_SECTION(cacheline, pagealigned, inittask) \
872 . = ALIGN(PAGE_SIZE); \
873 .data : AT(ADDR(.data) - LOAD_OFFSET) { \
874 INIT_TASK_DATA(inittask) \
875 NOSAVE_DATA \
876 PAGE_ALIGNED_DATA(pagealigned) \
877 CACHELINE_ALIGNED_DATA(cacheline) \
878 READ_MOSTLY_DATA(cacheline) \
879 DATA_DATA \
880 CONSTRUCTORS \
883 #define INIT_TEXT_SECTION(inittext_align) \
884 . = ALIGN(inittext_align); \
885 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { \
886 VMLINUX_SYMBOL(_sinittext) = .; \
887 INIT_TEXT \
888 VMLINUX_SYMBOL(_einittext) = .; \
891 #define INIT_DATA_SECTION(initsetup_align) \
892 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \
893 INIT_DATA \
894 INIT_SETUP(initsetup_align) \
895 INIT_CALLS \
896 CON_INITCALL \
897 SECURITY_INITCALL \
898 INIT_RAM_FS \
901 #define BSS_SECTION(sbss_align, bss_align, stop_align) \
902 . = ALIGN(sbss_align); \
903 VMLINUX_SYMBOL(__bss_start) = .; \
904 SBSS(sbss_align) \
905 BSS(bss_align) \
906 . = ALIGN(stop_align); \
907 VMLINUX_SYMBOL(__bss_stop) = .;