vmlinux.lds.h 24 KB

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