vmlinux.lds.h 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  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. *(.data..do_once) \
  321. STRUCT_ALIGN(); \
  322. *(__tracepoints) \
  323. /* implement dynamic printk debug */ \
  324. . = ALIGN(8); \
  325. BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \
  326. BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \
  327. CODETAG_SECTIONS() \
  328. LIKELY_PROFILE() \
  329. BRANCH_PROFILE() \
  330. TRACE_PRINTKS() \
  331. BPF_RAW_TP() \
  332. TRACEPOINT_STR() \
  333. KUNIT_TABLE()
  334. /*
  335. * Data section helpers
  336. */
  337. #define NOSAVE_DATA \
  338. . = ALIGN(PAGE_SIZE); \
  339. __nosave_begin = .; \
  340. *(.data..nosave) \
  341. . = ALIGN(PAGE_SIZE); \
  342. __nosave_end = .;
  343. #define PAGE_ALIGNED_DATA(page_align) \
  344. . = ALIGN(page_align); \
  345. *(.data..page_aligned) \
  346. . = ALIGN(page_align);
  347. #define READ_MOSTLY_DATA(align) \
  348. . = ALIGN(align); \
  349. *(.data..read_mostly) \
  350. . = ALIGN(align);
  351. #define CACHELINE_ALIGNED_DATA(align) \
  352. . = ALIGN(align); \
  353. *(.data..cacheline_aligned)
  354. #define INIT_TASK_DATA(align) \
  355. . = ALIGN(align); \
  356. __start_init_stack = .; \
  357. init_thread_union = .; \
  358. init_stack = .; \
  359. KEEP(*(.data..init_task)) \
  360. KEEP(*(.data..init_thread_info)) \
  361. . = __start_init_stack + THREAD_SIZE; \
  362. __end_init_stack = .;
  363. #define JUMP_TABLE_DATA \
  364. . = ALIGN(8); \
  365. BOUNDED_SECTION_BY(__jump_table, ___jump_table)
  366. #ifdef CONFIG_HAVE_STATIC_CALL_INLINE
  367. #define STATIC_CALL_DATA \
  368. . = ALIGN(8); \
  369. BOUNDED_SECTION_BY(.static_call_sites, _static_call_sites) \
  370. BOUNDED_SECTION_BY(.static_call_tramp_key, _static_call_tramp_key)
  371. #else
  372. #define STATIC_CALL_DATA
  373. #endif
  374. /*
  375. * Allow architectures to handle ro_after_init data on their
  376. * own by defining an empty RO_AFTER_INIT_DATA.
  377. */
  378. #ifndef RO_AFTER_INIT_DATA
  379. #define RO_AFTER_INIT_DATA \
  380. . = ALIGN(8); \
  381. __start_ro_after_init = .; \
  382. *(.data..ro_after_init) \
  383. JUMP_TABLE_DATA \
  384. STATIC_CALL_DATA \
  385. __end_ro_after_init = .;
  386. #endif
  387. /*
  388. * .kcfi_traps contains a list KCFI trap locations.
  389. */
  390. #ifndef KCFI_TRAPS
  391. #ifdef CONFIG_ARCH_USES_CFI_TRAPS
  392. #define KCFI_TRAPS \
  393. __kcfi_traps : AT(ADDR(__kcfi_traps) - LOAD_OFFSET) { \
  394. BOUNDED_SECTION_BY(.kcfi_traps, ___kcfi_traps) \
  395. }
  396. #else
  397. #define KCFI_TRAPS
  398. #endif
  399. #endif
  400. /*
  401. * Read only Data
  402. */
  403. #define RO_DATA(align) \
  404. . = ALIGN((align)); \
  405. .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
  406. __start_rodata = .; \
  407. *(.rodata) *(.rodata.*) *(.data.rel.ro*) \
  408. SCHED_DATA \
  409. RO_AFTER_INIT_DATA /* Read only after init */ \
  410. . = ALIGN(8); \
  411. BOUNDED_SECTION_BY(__tracepoints_ptrs, ___tracepoints_ptrs) \
  412. *(__tracepoints_strings)/* Tracepoints: strings */ \
  413. } \
  414. \
  415. .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
  416. *(.rodata1) \
  417. } \
  418. \
  419. /* PCI quirks */ \
  420. .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
  421. BOUNDED_SECTION_PRE_LABEL(.pci_fixup_early, _pci_fixups_early, __start, __end) \
  422. BOUNDED_SECTION_PRE_LABEL(.pci_fixup_header, _pci_fixups_header, __start, __end) \
  423. BOUNDED_SECTION_PRE_LABEL(.pci_fixup_final, _pci_fixups_final, __start, __end) \
  424. BOUNDED_SECTION_PRE_LABEL(.pci_fixup_enable, _pci_fixups_enable, __start, __end) \
  425. BOUNDED_SECTION_PRE_LABEL(.pci_fixup_resume, _pci_fixups_resume, __start, __end) \
  426. BOUNDED_SECTION_PRE_LABEL(.pci_fixup_suspend, _pci_fixups_suspend, __start, __end) \
  427. BOUNDED_SECTION_PRE_LABEL(.pci_fixup_resume_early, _pci_fixups_resume_early, __start, __end) \
  428. BOUNDED_SECTION_PRE_LABEL(.pci_fixup_suspend_late, _pci_fixups_suspend_late, __start, __end) \
  429. } \
  430. \
  431. FW_LOADER_BUILT_IN_DATA \
  432. TRACEDATA \
  433. \
  434. PRINTK_INDEX \
  435. \
  436. /* Kernel symbol table: Normal symbols */ \
  437. __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
  438. __start___ksymtab = .; \
  439. KEEP(*(SORT(___ksymtab+*))) \
  440. __stop___ksymtab = .; \
  441. } \
  442. \
  443. /* Kernel symbol table: GPL-only symbols */ \
  444. __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
  445. __start___ksymtab_gpl = .; \
  446. KEEP(*(SORT(___ksymtab_gpl+*))) \
  447. __stop___ksymtab_gpl = .; \
  448. } \
  449. \
  450. /* Kernel symbol table: Normal symbols */ \
  451. __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
  452. __start___kcrctab = .; \
  453. KEEP(*(SORT(___kcrctab+*))) \
  454. __stop___kcrctab = .; \
  455. } \
  456. \
  457. /* Kernel symbol table: GPL-only symbols */ \
  458. __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
  459. __start___kcrctab_gpl = .; \
  460. KEEP(*(SORT(___kcrctab_gpl+*))) \
  461. __stop___kcrctab_gpl = .; \
  462. } \
  463. \
  464. /* Kernel symbol table: strings */ \
  465. __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
  466. *(__ksymtab_strings) \
  467. } \
  468. \
  469. /* __*init sections */ \
  470. __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
  471. *(.ref.rodata) \
  472. } \
  473. \
  474. /* Built-in module parameters. */ \
  475. __param : AT(ADDR(__param) - LOAD_OFFSET) { \
  476. BOUNDED_SECTION_BY(__param, ___param) \
  477. } \
  478. \
  479. /* Built-in module versions. */ \
  480. __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
  481. BOUNDED_SECTION_BY(__modver, ___modver) \
  482. } \
  483. \
  484. KCFI_TRAPS \
  485. \
  486. RO_EXCEPTION_TABLE \
  487. NOTES \
  488. BTF \
  489. \
  490. . = ALIGN((align)); \
  491. __end_rodata = .;
  492. /*
  493. * Non-instrumentable text section
  494. */
  495. #define NOINSTR_TEXT \
  496. ALIGN_FUNCTION(); \
  497. __noinstr_text_start = .; \
  498. *(.noinstr.text) \
  499. __cpuidle_text_start = .; \
  500. *(.cpuidle.text) \
  501. __cpuidle_text_end = .; \
  502. __noinstr_text_end = .;
  503. /*
  504. * .text section. Map to function alignment to avoid address changes
  505. * during second ld run in second ld pass when generating System.map
  506. *
  507. * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead
  508. * code elimination is enabled, so these sections should be converted
  509. * to use ".." first.
  510. */
  511. #define TEXT_TEXT \
  512. ALIGN_FUNCTION(); \
  513. *(.text.hot .text.hot.*) \
  514. *(TEXT_MAIN .text.fixup) \
  515. *(.text.unlikely .text.unlikely.*) \
  516. *(.text.unknown .text.unknown.*) \
  517. NOINSTR_TEXT \
  518. *(.ref.text) \
  519. *(.text.asan.* .text.tsan.*)
  520. /* sched.text is aling to function alignment to secure we have same
  521. * address even at second ld pass when generating System.map */
  522. #define SCHED_TEXT \
  523. ALIGN_FUNCTION(); \
  524. __sched_text_start = .; \
  525. *(.sched.text) \
  526. __sched_text_end = .;
  527. /* spinlock.text is aling to function alignment to secure we have same
  528. * address even at second ld pass when generating System.map */
  529. #define LOCK_TEXT \
  530. ALIGN_FUNCTION(); \
  531. __lock_text_start = .; \
  532. *(.spinlock.text) \
  533. __lock_text_end = .;
  534. #define KPROBES_TEXT \
  535. ALIGN_FUNCTION(); \
  536. __kprobes_text_start = .; \
  537. *(.kprobes.text) \
  538. __kprobes_text_end = .;
  539. #define ENTRY_TEXT \
  540. ALIGN_FUNCTION(); \
  541. __entry_text_start = .; \
  542. *(.entry.text) \
  543. __entry_text_end = .;
  544. #define IRQENTRY_TEXT \
  545. ALIGN_FUNCTION(); \
  546. __irqentry_text_start = .; \
  547. *(.irqentry.text) \
  548. __irqentry_text_end = .;
  549. #define SOFTIRQENTRY_TEXT \
  550. ALIGN_FUNCTION(); \
  551. __softirqentry_text_start = .; \
  552. *(.softirqentry.text) \
  553. __softirqentry_text_end = .;
  554. #define STATIC_CALL_TEXT \
  555. ALIGN_FUNCTION(); \
  556. __static_call_text_start = .; \
  557. *(.static_call.text) \
  558. __static_call_text_end = .;
  559. /* Section used for early init (in .S files) */
  560. #define HEAD_TEXT KEEP(*(.head.text))
  561. #define HEAD_TEXT_SECTION \
  562. .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { \
  563. HEAD_TEXT \
  564. }
  565. /*
  566. * Exception table
  567. */
  568. #define EXCEPTION_TABLE(align) \
  569. . = ALIGN(align); \
  570. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \
  571. BOUNDED_SECTION_BY(__ex_table, ___ex_table) \
  572. }
  573. /*
  574. * .BTF
  575. */
  576. #ifdef CONFIG_DEBUG_INFO_BTF
  577. #define BTF \
  578. .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) { \
  579. BOUNDED_SECTION_BY(.BTF, _BTF) \
  580. } \
  581. . = ALIGN(4); \
  582. .BTF_ids : AT(ADDR(.BTF_ids) - LOAD_OFFSET) { \
  583. *(.BTF_ids) \
  584. }
  585. #else
  586. #define BTF
  587. #endif
  588. /*
  589. * Init task
  590. */
  591. #define INIT_TASK_DATA_SECTION(align) \
  592. . = ALIGN(align); \
  593. .data..init_task : AT(ADDR(.data..init_task) - LOAD_OFFSET) { \
  594. INIT_TASK_DATA(align) \
  595. }
  596. #ifdef CONFIG_CONSTRUCTORS
  597. #define KERNEL_CTORS() . = ALIGN(8); \
  598. __ctors_start = .; \
  599. KEEP(*(SORT(.ctors.*))) \
  600. KEEP(*(.ctors)) \
  601. KEEP(*(SORT(.init_array.*))) \
  602. KEEP(*(.init_array)) \
  603. __ctors_end = .;
  604. #else
  605. #define KERNEL_CTORS()
  606. #endif
  607. /* init and exit section handling */
  608. #define INIT_DATA \
  609. KEEP(*(SORT(___kentry+*))) \
  610. *(.init.data .init.data.*) \
  611. KERNEL_CTORS() \
  612. MCOUNT_REC() \
  613. *(.init.rodata .init.rodata.*) \
  614. FTRACE_EVENTS() \
  615. TRACE_SYSCALLS() \
  616. KPROBE_BLACKLIST() \
  617. ERROR_INJECT_WHITELIST() \
  618. CLK_OF_TABLES() \
  619. RESERVEDMEM_OF_TABLES() \
  620. TIMER_OF_TABLES() \
  621. CPU_METHOD_OF_TABLES() \
  622. CPUIDLE_METHOD_OF_TABLES() \
  623. KERNEL_DTB() \
  624. IRQCHIP_OF_MATCH_TABLE() \
  625. ACPI_PROBE_TABLE(irqchip) \
  626. ACPI_PROBE_TABLE(timer) \
  627. THERMAL_TABLE(governor) \
  628. EARLYCON_TABLE() \
  629. LSM_TABLE() \
  630. EARLY_LSM_TABLE() \
  631. KUNIT_INIT_TABLE()
  632. #define INIT_TEXT \
  633. *(.init.text .init.text.*) \
  634. *(.text.startup)
  635. #define EXIT_DATA \
  636. *(.exit.data .exit.data.*) \
  637. *(.fini_array .fini_array.*) \
  638. *(.dtors .dtors.*) \
  639. #define EXIT_TEXT \
  640. *(.exit.text) \
  641. *(.text.exit) \
  642. #define EXIT_CALL \
  643. *(.exitcall.exit)
  644. /*
  645. * bss (Block Started by Symbol) - uninitialized data
  646. * zeroed during startup
  647. */
  648. #define SBSS(sbss_align) \
  649. . = ALIGN(sbss_align); \
  650. .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
  651. *(.dynsbss) \
  652. *(SBSS_MAIN) \
  653. *(.scommon) \
  654. }
  655. /*
  656. * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
  657. * sections to the front of bss.
  658. */
  659. #ifndef BSS_FIRST_SECTIONS
  660. #define BSS_FIRST_SECTIONS
  661. #endif
  662. #define BSS(bss_align) \
  663. . = ALIGN(bss_align); \
  664. .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \
  665. BSS_FIRST_SECTIONS \
  666. . = ALIGN(PAGE_SIZE); \
  667. *(.bss..page_aligned) \
  668. . = ALIGN(PAGE_SIZE); \
  669. *(.dynbss) \
  670. *(BSS_MAIN) \
  671. *(COMMON) \
  672. }
  673. /*
  674. * DWARF debug sections.
  675. * Symbols in the DWARF debugging sections are relative to
  676. * the beginning of the section so we begin them at 0.
  677. */
  678. #define DWARF_DEBUG \
  679. /* DWARF 1 */ \
  680. .debug 0 : { *(.debug) } \
  681. .line 0 : { *(.line) } \
  682. /* GNU DWARF 1 extensions */ \
  683. .debug_srcinfo 0 : { *(.debug_srcinfo) } \
  684. .debug_sfnames 0 : { *(.debug_sfnames) } \
  685. /* DWARF 1.1 and DWARF 2 */ \
  686. .debug_aranges 0 : { *(.debug_aranges) } \
  687. .debug_pubnames 0 : { *(.debug_pubnames) } \
  688. /* DWARF 2 */ \
  689. .debug_info 0 : { *(.debug_info \
  690. .gnu.linkonce.wi.*) } \
  691. .debug_abbrev 0 : { *(.debug_abbrev) } \
  692. .debug_line 0 : { *(.debug_line) } \
  693. .debug_frame 0 : { *(.debug_frame) } \
  694. .debug_str 0 : { *(.debug_str) } \
  695. .debug_loc 0 : { *(.debug_loc) } \
  696. .debug_macinfo 0 : { *(.debug_macinfo) } \
  697. .debug_pubtypes 0 : { *(.debug_pubtypes) } \
  698. /* DWARF 3 */ \
  699. .debug_ranges 0 : { *(.debug_ranges) } \
  700. /* SGI/MIPS DWARF 2 extensions */ \
  701. .debug_weaknames 0 : { *(.debug_weaknames) } \
  702. .debug_funcnames 0 : { *(.debug_funcnames) } \
  703. .debug_typenames 0 : { *(.debug_typenames) } \
  704. .debug_varnames 0 : { *(.debug_varnames) } \
  705. /* GNU DWARF 2 extensions */ \
  706. .debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) } \
  707. .debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) } \
  708. /* DWARF 4 */ \
  709. .debug_types 0 : { *(.debug_types) } \
  710. /* DWARF 5 */ \
  711. .debug_addr 0 : { *(.debug_addr) } \
  712. .debug_line_str 0 : { *(.debug_line_str) } \
  713. .debug_loclists 0 : { *(.debug_loclists) } \
  714. .debug_macro 0 : { *(.debug_macro) } \
  715. .debug_names 0 : { *(.debug_names) } \
  716. .debug_rnglists 0 : { *(.debug_rnglists) } \
  717. .debug_str_offsets 0 : { *(.debug_str_offsets) }
  718. /* Stabs debugging sections. */
  719. #define STABS_DEBUG \
  720. .stab 0 : { *(.stab) } \
  721. .stabstr 0 : { *(.stabstr) } \
  722. .stab.excl 0 : { *(.stab.excl) } \
  723. .stab.exclstr 0 : { *(.stab.exclstr) } \
  724. .stab.index 0 : { *(.stab.index) } \
  725. .stab.indexstr 0 : { *(.stab.indexstr) }
  726. /* Required sections not related to debugging. */
  727. #define ELF_DETAILS \
  728. .comment 0 : { *(.comment) } \
  729. .symtab 0 : { *(.symtab) } \
  730. .strtab 0 : { *(.strtab) } \
  731. .shstrtab 0 : { *(.shstrtab) }
  732. #ifdef CONFIG_GENERIC_BUG
  733. #define BUG_TABLE \
  734. . = ALIGN(8); \
  735. __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \
  736. BOUNDED_SECTION_BY(__bug_table, ___bug_table) \
  737. }
  738. #else
  739. #define BUG_TABLE
  740. #endif
  741. #ifdef CONFIG_UNWINDER_ORC
  742. #define ORC_UNWIND_TABLE \
  743. .orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) { \
  744. BOUNDED_SECTION_BY(.orc_header, _orc_header) \
  745. } \
  746. . = ALIGN(4); \
  747. .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \
  748. BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip) \
  749. } \
  750. . = ALIGN(2); \
  751. .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) { \
  752. BOUNDED_SECTION_BY(.orc_unwind, _orc_unwind) \
  753. } \
  754. text_size = _etext - _stext; \
  755. . = ALIGN(4); \
  756. .orc_lookup : AT(ADDR(.orc_lookup) - LOAD_OFFSET) { \
  757. orc_lookup = .; \
  758. . += (((text_size + LOOKUP_BLOCK_SIZE - 1) / \
  759. LOOKUP_BLOCK_SIZE) + 1) * 4; \
  760. orc_lookup_end = .; \
  761. }
  762. #else
  763. #define ORC_UNWIND_TABLE
  764. #endif
  765. /* Built-in firmware blobs */
  766. #ifdef CONFIG_FW_LOADER
  767. #define FW_LOADER_BUILT_IN_DATA \
  768. .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) ALIGN(8) { \
  769. BOUNDED_SECTION_PRE_LABEL(.builtin_fw, _builtin_fw, __start, __end) \
  770. }
  771. #else
  772. #define FW_LOADER_BUILT_IN_DATA
  773. #endif
  774. #ifdef CONFIG_PM_TRACE
  775. #define TRACEDATA \
  776. . = ALIGN(4); \
  777. .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \
  778. BOUNDED_SECTION_POST_LABEL(.tracedata, __tracedata, _start, _end) \
  779. }
  780. #else
  781. #define TRACEDATA
  782. #endif
  783. #ifdef CONFIG_PRINTK_INDEX
  784. #define PRINTK_INDEX \
  785. .printk_index : AT(ADDR(.printk_index) - LOAD_OFFSET) { \
  786. BOUNDED_SECTION_BY(.printk_index, _printk_index) \
  787. }
  788. #else
  789. #define PRINTK_INDEX
  790. #endif
  791. /*
  792. * Discard .note.GNU-stack, which is emitted as PROGBITS by the compiler.
  793. * Otherwise, the type of .notes section would become PROGBITS instead of NOTES.
  794. *
  795. * Also, discard .note.gnu.property, otherwise it forces the notes section to
  796. * be 8-byte aligned which causes alignment mismatches with the kernel's custom
  797. * 4-byte aligned notes.
  798. */
  799. #define NOTES \
  800. /DISCARD/ : { \
  801. *(.note.GNU-stack) \
  802. *(.note.gnu.property) \
  803. } \
  804. .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
  805. BOUNDED_SECTION_BY(.note.*, _notes) \
  806. } NOTES_HEADERS \
  807. NOTES_HEADERS_RESTORE
  808. #define INIT_SETUP(initsetup_align) \
  809. . = ALIGN(initsetup_align); \
  810. BOUNDED_SECTION_POST_LABEL(.init.setup, __setup, _start, _end)
  811. #define INIT_CALLS_LEVEL(level) \
  812. __initcall##level##_start = .; \
  813. KEEP(*(.initcall##level##.init)) \
  814. KEEP(*(.initcall##level##s.init)) \
  815. #define INIT_CALLS \
  816. __initcall_start = .; \
  817. KEEP(*(.initcallearly.init)) \
  818. INIT_CALLS_LEVEL(0) \
  819. INIT_CALLS_LEVEL(1) \
  820. INIT_CALLS_LEVEL(2) \
  821. INIT_CALLS_LEVEL(3) \
  822. INIT_CALLS_LEVEL(4) \
  823. INIT_CALLS_LEVEL(5) \
  824. INIT_CALLS_LEVEL(rootfs) \
  825. INIT_CALLS_LEVEL(6) \
  826. INIT_CALLS_LEVEL(7) \
  827. __initcall_end = .;
  828. #define CON_INITCALL \
  829. BOUNDED_SECTION_POST_LABEL(.con_initcall.init, __con_initcall, _start, _end)
  830. #define NAMED_SECTION(name) \
  831. . = ALIGN(8); \
  832. name : AT(ADDR(name) - LOAD_OFFSET) \
  833. { BOUNDED_SECTION_PRE_LABEL(name, name, __start_, __stop_) }
  834. #define RUNTIME_CONST(t,x) NAMED_SECTION(runtime_##t##_##x)
  835. #define RUNTIME_CONST_VARIABLES \
  836. RUNTIME_CONST(shift, d_hash_shift) \
  837. RUNTIME_CONST(ptr, dentry_hashtable)
  838. /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
  839. #define KUNIT_TABLE() \
  840. . = ALIGN(8); \
  841. BOUNDED_SECTION_POST_LABEL(.kunit_test_suites, __kunit_suites, _start, _end)
  842. /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
  843. #define KUNIT_INIT_TABLE() \
  844. . = ALIGN(8); \
  845. BOUNDED_SECTION_POST_LABEL(.kunit_init_test_suites, \
  846. __kunit_init_suites, _start, _end)
  847. #ifdef CONFIG_BLK_DEV_INITRD
  848. #define INIT_RAM_FS \
  849. . = ALIGN(4); \
  850. __initramfs_start = .; \
  851. KEEP(*(.init.ramfs)) \
  852. . = ALIGN(8); \
  853. KEEP(*(.init.ramfs.info))
  854. #else
  855. #define INIT_RAM_FS
  856. #endif
  857. /*
  858. * Memory encryption operates on a page basis. Since we need to clear
  859. * the memory encryption mask for this section, it needs to be aligned
  860. * on a page boundary and be a page-size multiple in length.
  861. *
  862. * Note: We use a separate section so that only this section gets
  863. * decrypted to avoid exposing more than we wish.
  864. */
  865. #ifdef CONFIG_AMD_MEM_ENCRYPT
  866. #define PERCPU_DECRYPTED_SECTION \
  867. . = ALIGN(PAGE_SIZE); \
  868. *(.data..percpu..decrypted) \
  869. . = ALIGN(PAGE_SIZE);
  870. #else
  871. #define PERCPU_DECRYPTED_SECTION
  872. #endif
  873. /*
  874. * Default discarded sections.
  875. *
  876. * Some archs want to discard exit text/data at runtime rather than
  877. * link time due to cross-section references such as alt instructions,
  878. * bug table, eh_frame, etc. DISCARDS must be the last of output
  879. * section definitions so that such archs put those in earlier section
  880. * definitions.
  881. */
  882. #ifdef RUNTIME_DISCARD_EXIT
  883. #define EXIT_DISCARDS
  884. #else
  885. #define EXIT_DISCARDS \
  886. EXIT_TEXT \
  887. EXIT_DATA
  888. #endif
  889. /*
  890. * Clang's -fprofile-arcs, -fsanitize=kernel-address, and
  891. * -fsanitize=thread produce unwanted sections (.eh_frame
  892. * and .init_array.*), but CONFIG_CONSTRUCTORS wants to
  893. * keep any .init_array.* sections.
  894. * https://llvm.org/pr46478
  895. */
  896. #ifdef CONFIG_UNWIND_TABLES
  897. #define DISCARD_EH_FRAME
  898. #else
  899. #define DISCARD_EH_FRAME *(.eh_frame)
  900. #endif
  901. #if defined(CONFIG_GCOV_KERNEL) || defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN)
  902. # ifdef CONFIG_CONSTRUCTORS
  903. # define SANITIZER_DISCARDS \
  904. DISCARD_EH_FRAME
  905. # else
  906. # define SANITIZER_DISCARDS \
  907. *(.init_array) *(.init_array.*) \
  908. DISCARD_EH_FRAME
  909. # endif
  910. #else
  911. # define SANITIZER_DISCARDS
  912. #endif
  913. #define COMMON_DISCARDS \
  914. SANITIZER_DISCARDS \
  915. PATCHABLE_DISCARDS \
  916. *(.discard) \
  917. *(.discard.*) \
  918. *(.export_symbol) \
  919. *(.modinfo) \
  920. /* ld.bfd warns about .gnu.version* even when not emitted */ \
  921. *(.gnu.version*) \
  922. #define DISCARDS \
  923. /DISCARD/ : { \
  924. EXIT_DISCARDS \
  925. EXIT_CALL \
  926. COMMON_DISCARDS \
  927. }
  928. /**
  929. * PERCPU_INPUT - the percpu input sections
  930. * @cacheline: cacheline size
  931. *
  932. * The core percpu section names and core symbols which do not rely
  933. * directly upon load addresses.
  934. *
  935. * @cacheline is used to align subsections to avoid false cacheline
  936. * sharing between subsections for different purposes.
  937. */
  938. #define PERCPU_INPUT(cacheline) \
  939. __per_cpu_start = .; \
  940. *(.data..percpu..first) \
  941. . = ALIGN(PAGE_SIZE); \
  942. *(.data..percpu..page_aligned) \
  943. . = ALIGN(cacheline); \
  944. *(.data..percpu..read_mostly) \
  945. . = ALIGN(cacheline); \
  946. *(.data..percpu) \
  947. *(.data..percpu..shared_aligned) \
  948. PERCPU_DECRYPTED_SECTION \
  949. __per_cpu_end = .;
  950. /**
  951. * PERCPU_VADDR - define output section for percpu area
  952. * @cacheline: cacheline size
  953. * @vaddr: explicit base address (optional)
  954. * @phdr: destination PHDR (optional)
  955. *
  956. * Macro which expands to output section for percpu area.
  957. *
  958. * @cacheline is used to align subsections to avoid false cacheline
  959. * sharing between subsections for different purposes.
  960. *
  961. * If @vaddr is not blank, it specifies explicit base address and all
  962. * percpu symbols will be offset from the given address. If blank,
  963. * @vaddr always equals @laddr + LOAD_OFFSET.
  964. *
  965. * @phdr defines the output PHDR to use if not blank. Be warned that
  966. * output PHDR is sticky. If @phdr is specified, the next output
  967. * section in the linker script will go there too. @phdr should have
  968. * a leading colon.
  969. *
  970. * Note that this macros defines __per_cpu_load as an absolute symbol.
  971. * If there is no need to put the percpu section at a predetermined
  972. * address, use PERCPU_SECTION.
  973. */
  974. #define PERCPU_VADDR(cacheline, vaddr, phdr) \
  975. __per_cpu_load = .; \
  976. .data..percpu vaddr : AT(__per_cpu_load - LOAD_OFFSET) { \
  977. PERCPU_INPUT(cacheline) \
  978. } phdr \
  979. . = __per_cpu_load + SIZEOF(.data..percpu);
  980. /**
  981. * PERCPU_SECTION - define output section for percpu area, simple version
  982. * @cacheline: cacheline size
  983. *
  984. * Align to PAGE_SIZE and outputs output section for percpu area. This
  985. * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and
  986. * __per_cpu_start will be identical.
  987. *
  988. * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,)
  989. * except that __per_cpu_load is defined as a relative symbol against
  990. * .data..percpu which is required for relocatable x86_32 configuration.
  991. */
  992. #define PERCPU_SECTION(cacheline) \
  993. . = ALIGN(PAGE_SIZE); \
  994. .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \
  995. __per_cpu_load = .; \
  996. PERCPU_INPUT(cacheline) \
  997. }
  998. /*
  999. * Definition of the high level *_SECTION macros
  1000. * They will fit only a subset of the architectures
  1001. */
  1002. /*
  1003. * Writeable data.
  1004. * All sections are combined in a single .data section.
  1005. * The sections following CONSTRUCTORS are arranged so their
  1006. * typical alignment matches.
  1007. * A cacheline is typical/always less than a PAGE_SIZE so
  1008. * the sections that has this restriction (or similar)
  1009. * is located before the ones requiring PAGE_SIZE alignment.
  1010. * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
  1011. * matches the requirement of PAGE_ALIGNED_DATA.
  1012. *
  1013. * use 0 as page_align if page_aligned data is not used */
  1014. #define RW_DATA(cacheline, pagealigned, inittask) \
  1015. . = ALIGN(PAGE_SIZE); \
  1016. .data : AT(ADDR(.data) - LOAD_OFFSET) { \
  1017. INIT_TASK_DATA(inittask) \
  1018. NOSAVE_DATA \
  1019. PAGE_ALIGNED_DATA(pagealigned) \
  1020. CACHELINE_ALIGNED_DATA(cacheline) \
  1021. READ_MOSTLY_DATA(cacheline) \
  1022. DATA_DATA \
  1023. CONSTRUCTORS \
  1024. } \
  1025. BUG_TABLE \
  1026. #define INIT_TEXT_SECTION(inittext_align) \
  1027. . = ALIGN(inittext_align); \
  1028. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { \
  1029. _sinittext = .; \
  1030. INIT_TEXT \
  1031. _einittext = .; \
  1032. }
  1033. #define INIT_DATA_SECTION(initsetup_align) \
  1034. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \
  1035. INIT_DATA \
  1036. INIT_SETUP(initsetup_align) \
  1037. INIT_CALLS \
  1038. CON_INITCALL \
  1039. INIT_RAM_FS \
  1040. }
  1041. #define BSS_SECTION(sbss_align, bss_align, stop_align) \
  1042. . = ALIGN(sbss_align); \
  1043. __bss_start = .; \
  1044. SBSS(sbss_align) \
  1045. BSS(bss_align) \
  1046. . = ALIGN(stop_align); \
  1047. __bss_stop = .;