vmlinux.lds.h 24 KB

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