-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel.lds
67 lines (59 loc) · 1.59 KB
/
kernel.lds
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
ENTRY(_start)
SECTIONS
{
. = 0xffffff8000080000;
/*
It is important to start the text segment with the Assembly code,
because we set the stack right before it, hence the KEEP().
This way our load address is 0x80000,
the same as `_start` label and stack top.
*/
.text :
{
KEEP(*(.text.boot))
*(.text .text.* .gnu.linkonce.t*)
}
.rodata :
{
*(.rodata .rodata.* .gnu.linkonce.r*)
}
/*
ALIG() Return the location counter (.) or arbitrary expression aligned to the next align boundary.
*/
. = ALIGN(4096);
/*
we use PROVIDE to declare some symbols not declared in other object files
*/
PROVIDE(_data = .);
.data :
{
*(.data .data.* .gnu.linkonce.d*)
}
/*
The section should be marked as not loadable,
so that it will not be loaded into memory when the program is run.
*/
.bss (NOLOAD) :
{
. = ALIGN(16);
__bss_start = .;
*(.bss .bss.*)
/*
A special notation is needed for common symbols,
because in many object file formats common symbols do not have a particular input section.
The linker treats common symbols as though they are in an input section named ‘COMMON’.
*/
*(COMMON)
__bss_end = .;
}
. = ALIGN(4096);
_end = .;
_pg_dir = .;
. = 0xffffff8000800000;
init_sp = .;
}
/*
The symbol we defined here is used in start.S to clear the bss region,
the reason ">> 3" is the clear is at garentity of a word(8 byte)
*/
__bss_size = (__bss_end - __bss_start) >> 3;