-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathlinker.ld
88 lines (78 loc) · 1.73 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
/**
* Inspired from the IncludeOS unikernel (https://github.com/hioa-cs/IncludeOS)
*
* This is the smallest possible linker script that supports
* normal C and C++ operation, including global constructors,
* exceptions and linker GC sections option.
**/
ENTRY(_start)
SECTIONS
{
PROVIDE(_ELF_START_ = . + 0x100000);
PROVIDE(_LOAD_START_ = _ELF_START_);
. = _ELF_START_;
.multiboot (_ELF_START_ ): {
PROVIDE(_MULTIBOOT_START_ = .);
KEEP(*(.multiboot))
}
.text ALIGN(0x10) :
{
_TEXT_START_ = .;
*(.text*)
*(.gnu.linkonce.t*)
_TEXT_END_ = .;
}
.rodata :
{
_RODATA_START_ = .;
*(.rodata*)
*(.gnu.linkonce.r*)
_RODATA_END_ = .;
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array .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 = .);
}*/
/* For stack unwinding (exception handling) */
.eh_frame_hdr ALIGN(0x8):
{
KEEP(*(.eh_frame_hdr*))
}
.eh_frame ALIGN(0x8):
{
PROVIDE (__eh_frame_start = .);
KEEP(*(.eh_frame))
LONG (0);
}
.gcc_except_table :
{
*(.gcc_except_table)
}
.data :
{
_DATA_START_ = .;
*(.data*)
*(.gnu.linkonce.d*)
_DATA_END_ = .;
}
PROVIDE(_LOAD_END_ = .);
.bss :
{
_BSS_START_ = .;
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
_BSS_END_ = .;
}
. = ALIGN(0x10);
_end = .;
}