vmlinux.lds.h 24 KB

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