blob: a0f195a2abf2f5b52b5edf904d1664ec03e098e0 [file] [log] [blame]
Ben Cheng7823f2a2014-04-08 14:53:42 -07001/* Script for -N: mix text and data on same page; don't align data */
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)
Ben Cheng7823f2a2014-04-08 14:53:42 -070010SECTIONS
11{
12 /* Read-only sections, merged into text segment: */
Rong Xue1a8a482015-04-08 12:48:42 -070013 PROVIDE (__executable_start = 0x00010000); . = 0x00010000 + SIZEOF_HEADERS;
Ben Cheng7823f2a2014-04-08 14:53:42 -070014 .interp : { *(.interp) }
15 .note.gnu.build-id : { *(.note.gnu.build-id) }
16 .hash : { *(.hash) }
17 .gnu.hash : { *(.gnu.hash) }
18 .dynsym : { *(.dynsym) }
19 .dynstr : { *(.dynstr) }
20 .gnu.version : { *(.gnu.version) }
21 .gnu.version_d : { *(.gnu.version_d) }
22 .gnu.version_r : { *(.gnu.version_r) }
23 .rel.init : { *(.rel.init) }
24 .rela.init : { *(.rela.init) }
25 .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
26 .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
27 .rel.fini : { *(.rel.fini) }
28 .rela.fini : { *(.rela.fini) }
29 .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
30 .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
31 .rel.data.rel.ro : { *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) }
32 .rela.data.rel.ro : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
33 .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
34 .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
35 .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
36 .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
37 .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
38 .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
39 .rel.ctors : { *(.rel.ctors) }
40 .rela.ctors : { *(.rela.ctors) }
41 .rel.dtors : { *(.rel.dtors) }
42 .rela.dtors : { *(.rela.dtors) }
43 .rel.got : { *(.rel.got) }
44 .rela.got : { *(.rela.got) }
45 .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
46 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
47 .rel.iplt :
48 {
49 PROVIDE_HIDDEN (__rel_iplt_start = .);
50 *(.rel.iplt)
51 PROVIDE_HIDDEN (__rel_iplt_end = .);
52 }
53 .rela.iplt :
54 {
55 PROVIDE_HIDDEN (__rela_iplt_start = .);
56 *(.rela.iplt)
57 PROVIDE_HIDDEN (__rela_iplt_end = .);
58 }
59 .rel.plt :
60 {
61 *(.rel.plt)
62 }
63 .rela.plt :
64 {
65 *(.rela.plt)
66 }
67 .init :
68 {
69 KEEP (*(SORT_NONE(.init)))
70 }
71 .plt : { *(.plt) }
72 .iplt : { *(.iplt) }
73 .text :
74 {
75 *(.text.unlikely .text.*_unlikely .text.unlikely.*)
76 *(.text.exit .text.exit.*)
77 *(.text.startup .text.startup.*)
78 *(.text.hot .text.hot.*)
79 *(.text .stub .text.* .gnu.linkonce.t.*)
80 /* .gnu.warning sections are handled specially by elf32.em. */
81 *(.gnu.warning)
82 *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
83 }
84 .fini :
85 {
86 KEEP (*(SORT_NONE(.fini)))
87 }
88 PROVIDE (__etext = .);
89 PROVIDE (_etext = .);
90 PROVIDE (etext = .);
91 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
92 .rodata1 : { *(.rodata1) }
93 .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) }
94 PROVIDE_HIDDEN (__exidx_start = .);
95 .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
96 PROVIDE_HIDDEN (__exidx_end = .);
97 .eh_frame_hdr : { *(.eh_frame_hdr) }
98 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
99 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
100 .gcc_except_table.*) }
101 /* These sections are generated by the Sun/Oracle C++ compiler. */
102 .exception_ranges : ONLY_IF_RO { *(.exception_ranges
103 .exception_ranges*) }
Ben Cheng79781f52014-05-19 10:33:46 -0700104 /* Adjust the address for the data segment. For 32 bits we want to align
105 at exactly a page boundary to make life easier for apriori. */
Ben Cheng7823f2a2014-04-08 14:53:42 -0700106 . = .;
107 /* Exception handling */
108 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
109 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
110 .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
111 /* Thread Local Storage sections */
112 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
113 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
Ben Cheng79781f52014-05-19 10:33:46 -0700114 /* Ensure the __preinit_array_start label is properly aligned. We
115 could instead move the label definition inside the section, but
116 the linker would then create the section even if it turns out to
117 be empty, which isn't pretty. */
118 . = ALIGN(32 / 8);
119 PROVIDE_HIDDEN (__preinit_array_start = .);
Ben Cheng7823f2a2014-04-08 14:53:42 -0700120 .preinit_array :
121 {
Ben Cheng7823f2a2014-04-08 14:53:42 -0700122 KEEP (*(.preinit_array))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700123 }
Ben Cheng79781f52014-05-19 10:33:46 -0700124 PROVIDE_HIDDEN (__preinit_array_end = .);
125 PROVIDE_HIDDEN (__init_array_start = .);
Ben Cheng7823f2a2014-04-08 14:53:42 -0700126 .init_array :
127 {
Ben Cheng79781f52014-05-19 10:33:46 -0700128 KEEP (*crtbegin*.o(.init_array))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700129 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
Ben Cheng79781f52014-05-19 10:33:46 -0700130 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o ) .ctors))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700131 }
Ben Cheng79781f52014-05-19 10:33:46 -0700132 PROVIDE_HIDDEN (__init_array_end = .);
133 PROVIDE_HIDDEN (__fini_array_start = .);
Ben Cheng7823f2a2014-04-08 14:53:42 -0700134 .fini_array :
135 {
Ben Cheng79781f52014-05-19 10:33:46 -0700136 KEEP (*crtbegin*.o(.fini_array))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700137 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
Ben Cheng79781f52014-05-19 10:33:46 -0700138 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o ) .dtors))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700139 }
Ben Cheng79781f52014-05-19 10:33:46 -0700140 PROVIDE_HIDDEN (__fini_array_end = .);
Ben Cheng7823f2a2014-04-08 14:53:42 -0700141 .ctors :
142 {
143 /* gcc uses crtbegin.o to find the start of
144 the constructors, so we make sure it is
145 first. Because this is a wildcard, it
146 doesn't matter if the user does not
147 actually link against crtbegin.o; the
148 linker won't look for a file to match a
149 wildcard. The wildcard also means that it
150 doesn't matter which directory crtbegin.o
151 is in. */
152 KEEP (*crtbegin.o(.ctors))
Ben Cheng79781f52014-05-19 10:33:46 -0700153 KEEP (*crtbegin*.o(.ctors))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700154 /* We don't want to include the .ctor section from
155 the crtend.o file until after the sorted ctors.
156 The .ctor section from the crtend file contains the
157 end of ctors marker and it must be last */
Ben Cheng79781f52014-05-19 10:33:46 -0700158 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .ctors))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700159 KEEP (*(SORT(.ctors.*)))
160 KEEP (*(.ctors))
161 }
162 .dtors :
163 {
164 KEEP (*crtbegin.o(.dtors))
Ben Cheng79781f52014-05-19 10:33:46 -0700165 KEEP (*crtbegin*.o(.dtors))
166 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .dtors))
Ben Cheng7823f2a2014-04-08 14:53:42 -0700167 KEEP (*(SORT(.dtors.*)))
168 KEEP (*(.dtors))
169 }
170 .jcr : { KEEP (*(.jcr)) }
171 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
172 .dynamic : { *(.dynamic) }
173 .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
174 .data :
175 {
176 PROVIDE (__data_start = .);
177 *(.data .data.* .gnu.linkonce.d.*)
178 SORT(CONSTRUCTORS)
179 }
180 .data1 : { *(.data1) }
181 _edata = .; PROVIDE (edata = .);
182 . = .;
183 __bss_start = .;
184 __bss_start__ = .;
185 .bss :
186 {
187 *(.dynbss)
188 *(.bss .bss.* .gnu.linkonce.b.*)
189 *(COMMON)
190 /* Align here to ensure that the .bss section occupies space up to
191 _end. Align after .bss to ensure correct alignment even if the
Ben Cheng79781f52014-05-19 10:33:46 -0700192 .bss section disappears because there are no input sections. */
193 . = ALIGN(32 / 8);
Ben Cheng7823f2a2014-04-08 14:53:42 -0700194 }
195 _bss_end__ = . ; __bss_end__ = . ;
196 . = ALIGN(32 / 8);
197 . = SEGMENT_START("ldata-segment", .);
198 . = ALIGN(32 / 8);
199 __end__ = . ;
Ben Cheng79781f52014-05-19 10:33:46 -0700200 _end = .;
201 _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
202 PROVIDE (end = .);
Ben Cheng7823f2a2014-04-08 14:53:42 -0700203 /* Stabs debugging sections. */
204 .stab 0 : { *(.stab) }
205 .stabstr 0 : { *(.stabstr) }
206 .stab.excl 0 : { *(.stab.excl) }
207 .stab.exclstr 0 : { *(.stab.exclstr) }
208 .stab.index 0 : { *(.stab.index) }
209 .stab.indexstr 0 : { *(.stab.indexstr) }
210 .comment 0 : { *(.comment) }
211 /* DWARF debug sections.
212 Symbols in the DWARF debugging sections are relative to the beginning
213 of the section so we begin them at 0. */
214 /* DWARF 1 */
215 .debug 0 : { *(.debug) }
216 .line 0 : { *(.line) }
217 /* GNU DWARF 1 extensions */
218 .debug_srcinfo 0 : { *(.debug_srcinfo) }
219 .debug_sfnames 0 : { *(.debug_sfnames) }
220 /* DWARF 1.1 and DWARF 2 */
221 .debug_aranges 0 : { *(.debug_aranges) }
222 .debug_pubnames 0 : { *(.debug_pubnames) }
223 /* DWARF 2 */
224 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
225 .debug_abbrev 0 : { *(.debug_abbrev) }
226 .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
227 .debug_frame 0 : { *(.debug_frame) }
228 .debug_str 0 : { *(.debug_str) }
229 .debug_loc 0 : { *(.debug_loc) }
230 .debug_macinfo 0 : { *(.debug_macinfo) }
231 /* SGI/MIPS DWARF 2 extensions */
232 .debug_weaknames 0 : { *(.debug_weaknames) }
233 .debug_funcnames 0 : { *(.debug_funcnames) }
234 .debug_typenames 0 : { *(.debug_typenames) }
235 .debug_varnames 0 : { *(.debug_varnames) }
236 /* DWARF 3 */
237 .debug_pubtypes 0 : { *(.debug_pubtypes) }
238 .debug_ranges 0 : { *(.debug_ranges) }
239 /* DWARF Extension. */
240 .debug_macro 0 : { *(.debug_macro) }
241 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
242 .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
Ben Cheng79781f52014-05-19 10:33:46 -0700243 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) }
Ben Cheng7823f2a2014-04-08 14:53:42 -0700244}