]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/arm64/kernel/vmlinux.lds.S
arm64: add better page protections to arm64
[mirror_ubuntu-artful-kernel.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>
8#include <asm/thread_info.h>
9#include <asm/memory.h>
10#include <asm/page.h>
da141706 11#include <asm/pgtable.h>
8c2c3df3 12
a2c1d73b
MR
13#include "image.h"
14
07c802bd
WD
15/* .exit.text needed in case of alternative patching */
16#define ARM_EXIT_KEEP(x) x
17#define ARM_EXIT_DISCARD(x)
8c2c3df3
CM
18
19OUTPUT_ARCH(aarch64)
af885f40 20ENTRY(_text)
8c2c3df3
CM
21
22jiffies = jiffies_64;
23
2240bbb6
MZ
24#define HYPERVISOR_TEXT \
25 /* \
26 * Force the alignment to be compatible with \
27 * the vectors requirements \
28 */ \
29 . = ALIGN(2048); \
30 VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
31 *(.hyp.idmap.text) \
32 VMLINUX_SYMBOL(__hyp_idmap_text_end) = .; \
33 VMLINUX_SYMBOL(__hyp_text_start) = .; \
34 *(.hyp.text) \
35 VMLINUX_SYMBOL(__hyp_text_end) = .;
36
a352ea3e
AB
37/*
38 * The size of the PE/COFF section that covers the kernel image, which
39 * runs from stext to _edata, must be a round multiple of the PE/COFF
40 * FileAlignment, which we set to its minimum value of 0x200. 'stext'
41 * itself is 4 KB aligned, so padding out _edata to a 0x200 aligned
42 * boundary should be sufficient.
43 */
44PECOFF_FILE_ALIGNMENT = 0x200;
45
46#ifdef CONFIG_EFI
47#define PECOFF_EDATA_PADDING \
48 .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
49#else
50#define PECOFF_EDATA_PADDING
51#endif
52
da141706
LA
53#ifdef CONFIG_DEBUG_ALIGN_RODATA
54#define ALIGN_DEBUG_RO . = ALIGN(1<<SECTION_SHIFT);
55#define ALIGN_DEBUG_RO_MIN(min) ALIGN_DEBUG_RO
56#else
57#define ALIGN_DEBUG_RO
58#define ALIGN_DEBUG_RO_MIN(min) . = ALIGN(min);
59#endif
60
8c2c3df3
CM
61SECTIONS
62{
63 /*
64 * XXX: The linker does not define how output sections are
65 * assigned to input sections when there are multiple statements
66 * matching the same input section name. There is no documented
67 * order of matching.
68 */
69 /DISCARD/ : {
70 ARM_EXIT_DISCARD(EXIT_TEXT)
71 ARM_EXIT_DISCARD(EXIT_DATA)
72 EXIT_CALL
73 *(.discard)
74 *(.discard.*)
75 }
76
77 . = PAGE_OFFSET + TEXT_OFFSET;
78
79 .head.text : {
80 _text = .;
81 HEAD_TEXT
82 }
da141706 83 ALIGN_DEBUG_RO
8c2c3df3
CM
84 .text : { /* Real text segment */
85 _stext = .; /* Text and read-only data */
8c2c3df3
CM
86 __exception_text_start = .;
87 *(.exception.text)
88 __exception_text_end = .;
89 IRQENTRY_TEXT
90 TEXT_TEXT
91 SCHED_TEXT
92 LOCK_TEXT
2240bbb6 93 HYPERVISOR_TEXT
8c2c3df3
CM
94 *(.fixup)
95 *(.gnu.warning)
96 . = ALIGN(16);
97 *(.got) /* Global offset table */
98 }
99
da141706 100 ALIGN_DEBUG_RO
8c2c3df3 101 RO_DATA(PAGE_SIZE)
adace895 102 EXCEPTION_TABLE(8)
c80b7ee8 103 NOTES
da141706 104 ALIGN_DEBUG_RO
8c2c3df3
CM
105 _etext = .; /* End of text and rodata section */
106
da141706 107 ALIGN_DEBUG_RO_MIN(PAGE_SIZE)
8c2c3df3
CM
108 __init_begin = .;
109
110 INIT_TEXT_SECTION(8)
111 .exit.text : {
112 ARM_EXIT_KEEP(EXIT_TEXT)
113 }
da141706
LA
114
115 ALIGN_DEBUG_RO_MIN(16)
8c2c3df3
CM
116 .init.data : {
117 INIT_DATA
118 INIT_SETUP(16)
119 INIT_CALLS
120 CON_INITCALL
121 SECURITY_INITCALL
122 INIT_RAM_FS
123 }
124 .exit.data : {
125 ARM_EXIT_KEEP(EXIT_DATA)
126 }
127
128 PERCPU_SECTION(64)
129
562c85ca 130 . = ALIGN(PAGE_SIZE);
8c2c3df3 131 __init_end = .;
3c620626 132
e039ee4e
AP
133 . = ALIGN(4);
134 .altinstructions : {
135 __alt_instructions = .;
136 *(.altinstructions)
137 __alt_instructions_end = .;
138 }
139 .altinstr_replacement : {
140 *(.altinstr_replacement)
141 }
142
143 . = ALIGN(PAGE_SIZE);
3c620626 144 _data = .;
3c620626
MS
145 _sdata = .;
146 RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE)
a352ea3e 147 PECOFF_EDATA_PADDING
3c620626 148 _edata = .;
8c2c3df3 149
8c2c3df3 150 BSS_SECTION(0, 0, 0)
bd00cd5f
MR
151
152 . = ALIGN(PAGE_SIZE);
153 idmap_pg_dir = .;
154 . += IDMAP_DIR_SIZE;
155 swapper_pg_dir = .;
156 . += SWAPPER_DIR_SIZE;
157
8c2c3df3
CM
158 _end = .;
159
160 STABS_DEBUG
a2c1d73b
MR
161
162 HEAD_SYMBOLS
8c2c3df3 163}
2240bbb6
MZ
164
165/*
166 * The HYP init code can't be more than a page long.
167 */
168ASSERT(((__hyp_idmap_text_start + PAGE_SIZE) > __hyp_idmap_text_end),
169 "HYP init code too big")
da57a369
MR
170
171/*
172 * If padding is applied before .head.text, virt<->phys conversions will fail.
173 */
174ASSERT(_text == (PAGE_OFFSET + TEXT_OFFSET), "HEAD is misaligned")