xref: /DragonOS/kernel/src/arch/riscv64/link.ld (revision 1a72a751b18cf5bbe7b5b9e91aff530de0c18501)
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	KERNEL_VMA = 0;
15	. = 0x1000000;
16
17	.boot.text :
18	{
19		KEEP(*(.bootstrap))
20		*(.bootstrap.code64)
21		*(.bootstrap.data)
22		. = ALIGN(4096);
23	}
24
25	. += KERNEL_VMA;
26	. = ALIGN(32768);
27	text_start_pa = .;
28	.text (text_start_pa): AT(text_start_pa - KERNEL_VMA)
29	{
30		_text = .;
31
32		/* any files' .text */
33		*(.text)
34
35		/* any files' .text.*, for example: rust .text._ZN* */
36		*(.text.*)
37
38		_etext = .;
39	}
40	. = ALIGN(32768);
41	data_start_pa = .;
42	.data (data_start_pa): AT(data_start_pa - KERNEL_VMA)
43	{
44		_data = .;
45		*(.data)
46		*(.data.*)
47		*(.got.plt)
48   		*(.got)
49		_edata = .;
50	}
51
52	. = ALIGN(32768);
53
54	rodata_start_pa = .;
55	.rodata (rodata_start_pa): AT(rodata_start_pa - KERNEL_VMA)
56	{
57		_rodata = .;
58		*(.rodata)
59		*(.rodata.*)
60		_erodata = .;
61	}
62
63	. = ALIGN(32768);
64
65	init_proc_union_start_pa = .;
66	.data.init_proc_union (init_proc_union_start_pa): AT(init_proc_union_start_pa - KERNEL_VMA)
67	 { *(.data.init_proc_union) }
68
69	. = ALIGN(32768);
70	 bss_start_pa = .;
71	.bss (bss_start_pa): AT(bss_start_pa - KERNEL_VMA)
72	{
73		_bss = .;
74		*(.bss)
75		*(.bss.*)
76		_ebss = .;
77	}
78
79	eh_frame = .;
80	.eh_frame (eh_frame): AT(eh_frame - KERNEL_VMA)
81	{
82		__eh_frame_hdr_start = .;
83		*(.eh_frame_hdr)
84		__eh_frame_hdr_end = .;
85		__eh_frame_start = .;
86		*(.eh_frame)
87		*(.rela.eh_frame)
88		__eh_frame_end = .;
89	}
90
91	_end = .;
92
93	/DISCARD/ : {
94		/* *(.eh_frame) */
95
96	}
97}
98