Linux 4.4-rc4
[deliverable/linux.git] / arch / arm64 / kernel / vmlinux.lds.S
CommitLineData
8c2c3df3
CM
1/*
2 * ld script to make ARM Linux kernel
3 * taken from the i386 version by Russell King
4 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
5 */
6
7#include <asm-generic/vmlinux.lds.h>
87d1587b 8#include <asm/kernel-pgtable.h>
8c2c3df3
CM
9#include <asm/thread_info.h>
10#include <asm/memory.h>
11#include <asm/page.h>
da141706 12#include <asm/pgtable.h>
8c2c3df3 13
a2c1d73b
MR
14#include "image.h"
15
07c802bd
WD
16/* .exit.text needed in case of alternative patching */
17#define ARM_EXIT_KEEP(x) x
18#define ARM_EXIT_DISCARD(x)
8c2c3df3
CM
19
20OUTPUT_ARCH(aarch64)
af885f40 21ENTRY(_text)
8c2c3df3
CM
22
23jiffies = jiffies_64;
24
2240bbb6
MZ
25#define HYPERVISOR_TEXT \
26 /* \
06f75a1f
AB
27 * Align to 4 KB so that \
28 * a) the HYP vector table is at its minimum \
29 * alignment of 2048 bytes \
30 * b) the HYP init code will not cross a page \
31 * boundary if its size does not exceed \
32 * 4 KB (see related ASSERT() below) \
2240bbb6 33 */ \
06f75a1f 34 . = ALIGN(SZ_4K); \
2240bbb6
MZ
35 VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
36 *(.hyp.idmap.text) \
37 VMLINUX_SYMBOL(__hyp_idmap_text_end) = .; \
38 VMLINUX_SYMBOL(__hyp_text_start) = .; \
39 *(.hyp.text) \
40 VMLINUX_SYMBOL(__hyp_text_end) = .;
41
5dfe9d7d
AB
42#define IDMAP_TEXT \
43 . = ALIGN(SZ_4K); \
44 VMLINUX_SYMBOL(__idmap_text_start) = .; \
45 *(.idmap.text) \
46 VMLINUX_SYMBOL(__idmap_text_end) = .;
47
a352ea3e
AB
48/*
49 * The size of the PE/COFF section that covers the kernel image, which
50 * runs from stext to _edata, must be a round multiple of the PE/COFF
51 * FileAlignment, which we set to its minimum value of 0x200. 'stext'
52 * itself is 4 KB aligned, so padding out _edata to a 0x200 aligned
53 * boundary should be sufficient.
54 */
55PECOFF_FILE_ALIGNMENT = 0x200;
56
57#ifdef CONFIG_EFI
58#define PECOFF_EDATA_PADDING \
59 .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
60#else
61#define PECOFF_EDATA_PADDING
62#endif
63
cb083816 64#if defined(CONFIG_DEBUG_ALIGN_RODATA)
da141706
LA
65#define ALIGN_DEBUG_RO . = ALIGN(1<<SECTION_SHIFT);
66#define ALIGN_DEBUG_RO_MIN(min) ALIGN_DEBUG_RO
cb083816
MR
67#elif defined(CONFIG_DEBUG_RODATA)
68#define ALIGN_DEBUG_RO . = ALIGN(1<<PAGE_SHIFT);
69#define ALIGN_DEBUG_RO_MIN(min) ALIGN_DEBUG_RO
da141706
LA
70#else
71#define ALIGN_DEBUG_RO
72#define ALIGN_DEBUG_RO_MIN(min) . = ALIGN(min);
73#endif
74
8c2c3df3
CM
75SECTIONS
76{
77 /*
78 * XXX: The linker does not define how output sections are
79 * assigned to input sections when there are multiple statements
80 * matching the same input section name. There is no documented
81 * order of matching.
82 */
83 /DISCARD/ : {
84 ARM_EXIT_DISCARD(EXIT_TEXT)
85 ARM_EXIT_DISCARD(EXIT_DATA)
86 EXIT_CALL
87 *(.discard)
88 *(.discard.*)
89 }
90
91 . = PAGE_OFFSET + TEXT_OFFSET;
92
93 .head.text : {
94 _text = .;
95 HEAD_TEXT
96 }
da141706 97 ALIGN_DEBUG_RO
8c2c3df3
CM
98 .text : { /* Real text segment */
99 _stext = .; /* Text and read-only data */
8c2c3df3
CM
100 __exception_text_start = .;
101 *(.exception.text)
102 __exception_text_end = .;
103 IRQENTRY_TEXT
104 TEXT_TEXT
105 SCHED_TEXT
106 LOCK_TEXT
2240bbb6 107 HYPERVISOR_TEXT
5dfe9d7d 108 IDMAP_TEXT
8c2c3df3
CM
109 *(.fixup)
110 *(.gnu.warning)
111 . = ALIGN(16);
112 *(.got) /* Global offset table */
113 }
114
da141706 115 ALIGN_DEBUG_RO
8c2c3df3 116 RO_DATA(PAGE_SIZE)
adace895 117 EXCEPTION_TABLE(8)
c80b7ee8 118 NOTES
da141706 119 ALIGN_DEBUG_RO
8c2c3df3
CM
120 _etext = .; /* End of text and rodata section */
121
da141706 122 ALIGN_DEBUG_RO_MIN(PAGE_SIZE)
8c2c3df3
CM
123 __init_begin = .;
124
125 INIT_TEXT_SECTION(8)
126 .exit.text : {
127 ARM_EXIT_KEEP(EXIT_TEXT)
128 }
da141706
LA
129
130 ALIGN_DEBUG_RO_MIN(16)
8c2c3df3
CM
131 .init.data : {
132 INIT_DATA
133 INIT_SETUP(16)
134 INIT_CALLS
135 CON_INITCALL
136 SECURITY_INITCALL
137 INIT_RAM_FS
138 }
139 .exit.data : {
140 ARM_EXIT_KEEP(EXIT_DATA)
141 }
142
143 PERCPU_SECTION(64)
144
562c85ca 145 . = ALIGN(PAGE_SIZE);
8c2c3df3 146 __init_end = .;
3c620626 147
e039ee4e
AP
148 . = ALIGN(4);
149 .altinstructions : {
150 __alt_instructions = .;
151 *(.altinstructions)
152 __alt_instructions_end = .;
153 }
154 .altinstr_replacement : {
155 *(.altinstr_replacement)
156 }
157
158 . = ALIGN(PAGE_SIZE);
3c620626 159 _data = .;
3c620626
MS
160 _sdata = .;
161 RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE)
a352ea3e 162 PECOFF_EDATA_PADDING
3c620626 163 _edata = .;
8c2c3df3 164
8c2c3df3 165 BSS_SECTION(0, 0, 0)
bd00cd5f
MR
166
167 . = ALIGN(PAGE_SIZE);
168 idmap_pg_dir = .;
169 . += IDMAP_DIR_SIZE;
170 swapper_pg_dir = .;
171 . += SWAPPER_DIR_SIZE;
172
8c2c3df3
CM
173 _end = .;
174
175 STABS_DEBUG
a2c1d73b
MR
176
177 HEAD_SYMBOLS
8c2c3df3 178}
2240bbb6
MZ
179
180/*
5dfe9d7d 181 * The HYP init code and ID map text can't be longer than a page each,
06f75a1f 182 * and should not cross a page boundary.
2240bbb6 183 */
06f75a1f
AB
184ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
185 "HYP init code too big or misaligned")
5dfe9d7d
AB
186ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
187 "ID map text too big or misaligned")
da57a369
MR
188
189/*
190 * If padding is applied before .head.text, virt<->phys conversions will fail.
191 */
192ASSERT(_text == (PAGE_OFFSET + TEXT_OFFSET), "HEAD is misaligned")
This page took 0.160356 seconds and 5 git commands to generate.