xref: /netbsd-src/sys/arch/aarch64/conf/kern.ldscript (revision 181254a7b1bdde6873432bffef2d2decc4b5c22f)
1#include "assym.h"
2
3/* Default linker script, for normal executables */
4OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64",
5	      "elf64-littleaarch64")
6OUTPUT_ARCH(aarch64)
7ENTRY(_start)
8
9SECTIONS
10{
11	.text :
12	{
13		PROVIDE(__kernel_text = .);
14		*(.text)
15		*(.text.*)
16		*(.stub)
17	} =0
18
19	/* Move .rodata to the next L2 block to set unexecutable */
20	. = ALIGN(L2_SIZE);
21
22	PROVIDE(__rodata_start = .);
23	.rodata :
24	{
25		*(.rodata)
26		*(.rodata.*)
27		. = ALIGN(64);
28		__CTOR_LIST__ = .;
29		*(.ctors)
30		*(.init_array)
31		__CTOR_END__ = .;
32	}
33
34	PROVIDE(_etext = .);
35	PROVIDE(etext = .);
36
37	/*
38	 * Adjust the address for the data segment. Move .data to the next
39	 * L2 block, and .text and .rodata will be set readonly if needed.
40	 */
41	PROVIDE(_erodata = .);
42	. = ALIGN(L2_SIZE);
43
44	.data :
45	{
46		PROVIDE(__data_start = .);
47		*(.data)
48	}
49
50	. = ALIGN(COHERENCY_UNIT);
51	.data.cacheline_aligned :
52	{
53		*(.data.cacheline_aligned)
54	}
55	. = ALIGN(COHERENCY_UNIT);
56	.data.read_mostly :
57	{
58		*(.data.read_mostly)
59	}
60	. = ALIGN(COHERENCY_UNIT);
61
62	_edata = .;
63	PROVIDE (edata = .);
64
65	__bss_start = .;
66	__bss_start__ = .;
67	.bss :
68	{
69		*(.bss)
70		*(.bss.*)
71		*(COMMON)
72
73		/*
74		 * Align here to ensure that the .bss section occupies space
75		 * up to _end. Align after .bss to ensure correct alignment
76		 * even if the .bss section disappears because there are no
77		 * input sections.
78		 *
79		 * FIXME: Why do we need it? When there is no .bss section,
80		 * we don't pad the .data section.
81		 */
82		. = ALIGN(. != 0 ? 32 / 8 : 1);
83	}
84	_bss_end__ = . ;
85	__bss_end__ = . ;
86	. = ALIGN(32 / 8);
87
88	__end__ = . ;
89	_end = .;
90	PROVIDE(end = .);
91}
92