vmlinux.lds.h 33 KB

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