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 <asm-generic/vmlinux.lds.h>
11 #include <asm/cache.h>
12 #include <asm/thread_info.h>
13 #include <asm/memory.h>
17 * ld.lld does not support NOCROSSREFS:
18 * https://github.com/ClangBuiltLinux/linux/issues/1609
20 #ifdef CONFIG_LD_IS_LLD
24 /* Set start/end symbol names to the LMA for the section */
25 #define ARM_LMA(sym, section) \
26 sym##_start = LOADADDR(section); \
27 sym##_end = LOADADDR(section) + SIZEOF(section)
31 VMLINUX_SYMBOL(__proc_info_begin) = .; \
33 VMLINUX_SYMBOL(__proc_info_end) = .;
37 VMLINUX_SYMBOL(__idmap_text_start) = .; \
39 VMLINUX_SYMBOL(__idmap_text_end) = .; \
40 . = ALIGN(PAGE_SIZE); \
41 VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
43 VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;
45 #ifdef CONFIG_HOTPLUG_CPU
46 #define ARM_CPU_DISCARD(x)
47 #define ARM_CPU_KEEP(x) x
49 #define ARM_CPU_DISCARD(x) x
50 #define ARM_CPU_KEEP(x)
53 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
54 defined(CONFIG_GENERIC_BUG)
55 #define ARM_EXIT_KEEP(x) x
56 #define ARM_EXIT_DISCARD(x)
58 #define ARM_EXIT_KEEP(x)
59 #define ARM_EXIT_DISCARD(x) x
68 jiffies = jiffies_64 + 4;
74 * XXX: The linker does not define how output sections are
75 * assigned to input sections when there are multiple statements
76 * matching the same input section name. There is no documented
79 * unwind exit sections must be discarded before the rest of the
80 * unwind sections get included.
83 *(.ARM.exidx.exit.text)
84 *(.ARM.extab.exit.text)
85 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
86 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
87 ARM_EXIT_DISCARD(EXIT_TEXT)
88 ARM_EXIT_DISCARD(EXIT_DATA)
94 #ifndef CONFIG_SMP_ON_UP
101 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
102 _xiprom = .; /* XIP ROM area to be mapped */
109 .text : { /* Real text segment */
110 _stext = .; /* Text and read-only data */
112 __exception_text_start = .;
114 __exception_text_end = .;
125 *(.got) /* Global offset table */
126 ARM_CPU_KEEP(PROC_INFO)
132 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
133 __start___ex_table = .;
137 __stop___ex_table = .;
140 #ifdef CONFIG_ARM_UNWIND
142 * Stack unwinding tables
146 __start_unwind_idx = .;
148 __stop_unwind_idx = .;
151 __start_unwind_tab = .;
153 __stop_unwind_tab = .;
159 _etext = .; /* End of text and rodata section */
162 * The vectors and stubs are relocatable code, and the
163 * only thing that matters is their relative offsets
166 OVERLAY 0xffff0000 : NOCROSSREFS AT(__vectors_lma) {
171 *(.vectors.bhb.loop8)
173 .vectors.bhb.bpiall {
174 *(.vectors.bhb.bpiall)
177 ARM_LMA(__vectors, .vectors);
178 ARM_LMA(__vectors_bhb_loop8, .vectors.bhb.loop8);
179 ARM_LMA(__vectors_bhb_bpiall, .vectors.bhb.bpiall);
180 . = __vectors_lma + SIZEOF(.vectors) +
181 SIZEOF(.vectors.bhb.loop8) +
182 SIZEOF(.vectors.bhb.bpiall);
185 .stubs ADDR(.vectors) + 0x1000 : AT(__stubs_lma) {
188 ARM_LMA(__stubs, .stubs);
189 . = __stubs_lma + SIZEOF(.stubs);
191 PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
195 ARM_EXIT_KEEP(EXIT_TEXT)
198 ARM_CPU_DISCARD(PROC_INFO)
201 __arch_info_begin = .;
206 __tagtable_begin = .;
210 #ifdef CONFIG_SMP_ON_UP
218 __pv_table_begin = .;
231 PERCPU_SECTION(L1_CACHE_BYTES)
234 _exiprom = .; /* End of XIP ROM area */
235 __data_loc = ALIGN(4); /* location in binary */
236 . = PAGE_OFFSET + TEXT_OFFSET;
238 .data : AT(__data_loc) {
239 _data = .; /* address in memory */
243 * first, the init task union, aligned
244 * to an 8192 byte boundary.
246 INIT_TASK_DATA(THREAD_SIZE)
248 . = ALIGN(PAGE_SIZE);
251 ARM_EXIT_KEEP(EXIT_DATA)
252 . = ALIGN(PAGE_SIZE);
255 *(.data..ro_after_init)
258 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
259 READ_MOSTLY_DATA(L1_CACHE_BYTES)
262 * and the usual data section
269 _edata_loc = __data_loc + SIZEOF(.data);
273 #ifdef CONFIG_HAVE_TCM
275 * We align everything to a page boundary so we can
276 * free it after init has commenced and TCM contents have
277 * been copied to its destination.
280 . = ALIGN(PAGE_SIZE);
286 * Link these to the ITCM RAM
287 * Put VMA to the TCM address and LMA to the common RAM
288 * and we'll upload the contents from RAM to TCM and free
289 * the used RAM after that.
291 .text_itcm ITCM_OFFSET : AT(__itcm_start)
301 * Reset the dot pointer, this is needed to create the
302 * relative __dtcm_start below (to be used as extern in code).
304 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
310 /* TODO: add remainder of ITCM as well, that can be used for data! */
311 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
320 /* Reset the dot pointer or the linker gets confused */
321 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
323 /* End marker for freeing TCM copy in linked object */
324 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
325 . = ALIGN(PAGE_SIZE);
337 * These must never be empty
338 * If you have to comment these two assert statements out, your
339 * binutils is too old (for other reasons as well)
341 ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
342 ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
345 * The HYP init code can't be more than a page long,
346 * and should not cross a page boundary.
347 * The above comment applies as well.
349 ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE,
350 "HYP init code too big or misaligned")