1 /* SPDX-License-Identifier: GPL-2.0 */
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>
7 /* No __ro_after_init data in the .rodata section - which will always be ro */
8 #define RO_AFTER_INIT_DATA
10 #include <linux/sizes.h>
12 #include <asm-generic/vmlinux.lds.h>
13 #include <asm/cache.h>
14 #include <asm/thread_info.h>
15 #include <asm/memory.h>
18 #include "vmlinux.lds.h"
26 jiffies = jiffies_64 + 4;
32 * XXX: The linker does not define how output sections are
33 * assigned to input sections when there are multiple statements
34 * matching the same input section name. There is no documented
37 * unwind exit sections must be discarded before the rest of the
38 * unwind sections get included.
46 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
47 _xiprom = .; /* XIP ROM area to be mapped */
54 .text : { /* Real text segment */
55 _stext = .; /* Text and read-only data */
62 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
63 __start___ex_table = .;
64 ARM_MMU_KEEP(*(__ex_table))
65 __stop___ex_table = .;
68 #ifdef CONFIG_ARM_UNWIND
74 _etext = .; /* End of text and rodata section */
79 ARM_EXIT_KEEP(EXIT_TEXT)
82 ARM_CPU_DISCARD(PROC_INFO)
85 __arch_info_begin = .;
102 #ifdef CONFIG_ARM_MPU
105 _exiprom = .; /* End of XIP ROM area */
108 * From this point, stuff is considered writable and will be copied to RAM
110 __data_loc = ALIGN(4); /* location in file */
111 . = PAGE_OFFSET + TEXT_OFFSET; /* location in memory */
113 #define LOAD_OFFSET (PAGE_OFFSET + TEXT_OFFSET - __data_loc)
115 . = ALIGN(THREAD_SIZE);
117 RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
118 .data.ro_after_init : AT(ADDR(.data.ro_after_init) - LOAD_OFFSET) {
119 *(.data..ro_after_init)
123 . = ALIGN(PAGE_SIZE);
125 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
128 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
129 ARM_EXIT_KEEP(EXIT_DATA)
132 PERCPU_SECTION(L1_CACHE_BYTES)
135 #ifdef CONFIG_HAVE_TCM
140 * End of copied data. We need a dummy section to get its LMA.
141 * Also located before final ALIGN() as trailing padding is not stored
142 * in the resulting binary file and useless to copy.
144 .data.endmark : AT(ADDR(.data.endmark) - LOAD_OFFSET) { }
145 _edata_loc = LOADADDR(.data.endmark);
147 . = ALIGN(PAGE_SIZE);
157 * These must never be empty
158 * If you have to comment these two assert statements out, your
159 * binutils is too old (for other reasons as well)
161 ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
162 ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
165 * The HYP init code can't be more than a page long,
166 * and should not cross a page boundary.
167 * The above comment applies as well.
169 ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE,
170 "HYP init code too big or misaligned")
172 #ifdef CONFIG_XIP_DEFLATED_DATA
174 * The .bss is used as a stack area for __inflate_kernel_data() whose stack
175 * frame is 9568 bytes. Make sure it has extra room left.
177 ASSERT((_end - __bss_start) >= 12288, ".bss too small for CONFIG_XIP_DEFLATED_DATA")
180 #ifdef CONFIG_ARM_MPU
182 * Due to PMSAv7 restriction on base address and size we have to
183 * enforce minimal alignment restrictions. It was seen that weaker
184 * alignment restriction on _xiprom will likely force XIP address
185 * space spawns multiple MPU regions thus it is likely we run in
186 * situation when we are reprogramming MPU region we run on with
187 * something which doesn't cover reprogramming code itself, so as soon
188 * as we update MPU settings we'd immediately try to execute straight
189 * from background region which is XN.
190 * It seem that alignment in 1M should suit most users.
191 * _exiprom is aligned as 1/8 of 1M so can be covered by subregion
194 ASSERT(!(_xiprom & (SZ_1M - 1)), "XIP start address may cause MPU programming issues")
195 ASSERT(!(_exiprom & (SZ_128K - 1)), "XIP end address may cause MPU programming issues")