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