Linux Audio

Check our new training course

Loading...
v5.9
  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>
  5 */
  6
  7/* No __ro_after_init data in the .rodata section - which will always be ro */
  8#define RO_AFTER_INIT_DATA
  9
 10#include <linux/sizes.h>
 11
 12#include <asm-generic/vmlinux.lds.h>
 13#include <asm/cache.h>
 14#include <asm/thread_info.h>
 15#include <asm/memory.h>
 16#include <asm/mpu.h>
 17#include <asm/page.h>
 18
 19#include "vmlinux.lds.h"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 20
 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/ : {
 42		ARM_DISCARD
 
 
 
 
 
 
 
 
 
 
 
 43		*(.alt.smp.init)
 44		*(.pv_table)
 
 
 45	}
 46
 47	. = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
 48	_xiprom = .;			/* XIP ROM area to be mapped */
 49
 50	.head.text : {
 51		_text = .;
 52		HEAD_TEXT
 53	}
 54
 55	.text : {			/* Real text segment		*/
 56		_stext = .;		/* Text and read-only data	*/
 57		ARM_TEXT
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 58	}
 59
 60	RO_DATA(PAGE_SIZE)
 61
 62	. = ALIGN(4);
 63	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
 64		__start___ex_table = .;
 65		ARM_MMU_KEEP(*(__ex_table))
 
 
 66		__stop___ex_table = .;
 67	}
 68
 69#ifdef CONFIG_ARM_UNWIND
 70	ARM_UNWIND_SECTIONS
 
 
 
 
 
 
 
 
 
 
 
 
 
 71#endif
 72
 
 
 73	_etext = .;			/* End of text and rodata section */
 74
 75	ARM_VECTORS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 76	INIT_TEXT_SECTION(8)
 77	.exit.text : {
 78		ARM_EXIT_KEEP(EXIT_TEXT)
 79	}
 80	.init.proc.info : {
 81		ARM_CPU_DISCARD(PROC_INFO)
 82	}
 83	.init.arch.info : {
 84		__arch_info_begin = .;
 85		*(.arch.info.init)
 86		__arch_info_end = .;
 87	}
 88	.init.tagtable : {
 89		__tagtable_begin = .;
 90		*(.taglist.init)
 91		__tagtable_end = .;
 92	}
 93	.init.rodata : {
 
 
 
 
 
 
 
 
 
 
 
 
 94		INIT_SETUP(16)
 95		INIT_CALLS
 96		CON_INITCALL
 
 97		INIT_RAM_FS
 98	}
 99
100#ifdef CONFIG_ARM_MPU
101	. = ALIGN(SZ_128K);
102#endif
 
