vmlinux.lds.h 24 KB

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