vmlinux.lds.h 33 KB

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