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