-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlinker.ld
77 lines (66 loc) · 1.54 KB
/
linker.ld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
OUTPUT_ARCH(riscv)
ENTRY(_start)
BASE_ADDRESS = 0x80000000;
KERNAL_ENTRY = 0x80200000;
PROVIDE(_stack_size = 4K);
PROVIDE(_heap_size = 16K);
SECTIONS
{
/* Load the kernel at this address: "." means the current address */
. = BASE_ADDRESS;
start = .;
.text : {
_stext = .;
/* Place init sections first */
KEEP(*(.init));
KEEP(*(.init.rust));
*(.text .text.*)
_etext = .;
}
.rodata : {
_srodata = .;
*(.srodata .srodata.*);
*(.rodata .rodata.*)
/* 4-byte align the end (VMA) of this section.
This is required by LLD to ensure the LMA of the following .data
section will have the correct alignment. */
. = ALIGN(4);
_erodata = .;
}
.data : {
sidata = LOADADDR(.data);
_sdata = .;
/* Must be called __global_pointer$ for linker relaxations to work. */
PROVIDE(__global_pointer$ = . + 0x800);
*(.sdata .sdata.* .sdata2 .sdata2.*);
*(.data .data.*)
_edata = .;
}
.stack (NOLOAD) : ALIGN(4K) {
_estack = .;
. += _stack_size;
_sstack = .;
}
.bss(NOLOAD) : {
_sbss = .;
*(.bss .bss.*)
_ebss = .;
}
.heap (NOLOAD) : {
_sheap = .;
. += _heap_size;
. = ALIGN(4);
_eheap = .;
}
. = KERNAL_ENTRY;
.payload : {
_payload_start = .;
*(.payload)
. = ALIGN(8);
_payload_end = .;
}
PROVIDE(end = .);
/DISCARD/ : {
*(.eh_frame .eh_frame_hdr);
}
}