1 /* ld script to make ARM Linux kernel
2 * taken from the i386 version by Russell King
3 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6 #ifdef CONFIG_XIP_KERNEL
7 #include "vmlinux-xip.lds.S"
10 #include <asm-generic/vmlinux.lds.h>
11 #include <asm/cache.h>
12 #include <asm/thread_info.h>
13 #include <asm/memory.h>
15 #include <asm/pgtable.h>
18 * ld.lld does not support NOCROSSREFS:
19 * https://github.com/ClangBuiltLinux/linux/issues/1609
21 #ifdef CONFIG_LD_IS_LLD
25 /* Set start/end symbol names to the LMA for the section */
26 #define ARM_LMA(sym, section) \
27 sym##_start = LOADADDR(section); \
28 sym##_end = LOADADDR(section) + SIZEOF(section)
32 VMLINUX_SYMBOL(__proc_info_begin) = .; \
34 VMLINUX_SYMBOL(__proc_info_end) = .;
36 #define HYPERVISOR_TEXT \
37 VMLINUX_SYMBOL(__hyp_text_start) = .; \
39 VMLINUX_SYMBOL(__hyp_text_end) = .;
43 VMLINUX_SYMBOL(__idmap_text_start) = .; \
45 VMLINUX_SYMBOL(__idmap_text_end) = .; \
46 . = ALIGN(PAGE_SIZE); \
47 VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
49 VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;
51 #ifdef CONFIG_HOTPLUG_CPU
52 #define ARM_CPU_DISCARD(x)
53 #define ARM_CPU_KEEP(x) x
55 #define ARM_CPU_DISCARD(x) x
56 #define ARM_CPU_KEEP(x)
59 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
60 defined(CONFIG_GENERIC_BUG) || defined(CONFIG_JUMP_LABEL)
61 #define ARM_EXIT_KEEP(x) x
62 #define ARM_EXIT_DISCARD(x)
64 #define ARM_EXIT_KEEP(x)
65 #define ARM_EXIT_DISCARD(x) x
74 jiffies = jiffies_64 + 4;
80 * XXX: The linker does not define how output sections are
81 * assigned to input sections when there are multiple statements
82 * matching the same input section name. There is no documented
85 * unwind exit sections must be discarded before the rest of the
86 * unwind sections get included.
89 *(.ARM.exidx.exit.text)
90 *(.ARM.extab.exit.text)
91 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
92 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
93 ARM_EXIT_DISCARD(EXIT_TEXT)
94 ARM_EXIT_DISCARD(EXIT_DATA)
100 #ifndef CONFIG_SMP_ON_UP
107 . = PAGE_OFFSET + TEXT_OFFSET;
113 #ifdef CONFIG_DEBUG_RODATA
114 . = ALIGN(1<<SECTION_SHIFT);
117 .text : { /* Real text segment */
118 _stext = .; /* Text and read-only data */
120 __exception_text_start = .;
122 __exception_text_end = .;
135 *(.got) /* Global offset table */
136 ARM_CPU_KEEP(PROC_INFO)
139 #ifdef CONFIG_DEBUG_ALIGN_RODATA
140 . = ALIGN(1<<SECTION_SHIFT);
142 _etext = .; /* End of text section */
147 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
148 __start___ex_table = .;
152 __stop___ex_table = .;
155 #ifdef CONFIG_ARM_UNWIND
157 * Stack unwinding tables
161 __start_unwind_idx = .;
163 __stop_unwind_idx = .;
166 __start_unwind_tab = .;
168 __stop_unwind_tab = .;
174 #ifdef CONFIG_DEBUG_RODATA
175 . = ALIGN(1<<SECTION_SHIFT);
177 . = ALIGN(PAGE_SIZE);
182 * The vectors and stubs are relocatable code, and the
183 * only thing that matters is their relative offsets
186 OVERLAY 0xffff0000 : NOCROSSREFS AT(__vectors_lma) {
191 *(.vectors.bhb.loop8)
193 .vectors.bhb.bpiall {
194 *(.vectors.bhb.bpiall)
197 ARM_LMA(__vectors, .vectors);
198 ARM_LMA(__vectors_bhb_loop8, .vectors.bhb.loop8);
199 ARM_LMA(__vectors_bhb_bpiall, .vectors.bhb.bpiall);
200 . = __vectors_lma + SIZEOF(.vectors) +
201 SIZEOF(.vectors.bhb.loop8) +
202 SIZEOF(.vectors.bhb.bpiall);
205 .stubs ADDR(.vectors) + 0x1000 : AT(__stubs_lma) {
208 ARM_LMA(__stubs, .stubs);
209 . = __stubs_lma + SIZEOF(.stubs);
211 PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
215 ARM_EXIT_KEEP(EXIT_TEXT)
218 ARM_CPU_DISCARD(PROC_INFO)
221 __arch_info_begin = .;
226 __tagtable_begin = .;
230 #ifdef CONFIG_SMP_ON_UP
238 __pv_table_begin = .;
251 ARM_EXIT_KEEP(EXIT_DATA)
255 PERCPU_SECTION(L1_CACHE_BYTES)
258 #ifdef CONFIG_DEBUG_RODATA
259 . = ALIGN(1<<SECTION_SHIFT);
261 . = ALIGN(THREAD_SIZE);
266 .data : AT(__data_loc) {
267 _data = .; /* address in memory */
271 * first, the init task union, aligned
272 * to an 8192 byte boundary.
274 INIT_TASK_DATA(THREAD_SIZE)
277 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
278 READ_MOSTLY_DATA(L1_CACHE_BYTES)
281 * and the usual data section
288 _edata_loc = __data_loc + SIZEOF(.data);
290 #ifdef CONFIG_HAVE_TCM
292 * We align everything to a page boundary so we can
293 * free it after init has commenced and TCM contents have
294 * been copied to its destination.
297 . = ALIGN(PAGE_SIZE);
303 * Link these to the ITCM RAM
304 * Put VMA to the TCM address and LMA to the common RAM
305 * and we'll upload the contents from RAM to TCM and free
306 * the used RAM after that.
308 .text_itcm ITCM_OFFSET : AT(__itcm_start)
318 * Reset the dot pointer, this is needed to create the
319 * relative __dtcm_start below (to be used as extern in code).
321 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
327 /* TODO: add remainder of ITCM as well, that can be used for data! */
328 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
337 /* Reset the dot pointer or the linker gets confused */
338 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
340 /* End marker for freeing TCM copy in linked object */
341 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
342 . = ALIGN(PAGE_SIZE);
353 #ifdef CONFIG_DEBUG_RODATA
355 * Without CONFIG_DEBUG_ALIGN_RODATA, __start_rodata_section_aligned will
356 * be the first section-aligned location after __start_rodata. Otherwise,
357 * it will be equal to __start_rodata.
359 __start_rodata_section_aligned = ALIGN(__start_rodata, 1 << SECTION_SHIFT);
363 * These must never be empty
364 * If you have to comment these two assert statements out, your
365 * binutils is too old (for other reasons as well)
367 ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
368 ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
371 * The HYP init code can't be more than a page long,
372 * and should not cross a page boundary.
373 * The above comment applies as well.
375 ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE,
376 "HYP init code too big or misaligned")
378 #endif /* CONFIG_XIP_KERNEL */