-
Notifications
You must be signed in to change notification settings - Fork 2
/
link.ld
173 lines (140 loc) · 3.85 KB
/
link.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
OUTPUT_FORMAT(elf64-littleaarch64)
OUTPUT_ARCH(aarch64)
ENTRY(__module_start)
PHDRS
{
text PT_LOAD FLAGS(5);
rodata PT_LOAD FLAGS(4);
data PT_LOAD FLAGS(6);
dynamic PT_DYNAMIC;
}
SECTIONS
{
PROVIDE(__start__ = 0x0);
. = __start__;
__code_start__ = .;
/* App code */
.text : {
HIDDEN(__text_start__ = .);
KEEP (*(.text.crt0))
*(.text .text.*)
HIDDEN(__text_end__ = .);
} :text
/* Trampoline and stuffs */
.plt : { *(.plt .plt.*) } :text
__code_end__ = .;
/* Read-only sections */
. = ALIGN(0x1000);
/* App name */
.module_name : { KEEP (*(.nx-module-name)) } :rodata
/* Make sure everything is aligned */
. = ALIGN(8);
/* App rodata */
.rodata : {
*(.rodata .rodata.*)
} :rodata
/* All the symbols needed for relocation lookup */
.hash : { *(.hash) } :rodata
.gnu.hash : { *(.gnu.hash) } :rodata
.dynsym : { *(.dynsym .dynsym.*) } :rodata
.dynstr : { *(.dynstr .dynstr.*) } :rodata
__rel_dyn_start__ = .;
.rel.dyn : { *(.rel.dyn) } :rodata
__rel_dyn_end__ = .;
__rela_dyn_start__ = .;
.rela.dyn : { *(.rela.dyn) } :rodata
__rela_dyn_end__ = .;
__rel_plt_start__ = .;
.rel.plt : { *(.rel.plt) } :rodata
__rel_plt_end__ = .;
__rela_plt_start__ = .;
.rela.plt : { *(.rela.plt) } :rodata
__rela_plt_end__ = .;
/* All exception handling sections */
.gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) } :rodata
.eh_frame_hdr : {
HIDDEN(__eh_frame_hdr_start__ = .);
*(.eh_frame_hdr)
HIDDEN(__eh_frame_hdr_end__ = .);
} :rodata
.eh_frame : { KEEP (*(.eh_frame)) } :rodata
/* Misc .rodata stuffs (build-id, ect) */
.note.gnu.build-id : { *(.note.gnu.build-id) } :rodata
/* Read-write sections */
. = ALIGN(0x1000);
/* App data */
.data : {
*(.data .data.*)
} :data
/* This section should be made read only after relocation but in practice we will not do that */
.data.rela.ro : {
*(.data.rela.ro.local*)
*(.data.rela.ro .data.rela.ro.*)
} :data
/* This section should be made read only after relocation but in practice we will not do that */
.data.rel.ro : {
*(.data.rel.ro.local*)
*(.data.rel.ro .data.rel.ro.*)
} :data
/* All GOT sections */
__got_start__ = .;
.got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } :data
__got_end__ = .;
/* The dynamic section as we need it to be stored in the binary */
.dynamic : {
HIDDEN(__dynamic_start__ = .);
*(.dynamic)
} :data :dynamic
/* Align for .init_array/.fini_array */
. = ALIGN(8);
.preinit_array ALIGN(8) :
{
PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE (__preinit_array_end = .);
} :data
/* App init array */
.init_array : {
PROVIDE (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
KEEP (*(.init_array))
PROVIDE (__init_array_end = .);
} :data
/* App fini array */
.fini_array : {
PROVIDE (__fini_array_start__ = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
KEEP (*(.fini_array))
PROVIDE (__fini_array_end__ = .);
} :data
/* Thread Local sections */
.tdata : {
__tdata_align_abs__ = ABSOLUTE(.);
__tdata_start__ = .;
*(.tdata .tdata.*)
__tdata_end__ = .;
} :data
.tbss : {
__tbss_align_abs__ = ABSOLUTE(.);
__tbss_start__ = .;
*(.tbss .tbss.*)
*(.tcommon)
__tbss_end__ = .;
} :data
/* BSS section */
. = ALIGN(0x1000);
.bss : {
HIDDEN(__bss_start__ = .);
*(.bss .bss.*)
*(COMMON)
. = ALIGN(8);
HIDDEN(__bss_end__ = .);
. = ALIGN(0x1000);
} :data
__end__ = ABSOLUTE(.);
HIDDEN(__argdata__ = .);
/DISCARD/ : {
/* No need of the interpreter */
*(.interp)
}
}