103	_exiprom = .;			/* End of XIP ROM area */
 
 
104
105/*
106 * From this point, stuff is considered writable and will be copied to RAM
107 */
108	__data_loc = ALIGN(4);		/* location in file */
109	. = PAGE_OFFSET + TEXT_OFFSET;	/* location in memory */
110#undef LOAD_OFFSET
111#define LOAD_OFFSET (PAGE_OFFSET + TEXT_OFFSET - __data_loc)
112
113	. = ALIGN(THREAD_SIZE);
114	_sdata = .;
115	RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
116	.data.ro_after_init : AT(ADDR(.data.ro_after_init) - LOAD_OFFSET) {
117		*(.data..ro_after_init)
118	}
119	_edata = .;
120
121	. = ALIGN(PAGE_SIZE);
122	__init_begin = .;
123	.init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
124		INIT_DATA
125	}
126	.exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
127		ARM_EXIT_KEEP(EXIT_DATA)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128	}
129#ifdef CONFIG_SMP
130	PERCPU_SECTION(L1_CACHE_BYTES)
131#endif
132
133#ifdef CONFIG_HAVE_TCM
134	ARM_TCM
135#endif
 
 
 
 
 
 
 
 
136
137	/*
138	 * End of copied data. We need a dummy section to get its LMA.
139	 * Also located before final ALIGN() as trailing padding is not stored
140	 * in the resulting binary file and useless to copy.
141	 */
142	.data.endmark : AT(ADDR(.data.endmark) - LOAD_OFFSET) { }
143	_edata_loc = LOADADDR(.data.endmark);
144
145	. = ALIGN(PAGE_SIZE);
146	__init_end = .;
147
148	BSS_SECTION(0, 0, 8)
149#ifdef CONFIG_ARM_MPU
150	. = ALIGN(PMSAv8_MINALIGN);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151#endif
 
 
152	_end = .;
153
154	STABS_DEBUG
155}
156
157/*
158 * These must never be empty
159 * If you have to comment these two assert statements out, your
160 * binutils is too old (for other reasons as well)
161 */
162ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
163ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
164
165#ifdef CONFIG_XIP_DEFLATED_DATA
166/*
167 * The .bss is used as a stack area for __inflate_kernel_data() whose stack
168 * frame is 9568 bytes. Make sure it has extra room left.
 
169 */
170ASSERT((_end - __bss_start) >= 12288, ".bss too small for CONFIG_XIP_DEFLATED_DATA")
171#endif
172
173#ifdef CONFIG_ARM_MPU
174/*
175 * Due to PMSAv7 restriction on base address and size we have to
176 * enforce minimal alignment restrictions. It was seen that weaker
177 * alignment restriction on _xiprom will likely force XIP address
178 * space spawns multiple MPU regions thus it is likely we run in
179 * situation when we are reprogramming MPU region we run on with
180 * something which doesn't cover reprogramming code itself, so as soon
181 * as we update MPU settings we'd immediately try to execute straight
182 * from background region which is XN.
183 * It seem that alignment in 1M should suit most users.
184 * _exiprom is aligned as 1/8 of 1M so can be covered by subregion
185 * disable
186 */
187ASSERT(!(_xiprom & (SZ_1M - 1)), "XIP start address may cause MPU programming issues")
188ASSERT(!(_exiprom & (SZ_128K - 1)), "XIP end address may cause MPU programming issues")
189#endif
v4.10.11
 
  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>
  4 */
  5
  6/* No __ro_after_init data in the .rodata section - which will always be ro */
  7#define RO_AFTER_INIT_DATA
  8
 
 
  9#include <asm-generic/vmlinux.lds.h>
 10#include <asm/cache.h>
 11#include <asm/thread_info.h>
 12#include <asm/memory.h>
 
 13#include <asm/page.h>
 14
 15#define PROC_INFO							\
 16	. = ALIGN(4);							\
 17	VMLINUX_SYMBOL(__proc_info_begin) = .;				\
 18	*(.proc.info.init)						\
 19	VMLINUX_SYMBOL(__proc_info_end) = .;
 20
 21#define IDMAP_TEXT							\
 22	ALIGN_FUNCTION();						\
 23	VMLINUX_SYMBOL(__idmap_text_start) = .;				\
 24	*(.idmap.text)							\
 25	VMLINUX_SYMBOL(__idmap_text_end) = .;				\
 26	. = ALIGN(PAGE_SIZE);						\
 27	VMLINUX_SYMBOL(__hyp_idmap_text_start) = .;			\
 28	*(.hyp.idmap.text)						\
 29	VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;
 30
 31#ifdef CONFIG_HOTPLUG_CPU
 32#define ARM_CPU_DISCARD(x)
 33#define ARM_CPU_KEEP(x)		x
 34#else
 35#define ARM_CPU_DISCARD(x)	x
 36#define ARM_CPU_KEEP(x)
 37#endif
 38
 39#if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
 40	defined(CONFIG_GENERIC_BUG)
 41#define ARM_EXIT_KEEP(x)	x
 42#define ARM_EXIT_DISCARD(x)
 43#else
 44#define ARM_EXIT_KEEP(x)
 45#define ARM_EXIT_DISCARD(x)	x
 46#endif
 47
 48OUTPUT_ARCH(arm)
 49ENTRY(stext)
 50
 51#ifndef __ARMEB__
 52jiffies = jiffies_64;
 53#else
 54jiffies = jiffies_64 + 4;
 55#endif
 56
 57SECTIONS
 58{
 59	/*
 60	 * XXX: The linker does not define how output sections are
 61	 * assigned to input sections when there are multiple statements
 62	 * matching the same input section name.  There is no documented
 63	 * order of matching.
 64	 *
 65	 * unwind exit sections must be discarded before the rest of the
 66	 * unwind sections get included.
 67	 */
 68	/DISCARD/ : {
 69		*(.ARM.exidx.exit.text)
 70		*(.ARM.extab.exit.text)
 71		ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
 72		ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
 73		ARM_EXIT_DISCARD(EXIT_TEXT)
 74		ARM_EXIT_DISCARD(EXIT_DATA)
 75		EXIT_CALL
 76#ifndef CONFIG_MMU
 77		*(.text.fixup)
 78		*(__ex_table)
 79#endif
 80#ifndef CONFIG_SMP_ON_UP
 81		*(.alt.smp.init)
 82#endif
 83		*(.discard)
 84		*(.discard.*)
 85	}
 86
 87	. = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
 88	_xiprom = .;			/* XIP ROM area to be mapped */
 89
 90	.head.text : {
 91		_text = .;
 92		HEAD_TEXT
 93	}
 94
 95	.text : {			/* Real text segment		*/
 96		_stext = .;		/* Text and read-only data	*/
 97			IDMAP_TEXT
 98			__exception_text_start = .;
 99			*(.exception.text)
100			__exception_text_end = .;
101			IRQENTRY_TEXT
102			TEXT_TEXT
103			SCHED_TEXT
104			CPUIDLE_TEXT
105			LOCK_TEXT
106			KPROBES_TEXT
107			*(.gnu.warning)
108			*(.glue_7)
109			*(.glue_7t)
110		. = ALIGN(4);
111		*(.got)			/* Global offset table		*/
112			ARM_CPU_KEEP(PROC_INFO)
113	}
114
115	RO_DATA(PAGE_SIZE)
116
117	. = ALIGN(4);
118	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
119		__start___ex_table = .;
120#ifdef CONFIG_MMU
121		*(__ex_table)
122#endif
123		__stop___ex_table = .;
124	}
125
126#ifdef CONFIG_ARM_UNWIND
127	/*
128	 * Stack unwinding tables
129	 */
130	. = ALIGN(8);
131	.ARM.unwind_idx : {
132		__start_unwind_idx = .;
133		*(.ARM.exidx*)
134		__stop_unwind_idx = .;
135	}
136	.ARM.unwind_tab : {
137		__start_unwind_tab = .;
138		*(.ARM.extab*)
139		__stop_unwind_tab = .;
140	}
141#endif
142
143	NOTES
144
145	_etext = .;			/* End of text and rodata section */
146
147	/*
148	 * The vectors and stubs are relocatable code, and the
149	 * only thing that matters is their relative offsets
150	 */
151	__vectors_start = .;
152	.vectors 0xffff0000 : AT(__vectors_start) {
153		*(.vectors)
154	}
155	. = __vectors_start + SIZEOF(.vectors);
156	__vectors_end = .;
157
158	__stubs_start = .;
159	.stubs ADDR(.vectors) + 0x1000 : AT(__stubs_start) {
160		*(.stubs)
161	}
162	. = __stubs_start + SIZEOF(.stubs);
163	__stubs_end = .;
164
165	PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
166
167	INIT_TEXT_SECTION(8)
168	.exit.text : {
169		ARM_EXIT_KEEP(EXIT_TEXT)
170	}
171	.init.proc.info : {
172		ARM_CPU_DISCARD(PROC_INFO)
173	}
174	.init.arch.info : {
175		__arch_info_begin = .;
176		*(.arch.info.init)
177		__arch_info_end = .;
178	}
179	.init.tagtable : {
180		__tagtable_begin = .;
181		*(.taglist.init)
182		__tagtable_end = .;
183	}
184#ifdef CONFIG_SMP_ON_UP
185	.init.smpalt : {
186		__smpalt_begin = .;
187		*(.alt.smp.init)
188		__smpalt_end = .;
189	}
190#endif
191	.init.pv_table : {
192		__pv_table_begin = .;
193		*(.pv_table)
194		__pv_table_end = .;
195	}
196	.init.data : {
197		INIT_SETUP(16)
198		INIT_CALLS
199		CON_INITCALL
200		SECURITY_INITCALL
201		INIT_RAM_FS
202	}
203
204#ifdef CONFIG_SMP
205	PERCPU_SECTION(L1_CACHE_BYTES)
206#endif
207
208	_exiprom = .;			/* End of XIP ROM area */
209	__data_loc = ALIGN(4);		/* location in binary */
210	. = PAGE_OFFSET + TEXT_OFFSET;
211
212	.data : AT(__data_loc) {
213		_data = .;		/* address in memory */
214		_sdata = .;
215
216		/*
217		 * first, the init task union, aligned
218		 * to an 8192 byte boundary.
219		 */
220		INIT_TASK_DATA(THREAD_SIZE)
 
 
 
 
 
 
221
222		. = ALIGN(PAGE_SIZE);
223		__init_begin = .;
 
224		INIT_DATA
 
 
225		ARM_EXIT_KEEP(EXIT_DATA)
226		. = ALIGN(PAGE_SIZE);
227		__init_end = .;
228
229		*(.data..ro_after_init)
230
231		NOSAVE_DATA
232		CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
233		READ_MOSTLY_DATA(L1_CACHE_BYTES)
234
235		/*
236		 * and the usual data section
237		 */
238		DATA_DATA
239		CONSTRUCTORS
240
241		_edata = .;
242	}
243	_edata_loc = __data_loc + SIZEOF(.data);
 
 
244
245#ifdef CONFIG_HAVE_TCM
246        /*
247	 * We align everything to a page boundary so we can
248	 * free it after init has commenced and TCM contents have
249	 * been copied to its destination.
250	 */
251	.tcm_start : {
252		. = ALIGN(PAGE_SIZE);
253		__tcm_start = .;
254		__itcm_start = .;
255	}
256
257	/*
258	 * Link these to the ITCM RAM
259	 * Put VMA to the TCM address and LMA to the common RAM
260	 * and we'll upload the contents from RAM to TCM and free
261	 * the used RAM after that.
262	 */
263	.text_itcm ITCM_OFFSET : AT(__itcm_start)
264	{
265		__sitcm_text = .;
266		*(.tcm.text)
267		*(.tcm.rodata)
268		. = ALIGN(4);
269		__eitcm_text = .;
270	}
271
272	/*
273	 * Reset the dot pointer, this is needed to create the
274	 * relative __dtcm_start below (to be used as extern in code).
275	 */
276	. = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
277
278	.dtcm_start : {
279		__dtcm_start = .;
280	}
281
282	/* TODO: add remainder of ITCM as well, that can be used for data! */
283	.data_dtcm DTCM_OFFSET : AT(__dtcm_start)
284	{
285		. = ALIGN(4);
286		__sdtcm_data = .;
287		*(.tcm.data)
288		. = ALIGN(4);
289		__edtcm_data = .;
290	}
291
292	/* Reset the dot pointer or the linker gets confused */
293	. = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
294
295	/* End marker for freeing TCM copy in linked object */
296	.tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
297		. = ALIGN(PAGE_SIZE);
298		__tcm_end = .;
299	}
300#endif
301
302	BSS_SECTION(0, 0, 0)
303	_end = .;
304
305	STABS_DEBUG
306}
307
308/*
309 * These must never be empty
310 * If you have to comment these two assert statements out, your
311 * binutils is too old (for other reasons as well)
312 */
313ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
314ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
315
 
316/*
317 * The HYP init code can't be more than a page long,
318 * and should not cross a page boundary.
319 * The above comment applies as well.
320 */
321ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & PAGE_MASK) <= PAGE_SIZE,
322	"HYP init code too big or misaligned")