vmlinux.lds.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  1. /*
  2. * Helper macros to support writing architecture specific
  3. * linker scripts.
  4. *
  5. * A minimal linker scripts has following content:
  6. * [This is a sample, architectures may have special requiriements]
  7. *
  8. * OUTPUT_FORMAT(...)
  9. * OUTPUT_ARCH(...)
  10. * ENTRY(...)
  11. * SECTIONS
  12. * {
  13. * . = START;
  14. * __init_begin = .;
  15. * HEAD_TEXT_SECTION
  16. * INIT_TEXT_SECTION(PAGE_SIZE)
  17. * INIT_DATA_SECTION(...)
  18. * PERCPU_SECTION(CACHELINE_SIZE)
  19. * __init_end = .;
  20. *
  21. * _stext = .;
  22. * TEXT_SECTION = 0
  23. * _etext = .;
  24. *
  25. * _sdata = .;
  26. * RO_DATA_SECTION(PAGE_SIZE)
  27. * RW_DATA_SECTION(...)
  28. * _edata = .;
  29. *
  30. * EXCEPTION_TABLE(...)
  31. * NOTES
  32. *
  33. * BSS_SECTION(0, 0, 0)
  34. * _end = .;
  35. *
  36. * STABS_DEBUG
  37. * DWARF_DEBUG
  38. *
  39. * DISCARDS // must be the last
  40. * }
  41. *
  42. * [__init_begin, __init_end] is the init section that may be freed after init
  43. * // __init_begin and __init_end should be page aligned, so that we can
  44. * // free the whole .init memory
  45. * [_stext, _etext] is the text section
  46. * [_sdata, _edata] is the data section
  47. *
  48. * Some of the included output section have their own set of constants.
  49. * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
  50. * [__nosave_begin, __nosave_end] for the nosave data
  51. */
  52. #ifndef LOAD_OFFSET
  53. #define LOAD_OFFSET 0
  54. #endif
  55. #include <linux/export.h>
  56. /* Align . to a 8 byte boundary equals to maximum function alignment. */
  57. #define ALIGN_FUNCTION() . = ALIGN(8)
  58. /*
  59. * Align to a 32 byte boundary equal to the
  60. * alignment gcc 4.5 uses for a struct
  61. */
  62. #define STRUCT_ALIGNMENT 32
  63. #define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)
  64. /* The actual configuration determine if the init/exit sections
  65. * are handled as text/data or they can be discarded (which
  66. * often happens at runtime)
  67. */
  68. #ifdef CONFIG_HOTPLUG_CPU
  69. #define CPU_KEEP(sec) *(.cpu##sec)
  70. #define CPU_DISCARD(sec)
  71. #else
  72. #define CPU_KEEP(sec)
  73. #define CPU_DISCARD(sec) *(.cpu##sec)
  74. #endif
  75. #if defined(CONFIG_MEMORY_HOTPLUG)
  76. #define MEM_KEEP(sec) *(.mem##sec)
  77. #define MEM_DISCARD(sec)
  78. #else
  79. #define MEM_KEEP(sec)
  80. #define MEM_DISCARD(sec) *(.mem##sec)
  81. #endif
  82. #ifdef CONFIG_FTRACE_MCOUNT_RECORD
  83. #define MCOUNT_REC() . = ALIGN(8); \
  84. VMLINUX_SYMBOL(__start_mcount_loc) = .; \
  85. *(__mcount_loc) \
  86. VMLINUX_SYMBOL(__stop_mcount_loc) = .;
  87. #else
  88. #define MCOUNT_REC()
  89. #endif
  90. #ifdef CONFIG_TRACE_BRANCH_PROFILING
  91. #define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \
  92. *(_ftrace_annotated_branch) \
  93. VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .;
  94. #else
  95. #define LIKELY_PROFILE()
  96. #endif
  97. #ifdef CONFIG_PROFILE_ALL_BRANCHES
  98. #define BRANCH_PROFILE() VMLINUX_SYMBOL(__start_branch_profile) = .; \
  99. *(_ftrace_branch) \
  100. VMLINUX_SYMBOL(__stop_branch_profile) = .;
  101. #else
  102. #define BRANCH_PROFILE()
  103. #endif
  104. #ifdef CONFIG_KPROBES
  105. #define KPROBE_BLACKLIST() . = ALIGN(8); \
  106. VMLINUX_SYMBOL(__start_kprobe_blacklist) = .; \
  107. *(_kprobe_blacklist) \
  108. VMLINUX_SYMBOL(__stop_kprobe_blacklist) = .;
  109. #else
  110. #define KPROBE_BLACKLIST()
  111. #endif
  112. #ifdef CONFIG_EVENT_TRACING
  113. #define FTRACE_EVENTS() . = ALIGN(8); \
  114. VMLINUX_SYMBOL(__start_ftrace_events) = .; \
  115. *(_ftrace_events) \
  116. VMLINUX_SYMBOL(__stop_ftrace_events) = .; \
  117. VMLINUX_SYMBOL(__start_ftrace_enum_maps) = .; \
  118. *(_ftrace_enum_map) \
  119. VMLINUX_SYMBOL(__stop_ftrace_enum_maps) = .;
  120. #else
  121. #define FTRACE_EVENTS()
  122. #endif
  123. #ifdef CONFIG_TRACING
  124. #define TRACE_PRINTKS() VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .; \
  125. *(__trace_printk_fmt) /* Trace_printk fmt' pointer */ \
  126. VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .;
  127. #define TRACEPOINT_STR() VMLINUX_SYMBOL(__start___tracepoint_str) = .; \
  128. *(__tracepoint_str) /* Trace_printk fmt' pointer */ \
  129. VMLINUX_SYMBOL(__stop___tracepoint_str) = .;
  130. #else
  131. #define TRACE_PRINTKS()
  132. #define TRACEPOINT_STR()
  133. #endif
  134. #ifdef CONFIG_FTRACE_SYSCALLS
  135. #define TRACE_SYSCALLS() . = ALIGN(8); \
  136. VMLINUX_SYMBOL(__start_syscalls_metadata) = .; \
  137. *(__syscalls_metadata) \
  138. VMLINUX_SYMBOL(__stop_syscalls_metadata) = .;
  139. #else
  140. #define TRACE_SYSCALLS()
  141. #endif
  142. #ifdef CONFIG_SERIAL_EARLYCON
  143. #define EARLYCON_TABLE() STRUCT_ALIGN(); \
  144. VMLINUX_SYMBOL(__earlycon_table) = .; \
  145. *(__earlycon_table) \
  146. *(__earlycon_table_end)
  147. #else
  148. #define EARLYCON_TABLE()
  149. #endif
  150. #define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name)
  151. #define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name)
  152. #define OF_TABLE(cfg, name) __OF_TABLE(config_enabled(cfg), name)
  153. #define _OF_TABLE_0(name)
  154. #define _OF_TABLE_1(name) \
  155. . = ALIGN(8); \
  156. VMLINUX_SYMBOL(__##name##_of_table) = .; \
  157. *(__##name##_of_table) \
  158. *(__##name##_of_table_end)
  159. #define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc)
  160. #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
  161. #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk)
  162. #define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu)
  163. #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
  164. #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)
  165. #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
  166. #define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)
  167. #define KERNEL_DTB() \
  168. STRUCT_ALIGN(); \
  169. VMLINUX_SYMBOL(__dtb_start) = .; \
  170. *(.dtb.init.rodata) \
  171. VMLINUX_SYMBOL(__dtb_end) = .;
  172. /* .data section */
  173. #define DATA_DATA \
  174. *(.data) \
  175. *(.ref.data) \
  176. *(.data..shared_aligned) /* percpu related */ \
  177. MEM_KEEP(init.data) \
  178. MEM_KEEP(exit.data) \
  179. *(.data.unlikely) \
  180. STRUCT_ALIGN(); \
  181. *(__tracepoints) \
  182. /* implement dynamic printk debug */ \
  183. . = ALIGN(8); \
  184. VMLINUX_SYMBOL(__start___jump_table) = .; \
  185. *(__jump_table) \
  186. VMLINUX_SYMBOL(__stop___jump_table) = .; \
  187. . = ALIGN(8); \
  188. VMLINUX_SYMBOL(__start___verbose) = .; \
  189. *(__verbose) \
  190. VMLINUX_SYMBOL(__stop___verbose) = .; \
  191. LIKELY_PROFILE() \
  192. BRANCH_PROFILE() \
  193. TRACE_PRINTKS() \
  194. TRACEPOINT_STR()
  195. /*
  196. * Data section helpers
  197. */
  198. #define NOSAVE_DATA \
  199. . = ALIGN(PAGE_SIZE); \
  200. VMLINUX_SYMBOL(__nosave_begin) = .; \
  201. *(.data..nosave) \
  202. . = ALIGN(PAGE_SIZE); \
  203. VMLINUX_SYMBOL(__nosave_end) = .;
  204. #define PAGE_ALIGNED_DATA(page_align) \
  205. . = ALIGN(page_align); \
  206. *(.data..page_aligned)
  207. #define READ_MOSTLY_DATA(align) \
  208. . = ALIGN(align); \
  209. *(.data..read_mostly) \
  210. . = ALIGN(align);
  211. #define CACHELINE_ALIGNED_DATA(align) \
  212. . = ALIGN(align); \
  213. *(.data..cacheline_aligned)
  214. #define INIT_TASK_DATA(align) \
  215. . = ALIGN(align); \
  216. *(.data..init_task)
  217. /*
  218. * Read only Data
  219. */
  220. #define RO_DATA_SECTION(align) \
  221. . = ALIGN((align)); \
  222. .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
  223. VMLINUX_SYMBOL(__start_rodata) = .; \
  224. *(.rodata) *(.rodata.*) \
  225. *(__vermagic) /* Kernel version magic */ \
  226. . = ALIGN(8); \
  227. VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
  228. *(__tracepoints_ptrs) /* Tracepoints: pointer array */\
  229. VMLINUX_SYMBOL(__stop___tracepoints_ptrs) = .; \
  230. *(__tracepoints_strings)/* Tracepoints: strings */ \
  231. } \
  232. \
  233. .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
  234. *(.rodata1) \
  235. } \
  236. \
  237. BUG_TABLE \
  238. \
  239. /* PCI quirks */ \
  240. .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
  241. VMLINUX_SYMBOL(__start_pci_fixups_early) = .; \
  242. *(.pci_fixup_early) \
  243. VMLINUX_SYMBOL(__end_pci_fixups_early) = .; \
  244. VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
  245. *(.pci_fixup_header) \
  246. VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
  247. VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \
  248. *(.pci_fixup_final) \
  249. VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \
  250. VMLINUX_SYMBOL(__start_pci_fixups_enable) = .; \
  251. *(.pci_fixup_enable) \
  252. VMLINUX_SYMBOL(__end_pci_fixups_enable) = .; \
  253. VMLINUX_SYMBOL(__start_pci_fixups_resume) = .; \
  254. *(.pci_fixup_resume) \
  255. VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \
  256. VMLINUX_SYMBOL(__start_pci_fixups_resume_early) = .; \
  257. *(.pci_fixup_resume_early) \
  258. VMLINUX_SYMBOL(__end_pci_fixups_resume_early) = .; \
  259. VMLINUX_SYMBOL(__start_pci_fixups_suspend) = .; \
  260. *(.pci_fixup_suspend) \
  261. VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .; \
  262. VMLINUX_SYMBOL(__start_pci_fixups_suspend_late) = .; \
  263. *(.pci_fixup_suspend_late) \
  264. VMLINUX_SYMBOL(__end_pci_fixups_suspend_late) = .; \
  265. } \
  266. \
  267. /* Built-in firmware blobs */ \
  268. .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \
  269. VMLINUX_SYMBOL(__start_builtin_fw) = .; \
  270. *(.builtin_fw) \
  271. VMLINUX_SYMBOL(__end_builtin_fw) = .; \
  272. } \
  273. \
  274. TRACEDATA \
  275. \
  276. /* Kernel symbol table: Normal symbols */ \
  277. __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
  278. VMLINUX_SYMBOL(__start___ksymtab) = .; \
  279. *(SORT(___ksymtab+*)) \
  280. VMLINUX_SYMBOL(__stop___ksymtab) = .; \
  281. } \
  282. \
  283. /* Kernel symbol table: GPL-only symbols */ \
  284. __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
  285. VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
  286. *(SORT(___ksymtab_gpl+*)) \
  287. VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
  288. } \
  289. \
  290. /* Kernel symbol table: Normal unused symbols */ \
  291. __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \
  292. VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \
  293. *(SORT(___ksymtab_unused+*)) \
  294. VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \
  295. } \
  296. \
  297. /* Kernel symbol table: GPL-only unused symbols */ \
  298. __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
  299. VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \
  300. *(SORT(___ksymtab_unused_gpl+*)) \
  301. VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \
  302. } \
  303. \
  304. /* Kernel symbol table: GPL-future-only symbols */ \
  305. __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
  306. VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \
  307. *(SORT(___ksymtab_gpl_future+*)) \
  308. VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \
  309. } \
  310. \
  311. /* Kernel symbol table: Normal symbols */ \
  312. __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
  313. VMLINUX_SYMBOL(__start___kcrctab) = .; \
  314. *(SORT(___kcrctab+*)) \
  315. VMLINUX_SYMBOL(__stop___kcrctab) = .; \
  316. } \
  317. \
  318. /* Kernel symbol table: GPL-only symbols */ \
  319. __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
  320. VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \
  321. *(SORT(___kcrctab_gpl+*)) \
  322. VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
  323. } \
  324. \
  325. /* Kernel symbol table: Normal unused symbols */ \
  326. __kcrctab_unused : AT(ADDR(__kcrctab_unused) - LOAD_OFFSET) { \
  327. VMLINUX_SYMBOL(__start___kcrctab_unused) = .; \
  328. *(SORT(___kcrctab_unused+*)) \
  329. VMLINUX_SYMBOL(__stop___kcrctab_unused) = .; \
  330. } \
  331. \
  332. /* Kernel symbol table: GPL-only unused symbols */ \
  333. __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
  334. VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .; \
  335. *(SORT(___kcrctab_unused_gpl+*)) \
  336. VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .; \
  337. } \
  338. \
  339. /* Kernel symbol table: GPL-future-only symbols */ \
  340. __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
  341. VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \
  342. *(SORT(___kcrctab_gpl_future+*)) \
  343. VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .; \
  344. } \
  345. \
  346. /* Kernel symbol table: strings */ \
  347. __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
  348. *(__ksymtab_strings) \
  349. } \
  350. \
  351. /* __*init sections */ \
  352. __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
  353. *(.ref.rodata) \
  354. MEM_KEEP(init.rodata) \
  355. MEM_KEEP(exit.rodata) \
  356. } \
  357. \
  358. /* Built-in module parameters. */ \
  359. __param : AT(ADDR(__param) - LOAD_OFFSET) { \
  360. VMLINUX_SYMBOL(__start___param) = .; \
  361. *(__param) \
  362. VMLINUX_SYMBOL(__stop___param) = .; \
  363. } \
  364. \
  365. /* Built-in module versions. */ \
  366. __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
  367. VMLINUX_SYMBOL(__start___modver) = .; \
  368. *(__modver) \
  369. VMLINUX_SYMBOL(__stop___modver) = .; \
  370. . = ALIGN((align)); \
  371. VMLINUX_SYMBOL(__end_rodata) = .; \
  372. } \
  373. . = ALIGN((align));
  374. /* RODATA & RO_DATA provided for backward compatibility.
  375. * All archs are supposed to use RO_DATA() */
  376. #define RODATA RO_DATA_SECTION(4096)
  377. #define RO_DATA(align) RO_DATA_SECTION(align)
  378. #define SECURITY_INIT \
  379. .security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \
  380. VMLINUX_SYMBOL(__security_initcall_start) = .; \
  381. *(.security_initcall.init) \
  382. VMLINUX_SYMBOL(__security_initcall_end) = .; \
  383. }
  384. /* .text section. Map to function alignment to avoid address changes
  385. * during second ld run in second ld pass when generating System.map */
  386. #define TEXT_TEXT \
  387. ALIGN_FUNCTION(); \
  388. *(.text.hot) \
  389. *(.text .text.fixup) \
  390. *(.ref.text) \
  391. MEM_KEEP(init.text) \
  392. MEM_KEEP(exit.text) \
  393. *(.text.unlikely)
  394. /* sched.text is aling to function alignment to secure we have same
  395. * address even at second ld pass when generating System.map */
  396. #define SCHED_TEXT \
  397. ALIGN_FUNCTION(); \
  398. VMLINUX_SYMBOL(__sched_text_start) = .; \
  399. *(.sched.text) \
  400. VMLINUX_SYMBOL(__sched_text_end) = .;
  401. /* spinlock.text is aling to function alignment to secure we have same
  402. * address even at second ld pass when generating System.map */
  403. #define LOCK_TEXT \
  404. ALIGN_FUNCTION(); \
  405. VMLINUX_SYMBOL(__lock_text_start) = .; \
  406. *(.spinlock.text) \
  407. VMLINUX_SYMBOL(__lock_text_end) = .;
  408. #define KPROBES_TEXT \
  409. ALIGN_FUNCTION(); \
  410. VMLINUX_SYMBOL(__kprobes_text_start) = .; \
  411. *(.kprobes.text) \
  412. VMLINUX_SYMBOL(__kprobes_text_end) = .;
  413. #define ENTRY_TEXT \
  414. ALIGN_FUNCTION(); \
  415. VMLINUX_SYMBOL(__entry_text_start) = .; \
  416. *(.entry.text) \
  417. VMLINUX_SYMBOL(__entry_text_end) = .;
  418. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  419. #define IRQENTRY_TEXT \
  420. ALIGN_FUNCTION(); \
  421. VMLINUX_SYMBOL(__irqentry_text_start) = .; \
  422. *(.irqentry.text) \
  423. VMLINUX_SYMBOL(__irqentry_text_end) = .;
  424. #else
  425. #define IRQENTRY_TEXT
  426. #endif
  427. /* Section used for early init (in .S files) */
  428. #define HEAD_TEXT *(.head.text)
  429. #define HEAD_TEXT_SECTION \
  430. .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { \
  431. HEAD_TEXT \
  432. }
  433. /*
  434. * Exception table
  435. */
  436. #define EXCEPTION_TABLE(align) \
  437. . = ALIGN(align); \
  438. __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \
  439. VMLINUX_SYMBOL(__start___ex_table) = .; \
  440. *(__ex_table) \
  441. VMLINUX_SYMBOL(__stop___ex_table) = .; \
  442. }
  443. /*
  444. * Init task
  445. */
  446. #define INIT_TASK_DATA_SECTION(align) \
  447. . = ALIGN(align); \
  448. .data..init_task : AT(ADDR(.data..init_task) - LOAD_OFFSET) { \
  449. INIT_TASK_DATA(align) \
  450. }
  451. #ifdef CONFIG_CONSTRUCTORS
  452. #define KERNEL_CTORS() . = ALIGN(8); \
  453. VMLINUX_SYMBOL(__ctors_start) = .; \
  454. *(.ctors) \
  455. *(SORT(.init_array.*)) \
  456. *(.init_array) \
  457. VMLINUX_SYMBOL(__ctors_end) = .;
  458. #else
  459. #define KERNEL_CTORS()
  460. #endif
  461. /* init and exit section handling */
  462. #define INIT_DATA \
  463. *(.init.data) \
  464. MEM_DISCARD(init.data) \
  465. KERNEL_CTORS() \
  466. MCOUNT_REC() \
  467. *(.init.rodata) \
  468. FTRACE_EVENTS() \
  469. TRACE_SYSCALLS() \
  470. KPROBE_BLACKLIST() \
  471. MEM_DISCARD(init.rodata) \
  472. CLK_OF_TABLES() \
  473. RESERVEDMEM_OF_TABLES() \
  474. CLKSRC_OF_TABLES() \
  475. IOMMU_OF_TABLES() \
  476. CPU_METHOD_OF_TABLES() \
  477. CPUIDLE_METHOD_OF_TABLES() \
  478. KERNEL_DTB() \
  479. IRQCHIP_OF_MATCH_TABLE() \
  480. EARLYCON_TABLE() \
  481. EARLYCON_OF_TABLES()
  482. #define INIT_TEXT \
  483. *(.init.text) \
  484. MEM_DISCARD(init.text)
  485. #define EXIT_DATA \
  486. *(.exit.data) \
  487. MEM_DISCARD(exit.data) \
  488. MEM_DISCARD(exit.rodata)
  489. #define EXIT_TEXT \
  490. *(.exit.text) \
  491. MEM_DISCARD(exit.text)
  492. #define EXIT_CALL \
  493. *(.exitcall.exit)
  494. /*
  495. * bss (Block Started by Symbol) - uninitialized data
  496. * zeroed during startup
  497. */
  498. #define SBSS(sbss_align) \
  499. . = ALIGN(sbss_align); \
  500. .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
  501. *(.sbss) \
  502. *(.scommon) \
  503. }
  504. /*
  505. * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
  506. * sections to the front of bss.
  507. */
  508. #ifndef BSS_FIRST_SECTIONS
  509. #define BSS_FIRST_SECTIONS
  510. #endif
  511. #define BSS(bss_align) \
  512. . = ALIGN(bss_align); \
  513. .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \
  514. BSS_FIRST_SECTIONS \
  515. *(.bss..page_aligned) \
  516. *(.dynbss) \
  517. *(.bss) \
  518. *(COMMON) \
  519. }
  520. /*
  521. * DWARF debug sections.
  522. * Symbols in the DWARF debugging sections are relative to
  523. * the beginning of the section so we begin them at 0.
  524. */
  525. #define DWARF_DEBUG \
  526. /* DWARF 1 */ \
  527. .debug 0 : { *(.debug) } \
  528. .line 0 : { *(.line) } \
  529. /* GNU DWARF 1 extensions */ \
  530. .debug_srcinfo 0 : { *(.debug_srcinfo) } \
  531. .debug_sfnames 0 : { *(.debug_sfnames) } \
  532. /* DWARF 1.1 and DWARF 2 */ \
  533. .debug_aranges 0 : { *(.debug_aranges) } \
  534. .debug_pubnames 0 : { *(.debug_pubnames) } \
  535. /* DWARF 2 */ \
  536. .debug_info 0 : { *(.debug_info \
  537. .gnu.linkonce.wi.*) } \
  538. .debug_abbrev 0 : { *(.debug_abbrev) } \
  539. .debug_line 0 : { *(.debug_line) } \
  540. .debug_frame 0 : { *(.debug_frame) } \
  541. .debug_str 0 : { *(.debug_str) } \
  542. .debug_loc 0 : { *(.debug_loc) } \
  543. .debug_macinfo 0 : { *(.debug_macinfo) } \
  544. /* SGI/MIPS DWARF 2 extensions */ \
  545. .debug_weaknames 0 : { *(.debug_weaknames) } \
  546. .debug_funcnames 0 : { *(.debug_funcnames) } \
  547. .debug_typenames 0 : { *(.debug_typenames) } \
  548. .debug_varnames 0 : { *(.debug_varnames) } \
  549. /* Stabs debugging sections. */
  550. #define STABS_DEBUG \
  551. .stab 0 : { *(.stab) } \
  552. .stabstr 0 : { *(.stabstr) } \
  553. .stab.excl 0 : { *(.stab.excl) } \
  554. .stab.exclstr 0 : { *(.stab.exclstr) } \
  555. .stab.index 0 : { *(.stab.index) } \
  556. .stab.indexstr 0 : { *(.stab.indexstr) } \
  557. .comment 0 : { *(.comment) }
  558. #ifdef CONFIG_GENERIC_BUG
  559. #define BUG_TABLE \
  560. . = ALIGN(8); \
  561. __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \
  562. VMLINUX_SYMBOL(__start___bug_table) = .; \
  563. *(__bug_table) \
  564. VMLINUX_SYMBOL(__stop___bug_table) = .; \
  565. }
  566. #else
  567. #define BUG_TABLE
  568. #endif
  569. #ifdef CONFIG_PM_TRACE
  570. #define TRACEDATA \
  571. . = ALIGN(4); \
  572. .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \
  573. VMLINUX_SYMBOL(__tracedata_start) = .; \
  574. *(.tracedata) \
  575. VMLINUX_SYMBOL(__tracedata_end) = .; \
  576. }
  577. #else
  578. #define TRACEDATA
  579. #endif
  580. #define NOTES \
  581. .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
  582. VMLINUX_SYMBOL(__start_notes) = .; \
  583. *(.note.*) \
  584. VMLINUX_SYMBOL(__stop_notes) = .; \
  585. }
  586. #define INIT_SETUP(initsetup_align) \
  587. . = ALIGN(initsetup_align); \
  588. VMLINUX_SYMBOL(__setup_start) = .; \
  589. *(.init.setup) \
  590. VMLINUX_SYMBOL(__setup_end) = .;
  591. #define INIT_CALLS_LEVEL(level) \
  592. VMLINUX_SYMBOL(__initcall##level##_start) = .; \
  593. *(.initcall##level##.init) \
  594. *(.initcall##level##s.init) \
  595. #define INIT_CALLS \
  596. VMLINUX_SYMBOL(__initcall_start) = .; \
  597. *(.initcallearly.init) \
  598. INIT_CALLS_LEVEL(0) \
  599. INIT_CALLS_LEVEL(1) \
  600. INIT_CALLS_LEVEL(2) \
  601. INIT_CALLS_LEVEL(3) \
  602. INIT_CALLS_LEVEL(4) \
  603. INIT_CALLS_LEVEL(5) \
  604. INIT_CALLS_LEVEL(rootfs) \
  605. INIT_CALLS_LEVEL(6) \
  606. INIT_CALLS_LEVEL(7) \
  607. VMLINUX_SYMBOL(__initcall_end) = .;
  608. #define CON_INITCALL \
  609. VMLINUX_SYMBOL(__con_initcall_start) = .; \
  610. *(.con_initcall.init) \
  611. VMLINUX_SYMBOL(__con_initcall_end) = .;
  612. #define SECURITY_INITCALL \
  613. VMLINUX_SYMBOL(__security_initcall_start) = .; \
  614. *(.security_initcall.init) \
  615. VMLINUX_SYMBOL(__security_initcall_end) = .;
  616. #ifdef CONFIG_BLK_DEV_INITRD
  617. #define INIT_RAM_FS \
  618. . = ALIGN(4); \
  619. VMLINUX_SYMBOL(__initramfs_start) = .; \
  620. *(.init.ramfs) \
  621. . = ALIGN(8); \
  622. *(.init.ramfs.info)
  623. #else
  624. #define INIT_RAM_FS
  625. #endif
  626. /*
  627. * Default discarded sections.
  628. *
  629. * Some archs want to discard exit text/data at runtime rather than
  630. * link time due to cross-section references such as alt instructions,
  631. * bug table, eh_frame, etc. DISCARDS must be the last of output
  632. * section definitions so that such archs put those in earlier section
  633. * definitions.
  634. */
  635. #define DISCARDS \
  636. /DISCARD/ : { \
  637. EXIT_TEXT \
  638. EXIT_DATA \
  639. EXIT_CALL \
  640. *(.discard) \
  641. *(.discard.*) \
  642. }
  643. /**
  644. * PERCPU_INPUT - the percpu input sections
  645. * @cacheline: cacheline size
  646. *
  647. * The core percpu section names and core symbols which do not rely
  648. * directly upon load addresses.
  649. *
  650. * @cacheline is used to align subsections to avoid false cacheline
  651. * sharing between subsections for different purposes.
  652. */
  653. #define PERCPU_INPUT(cacheline) \
  654. VMLINUX_SYMBOL(__per_cpu_start) = .; \
  655. *(.data..percpu..first) \
  656. . = ALIGN(PAGE_SIZE); \
  657. *(.data..percpu..page_aligned) \
  658. . = ALIGN(cacheline); \
  659. *(.data..percpu..read_mostly) \
  660. . = ALIGN(cacheline); \
  661. *(.data..percpu) \
  662. *(.data..percpu..shared_aligned) \
  663. VMLINUX_SYMBOL(__per_cpu_end) = .;
  664. /**
  665. * PERCPU_VADDR - define output section for percpu area
  666. * @cacheline: cacheline size
  667. * @vaddr: explicit base address (optional)
  668. * @phdr: destination PHDR (optional)
  669. *
  670. * Macro which expands to output section for percpu area.
  671. *
  672. * @cacheline is used to align subsections to avoid false cacheline
  673. * sharing between subsections for different purposes.
  674. *
  675. * If @vaddr is not blank, it specifies explicit base address and all
  676. * percpu symbols will be offset from the given address. If blank,
  677. * @vaddr always equals @laddr + LOAD_OFFSET.
  678. *
  679. * @phdr defines the output PHDR to use if not blank. Be warned that
  680. * output PHDR is sticky. If @phdr is specified, the next output
  681. * section in the linker script will go there too. @phdr should have
  682. * a leading colon.
  683. *
  684. * Note that this macros defines __per_cpu_load as an absolute symbol.
  685. * If there is no need to put the percpu section at a predetermined
  686. * address, use PERCPU_SECTION.
  687. */
  688. #define PERCPU_VADDR(cacheline, vaddr, phdr) \
  689. VMLINUX_SYMBOL(__per_cpu_load) = .; \
  690. .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
  691. - LOAD_OFFSET) { \
  692. PERCPU_INPUT(cacheline) \
  693. } phdr \
  694. . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
  695. /**
  696. * PERCPU_SECTION - define output section for percpu area, simple version
  697. * @cacheline: cacheline size
  698. *
  699. * Align to PAGE_SIZE and outputs output section for percpu area. This
  700. * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and
  701. * __per_cpu_start will be identical.
  702. *
  703. * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,)
  704. * except that __per_cpu_load is defined as a relative symbol against
  705. * .data..percpu which is required for relocatable x86_32 configuration.
  706. */
  707. #define PERCPU_SECTION(cacheline) \
  708. . = ALIGN(PAGE_SIZE); \
  709. .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \
  710. VMLINUX_SYMBOL(__per_cpu_load) = .; \
  711. PERCPU_INPUT(cacheline) \
  712. }
  713. /*
  714. * Definition of the high level *_SECTION macros
  715. * They will fit only a subset of the architectures
  716. */
  717. /*
  718. * Writeable data.
  719. * All sections are combined in a single .data section.
  720. * The sections following CONSTRUCTORS are arranged so their
  721. * typical alignment matches.
  722. * A cacheline is typical/always less than a PAGE_SIZE so
  723. * the sections that has this restriction (or similar)
  724. * is located before the ones requiring PAGE_SIZE alignment.
  725. * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
  726. * matches the requirement of PAGE_ALIGNED_DATA.
  727. *
  728. * use 0 as page_align if page_aligned data is not used */
  729. #define RW_DATA_SECTION(cacheline, pagealigned, inittask) \
  730. . = ALIGN(PAGE_SIZE); \
  731. .data : AT(ADDR(.data) - LOAD_OFFSET) { \
  732. INIT_TASK_DATA(inittask) \
  733. NOSAVE_DATA \
  734. PAGE_ALIGNED_DATA(pagealigned) \
  735. CACHELINE_ALIGNED_DATA(cacheline) \
  736. READ_MOSTLY_DATA(cacheline) \
  737. DATA_DATA \
  738. CONSTRUCTORS \
  739. }
  740. #define INIT_TEXT_SECTION(inittext_align) \
  741. . = ALIGN(inittext_align); \
  742. .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { \
  743. VMLINUX_SYMBOL(_sinittext) = .; \
  744. INIT_TEXT \
  745. VMLINUX_SYMBOL(_einittext) = .; \
  746. }
  747. #define INIT_DATA_SECTION(initsetup_align) \
  748. .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \
  749. INIT_DATA \
  750. INIT_SETUP(initsetup_align) \
  751. INIT_CALLS \
  752. CON_INITCALL \
  753. SECURITY_INITCALL \
  754. INIT_RAM_FS \
  755. }
  756. #define BSS_SECTION(sbss_align, bss_align, stop_align) \
  757. . = ALIGN(sbss_align); \
  758. VMLINUX_SYMBOL(__bss_start) = .; \
  759. SBSS(sbss_align) \
  760. BSS(bss_align) \
  761. . = ALIGN(stop_align); \
  762. VMLINUX_SYMBOL(__bss_stop) = .;