blob: c615b0ffd496f01c99cb927ad5015ed1325a06c7 [file] [log] [blame]
Ben Cheng09ebc132013-10-18 00:02:49 -07001/* Default linker script, for normal executables */
2/* Modified for Android. */
3OUTPUT_FORMAT("elf64-bigaarch64", "elf64-bigaarch64",
4 "elf64-littleaarch64")
5OUTPUT_ARCH(aarch64)
6ENTRY(_start)
7SECTIONS
8{
9 /* Read-only sections, merged into text segment: */
10 PROVIDE (__executable_start = 0x400000); . = 0x400000 + SIZEOF_HEADERS;
11 .interp : { *(.interp) }
12 .note.gnu.build-id : { *(.note.gnu.build-id) }
13 .hash : { *(.hash) }
14 .gnu.hash : { *(.gnu.hash) }
15 .dynsym : { *(.dynsym) }
16 .dynstr : { *(.dynstr) }
17 .gnu.version : { *(.gnu.version) }
18 .gnu.version_d : { *(.gnu.version_d) }
19 .gnu.version_r : { *(.gnu.version_r) }
20 .rela.init : { *(.rela.init) }
21 .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
22 .rela.fini : { *(.rela.fini) }
23 .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
24 .rela.data.rel.ro : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
25 .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
26 .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
27 .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
28 .rela.ctors : { *(.rela.ctors) }
29 .rela.dtors : { *(.rela.dtors) }
30 .rela.got : { *(.rela.got) }
31 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
32 .rela.ifunc : { *(.rela.ifunc) }
33 .rela.plt :
34 {
35 *(.rela.plt)
36 PROVIDE_HIDDEN (__rela_iplt_start = .);
37 *(.rela.iplt)
38 PROVIDE_HIDDEN (__rela_iplt_end = .);
39 }
40 .init :
41 {
42 KEEP (*(SORT_NONE(.init)))
43 } =0
44 .plt : ALIGN(16) { *(.plt) *(.iplt) }
45 .text :
46 {
47 *(.text.unlikely .text.*_unlikely)
48 *(.text.exit .text.exit.*)
49 *(.text.startup .text.startup.*)
50 *(.text.hot .text.hot.*)
51 *(.text .stub .text.* .gnu.linkonce.t.*)
52 /* .gnu.warning sections are handled specially by elf32.em. */
53 *(.gnu.warning)
54 } =0
55 .fini :
56 {
57 KEEP (*(SORT_NONE(.fini)))
58 } =0
59 PROVIDE (__etext = .);
60 PROVIDE (_etext = .);
61 PROVIDE (etext = .);
62 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
63 .rodata1 : { *(.rodata1) }
64 .eh_frame_hdr : { *(.eh_frame_hdr) }
65 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
66 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
67 .gcc_except_table.*) }
68 /* These sections are generated by the Sun/Oracle C++ compiler. */
69 .exception_ranges : ONLY_IF_RO { *(.exception_ranges
70 .exception_ranges*) }
Ben Cheng61719eb2014-02-07 12:27:51 -080071 /* Adjust the address for the data segment. For 32 bits we want to align
72 at exactly a page boundary to make life easier for apriori. */
Ben Cheng09ebc132013-10-18 00:02:49 -070073 . = ALIGN (CONSTANT (MAXPAGESIZE)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
74 /* Exception handling */
75 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
76 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
77 .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
78 /* Thread Local Storage sections */
79 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
80 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
81 /* Ensure the __preinit_array_start label is properly aligned. We
82 could instead move the label definition inside the section, but
83 the linker would then create the section even if it turns out to
84 be empty, which isn't pretty. */
85 . = ALIGN(32 / 8);
86 PROVIDE_HIDDEN (__preinit_array_start = .);
87 .preinit_array :
88 {
89 KEEP (*(.preinit_array))
90 }
91 PROVIDE_HIDDEN (__preinit_array_end = .);
92 PROVIDE_HIDDEN (__init_array_start = .);
93 .init_array :
94 {
95 KEEP (*crtbegin*.o(.init_array))
96 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
97 KEEP (*(.init_array))
98 KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
99 }
100 PROVIDE_HIDDEN (__init_array_end = .);
101 PROVIDE_HIDDEN (__fini_array_start = .);
102 .fini_array :
103 {
104 KEEP (*crtbegin*.o(.fini_array))
105 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
106 KEEP (*(.fini_array))
107 KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
108 }
109 PROVIDE_HIDDEN (__fini_array_end = .);
110 .ctors :
111 {
112 /* gcc uses crtbegin.o to find the start of
113 the constructors, so we make sure it is
114 first. Because this is a wildcard, it
115 doesn't matter if the user does not
116 actually link against crtbegin.o; the
117 linker won't look for a file to match a
118 wildcard. The wildcard also means that it
119 doesn't matter which directory crtbegin.o
120 is in. */
121 KEEP (*crtbegin.o(.ctors))
122 KEEP (*crtbegin*.o(.ctors))
123 /* We don't want to include the .ctor section from
124 the crtend.o file until after the sorted ctors.
125 The .ctor section from the crtend file contains the
126 end of ctors marker and it must be last */
127 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .ctors))
128 KEEP (*(SORT(.ctors.*)))
129 KEEP (*(.ctors))
130 }
131 .dtors :
132 {
133 KEEP (*crtbegin.o(.dtors))
134 KEEP (*crtbegin*.o(.dtors))
135 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .dtors))
136 KEEP (*(SORT(.dtors.*)))
137 KEEP (*(.dtors))
138 }
139 .jcr : { KEEP (*(.jcr)) }
140 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
141 .dynamic : { *(.dynamic) }
142 .got : { *(.got) *(.igot) }
143 . = DATA_SEGMENT_RELRO_END (24, .);
144 .got.plt : { *(.got.plt) *(.igot.plt) }
145 .data :
146 {
147 PROVIDE (__data_start = .);
148 *(.data .data.* .gnu.linkonce.d.*)
149 SORT(CONSTRUCTORS)
150 }
151 .data1 : { *(.data1) }
152 _edata = .; PROVIDE (edata = .);
153 . = .;
154 __bss_start = .;
155 __bss_start__ = .;
156 .bss :
157 {
158 *(.dynbss)
159 *(.bss .bss.* .gnu.linkonce.b.*)
160 *(COMMON)
161 /* Align here to ensure that the .bss section occupies space up to
162 _end. Align after .bss to ensure correct alignment even if the
163 .bss section disappears because there are no input sections. */
164 . = ALIGN(32 / 8);
165 }
166 _bss_end__ = . ; __bss_end__ = . ;
167 . = ALIGN(32 / 8);
168 . = ALIGN(32 / 8);
169 __end__ = . ;
170 _end = .;
171 _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
172 PROVIDE (end = .);
173 . = DATA_SEGMENT_END (.);
174 /* Stabs debugging sections. */
175 .stab 0 : { *(.stab) }
176 .stabstr 0 : { *(.stabstr) }
177 .stab.excl 0 : { *(.stab.excl) }
178 .stab.exclstr 0 : { *(.stab.exclstr) }
179 .stab.index 0 : { *(.stab.index) }
180 .stab.indexstr 0 : { *(.stab.indexstr) }
181 .comment 0 : { *(.comment) }
182 /* DWARF debug sections.
183 Symbols in the DWARF debugging sections are relative to the beginning
184 of the section so we begin them at 0. */
185 /* DWARF 1 */
186 .debug 0 : { *(.debug) }
187 .line 0 : { *(.line) }
188 /* GNU DWARF 1 extensions */
189 .debug_srcinfo 0 : { *(.debug_srcinfo) }
190 .debug_sfnames 0 : { *(.debug_sfnames) }
191 /* DWARF 1.1 and DWARF 2 */
192 .debug_aranges 0 : { *(.debug_aranges) }
193 .debug_pubnames 0 : { *(.debug_pubnames) }
194 /* DWARF 2 */
195 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
196 .debug_abbrev 0 : { *(.debug_abbrev) }
197 .debug_line 0 : { *(.debug_line) }
198 .debug_frame 0 : { *(.debug_frame) }
199 .debug_str 0 : { *(.debug_str) }
200 .debug_loc 0 : { *(.debug_loc) }
201 .debug_macinfo 0 : { *(.debug_macinfo) }
202 /* SGI/MIPS DWARF 2 extensions */
203 .debug_weaknames 0 : { *(.debug_weaknames) }
204 .debug_funcnames 0 : { *(.debug_funcnames) }
205 .debug_typenames 0 : { *(.debug_typenames) }
206 .debug_varnames 0 : { *(.debug_varnames) }
207 /* DWARF 3 */
208 .debug_pubtypes 0 : { *(.debug_pubtypes) }
209 .debug_ranges 0 : { *(.debug_ranges) }
210 /* DWARF Extension. */
211 .debug_macro 0 : { *(.debug_macro) }
212 .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }
213 .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
214 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) }
215}