This repository was archived by the owner on Jan 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvoidframe.ld
More file actions
88 lines (77 loc) · 2.08 KB
/
voidframe.ld
File metadata and controls
88 lines (77 loc) · 2.08 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
88
/*
* VoidFrame Kernel Linker Script
* Optimized for x86_64 with proper alignment and memory layout
*/
ENTRY(start)
/* Define constants */
PAGE_SIZE = 4K;
KERNEL_BASE = 1M;
SECTIONS
{
. = KERNEL_BASE;
_kernel_phys_start = .;
/* Multiboot header - must be early in file */
.boot ALIGN(PAGE_SIZE) :
{
*(.multiboot*)
. = ALIGN(PAGE_SIZE);
}
/* Executable code - read-only, executable */
.text ALIGN(PAGE_SIZE) :
{
_text_start = .;
*(.text.boot) /* Boot code first */
*(.text.hot) /* Hot/frequently used code */
*(.text) /* Regular code */
*(.text.*) /* Other text sections */
. = ALIGN(PAGE_SIZE);
_text_end = .;
}
/* Read-only data - read-only, non-executable */
.rodata ALIGN(PAGE_SIZE) :
{
_rodata_start = .;
*(.rodata.str*) /* String literals first */
*(.rodata) /* Regular rodata */
*(.rodata.*)
. = ALIGN(PAGE_SIZE);
_rodata_end = .;
}
/* Initialized data - read-write */
.data ALIGN(PAGE_SIZE) :
{
_data_start = .;
*(.data)
*(.data.*)
. = ALIGN(PAGE_SIZE);
_data_end = .;
}
/* Uninitialized data - read-write, zero-initialized */
.bss ALIGN(PAGE_SIZE) :
{
_bss_start = .;
*(.bss)
*(.bss.*)
*(COMMON) /* Common symbols */
. = ALIGN(PAGE_SIZE);
_bss_end = .;
}
/* Kernel end marker */
. = ALIGN(PAGE_SIZE);
_kernel_phys_end = .;
_kernel_size = _kernel_phys_end - _kernel_phys_start;
/* Discard unnecessary sections */
/DISCARD/ :
{
*(.comment)
*(.note*)
*(.eh_frame*)
*(.dynamic*)
}
}
/* Sanity checks */
ASSERT(_kernel_size < 16M, "Kernel too large (>16MB)")
ASSERT(_text_start >= _kernel_phys_start, "Text section misaligned")
ASSERT(_rodata_start >= _text_end, "Rodata section misaligned")
ASSERT(_data_start >= _rodata_end, "Data section misaligned")
ASSERT(_bss_start >= _data_end, "BSS section misaligned")