Rename elf32.em to elf.em
[deliverable/binutils-gdb.git] / ld / scripttempl / elfarcv2.sc
CommitLineData
886a2506
NC
1#
2# Unusual variables checked by this code:
3# NOP - four byte opcode for no-op (defaults to 0)
4# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
5# empty.
6# OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
7# (e.g., .PARISC.milli)
8# When adding sections, do note that the names of some sections are used
9# when specifying the start address of the next.
10#
11test -z "$ENTRY" && ENTRY=start
12test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
13test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
14# If we request a big endian toolchain, give a big endian linker
2bf2bf23 15test -z "$GOT" && GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) } ${RELOCATING+ > ${DATA_MEMORY}}"
886a2506
NC
16test "${ARC_ENDIAN}" == "big" && OUTPUT_FORMAT=${BIG_OUTPUT_FORMAT}
17if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
18test -z "${ELFSIZE}" && ELFSIZE=32
19test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
20test "$LD_FLAG" = "N" && DATA_ADDR=.
21
6c19b93b 22CTOR=".ctors ${CONSTRUCTING-0} :
886a2506
NC
23 {
24 ${CONSTRUCTING+${CTOR_START}}
25 /* gcc uses crtbegin.o to find the start of
26 the constructors, so we make sure it is
27 first. Because this is a wildcard, it
28 doesn't matter if the user does not
29 actually link against crtbegin.o; the
30 linker won't look for a file to match a
31 wildcard. The wildcard also means that it
32 doesn't matter which directory crtbegin.o
33 is in. */
34
35 KEEP (*crtbegin*.o(.ctors))
36
37 /* We don't want to include the .ctor section from
38 from the crtend.o file until after the sorted ctors.
39 The .ctor section from the crtend file contains the
40 end of ctors marker and it must be last */
41
42 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
43 KEEP (*(SORT(.ctors.*)))
44 KEEP (*(.ctors))
45 ${CONSTRUCTING+${CTOR_END}}
46 } ${RELOCATING+ > ${DATA_MEMORY}}"
47DTOR=".dtors ${CONSTRUCTING-0} :
48 {
49 ${CONSTRUCTING+${DTOR_START}}
50 KEEP (*crtbegin*.o(.dtors))
51 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
52 KEEP (*(SORT(.dtors.*)))
53 KEEP (*(.dtors))
54 ${CONSTRUCTING+${DTOR_END}}
55 } ${RELOCATING+ > ${DATA_MEMORY}}"
56
57if test -z "${NO_SMALL_DATA}"; then
58 SBSS=".sbss ${RELOCATING-0} :
59 {
60 ${RELOCATING+PROVIDE (__sbss_start = .);}
61 ${RELOCATING+PROVIDE (___sbss_start = .);}
62 *(.dynsbss)
63 *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
64 *(.scommon)
65 ${RELOCATING+PROVIDE (__sbss_end = .);}
66 ${RELOCATING+PROVIDE (___sbss_end = .);}
67 } ${RELOCATING+ > ${SDATA_MEMORY}}"
68 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) } ${RELOCATING+ > ${SDATA_MEMORY}}"
69 SDATA="/* We want the small data sections together, so single-instruction offsets
70 can access them all, and initialized data all before uninitialized, so
71 we can shorten the on-disk segment size. */
72 .sdata ${RELOCATING-0} :
73 {
74 ${RELOCATING+${SDATA_START_SYMBOLS}}
75 *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
76
77 ${RELOCATING+_edata = .;}
78 ${RELOCATING+PROVIDE (edata = .);}
79 } ${RELOCATING+ > ${SDATA_MEMORY}}"
80 SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) } ${RELOCATING+ > ${SDATA_MEMORY}}"
81 REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
82 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
83 REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
84 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
85 REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
86 .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
87 REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
88 .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
89fi
90
91#
92# We provide two emulations: a fixed on that defines some memory banks
93# and a configurable one that includes a user provided memory definition.
94#
95case $GENERIC_BOARD in
96 yes|1|YES)
97 MEMORY_DEF="
98/* Get memory banks definition from some user configuration file.
99 This file must be located in some linker directory (search path
100 with -L<dir>). See fixed memory banks emulation script. */
101INCLUDE memory.x;
102"
103 ;;
104 *)
105MEMORY_DEF="
106/* Fixed definition of the available memory banks.
107 See generic emulation script for a user defined configuration. */
108MEMORY
109{
110 ICCM : ORIGIN = 0x00000000, LENGTH = ${ICCM_SIZE}
111 DCCM : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
112}
113
114/* Setup the stack on the top of the data memory bank. */
115PROVIDE (__stack_top = (${RAM_START_ADDR} + ${RAM_SIZE} - 1) & -4);
116PROVIDE (__end_heap = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
117"
118 ;;
119esac
120
121cat <<EOF
122OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}")
123OUTPUT_ARCH(${OUTPUT_ARCH})
124${RELOCATING+ENTRY(${ENTRY})}
125
126${RELOCATING+${LIB_SEARCH_DIRS}}
127${RELOCATING+${EXECUTABLE_SYMBOLS}}
128${RELOCATING+${MEMORY_DEF}}
129
130SECTIONS
131{
132 .ivt 0x00 :
133 {
134 KEEP (*(.ivt));
135 } ${RELOCATING+ > ${STARTUP_MEMORY}}
136
137 .startup 0x100:
138 {
139 KEEP (*crt0.o(.text.__startup))
140 } ${RELOCATING+ > ${STARTUP_MEMORY}}
141
142 /* Read-only sections, merged into text segment: */
143 ${TEXT_DYNAMIC+${DYNAMIC}}
144 .hash ${RELOCATING-0} : { *(.hash) }
145 .dynsym ${RELOCATING-0} : { *(.dynsym) }
146 .dynstr ${RELOCATING-0} : { *(.dynstr) }
147 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
148 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
149 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
150
151 .rel.init ${RELOCATING-0} : { *(.rel.init) }
152 .rela.init ${RELOCATING-0} : { *(.rela.init) }
153 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
154 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
155 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
156 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
157 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
158 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
159 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
160 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
161 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
162 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
163 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
164 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
165 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
166 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
167 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
168 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
169 .rel.got ${RELOCATING-0} : { *(.rel.got) }
170 .rela.got ${RELOCATING-0} : { *(.rela.got) }
171 ${REL_SDATA}
172 ${REL_SBSS}
173 ${REL_SDATA2}
174 ${REL_SBSS2}
175 .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
176 .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
177
178 .jcr : { KEEP (*(.jcr)) } ${RELOCATING+> ${TEXT_MEMORY}}
179 .eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ${TEXT_MEMORY}}
2bf2bf23 180 .gcc_except_table : { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } ${RELOCATING+> ${TEXT_MEMORY}}
886a2506 181 .plt : { *(.plt) } ${RELOCATING+> ${TEXT_MEMORY}}
684d5a10
JEM
182 .jlitab :
183 {
184 ${RELOCATING+${JLI_START_TABLE}}
2bf2bf23
AM
185 ${RELOCATING+jlitab*.o:(.jlitab*)}
186 *(.jlitab${RELOCATING+*})
684d5a10 187 } ${RELOCATING+> ${TEXT_MEMORY}}
886a2506
NC
188
189 .rodata ${RELOCATING-0} :
190 {
191 *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)}
192 } ${RELOCATING+> ${TEXT_MEMORY}}
193
194 .rodata1 ${RELOCATING-0} : { *(.rodata1) } ${RELOCATING+> ${TEXT_MEMORY}}
195
196 .init ${RELOCATING-0} :
197 {
198 ${RELOCATING+${INIT_START}}
2d3181c7 199 KEEP (*(SORT_NONE(.init)))
886a2506
NC
200 ${RELOCATING+${INIT_END}}
201 } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
202
203 .text ${RELOCATING-0} :
204 {
205 ${RELOCATING+${TEXT_START_SYMBOLS}}
206
207 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
075a2b89 208 /* .gnu.warning sections are handled specially by elf.em. */
886a2506
NC
209 *(.gnu.warning)
210
211 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
212
213 } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
214
215 .fini ${RELOCATING-0} :
216 {
217 ${RELOCATING+${FINI_START}}
2d3181c7 218 KEEP (*(SORT_NONE(.fini)))
886a2506
NC
219 ${RELOCATING+${FINI_END}}
220
221 ${RELOCATING+PROVIDE (__etext = .);}
222 ${RELOCATING+PROVIDE (_etext = .);}
223 ${RELOCATING+PROVIDE (etext = .);}
224 } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
225
226 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
227
228 /* Start of the data section image in ROM. */
229 ${RELOCATING+__data_image = .;}
230 ${RELOCATING+PROVIDE (__data_image = .);}
231
232 .data ${RELOCATING-0} :
233 {
234 ${RELOCATING+ PROVIDE (__data_start = .) ; }
235 /* --gc-sections will delete empty .data. This leads to wrong start
236 addresses for subsequent sections because -Tdata= from the command
237 line will have no effect, see PR13697. Thus, keep .data */
238 KEEP (*(.data))
239 ${RELOCATING+${DATA_START_SYMBOLS}}
2bf2bf23 240 ${RELOCATING+*(.data.* .gnu.linkonce.d.*)}
886a2506
NC
241 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
242
243 } ${RELOCATING+ > ${DATA_MEMORY}}
244
245 ${GOT}
246 ${RELOCATING+${CTOR}}
247 ${RELOCATING+${DTOR}}
248
249 ${RELOCATING+${SDATA}}
250 ${RELOCATING+${SDATA2}}
251 ${RELOCATING+${SBSS}}
252 ${RELOCATING+${SBSS2}}
253 .bss ${RELOCATING-0} :
254 {
2bf2bf23
AM
255 ${RELOCATING+*(.dynbss)}
256 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
257 ${RELOCATING+*(COMMON)
258 /* Align here to ensure that the .bss section occupies space up to
259 _end. Align after .bss to ensure correct alignment even if the
260 .bss section disappears because there are no input sections. */
261 . = ALIGN(${ALIGNMENT});}
886a2506
NC
262 ${RELOCATING+_end = .;}
263 ${RELOCATING+PROVIDE (end = .);}
264 } ${RELOCATING+ > ${DATA_MEMORY}}
265
266 /* Global data not cleared after reset. */
267 .noinit ${RELOCATING-0}:
268 {
269 *(.noinit*)
270 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
271 ${RELOCATING+ PROVIDE (__start_heap = .) ; }
272 } ${RELOCATING+ > ${DATA_MEMORY}}
273
274
275 /* Stabs debugging sections. */
276 .stab 0 : { *(.stab) }
277 .stabstr 0 : { *(.stabstr) }
278 .stab.excl 0 : { *(.stab.excl) }
279 .stab.exclstr 0 : { *(.stab.exclstr) }
280 .stab.index 0 : { *(.stab.index) }
281 .stab.indexstr 0 : { *(.stab.indexstr) }
282
283 .comment 0 : { *(.comment) }
284
285 /* DWARF debug sections.
286 Symbols in the DWARF debugging sections are relative to the beginning
287 of the section so we begin them at 0. */
288
289 /* DWARF 1 */
290 .debug 0 : { *(.debug) }
291 .line 0 : { *(.line) }
292
293 /* GNU DWARF 1 extensions */
294 .debug_srcinfo 0 : { *(.debug_srcinfo) }
295 .debug_sfnames 0 : { *(.debug_sfnames) }
296
297 /* DWARF 1.1 and DWARF 2 */
298 .debug_aranges 0 : { *(.debug_aranges) }
299 .debug_pubnames 0 : { *(.debug_pubnames) }
300
301 /* DWARF 2 */
2bf2bf23 302 .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*}) }
886a2506
NC
303 .debug_abbrev 0 : { *(.debug_abbrev) }
304 .debug_line 0 : { *(.debug_line) }
305 .debug_frame 0 : { *(.debug_frame) }
306 .debug_str 0 : { *(.debug_str) }
307 .debug_loc 0 : { *(.debug_loc) }
308 .debug_macinfo 0 : { *(.debug_macinfo) }
309
310 /* DWARF 3 */
311 .debug_pubtypes 0 : { *(.debug_pubtypes) }
312 .debug_ranges 0 : { *(.debug_ranges) }
313
314 /* DWARF Extension. */
315 .debug_macro 0 : { *(.debug_macro) }
316
317 /* ARC Extension Sections */
318 .arcextmap 0 : { *(.gnu.linkonce.arcextmap.*) }
319}
320EOF
This page took 0.212336 seconds and 4 git commands to generate.