-
Notifications
You must be signed in to change notification settings - Fork 0
/
linker.ld
143 lines (118 loc) · 3.13 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* The bootloader will look at this image and start execution at the symbol designated as the entry point. */
ENTRY(_start)
_high_offset = 0xC0000000;
/* Tell where the various sections of the object files will be put in the final kernel image. */
SECTIONS {
/* Low memory sections */
/* Begin putting sections at 1 MiB, a conventional place for kernels to be
loaded at by the bootloader. */
. = 1M;
.text BLOCK(4K) :
{
*(.multiboot)
obj/main/boot.o(.text)
obj/main/lomain.o(.text)
obj/hw/loacpi.o(.text)
obj/main/loerror.o(.text)
}
/* Read-only data. */
.rodata BLOCK(4K) :
{
obj/main/lomain.o(.rodata)
obj/main/boot.o(.rodata)
obj/hw/loacpi.o(.rodata)
obj/main/loerror.o(.rodata)
obj/main/lomain.o(.rodata*)
obj/main/boot.o(.rodata*)
obj/hw/loacpi.o(.rodata*)
obj/main/loerror.o(.rodata*)
}
/* Read-write data (initialized) */
.data BLOCK(4K) :
{
obj/main/lomain.o(.data)
obj/main/boot.o(.data)
obj/hw/loacpi.o(.data)
obj/main/loerror.o(.data)
}
/* Read-write data (uninitialized) and stack */
.bss BLOCK(4K) :
{
obj/main/lomain.o(COMMON)
obj/main/boot.o(COMMON)
obj/hw/loacpi.o(COMMON)
obj/main/loerror.o(COMMON)
obj/main/lomain.o(.bss)
obj/main/boot.o(.bss)
obj/hw/loacpi.o(.bss)
obj/main/loerror.o(.bss)
}
/* HIGH MEMORY */
. = _high_offset + .;
_startofro = ALIGN(4K);
.hi-text BLOCK(4K) : AT(ADDR(.hi-text) - _high_offset)
{
*(.text)
*(.text*)
}
/** Init data */
.hi-init : AT(ADDR(.hi-init) - _high_offset)
{
*(.init)
}
/** Finish data */
.hi-fini : AT(ADDR(.hi-fini) - _high_offset)
{
*(.fini)
}
.eh_frame : AT(ADDR(.eh_frame) - _high_offset)
{
*(.eh_frame)
}
/* Read-only data. */
.hi-rodata BLOCK(4K) : AT(ADDR(.hi-rodata) - _high_offset)
{
*(.rodata)
*(.rodata*)
}
_endofro = ALIGN(4K);
_startofrw = ALIGN(4K);
/* Read-write data (initialized) */
.hi-data BLOCK(4K) : AT(ADDR(.hi-data) - _high_offset)
{
*(.data)
}
/* Read-write data (uninitialized) and stack */
.hi-bss BLOCK(4K) : AT(ADDR(.hi-bss) - _high_offset)
{
*(.hi-bss)
*(COMMON)
*(.bss)
}
.jcr BLOCK(4K) : AT(ADDR(.jcr) - _high_offset) {
*(.jcr)
}
.ctors : AT(ADDR(.ctors) - _high_offset) {
*(.ctors)
}
.dtors : AT(ADDR(.dtors) - _high_offset) {
*(.dtors)
}
_startofap = .;
. = 4K;
/* AP start area sections (VERY low) */
.ap-text-start : AT(_startofap - _high_offset) {
*(.ap-text-start)
}
.ap-data-start : AT(_startofap - _high_offset + SIZEOF(.ap-text-start)) {
*(.ap-data-start)
}
_endofap = _startofap + SIZEOF(.ap-text-start) + SIZEOF(.ap-data-start);
. = _endofap;
. = ALIGN(4K);
_endofrw = .;
.padding BLOCK(4K) : AT(ADDR(.padding) - _high_offset) {
BYTE(0xff);
FILL(0x00);
}
}