.. | .. |
---|
23 | 23 | * _etext = .; |
---|
24 | 24 | * |
---|
25 | 25 | * _sdata = .; |
---|
26 | | - * RO_DATA_SECTION(PAGE_SIZE) |
---|
27 | | - * RW_DATA_SECTION(...) |
---|
| 26 | + * RO_DATA(PAGE_SIZE) |
---|
| 27 | + * RW_DATA(...) |
---|
28 | 28 | * _edata = .; |
---|
29 | 29 | * |
---|
30 | 30 | * EXCEPTION_TABLE(...) |
---|
31 | | - * NOTES |
---|
32 | 31 | * |
---|
33 | 32 | * BSS_SECTION(0, 0, 0) |
---|
34 | 33 | * _end = .; |
---|
35 | 34 | * |
---|
36 | 35 | * STABS_DEBUG |
---|
37 | 36 | * DWARF_DEBUG |
---|
| 37 | + * ELF_DETAILS |
---|
38 | 38 | * |
---|
39 | 39 | * DISCARDS // must be the last |
---|
40 | 40 | * } |
---|
.. | .. |
---|
54 | 54 | #define LOAD_OFFSET 0 |
---|
55 | 55 | #endif |
---|
56 | 56 | |
---|
| 57 | +/* |
---|
| 58 | + * Only some architectures want to have the .notes segment visible in |
---|
| 59 | + * a separate PT_NOTE ELF Program Header. When this happens, it needs |
---|
| 60 | + * to be visible in both the kernel text's PT_LOAD and the PT_NOTE |
---|
| 61 | + * Program Headers. In this case, though, the PT_LOAD needs to be made |
---|
| 62 | + * the default again so that all the following sections don't also end |
---|
| 63 | + * up in the PT_NOTE Program Header. |
---|
| 64 | + */ |
---|
| 65 | +#ifdef EMITS_PT_NOTE |
---|
| 66 | +#define NOTES_HEADERS :text :note |
---|
| 67 | +#define NOTES_HEADERS_RESTORE __restore_ph : { *(.__restore_ph) } :text |
---|
| 68 | +#else |
---|
| 69 | +#define NOTES_HEADERS |
---|
| 70 | +#define NOTES_HEADERS_RESTORE |
---|
| 71 | +#endif |
---|
| 72 | + |
---|
| 73 | +/* |
---|
| 74 | + * Some architectures have non-executable read-only exception tables. |
---|
| 75 | + * They can be added to the RO_DATA segment by specifying their desired |
---|
| 76 | + * alignment. |
---|
| 77 | + */ |
---|
| 78 | +#ifdef RO_EXCEPTION_TABLE_ALIGN |
---|
| 79 | +#define RO_EXCEPTION_TABLE EXCEPTION_TABLE(RO_EXCEPTION_TABLE_ALIGN) |
---|
| 80 | +#else |
---|
| 81 | +#define RO_EXCEPTION_TABLE |
---|
| 82 | +#endif |
---|
| 83 | + |
---|
57 | 84 | /* Align . to a 8 byte boundary equals to maximum function alignment. */ |
---|
58 | 85 | #define ALIGN_FUNCTION() . = ALIGN(8) |
---|
59 | 86 | |
---|
.. | .. |
---|
63 | 90 | * .data. We don't want to pull in .data..other sections, which Linux |
---|
64 | 91 | * has defined. Same for text and bss. |
---|
65 | 92 | * |
---|
| 93 | + * With LTO_CLANG, the linker also splits sections by default, so we need |
---|
| 94 | + * these macros to combine the sections during the final link. |
---|
| 95 | + * |
---|
66 | 96 | * RODATA_MAIN is not used because existing code already defines .rodata.x |
---|
67 | 97 | * sections to be brought in with rodata. |
---|
68 | 98 | */ |
---|
69 | 99 | #if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG) |
---|
70 | 100 | #define TEXT_MAIN .text .text.[0-9a-zA-Z_]* |
---|
71 | | -#define TEXT_CFI_MAIN .text.[0-9a-zA-Z_]*.cfi |
---|
72 | 101 | #define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* |
---|
73 | 102 | #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]* |
---|
74 | 103 | #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L* |
---|
.. | .. |
---|
76 | 105 | #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]* |
---|
77 | 106 | #else |
---|
78 | 107 | #define TEXT_MAIN .text |
---|
79 | | -#define TEXT_CFI_MAIN .text.cfi |
---|
80 | 108 | #define DATA_MAIN .data |
---|
81 | 109 | #define SDATA_MAIN .sdata |
---|
82 | 110 | #define RODATA_MAIN .rodata |
---|
.. | .. |
---|
85 | 113 | #endif |
---|
86 | 114 | |
---|
87 | 115 | /* |
---|
88 | | - * Align to a 32 byte boundary equal to the |
---|
89 | | - * alignment gcc 4.5 uses for a struct |
---|
| 116 | + * GCC 4.5 and later have a 32 bytes section alignment for structures. |
---|
| 117 | + * Except GCC 4.9, that feels the need to align on 64 bytes. |
---|
90 | 118 | */ |
---|
| 119 | +#if __GNUC__ == 4 && __GNUC_MINOR__ == 9 |
---|
| 120 | +#define STRUCT_ALIGNMENT 64 |
---|
| 121 | +#else |
---|
91 | 122 | #define STRUCT_ALIGNMENT 32 |
---|
| 123 | +#endif |
---|
92 | 124 | #define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT) |
---|
| 125 | + |
---|
| 126 | +/* |
---|
| 127 | + * The order of the sched class addresses are important, as they are |
---|
| 128 | + * used to determine the order of the priority of each sched class in |
---|
| 129 | + * relation to each other. |
---|
| 130 | + */ |
---|
| 131 | +#define SCHED_DATA \ |
---|
| 132 | + STRUCT_ALIGN(); \ |
---|
| 133 | + __begin_sched_classes = .; \ |
---|
| 134 | + *(__idle_sched_class) \ |
---|
| 135 | + *(__fair_sched_class) \ |
---|
| 136 | + *(__rt_sched_class) \ |
---|
| 137 | + *(__dl_sched_class) \ |
---|
| 138 | + *(__stop_sched_class) \ |
---|
| 139 | + __end_sched_classes = .; |
---|
93 | 140 | |
---|
94 | 141 | /* The actual configuration determine if the init/exit sections |
---|
95 | 142 | * are handled as text/data or they can be discarded (which |
---|
.. | .. |
---|
112 | 159 | #endif |
---|
113 | 160 | |
---|
114 | 161 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
---|
| 162 | +/* |
---|
| 163 | + * The ftrace call sites are logged to a section whose name depends on the |
---|
| 164 | + * compiler option used. A given kernel image will only use one, AKA |
---|
| 165 | + * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header |
---|
| 166 | + * dependencies for FTRACE_CALLSITE_SECTION's definition. |
---|
| 167 | + * |
---|
| 168 | + * Need to also make ftrace_stub_graph point to ftrace_stub |
---|
| 169 | + * so that the same stub location may have different protocols |
---|
| 170 | + * and not mess up with C verifiers. |
---|
| 171 | + */ |
---|
115 | 172 | #define MCOUNT_REC() . = ALIGN(8); \ |
---|
116 | 173 | __start_mcount_loc = .; \ |
---|
117 | 174 | KEEP(*(__mcount_loc)) \ |
---|
118 | | - __stop_mcount_loc = .; |
---|
| 175 | + KEEP(*(__patchable_function_entries)) \ |
---|
| 176 | + __stop_mcount_loc = .; \ |
---|
| 177 | + ftrace_stub_graph = ftrace_stub; |
---|
119 | 178 | #else |
---|
120 | | -#define MCOUNT_REC() |
---|
| 179 | +# ifdef CONFIG_FUNCTION_TRACER |
---|
| 180 | +# define MCOUNT_REC() ftrace_stub_graph = ftrace_stub; |
---|
| 181 | +# else |
---|
| 182 | +# define MCOUNT_REC() |
---|
| 183 | +# endif |
---|
121 | 184 | #endif |
---|
122 | 185 | |
---|
123 | 186 | #ifdef CONFIG_TRACE_BRANCH_PROFILING |
---|
.. | .. |
---|
205 | 268 | #define EARLYCON_TABLE() |
---|
206 | 269 | #endif |
---|
207 | 270 | |
---|
| 271 | +#ifdef CONFIG_SECURITY |
---|
| 272 | +#define LSM_TABLE() . = ALIGN(8); \ |
---|
| 273 | + __start_lsm_info = .; \ |
---|
| 274 | + KEEP(*(.lsm_info.init)) \ |
---|
| 275 | + __end_lsm_info = .; |
---|
| 276 | +#define EARLY_LSM_TABLE() . = ALIGN(8); \ |
---|
| 277 | + __start_early_lsm_info = .; \ |
---|
| 278 | + KEEP(*(.early_lsm_info.init)) \ |
---|
| 279 | + __end_early_lsm_info = .; |
---|
| 280 | +#else |
---|
| 281 | +#define LSM_TABLE() |
---|
| 282 | +#define EARLY_LSM_TABLE() |
---|
| 283 | +#endif |
---|
| 284 | + |
---|
208 | 285 | #define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name) |
---|
209 | 286 | #define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name) |
---|
210 | 287 | #define OF_TABLE(cfg, name) __OF_TABLE(IS_ENABLED(cfg), name) |
---|
.. | .. |
---|
232 | 309 | #define ACPI_PROBE_TABLE(name) |
---|
233 | 310 | #endif |
---|
234 | 311 | |
---|
| 312 | +#ifdef CONFIG_THERMAL |
---|
| 313 | +#define THERMAL_TABLE(name) \ |
---|
| 314 | + . = ALIGN(8); \ |
---|
| 315 | + __##name##_thermal_table = .; \ |
---|
| 316 | + KEEP(*(__##name##_thermal_table)) \ |
---|
| 317 | + __##name##_thermal_table_end = .; |
---|
| 318 | +#else |
---|
| 319 | +#define THERMAL_TABLE(name) |
---|
| 320 | +#endif |
---|
| 321 | + |
---|
| 322 | +#ifdef CONFIG_DTPM |
---|
| 323 | +#define DTPM_TABLE() \ |
---|
| 324 | + . = ALIGN(8); \ |
---|
| 325 | + __dtpm_table = .; \ |
---|
| 326 | + KEEP(*(__dtpm_table)) \ |
---|
| 327 | + __dtpm_table_end = .; |
---|
| 328 | +#else |
---|
| 329 | +#define DTPM_TABLE() |
---|
| 330 | +#endif |
---|
| 331 | + |
---|
235 | 332 | #define KERNEL_DTB() \ |
---|
236 | 333 | STRUCT_ALIGN(); \ |
---|
237 | 334 | __dtb_start = .; \ |
---|
.. | .. |
---|
244 | 341 | #define DATA_DATA \ |
---|
245 | 342 | *(.xiptext) \ |
---|
246 | 343 | *(DATA_MAIN) \ |
---|
| 344 | + *(.data..decrypted) \ |
---|
247 | 345 | *(.ref.data) \ |
---|
248 | 346 | *(.data..shared_aligned) /* percpu related */ \ |
---|
249 | 347 | MEM_KEEP(init.data*) \ |
---|
.. | .. |
---|
255 | 353 | STRUCT_ALIGN(); \ |
---|
256 | 354 | *(__tracepoints) \ |
---|
257 | 355 | /* implement dynamic printk debug */ \ |
---|
258 | | - . = ALIGN(8); \ |
---|
259 | | - __start___jump_table = .; \ |
---|
260 | | - KEEP(*(__jump_table)) \ |
---|
261 | | - __stop___jump_table = .; \ |
---|
262 | 356 | . = ALIGN(8); \ |
---|
263 | | - __start___verbose = .; \ |
---|
264 | | - KEEP(*(__verbose)) \ |
---|
265 | | - __stop___verbose = .; \ |
---|
| 357 | + __start___dyndbg = .; \ |
---|
| 358 | + KEEP(*(__dyndbg)) \ |
---|
| 359 | + __stop___dyndbg = .; \ |
---|
266 | 360 | LIKELY_PROFILE() \ |
---|
267 | 361 | BRANCH_PROFILE() \ |
---|
268 | 362 | TRACE_PRINTKS() \ |
---|
.. | .. |
---|
303 | 397 | . = __start_init_task + THREAD_SIZE; \ |
---|
304 | 398 | __end_init_task = .; |
---|
305 | 399 | |
---|
| 400 | +#define JUMP_TABLE_DATA \ |
---|
| 401 | + . = ALIGN(8); \ |
---|
| 402 | + __start___jump_table = .; \ |
---|
| 403 | + KEEP(*(__jump_table)) \ |
---|
| 404 | + __stop___jump_table = .; |
---|
| 405 | + |
---|
| 406 | +#define STATIC_CALL_DATA \ |
---|
| 407 | + . = ALIGN(8); \ |
---|
| 408 | + __start_static_call_sites = .; \ |
---|
| 409 | + KEEP(*(.static_call_sites)) \ |
---|
| 410 | + __stop_static_call_sites = .; \ |
---|
| 411 | + __start_static_call_tramp_key = .; \ |
---|
| 412 | + KEEP(*(.static_call_tramp_key)) \ |
---|
| 413 | + __stop_static_call_tramp_key = .; |
---|
| 414 | + |
---|
306 | 415 | /* |
---|
307 | 416 | * Allow architectures to handle ro_after_init data on their |
---|
308 | 417 | * own by defining an empty RO_AFTER_INIT_DATA. |
---|
.. | .. |
---|
312 | 421 | . = ALIGN(8); \ |
---|
313 | 422 | __start_ro_after_init = .; \ |
---|
314 | 423 | *(.data..ro_after_init) \ |
---|
| 424 | + JUMP_TABLE_DATA \ |
---|
| 425 | + STATIC_CALL_DATA \ |
---|
315 | 426 | __end_ro_after_init = .; |
---|
316 | 427 | #endif |
---|
317 | 428 | |
---|
318 | 429 | /* |
---|
319 | 430 | * Read only Data |
---|
320 | 431 | */ |
---|
321 | | -#define RO_DATA_SECTION(align) \ |
---|
| 432 | +#define RO_DATA(align) \ |
---|
322 | 433 | . = ALIGN((align)); \ |
---|
323 | 434 | .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ |
---|
324 | 435 | __start_rodata = .; \ |
---|
325 | 436 | *(.rodata) *(.rodata.*) \ |
---|
| 437 | + SCHED_DATA \ |
---|
326 | 438 | RO_AFTER_INIT_DATA /* Read only after init */ \ |
---|
327 | | - KEEP(*(__vermagic)) /* Kernel version magic */ \ |
---|
328 | 439 | . = ALIGN(8); \ |
---|
329 | 440 | __start___tracepoints_ptrs = .; \ |
---|
330 | 441 | KEEP(*(__tracepoints_ptrs)) /* Tracepoints: pointer array */ \ |
---|
.. | .. |
---|
467 | 578 | __start___modver = .; \ |
---|
468 | 579 | KEEP(*(__modver)) \ |
---|
469 | 580 | __stop___modver = .; \ |
---|
470 | | - . = ALIGN((align)); \ |
---|
471 | | - __end_rodata = .; \ |
---|
472 | 581 | } \ |
---|
473 | | - . = ALIGN((align)); |
---|
| 582 | + \ |
---|
| 583 | + RO_EXCEPTION_TABLE \ |
---|
| 584 | + NOTES \ |
---|
| 585 | + BTF \ |
---|
| 586 | + \ |
---|
| 587 | + . = ALIGN((align)); \ |
---|
| 588 | + __end_rodata = .; |
---|
474 | 589 | |
---|
475 | | -/* RODATA & RO_DATA provided for backward compatibility. |
---|
476 | | - * All archs are supposed to use RO_DATA() */ |
---|
477 | | -#define RODATA RO_DATA_SECTION(4096) |
---|
478 | | -#define RO_DATA(align) RO_DATA_SECTION(align) |
---|
479 | 590 | |
---|
480 | | -#define SECURITY_INIT \ |
---|
481 | | - .security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \ |
---|
482 | | - __security_initcall_start = .; \ |
---|
483 | | - KEEP(*(.security_initcall.init)) \ |
---|
484 | | - __security_initcall_end = .; \ |
---|
485 | | - } |
---|
| 591 | +/* |
---|
| 592 | + * .text..L.cfi.jumptable.* contain Control-Flow Integrity (CFI) |
---|
| 593 | + * jump table entries. |
---|
| 594 | + */ |
---|
| 595 | +#ifdef CONFIG_CFI_CLANG |
---|
| 596 | +#define TEXT_CFI_JT \ |
---|
| 597 | + . = ALIGN(PMD_SIZE); \ |
---|
| 598 | + __cfi_jt_start = .; \ |
---|
| 599 | + *(.text..L.cfi.jumptable .text..L.cfi.jumptable.*) \ |
---|
| 600 | + . = ALIGN(PMD_SIZE); \ |
---|
| 601 | + __cfi_jt_end = .; |
---|
| 602 | +#else |
---|
| 603 | +#define TEXT_CFI_JT |
---|
| 604 | +#endif |
---|
486 | 605 | |
---|
487 | 606 | /* |
---|
488 | 607 | * Non-instrumentable text section |
---|
.. | .. |
---|
507 | 626 | *(TEXT_MAIN .text.fixup) \ |
---|
508 | 627 | *(.text.unlikely .text.unlikely.*) \ |
---|
509 | 628 | *(.text.unknown .text.unknown.*) \ |
---|
510 | | - *(TEXT_CFI_MAIN) \ |
---|
511 | 629 | NOINSTR_TEXT \ |
---|
512 | 630 | *(.text..refcount) \ |
---|
513 | | - *(.text..ftrace) \ |
---|
514 | 631 | *(.ref.text) \ |
---|
515 | 632 | *(.text.asan.* .text.tsan.*) \ |
---|
| 633 | + TEXT_CFI_JT \ |
---|
516 | 634 | MEM_KEEP(init.text*) \ |
---|
517 | 635 | MEM_KEEP(exit.text*) \ |
---|
518 | 636 | |
---|
.. | .. |
---|
563 | 681 | *(.softirqentry.text) \ |
---|
564 | 682 | __softirqentry_text_end = .; |
---|
565 | 683 | |
---|
| 684 | +#define STATIC_CALL_TEXT \ |
---|
| 685 | + ALIGN_FUNCTION(); \ |
---|
| 686 | + __static_call_text_start = .; \ |
---|
| 687 | + *(.static_call.text) \ |
---|
| 688 | + __static_call_text_end = .; |
---|
| 689 | + |
---|
566 | 690 | /* Section used for early init (in .S files) */ |
---|
567 | 691 | #define HEAD_TEXT KEEP(*(.head.text)) |
---|
568 | 692 | |
---|
.. | .. |
---|
583 | 707 | } |
---|
584 | 708 | |
---|
585 | 709 | /* |
---|
| 710 | + * .BTF |
---|
| 711 | + */ |
---|
| 712 | +#ifdef CONFIG_DEBUG_INFO_BTF |
---|
| 713 | +#define BTF \ |
---|
| 714 | + .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) { \ |
---|
| 715 | + __start_BTF = .; \ |
---|
| 716 | + KEEP(*(.BTF)) \ |
---|
| 717 | + __stop_BTF = .; \ |
---|
| 718 | + } \ |
---|
| 719 | + . = ALIGN(4); \ |
---|
| 720 | + .BTF_ids : AT(ADDR(.BTF_ids) - LOAD_OFFSET) { \ |
---|
| 721 | + *(.BTF_ids) \ |
---|
| 722 | + } |
---|
| 723 | +#else |
---|
| 724 | +#define BTF |
---|
| 725 | +#endif |
---|
| 726 | + |
---|
| 727 | +/* |
---|
586 | 728 | * Init task |
---|
587 | 729 | */ |
---|
588 | 730 | #define INIT_TASK_DATA_SECTION(align) \ |
---|
.. | .. |
---|
594 | 736 | #ifdef CONFIG_CONSTRUCTORS |
---|
595 | 737 | #define KERNEL_CTORS() . = ALIGN(8); \ |
---|
596 | 738 | __ctors_start = .; \ |
---|
| 739 | + KEEP(*(SORT(.ctors.*))) \ |
---|
597 | 740 | KEEP(*(.ctors)) \ |
---|
598 | 741 | KEEP(*(SORT(.init_array.*))) \ |
---|
599 | 742 | KEEP(*(.init_array)) \ |
---|
.. | .. |
---|
624 | 767 | IRQCHIP_OF_MATCH_TABLE() \ |
---|
625 | 768 | ACPI_PROBE_TABLE(irqchip) \ |
---|
626 | 769 | ACPI_PROBE_TABLE(timer) \ |
---|
627 | | - EARLYCON_TABLE() |
---|
| 770 | + THERMAL_TABLE(governor) \ |
---|
| 771 | + DTPM_TABLE() \ |
---|
| 772 | + EARLYCON_TABLE() \ |
---|
| 773 | + LSM_TABLE() \ |
---|
| 774 | + EARLY_LSM_TABLE() \ |
---|
| 775 | + KUNIT_TABLE() |
---|
628 | 776 | |
---|
629 | 777 | #define INIT_TEXT \ |
---|
630 | 778 | *(.init.text .init.text.*) \ |
---|
.. | .. |
---|
679 | 827 | } |
---|
680 | 828 | |
---|
681 | 829 | /* |
---|
| 830 | + * Keep .eh_frame with CFI. |
---|
| 831 | + */ |
---|
| 832 | +#ifdef CONFIG_CFI_CLANG |
---|
| 833 | +#define EH_FRAME .eh_frame : { *(.eh_frame) } |
---|
| 834 | +#else |
---|
| 835 | +#define EH_FRAME |
---|
| 836 | +#endif |
---|
| 837 | + |
---|
| 838 | +/* |
---|
682 | 839 | * DWARF debug sections. |
---|
683 | 840 | * Symbols in the DWARF debugging sections are relative to |
---|
684 | 841 | * the beginning of the section so we begin them at 0. |
---|
685 | 842 | */ |
---|
686 | 843 | #define DWARF_DEBUG \ |
---|
| 844 | + EH_FRAME \ |
---|
687 | 845 | /* DWARF 1 */ \ |
---|
688 | 846 | .debug 0 : { *(.debug) } \ |
---|
689 | 847 | .line 0 : { *(.line) } \ |
---|
.. | .. |
---|
724 | 882 | .debug_rnglists 0 : { *(.debug_rnglists) } \ |
---|
725 | 883 | .debug_str_offsets 0 : { *(.debug_str_offsets) } |
---|
726 | 884 | |
---|
727 | | - /* Stabs debugging sections. */ |
---|
| 885 | +/* Stabs debugging sections. */ |
---|
728 | 886 | #define STABS_DEBUG \ |
---|
729 | 887 | .stab 0 : { *(.stab) } \ |
---|
730 | 888 | .stabstr 0 : { *(.stabstr) } \ |
---|
731 | 889 | .stab.excl 0 : { *(.stab.excl) } \ |
---|
732 | 890 | .stab.exclstr 0 : { *(.stab.exclstr) } \ |
---|
733 | 891 | .stab.index 0 : { *(.stab.index) } \ |
---|
734 | | - .stab.indexstr 0 : { *(.stab.indexstr) } \ |
---|
735 | | - .comment 0 : { *(.comment) } |
---|
| 892 | + .stab.indexstr 0 : { *(.stab.indexstr) } |
---|
| 893 | + |
---|
| 894 | +/* Required sections not related to debugging. */ |
---|
| 895 | +#define ELF_DETAILS \ |
---|
| 896 | + .comment 0 : { *(.comment) } \ |
---|
| 897 | + .symtab 0 : { *(.symtab) } \ |
---|
| 898 | + .strtab 0 : { *(.strtab) } \ |
---|
| 899 | + .shstrtab 0 : { *(.shstrtab) } |
---|
736 | 900 | |
---|
737 | 901 | #ifdef CONFIG_GENERIC_BUG |
---|
738 | 902 | #define BUG_TABLE \ |
---|
.. | .. |
---|
783 | 947 | #define TRACEDATA |
---|
784 | 948 | #endif |
---|
785 | 949 | |
---|
| 950 | +/* |
---|
| 951 | + * Discard .note.GNU-stack, which is emitted as PROGBITS by the compiler. |
---|
| 952 | + * Otherwise, the type of .notes section would become PROGBITS instead of NOTES. |
---|
| 953 | + */ |
---|
786 | 954 | #define NOTES \ |
---|
| 955 | + /DISCARD/ : { *(.note.GNU-stack) } \ |
---|
787 | 956 | .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \ |
---|
788 | 957 | __start_notes = .; \ |
---|
789 | 958 | KEEP(*(.note.*)) \ |
---|
790 | 959 | __stop_notes = .; \ |
---|
791 | | - } |
---|
| 960 | + } NOTES_HEADERS \ |
---|
| 961 | + NOTES_HEADERS_RESTORE |
---|
792 | 962 | |
---|
793 | 963 | #define INIT_SETUP(initsetup_align) \ |
---|
794 | 964 | . = ALIGN(initsetup_align); \ |
---|
.. | .. |
---|
821 | 991 | KEEP(*(.con_initcall.init)) \ |
---|
822 | 992 | __con_initcall_end = .; |
---|
823 | 993 | |
---|
824 | | -#define SECURITY_INITCALL \ |
---|
825 | | - __security_initcall_start = .; \ |
---|
826 | | - KEEP(*(.security_initcall.init)) \ |
---|
827 | | - __security_initcall_end = .; |
---|
| 994 | +/* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */ |
---|
| 995 | +#define KUNIT_TABLE() \ |
---|
| 996 | + . = ALIGN(8); \ |
---|
| 997 | + __kunit_suites_start = .; \ |
---|
| 998 | + KEEP(*(.kunit_test_suites)) \ |
---|
| 999 | + __kunit_suites_end = .; |
---|
828 | 1000 | |
---|
829 | 1001 | #ifdef CONFIG_BLK_DEV_INITRD |
---|
830 | 1002 | #define INIT_RAM_FS \ |
---|
.. | .. |
---|
848 | 1020 | #ifdef CONFIG_AMD_MEM_ENCRYPT |
---|
849 | 1021 | #define PERCPU_DECRYPTED_SECTION \ |
---|
850 | 1022 | . = ALIGN(PAGE_SIZE); \ |
---|
851 | | - *(.data..decrypted) \ |
---|
852 | 1023 | *(.data..percpu..decrypted) \ |
---|
853 | 1024 | . = ALIGN(PAGE_SIZE); |
---|
854 | 1025 | #else |
---|
.. | .. |
---|
865 | 1036 | * section definitions so that such archs put those in earlier section |
---|
866 | 1037 | * definitions. |
---|
867 | 1038 | */ |
---|
868 | | -#define DISCARDS \ |
---|
869 | | - /DISCARD/ : { \ |
---|
| 1039 | +#ifdef RUNTIME_DISCARD_EXIT |
---|
| 1040 | +#define EXIT_DISCARDS |
---|
| 1041 | +#else |
---|
| 1042 | +#define EXIT_DISCARDS \ |
---|
870 | 1043 | EXIT_TEXT \ |
---|
871 | | - EXIT_DATA \ |
---|
872 | | - EXIT_CALL \ |
---|
| 1044 | + EXIT_DATA |
---|
| 1045 | +#endif |
---|
| 1046 | + |
---|
| 1047 | +/* |
---|
| 1048 | + * Clang's -fprofile-arcs, -fsanitize=kernel-address, and |
---|
| 1049 | + * -fsanitize=thread produce unwanted sections (.eh_frame |
---|
| 1050 | + * and .init_array.*), but CONFIG_CONSTRUCTORS wants to |
---|
| 1051 | + * keep any .init_array.* sections. |
---|
| 1052 | + * https://bugs.llvm.org/show_bug.cgi?id=46478 |
---|
| 1053 | + */ |
---|
| 1054 | +#if defined(CONFIG_GCOV_KERNEL) || defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN) |
---|
| 1055 | +# ifdef CONFIG_CONSTRUCTORS |
---|
| 1056 | +# define SANITIZER_DISCARDS \ |
---|
| 1057 | + *(.eh_frame) |
---|
| 1058 | +# else |
---|
| 1059 | +# define SANITIZER_DISCARDS \ |
---|
| 1060 | + *(.init_array) *(.init_array.*) \ |
---|
| 1061 | + *(.eh_frame) |
---|
| 1062 | +# endif |
---|
| 1063 | +#else |
---|
| 1064 | +# define SANITIZER_DISCARDS |
---|
| 1065 | +#endif |
---|
| 1066 | + |
---|
| 1067 | +#define COMMON_DISCARDS \ |
---|
| 1068 | + SANITIZER_DISCARDS \ |
---|
873 | 1069 | *(.discard) \ |
---|
874 | 1070 | *(.discard.*) \ |
---|
| 1071 | + *(.modinfo) \ |
---|
| 1072 | + /* ld.bfd warns about .gnu.version* even when not emitted */ \ |
---|
| 1073 | + *(.gnu.version*) \ |
---|
| 1074 | + |
---|
| 1075 | +#define DISCARDS \ |
---|
| 1076 | + /DISCARD/ : { \ |
---|
| 1077 | + EXIT_DISCARDS \ |
---|
| 1078 | + EXIT_CALL \ |
---|
| 1079 | + COMMON_DISCARDS \ |
---|
875 | 1080 | } |
---|
876 | 1081 | |
---|
877 | 1082 | /** |
---|
.. | .. |
---|
966 | 1171 | * matches the requirement of PAGE_ALIGNED_DATA. |
---|
967 | 1172 | * |
---|
968 | 1173 | * use 0 as page_align if page_aligned data is not used */ |
---|
969 | | -#define RW_DATA_SECTION(cacheline, pagealigned, inittask) \ |
---|
| 1174 | +#define RW_DATA(cacheline, pagealigned, inittask) \ |
---|
970 | 1175 | . = ALIGN(PAGE_SIZE); \ |
---|
971 | 1176 | .data : AT(ADDR(.data) - LOAD_OFFSET) { \ |
---|
972 | 1177 | INIT_TASK_DATA(inittask) \ |
---|
.. | .. |
---|
993 | 1198 | INIT_SETUP(initsetup_align) \ |
---|
994 | 1199 | INIT_CALLS \ |
---|
995 | 1200 | CON_INITCALL \ |
---|
996 | | - SECURITY_INITCALL \ |
---|
997 | 1201 | INIT_RAM_FS \ |
---|
998 | 1202 | } |
---|
999 | 1203 | |
---|