vmlinux.lds.h 34 KB

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