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 /* No __ro_after_init data in the .rodata section - which will always be ro */
7 #define RO_AFTER_INIT_DATA
9 #include <asm-generic/vmlinux.lds.h>
10 #include <asm/cache.h>
11 #include <asm/thread_info.h>
12 #include <asm/memory.h>
16 * ld.lld does not support NOCROSSREFS:
17 * https://github.com/ClangBuiltLinux/linux/issues/1609
19 #ifdef CONFIG_LD_IS_LLD
23 /* Set start/end symbol names to the LMA for the section */
24 #define ARM_LMA(sym, section) \
25 sym##_start = LOADADDR(section); \
26 sym##_end = LOADADDR(section) + SIZEOF(section)
30 VMLINUX_SYMBOL(__proc_info_begin) = .; \
32 VMLINUX_SYMBOL(__proc_info_end) = .;
36 VMLINUX_SYMBOL(__idmap_text_start) = .; \
38 VMLINUX_SYMBOL(__idmap_text_end) = .; \
39 . = ALIGN(PAGE_SIZE); \
40 VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
42 VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;
44 #ifdef CONFIG_HOTPLUG_CPU
45 #define ARM_CPU_DISCARD(x)
46 #define ARM_CPU_KEEP(x) x
48 #define ARM_CPU_DISCARD(x) x
49 #define ARM_CPU_KEEP(x)
52 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
53 defined(CONFIG_GENERIC_BUG)
54 #define ARM_EXIT_KEEP(x) x
55 #define ARM_EXIT_DISCARD(x)
57 #define ARM_EXIT_KEEP(x)
58 #define ARM_EXIT_DISCARD(x) x
67 jiffies = jiffies_64 + 4;
73 * XXX: The linker does not define how output sections are
74 * assigned to input sections when there are multiple statements
75 * matching the same input section name. There is no documented
78 * unwind exit sections must be discarded before the rest of the
79 * unwind sections get included.
82 *(.ARM.exidx.exit.text)
83 *(.ARM.extab.exit.text)
84 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
85 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
86 ARM_EXIT_DISCARD(EXIT_TEXT)
87 ARM_EXIT_DISCARD(EXIT_DATA)
93 #ifndef CONFIG_SMP_ON_UP
100 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
101 _xiprom = .; /* XIP ROM area to be mapped */
108 .text : { /* Real text segment */
109 _stext = .; /* Text and read-only data */
111 __exception_text_start = .;
113 __exception_text_end = .;
124 *(.got) /* Global offset table */
125 ARM_CPU_KEEP(PROC_INFO)
131 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
132 __start___ex_table = .;
136 __stop___ex_table = .;
139 #ifdef CONFIG_ARM_UNWIND
141 * Stack unwinding tables
145 __start_unwind_idx = .;
147 __stop_unwind_idx = .;
150 __start_unwind_tab = .;
152 __stop_unwind_tab = .;
158 _etext = .; /* End of text and rodata section */
161 * The vectors and stubs are relocatable code, and the
162 * only thing that matters is their relative offsets
165 OVERLAY 0xffff0000 : NOCROSSREFS AT(__vectors_lma) {
170 *(.vectors.bhb.loop8)
172 .vectors.bhb.bpiall {
173 *(.vectors.bhb.bpiall)
176 ARM_LMA(__vectors, .vectors);
177 ARM_LMA(__vectors_bhb_loop8, .vectors.bhb.loop8);
178 ARM_LMA(__vectors_bhb_bpiall, .vectors.bhb.bpiall);
179 . = __vectors_lma + SIZEOF(.vectors) +
180 SIZEOF(.vectors.bhb.loop8) +
181 SIZEOF(.vectors.bhb.bpiall);
184 .stubs ADDR(.vectors) + 0x1000 : AT(__stubs_lma) {
187 ARM_LMA(__stubs, .stubs);
188 . = __stubs_lma + SIZEOF(.stubs);
190 PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
194 ARM_EXIT_KEEP(EXIT_TEXT)
197 ARM_CPU_DISCARD(PROC_INFO)
200 __arch_info_begin = .;
205 __tagtable_begin = .;
209 #ifdef CONFIG_SMP_ON_UP
217 __pv_table_begin = .;
230 PERCPU_SECTION(L1_CACHE_BYTES)
233 _exiprom = .; /* End of XIP ROM area */
234 __data_loc = ALIGN(4); /* location in binary */
235 . = PAGE_OFFSET + TEXT_OFFSET;
237 .data : AT(__data_loc) {
238 _data = .; /* address in memory */
242 * first, the init task union, aligned
243 * to an 8192 byte boundary.
245 INIT_TASK_DATA(THREAD_SIZE)
247 . = ALIGN(PAGE_SIZE);
250 ARM_EXIT_KEEP(EXIT_DATA)
251 . = ALIGN(PAGE_SIZE);
254 *(.data..ro_after_init)
257 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
258 READ_MOSTLY_DATA(L1_CACHE_BYTES)
261 * and the usual data section
268 _edata_loc = __data_loc + SIZEOF(.data);
270 #ifdef CONFIG_HAVE_TCM
272 * We align everything to a page boundary so we can
273 * free it after init has commenced and TCM contents have
274 * been copied to its destination.
277 . = ALIGN(PAGE_SIZE);
283 * Link these to the ITCM RAM
284 * Put VMA to the TCM address and LMA to the common RAM
285 * and we'll upload the contents from RAM to TCM and free
286 * the used RAM after that.
288 .text_itcm ITCM_OFFSET : AT(__itcm_start)
298 * Reset the dot pointer, this is needed to create the
299 * relative __dtcm_start below (to be used as extern in code).
301 . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
307 /* TODO: add remainder of ITCM as well, that can be used for data! */
308 .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
317 /* Reset the dot pointer or the linker gets confused */
318 . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
320 /* End marker for freeing TCM copy in linked object */
321 .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
322 . = ALIGN(PAGE_SIZE);
334 * These must never be empty
335 * If you have to comment these two assert statements out, your
336 * binutils is too old (for other reasons as well)
338 ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
339 ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
342 * The HYP init code can't be more than a page long,
343 * and should not cross a page boundary.
344 * The above comment applies as well.
346 ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE,
347 "HYP init code too big or misaligned")