xref: /DragonOS/kernel/src/arch/riscv64/link.ld (revision c635d8a9cfe25bc11779f323ef0c7d7a0f597d4a)
1OUTPUT_FORMAT(
2    "elf64-littleriscv",
3    "elf64-littleriscv",
4	"elf64-littleriscv"
5)
6
7OUTPUT_ARCH(riscv)
8ENTRY(_start)
9
10
11SECTIONS
12{
13	KERNEL_VMA = 0xffffffc000000000;
14	. = 0x1000000;
15	. += KERNEL_VMA;
16	. = ALIGN(4096);
17	boot_text_start_pa = .;
18	.boot.text : AT(boot_text_start_pa - KERNEL_VMA)
19	{
20		KEEP(*(.bootstrap))
21		*(.bootstrap)
22		*(.bootstrap.*)
23		. = ALIGN(4096);
24		*(.initial_pgtable_section)
25		. = ALIGN(4096);
26	}
27
28
29	. = ALIGN(4096);
30	text_start_pa = .;
31	.text (text_start_pa): AT(text_start_pa - KERNEL_VMA)
32	{
33		_text = .;
34
35		/* any files' .text */
36		*(.text)
37
38		/* any files' .text.*, for example: rust .text._ZN* */
39		*(.text.*)
40
41		_etext = .;
42	}
43	. = ALIGN(32768);
44	data_start_pa = .;
45	.data (data_start_pa): AT(data_start_pa - KERNEL_VMA)
46	{
47		_data = .;
48		*(.data)
49		*(.data.*)
50		*(.got.plt)
51   		*(.got)
52		_edata = .;
53	}
54
55	. = ALIGN(32768);
56
57	rodata_start_pa = .;
58	.rodata (rodata_start_pa): AT(rodata_start_pa - KERNEL_VMA)
59	{
60		_rodata = .;
61		*(.rodata)
62		*(.rodata.*)
63		_erodata = .;
64	}
65
66	. = ALIGN(32768);
67
68	init_proc_union_start_pa = .;
69	.data.init_proc_union (init_proc_union_start_pa): AT(init_proc_union_start_pa - KERNEL_VMA)
70	 { *(.data.init_proc_union) }
71
72	. = ALIGN(32768);
73	 bss_start_pa = .;
74	.bss (bss_start_pa): AT(bss_start_pa - KERNEL_VMA)
75	{
76		_bss = .;
77		*(.bss)
78		*(.bss.*)
79		*(.sbss)
80		*(.sbss.*)
81		_ebss = .;
82	}
83
84	eh_frame = .;
85	.eh_frame (eh_frame): AT(eh_frame - KERNEL_VMA)
86	{
87		__eh_frame_hdr_start = .;
88		*(.eh_frame_hdr)
89		__eh_frame_hdr_end = .;
90		__eh_frame_start = .;
91		*(.eh_frame)
92		*(.rela.eh_frame)
93		__eh_frame_end = .;
94	}
95
96	_end = .;
97
98	/DISCARD/ : {
99		/* *(.eh_frame) */
100
101	}
102}
103