xref: /openbsd/sys/arch/arm64/conf/kern.ldscript (revision 274d7c50)
1/*     $OpenBSD: kern.ldscript,v 1.9 2019/11/09 20:07:00 guenther 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		*(.glue_7t) *(.glue_7)
28	} :text =0
29	PROVIDE (_etext = .);
30	PROVIDE (etext = .);
31
32	/* Move rodata to the next page, so we can nuke X and W bit on it */
33	. = ALIGN(__ALIGN_SIZE);
34	PROVIDE (__rodata_start = .);
35	.rodata :
36	{
37		*(.rodata .rodata.*)
38	} :rodata
39	.openbsd.randomdata :
40	{
41		__retguard_start = ABSOLUTE(.);
42		*(.openbsd.randomdata.retguard .openbsd.randomdata.retguard.*)
43		/* XXX needed? . = ALIGN(__ALIGN_SIZE); */
44		__retguard_end = ABSOLUTE(.);
45		*(.openbsd.randomdata .openbsd.randomdata.*)
46	} :openbsd_randomize :rodata
47	PROVIDE (_erodata = .);
48
49	/* Move .data to the next page, so we can add W bit on it */
50	. = ALIGN(__ALIGN_SIZE);
51	PROVIDE (__data_start = .);
52	.got :
53	{
54		*(.got .got.*)
55	} :data
56	.data :
57	{
58		*(.data .data.*)
59	} :data
60	.sdata :
61	{
62		*(.sdata .sdata.*)
63	} :data
64	PROVIDE (_edata = .);
65
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(64 / 8);
84	} :data
85	PROVIDE (_end = .);
86	PROVIDE (end = .);
87}
88