-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel.ld
81 lines (68 loc) · 2.17 KB
/
kernel.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
78
79
80
81
OUTPUT_FORMAT(elf64-x86-64)
ENTRY(kernel_entry)
PHDRS {
low PT_LOAD;
text PT_LOAD;
}
SECTIONS {
/* Boot process uses 0x1000-0x3FFF */
/* Low text and data must be at very low physical addresses */
. = 0xFFFFFFFF80004000;
_low_data_start = .;
.lowtext : {
KEEP (*(.lowtext))
} :low
.lowdata (NOLOAD) : {
*(.lowdata)
} :NONE
_low_data_end = .;
/* Text segment: instructions and read-only globals */
. = 0xFFFFFFFF80100000;
_kernel_start = .;
.text : {
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
} :text
_etext = .;
.rodata : {
*(.rodata .rodata.* .gnu.linkonce.r.*)
*(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*)
*(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*)
} :text
/* Constructors: these sections support global initialization
functions, such as for global C++ objects with constructors. */
.init_array : {
PROVIDE(__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)
SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array .ctors))
PROVIDE(__init_array_end = .);
} :text
.ctors : {
KEEP (*crtbegin.o(.ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
} :text
/* Data segment: read/write and zero-initialized globals */
. = ALIGN(4096); /* Align to a page boundary */
.data : {
*(.data .data.* .gnu.linkonce.d.*)
. = ALIGN(16);
interrupt_descriptors = .;
KEEP (*(.interrupt_descriptors))
} :text
.bss : {
*(.bss .bss.* .gnu.linkonce.b.*)
} :text
PROVIDE(_kernel_end = .);
PROVIDE(console = 0xFFFFFFFF800B8000);
PROVIDE(cursorpos = 0xFFFFFFFF800B8FF8);
PROVIDE(consoletype = 0xFFFFFFFF800B8FFC);
PROVIDE(early_pagetable_low = early_pagetable & 0xFFFF);
PROVIDE(early_gdt_low = early_gdt & 0xFFFF);
PROVIDE(ap_rest_low = ap_rest & 0xFFFF);
/DISCARD/ : { *(.eh_frame .note.GNU-stack) }
}