xref: /openbsd/sys/arch/arm64/conf/kern.ldscript (revision d415bd75)
1/*     $OpenBSD: kern.ldscript,v 1.11 2022/01/07 13:56:54 kevlo Exp $         */
2/*     $NetBSD: ldscript.evbarm,v 1.2 2003/03/05 23:54:22 thorpej Exp $        */
3
4OUTPUT_ARCH(aarch64)
5
6/* Define how we want our ELF binary to look like. */
7PHDRS
8{
9	text PT_LOAD;
10	rodata PT_LOAD FLAGS (4);
11	data PT_LOAD;
12	openbsd_randomize PT_OPENBSD_RANDOMIZE;
13}
14
15__ALIGN_SIZE = 0x200000;
16__kernel_base = @KERNEL_BASE_VIRT@;
17
18ENTRY(_start)
19SECTIONS
20{
21	. = __kernel_base;
22	PROVIDE (__text_start = .);
23	.text :
24	{
25		*(.text .text.*)
26		*(.stub)
27	} :text =0
28	PROVIDE (_etext = .);
29	PROVIDE (etext = .);
30
31	/* Move rodata to the next page, so we can nuke X and W bit on it */
32	. = ALIGN(__ALIGN_SIZE);
33	PROVIDE (__rodata_start = .);
34	.rodata :
35	{
36		*(.rodata .rodata.*)
37	} :rodata
38	.openbsd.randomdata :
39	{
40		__retguard_start = ABSOLUTE(.);
41		*(.openbsd.randomdata.retguard .openbsd.randomdata.retguard.*)
42		/* XXX needed? . = ALIGN(__ALIGN_SIZE); */
43		__retguard_end = ABSOLUTE(.);
44		*(.openbsd.randomdata .openbsd.randomdata.*)
45	} :openbsd_randomize :rodata
46	PROVIDE (_erodata = .);
47
48	/* Move .data to the next page, so we can add W bit on it */
49	. = ALIGN(__ALIGN_SIZE);
50	PROVIDE (__data_start = .);
51	.got :
52	{
53		*(.got .got.*)
54	} :data
55	.data :
56	{
57		*(.data .data.*)
58	} :data
59	.sdata :
60	{
61		*(.sdata .sdata.*)
62	} :data
63	PROVIDE (_edata = .);
64
65	. = ALIGN(8);
66	PROVIDE (__bss_start = .);
67	.sbss :
68	{
69		*(.dynsbss)
70		*(.sbss)
71		*(.sbss.*)
72		*(.scommon)
73	} :data
74	.bss :
75	{
76		*(.dynbss)
77		*(.bss)
78		*(.bss.*)
79		*(COMMON)
80		/* Align here to ensure that the .bss section occupies space up to
81		   _end.  Align after .bss to ensure correct alignment even if the
82		   .bss section disappears because there are no input sections.  */
83		. = ALIGN(8);
84	} :data
85	PROVIDE (_end = .);
86	PROVIDE (end = .);
87}
88