vmlinux.lds.h 24 KB

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