vmlinux.lds.h 24 KB

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