-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathkernel.ld
More file actions
87 lines (76 loc) · 2.11 KB
/
kernel.ld
File metadata and controls
87 lines (76 loc) · 2.11 KB
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
78
79
80
81
82
83
84
85
86
87
ASSERT(SIZEOF(.text) < 0x00100000, "Error: .text grew beyond the 1 MiB safety window");
OUTPUT_ARCH(arm)
OUTPUT_FORMAT("elf32-littlearm","elf32-bigarm","elf32-littlearm")
ENTRY(_start)
MEMORY
{
RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 128M /* 128 MB */
}
SECTIONS
{
/* Exception vector table at 0x00000000
* the . line can be removed at some point
* if we want, as the VBAR alone determine where
* exceptions land. This will be done once the MMU
* is fully enabled. For this, we will need to have
* the page table in place (vector Virtual Addres (VA) mapped)
*/
. = ORIGIN(RAM);
.vectors ALIGN(32) : /* Aligned by 32 bytes */
{
KEEP(*(.vectors))
} > RAM
/* Main kernel starts at 64KB */
. = 0x00010000;
.text BLOCK(4K) : ALIGN(4K)
{
__text_start = .;
*(.text .text.*)
__text_end = .;
} > RAM
.rodata BLOCK(4K) : ALIGN(4K)
{
__rodata_start = .;
*(.rodata .rodata.*)
__rodata_end = .;
} > RAM
.data BLOCK(4K) : ALIGN(4K)
{
__data_start = .;
*(.data)
__data_end = .;
} > RAM AT > RAM
__data_load = LOADADDR(.data);
/* Reserved space for initial page tables (MMU) */
.ptables BLOCK(16K) : ALIGN(16K)
{
__ptables_start = .;
/* Reserve 16 KiB for L1 table; extend as needed for L2 tables */
. = . + 0x4000;
__ptables_end = .;
} > RAM
.bss BLOCK(4K) : ALIGN(4K)
{
__bss_start = .;
*(.bss .bss.*)
*(.sbss .sbss.*)
*(COMMON)
__bss_end = .;
} > RAM
/* Stack pointer = top of RAM */
__stack_top__ = ORIGIN(RAM) + LENGTH(RAM);
/* Reserve space for kernel stacks (64 KiB total) */
__stack_bottom__ = __stack_top__ - 64K;
/* Heap starts right after .bss */
__heap_start__ = .;
__heap_end__ = __stack_bottom__;
__heap_size__ = __heap_end__ - __heap_start__;
/* Discard unneeded sections to keep image lean */
/DISCARD/ :
{
*(.comment)
*(.note*)
*(.debug* .gnu.debug*)
*(.stab* .stabstr*)
}
}