vmlinux.lds.h 23 KB

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