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