vmlinux.lds.h 25 KB

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