-
Notifications
You must be signed in to change notification settings - Fork 21
/
linker.script
107 lines (91 loc) · 2.68 KB
/
linker.script
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
ENTRY(main)
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
PAGE_SIZE = 0x1000;
/* Needs to be bigger for DEBUG mode, can be 16 for non debug */
/* FIXME: Needs to be more accurately sized in both modes once guard page is fixed */
STACK_SIZE = 16 * PAGE_SIZE;
PHDRS {
text PT_LOAD FLAGS(5); /* R_E */
rodata PT_LOAD FLAGS(4); /* R__ */
data PT_LOAD FLAGS(6); /* RW_ */
}
SECTIONS {
. = 0x1000;
/* 2^64 - 2GB + 16MB */
/* Kernel is loaded at Physical Address 16MB (with BIOS load) */
.text (0xffffffff81000000) : {
_kernel_start = .;
_text_start = .;
*(.text .text.*)
} :text
.rela.plt :{
*(.rela.plt)
PROVIDE_HIDDEN (__rela_iplt_start = .);
*(.rela.iplt)
PROVIDE_HIDDEN (__rela_iplt_end = .);
}
.init : {
KEEP (*(SORT_NONE(.init)))
}
PROVIDE(_text_end = .);
.rodata : ALIGN(0x1000) {
_rodata_start = .;
*(.rodata .rodata.*)
_rodata_end = .;
} :rodata
. = ALIGN(0x1000);
.data : ALIGN(0x10) {
_data_start = .;
*(.data .data.*)
} :data
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.got : { *(.got) *(.igot) }
.got.plt : { *(.got.plt) *(.igot.plt) }
.plt : { *(.plt) *(.iplt) }
.plt.got : { *(.plt.got) }
.plt.bnd : { *(.plt.bnd) }
PROVIDE(_data_end = .);
. = ALIGN(0x1000);
/* Thread Local Storage sections */
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.bss ALIGN(0x1000) : {
_bss_start = .;
*(.bss..allocated_pages)
*(.bss .bss.*)
*(COMMON)
. = ALIGN(PAGE_SIZE);
_guard_page = .;
. += PAGE_SIZE;
_stack_start = .;
. += STACK_SIZE;
_kernel_stack = .; /* Top of stack so label comes after */
. += PAGE_SIZE;
_ist1_stack_top = .;
_heap_start = .;
. += PAGE_SIZE * 128;
_heap_end = .;
_bss_end = .;
}
. = ALIGN(PAGE_SIZE);
_kernel_end = .;
/DISCARD/ : {
*(.comment)
}
}