vmlinux.lds.h 24 KB

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