-
Notifications
You must be signed in to change notification settings - Fork 1
/
Kernel.ld
83 lines (67 loc) · 1.84 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
82
83
/*
ENTRY is used to specify the symbol that is to be used as the entry point
of our output executable.
*/
ENTRY(_kernelStart)
/*
SECTIONS is used to specify where certain symbols are placed in our output
executable.
*/
SECTIONS
{
/*
. is the location counter variable. When in the root of the SECTIONS
statement, its value is the byte offset from that of the start of the
SECTIONS statement.
When the location counter variable is used within a section definition,
its value is the byte offset from the start of said section definition.
*/
/*
Here, we set the location counter to 1Mb into the file. This is done
because, for one, Grub cannot load kernels below the 1Mb mark.
The reason for that, is because there are apparently lots of special
things located below the 1Mb mark, such as the VGA-buffer.
References:
http://os.phil-opp.com/multiboot-kernel.html#fn:Linker-1M
http://wiki.osdev.org/Memory_Map_(x86)#.22Low.22_memory_.28.3C_1_MiB.29
*/
. = 1M;
/*
Format of section definition:
name : {
contents
}
*/
/*
The * operator is used to specify that we want to look in all input
files, for the symbol (or symbols) specified within the parenthesis that
follows.
Example:
.text : {
*(.blah)
}
In the above example, the linker will look in all input files for the
.blah symbol.
*/
.multiboot :
{
*(.multiboot)
}
.text :
{
*(.text)
}
.rodata :
{
*(.rodata)
}
.data :
{
*(.data)
}
.bss :
{
*(COMMON)
*(.bss)
}
}