-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlinker.ld
More file actions
83 lines (69 loc) · 2.06 KB
/
linker.ld
File metadata and controls
83 lines (69 loc) · 2.06 KB
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
/* Tell the linker that we want an x86_64 ELF64 output file */
OUTPUT_FORMAT(elf64-x86-64)
OUTPUT_ARCH(i386:x86-64)
/* We want the symbol _start to be our entry point */
ENTRY(_start)
/* Define the program headers we want so the bootloader gives us the right permissions */
PHDRS
{
text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */
rodata PT_LOAD FLAGS((1 << 2)) ; /* Read only */
requests PT_LOAD FLAGS((1 << 2)) ; /* Read only */
data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ; /* Write + Read */
}
SECTIONS
{
/* We want to be loaded in the high half of memory */
. = 0xffffffff80000000;
.text ALIGN(4096) : {
__text_start = .;
*(.text .text.*)
__text_end = .;
} :text
.rodata ALIGN(4096) : {
__rodata_start = .;
*(.rodata .rodata.*)
__rodata_end = .;
} :rodata
.requests ALIGN(4096) : {
__requests_start = .;
KEEP(*(.requests_start))
KEEP(*(.requests))
KEEP(*(.requests_end))
__requests_end = .;
} :requests
/* Add a full page of padding to guarantee separation from writable data */
. = ALIGN(4096);
. += 4096;
.data ALIGN(4096) : {
__data_start = .;
*(.data .data.*)
*(.got .got.*)
*(.data.rel.ro .data.rel.ro.*)
/* C++ global constructors */
. = ALIGN(8);
__init_array_start = .;
KEEP(*(.init_array .init_array.*))
. = ALIGN(8);
__init_array_end = .;
/* Kernel Unit Tests */
. = ALIGN(16);
__ktests_start = .;
KEEP(*(.ktests))
__ktests_end = .;
__data_end = .;
} :data
.bss ALIGN(4096) : {
__bss_start = .;
*(.bss .bss.*)
*(COMMON)
__bss_end = .;
} :data
. = ALIGN(4096);
__kernel_end = .;
/* Discard .note.* and .eh_frame since they may cause issues on some hosts. */
/DISCARD/ : {
*(.eh_frame)
*(.note .note.*)
}
}