blob: 830b7c4109ebdc80be2fd651968f7f636bd19a65 [file] [log] [blame]
Ben Cheng7823f2a2014-04-08 14:53:42 -07001/* Script for --shared -z combreloc -z now -z relro: shared library, combine & sort relocs */
Rong Xue1a8a482015-04-08 12:48:42 -07002/* Copyright (C) 2014 Free Software Foundation, Inc.
3 Copying and distribution of this script, with or without modification,
4 are permitted in any medium without royalty provided the copyright
5 notice and this notice are preserved. */
Ben Cheng7823f2a2014-04-08 14:53:42 -07006OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
7 "elf32-littlearm")
8OUTPUT_ARCH(arm)
9ENTRY(_start)
10SECTIONS
11{
12 /* Read-only sections, merged into text segment: */
Ben Cheng79781f52014-05-19 10:33:46 -070013 . = 0 + SIZEOF_HEADERS;
Ben Cheng7823f2a2014-04-08 14:53:42 -070014 .note.gnu.build-id : { *(.note.gnu.build-id) }
15 .hash : { *(.hash) }
16 .gnu.hash : { *(.gnu.hash) }
17 .dynsym : { *(.dynsym) }
18 .dynstr : { *(.dynstr) }
19 .gnu.version : { *(.gnu.version) }
20 .gnu.version_d : { *(.gnu.version_d) }
21 .gnu.version_r : { *(.gnu.version_r) }
22 .rel.dyn :
23 {
24 *(.rel.init)
25 *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
26 *(.rel.fini)
27 *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
28 *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*)
29 *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
30 *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
31 *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
32 *(.rel.ctors)
33 *(.rel.dtors)
34 *(.rel.got)
35 *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
36 *(.rel.iplt)
37 }
38 .rela.dyn :
39 {
40 *(.rela.init)
41 *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
42 *(.rela.fini)
43 *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
44 *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
45 *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
46 *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
47 *(.rela.ctors)
48 *(.rela.dtors)
49 *(.rela.got)
50 *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
51 *(.rela.iplt)
52 }
53 .rel.plt :
54 {
55 *(.rel.plt)
56 }
57 .rela.plt :
58 {
59 *(.rela.plt)
60 }
61 .init :
62 {
63 KEEP (*(SORT_NONE(.init)))
64 }
65 .plt : { *(.plt) }
66 .iplt : { *(.iplt) }
67 .text :
68 {
69 *(.text.unlikely .text.*_unlikely .text.unlikely.*)
70 *(.text.exit .text.exit.*)
71 *(.text.startup .text.startup.*)
72 *(.text.hot .text.hot.*)
73 *(.text .stub .text.* .gnu.linkonce.t.*)
74 /* .gnu.warning sections are handled specially by elf32.em. */
75 *(.gnu.warning)
76 *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
77 }
78 .fini :
79 {
80 KEEP (*(SORT_NONE(.fini)))
81 }
82 PROVIDE (__etext = .);
83 PROVIDE (_etext = .);
84 PROVIDE (etext = .);
85 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
86 .rodata1 : { *(.rodata1) }
87 .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) }
88 PROVIDE_HIDDEN (__exidx_start = .);
89 .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
90 PROVIDE_HIDDEN (__exidx_end = .);
91 .eh_frame_hdr : { *(.eh_frame_hdr) }
92 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
93 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
94 .gcc_except_table.*) }
95 /* These sections are generated by the Sun/Oracle C++ compiler. */
96 .exception_ranges : ONLY_IF_RO { *(.exception_ranges
97 .exception_ranges*) }
Ben Cheng79781f52014-05-19 10:33:46 -070098 /* Adjust the address for the data segment. For 32 bits we want to align
99 at exactly a page boundary to make life easier for apriori. */
Ben Cheng7823f2a2014-04-08 14:53:42 -0700100 . = ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1));
101 /* Exception handling */
102 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
103 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
104 .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
105 /* Thread Local Storage sections */
106 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
107 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
Ben Cheng79781f52014-05-19 10:33:46 -0700108 /* Ensure the __preinit_array_start label is properly aligned. We
109 could instead move the label definition inside the section, but
110 the linker would then create the section even if it turns out to
111 be empty, which isn't pretty. */
112 . = ALIGN(32 / 8);
Ben Cheng7823f2a2014-04-08 14:53:42 -0700113 .preinit_array :
114 {
115 KEEP (*(.preinit_array))
116 }
117 .init_array :
118 {
Ben Cheng79781f52014-05-19 10:33:46 -0700119 KEEP (*crtbegin*.o(.init_array))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700120 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
Ben Cheng79781f52014-05-19 10:33:46 -0700121 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o ) .ctors))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700122 }
123 .fini_array :
124 {
Ben Cheng79781f52014-05-19 10:33:46 -0700125 KEEP (*crtbegin*.o(.fini_array))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700126 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
Ben Cheng79781f52014-05-19 10:33:46 -0700127 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o ) .dtors))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700128 }
129 .ctors :
130 {
131 /* gcc uses crtbegin.o to find the start of
132 the constructors, so we make sure it is
133 first. Because this is a wildcard, it
134 doesn't matter if the user does not
135 actually link against crtbegin.o; the
136 linker won't look for a file to match a
137 wildcard. The wildcard also means that it
138 doesn't matter which directory crtbegin.o
139 is in. */
140 KEEP (*crtbegin.o(.ctors))
Ben Cheng79781f52014-05-19 10:33:46 -0700141 KEEP (*crtbegin*.o(.ctors))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700142 /* We don't want to include the .ctor section from
143 the crtend.o file until after the sorted ctors.
144 The .ctor section from the crtend file contains the
145 end of ctors marker and it must be last */
Ben Cheng79781f52014-05-19 10:33:46 -0700146 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .ctors))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700147 KEEP (*(SORT(.ctors.*)))
148 KEEP (*(.ctors))
149 }
150 .dtors :
151 {
152 KEEP (*crtbegin.o(.dtors))
Ben Cheng79781f52014-05-19 10:33:46 -0700153 KEEP (*crtbegin*.o(.dtors))
154 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .dtors))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700155 KEEP (*(SORT(.dtors.*)))
156 KEEP (*(.dtors))
157 }
158 .jcr : { KEEP (*(.jcr)) }
159 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
160 .dynamic : { *(.dynamic) }
161 .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
162 .data :
163 {
164 __data_start = . ;
165 *(.data .data.* .gnu.linkonce.d.*)
166 SORT(CONSTRUCTORS)
167 }
168 .data1 : { *(.data1) }
169 _edata = .; PROVIDE (edata = .);
170 . = .;
171 __bss_start = .;
172 __bss_start__ = .;
173 .bss :
174 {
175 *(.dynbss)
176 *(.bss .bss.* .gnu.linkonce.b.*)
177 *(COMMON)
178 /* Align here to ensure that the .bss section occupies space up to
179 _end. Align after .bss to ensure correct alignment even if the
Ben Cheng79781f52014-05-19 10:33:46 -0700180 .bss section disappears because there are no input sections. */
181 . = ALIGN(32 / 8);
Ben Cheng7823f2a2014-04-08 14:53:42 -0700182 }
183 _bss_end__ = . ; __bss_end__ = . ;
184 . = ALIGN(32 / 8);
185 . = SEGMENT_START("ldata-segment", .);
186 . = ALIGN(32 / 8);
187 __end__ = . ;
Ben Cheng79781f52014-05-19 10:33:46 -0700188 _end = .;
189 _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
190 PROVIDE (end = .);
Ben Cheng7823f2a2014-04-08 14:53:42 -0700191 /* Stabs debugging sections. */
192 .stab 0 : { *(.stab) }
193 .stabstr 0 : { *(.stabstr) }
194 .stab.excl 0 : { *(.stab.excl) }
195 .stab.exclstr 0 : { *(.stab.exclstr) }
196 .stab.index 0 : { *(.stab.index) }
197 .stab.indexstr 0 : { *(.stab.indexstr) }
198 .comment 0 : { *(.comment) }
199 /* DWARF debug sections.
200 Symbols in the DWARF debugging sections are relative to the beginning
201 of the section so we begin them at 0. */
202 /* DWARF 1 */
203 .debug 0 : { *(.debug) }
204 .line 0 : { *(.line) }
205 /* GNU DWARF 1 extensions */
206 .debug_srcinfo 0 : { *(.debug_srcinfo) }
207 .debug_sfnames 0 : { *(.debug_sfnames) }
208 /* DWARF 1.1 and DWARF 2 */
209 .debug_aranges 0 : { *(.debug_aranges) }
210 .debug_pubnames 0 : { *(.debug_pubnames) }
211 /* DWARF 2 */
212 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
213 .debug_abbrev 0 : { *(.debug_abbrev) }
214 .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
215 .debug_frame 0 : { *(.debug_frame) }
216 .debug_str 0 : { *(.debug_str) }
217 .debug_loc 0 : { *(.debug_loc) }
218 .debug_macinfo 0 : { *(.debug_macinfo) }
219 /* SGI/MIPS DWARF 2 extensions */
220 .debug_weaknames 0 : { *(.debug_weaknames) }
221 .debug_funcnames 0 : { *(.debug_funcnames) }
222 .debug_typenames 0 : { *(.debug_typenames) }
223 .debug_varnames 0 : { *(.debug_varnames) }
224 /* DWARF 3 */
225 .debug_pubtypes 0 : { *(.debug_pubtypes) }
226 .debug_ranges 0 : { *(.debug_ranges) }
227 /* DWARF Extension. */
228 .debug_macro 0 : { *(.debug_macro) }
229 .stack 0x80000 :
230 {
231 _stack = .;
232 *(.stack)
233 }
234 .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }
235 .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
Ben Cheng79781f52014-05-19 10:33:46 -0700236 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) }
Ben Cheng7823f2a2014-04-08 14:53:42 -0700237}