blob: 8c74037ade22958688e4766e4ef762a6cad514d9 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Chris Brandt538bf462016-02-03 15:58:10 +01002/* 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
Russell King2a381102016-11-16 23:51:19 +00007/* No __ro_after_init data in the .rodata section - which will always be ro */
8#define RO_AFTER_INIT_DATA
9
Vladimir Murzin21621832017-10-16 13:00:45 +010010#include <linux/sizes.h>
11
Chris Brandt538bf462016-02-03 15:58:10 +010012#include <asm-generic/vmlinux.lds.h>
13#include <asm/cache.h>
14#include <asm/thread_info.h>
15#include <asm/memory.h>
Vladimir Murzin046835b2018-04-03 10:39:23 +010016#include <asm/mpu.h>
Chris Brandt538bf462016-02-03 15:58:10 +010017#include <asm/page.h>
Chris Brandt538bf462016-02-03 15:58:10 +010018
Nicolas Pitre2f181e02018-02-27 22:39:27 -050019#include "vmlinux.lds.h"
Chris Brandt538bf462016-02-03 15:58:10 +010020
21OUTPUT_ARCH(arm)
22ENTRY(stext)
23
24#ifndef __ARMEB__
25jiffies = jiffies_64;
26#else
27jiffies = jiffies_64 + 4;
28#endif
29
30SECTIONS
31{
32 /*
33 * XXX: The linker does not define how output sections are
34 * assigned to input sections when there are multiple statements
35 * matching the same input section name. There is no documented
36 * order of matching.
37 *
38 * unwind exit sections must be discarded before the rest of the
39 * unwind sections get included.
40 */
41 /DISCARD/ : {
Nicolas Pitreab42fad2018-03-05 16:34:03 -050042 ARM_DISCARD
Chris Brandt538bf462016-02-03 15:58:10 +010043 *(.alt.smp.init)
Nicolas Pitreab42fad2018-03-05 16:34:03 -050044 *(.pv_table)
Chris Brandt538bf462016-02-03 15:58:10 +010045 }
46
47 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
Chris Brandt02afa9a2016-02-09 19:34:43 +010048 _xiprom = .; /* XIP ROM area to be mapped */
Chris Brandt538bf462016-02-03 15:58:10 +010049
50 .head.text : {
51 _text = .;
52 HEAD_TEXT
53 }
54
Chris Brandt538bf462016-02-03 15:58:10 +010055 .text : { /* Real text segment */
56 _stext = .; /* Text and read-only data */
Nicolas Pitre47b4c772018-03-05 16:34:03 -050057 ARM_TEXT
Chris Brandt538bf462016-02-03 15:58:10 +010058 }
59
Chris Brandt538bf462016-02-03 15:58:10 +010060 RO_DATA(PAGE_SIZE)
61
62 . = ALIGN(4);
63 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
64 __start___ex_table = .;
Nicolas Pitreab42fad2018-03-05 16:34:03 -050065 ARM_MMU_KEEP(*(__ex_table))
Chris Brandt538bf462016-02-03 15:58:10 +010066 __stop___ex_table = .;
67 }
68
69#ifdef CONFIG_ARM_UNWIND
Nicolas Pitred9a46e62018-03-01 17:32:28 -050070 ARM_UNWIND_SECTIONS
Chris Brandt538bf462016-02-03 15:58:10 +010071#endif
72
73 NOTES
74
75 _etext = .; /* End of text and rodata section */
76
Nicolas Pitre91470952018-03-01 22:17:03 -050077 ARM_VECTORS
Chris Brandt538bf462016-02-03 15:58:10 +010078 INIT_TEXT_SECTION(8)
79 .exit.text : {
80 ARM_EXIT_KEEP(EXIT_TEXT)
81 }
82 .init.proc.info : {
83 ARM_CPU_DISCARD(PROC_INFO)
84 }
85 .init.arch.info : {
86 __arch_info_begin = .;
87 *(.arch.info.init)
88 __arch_info_end = .;
89 }
90 .init.tagtable : {
91 __tagtable_begin = .;
92 *(.taglist.init)
93 __tagtable_end = .;
94 }
Nicolas Pitre0d302c72017-08-29 17:58:41 -040095 .init.rodata : {
Chris Brandt538bf462016-02-03 15:58:10 +010096 INIT_SETUP(16)
97 INIT_CALLS
98 CON_INITCALL
Chris Brandt538bf462016-02-03 15:58:10 +010099 INIT_RAM_FS
100 }
101
Vladimir Murzin21621832017-10-16 13:00:45 +0100102#ifdef CONFIG_ARM_MPU
103 . = ALIGN(SZ_128K);
104#endif
Nicolas Pitre0d302c72017-08-29 17:58:41 -0400105 _exiprom = .; /* End of XIP ROM area */
106
107/*
108 * From this point, stuff is considered writable and will be copied to RAM
109 */
110 __data_loc = ALIGN(4); /* location in file */
111 . = PAGE_OFFSET + TEXT_OFFSET; /* location in memory */
112#undef LOAD_OFFSET
113#define LOAD_OFFSET (PAGE_OFFSET + TEXT_OFFSET - __data_loc)
114
115 . = ALIGN(THREAD_SIZE);
116 _sdata = .;
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)
120 }
121 _edata = .;
122
123 . = ALIGN(PAGE_SIZE);
124 __init_begin = .;
125 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
126 INIT_DATA
127 }
128 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
129 ARM_EXIT_KEEP(EXIT_DATA)
130 }
Chris Brandt538bf462016-02-03 15:58:10 +0100131#ifdef CONFIG_SMP
132 PERCPU_SECTION(L1_CACHE_BYTES)
133#endif
134
Nicolas Pitreb54290e2018-03-08 21:12:04 -0500135#ifdef CONFIG_HAVE_TCM
136 ARM_TCM
137#endif
138
Nicolas Pitre0d302c72017-08-29 17:58:41 -0400139 /*
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.
143 */
144 .data.endmark : AT(ADDR(.data.endmark) - LOAD_OFFSET) { }
145 _edata_loc = LOADADDR(.data.endmark);
Chris Brandt538bf462016-02-03 15:58:10 +0100146
Nicolas Pitre0d302c72017-08-29 17:58:41 -0400147 . = ALIGN(PAGE_SIZE);
148 __init_end = .;
Peter Zijlstrab5effd32017-03-30 17:49:27 +0200149
Nicolas Pitre9520b1a2017-08-24 15:54:47 -0400150 BSS_SECTION(0, 0, 8)
Vladimir Murzin046835b2018-04-03 10:39:23 +0100151#ifdef CONFIG_ARM_MPU
152 . = ALIGN(PMSAv8_MINALIGN);
153#endif
Chris Brandt538bf462016-02-03 15:58:10 +0100154 _end = .;
155
156 STABS_DEBUG
157}
158
159/*
160 * These must never be empty
161 * If you have to comment these two assert statements out, your
162 * binutils is too old (for other reasons as well)
163 */
164ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
165ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
166
167/*
168 * The HYP init code can't be more than a page long,
169 * and should not cross a page boundary.
170 * The above comment applies as well.
171 */
172ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE,
173 "HYP init code too big or misaligned")
Nicolas Pitreca8b5d92017-08-25 00:54:18 -0400174
175#ifdef CONFIG_XIP_DEFLATED_DATA
176/*
177 * The .bss is used as a stack area for __inflate_kernel_data() whose stack
178 * frame is 9568 bytes. Make sure it has extra room left.
179 */
180ASSERT((_end - __bss_start) >= 12288, ".bss too small for CONFIG_XIP_DEFLATED_DATA")
181#endif
Vladimir Murzin21621832017-10-16 13:00:45 +0100182
183#ifdef CONFIG_ARM_MPU
184/*
185 * Due to PMSAv7 restriction on base address and size we have to
186 * enforce minimal alignment restrictions. It was seen that weaker
187 * alignment restriction on _xiprom will likely force XIP address
188 * space spawns multiple MPU regions thus it is likely we run in
189 * situation when we are reprogramming MPU region we run on with
190 * something which doesn't cover reprogramming code itself, so as soon
191 * as we update MPU settings we'd immediately try to execute straight
192 * from background region which is XN.
193 * It seem that alignment in 1M should suit most users.
194 * _exiprom is aligned as 1/8 of 1M so can be covered by subregion
195 * disable
196 */
197ASSERT(!(_xiprom & (SZ_1M - 1)), "XIP start address may cause MPU programming issues")
198ASSERT(!(_exiprom & (SZ_128K - 1)), "XIP end address may cause MPU programming issues")
199#endif