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
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.
11 test -z "$ENTRY" && ENTRY=start
12 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
13 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
14 # If we request a big endian toolchain, give a big endian linker
15 test -z "$GOT" && GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) } ${RELOCATING+ > ${DATA_MEMORY}}"
16 test "${ARC_ENDIAN}" == "big" && OUTPUT_FORMAT=${BIG_OUTPUT_FORMAT}
17 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
18 test -z "${ELFSIZE}" && ELFSIZE=32
19 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
20 test "$LD_FLAG" = "N" && DATA_ADDR=.
22 CTOR=".ctors ${CONSTRUCTING-0} :
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
35 KEEP (*crtbegin*.o(.ctors))
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 */
42 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
43 KEEP (*(SORT(.ctors.*)))
45 ${CONSTRUCTING+${CTOR_END}}
46 } ${RELOCATING+ > ${DATA_MEMORY}}"
47 DTOR=".dtors ${CONSTRUCTING-0} :
49 ${CONSTRUCTING+${DTOR_START}}
50 KEEP (*crtbegin*.o(.dtors))
51 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
52 KEEP (*(SORT(.dtors.*)))
54 ${CONSTRUCTING+${DTOR_END}}
55 } ${RELOCATING+ > ${DATA_MEMORY}}"
57 if test -z "${NO_SMALL_DATA}"; then
58 SBSS=".sbss ${RELOCATING-0} :
60 ${RELOCATING+PROVIDE (__sbss_start = .);}
61 ${RELOCATING+PROVIDE (___sbss_start = .);}
63 *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
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} :
74 ${RELOCATING+${SDATA_START_SYMBOLS}}
75 *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
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.*}) }"
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.
95 case $GENERIC_BOARD in
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. */
106 /* Fixed definition of the available memory banks.
107 See generic emulation script for a user defined configuration. */
110 ICCM : ORIGIN = 0x00000000, LENGTH = ${ICCM_SIZE}
111 DCCM : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
114 /* Setup the stack on the top of the data memory bank. */
115 PROVIDE (__stack_top = (${RAM_START_ADDR} + ${RAM_SIZE} - 1) & -4);
116 PROVIDE (__end_heap = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
122 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}")
123 OUTPUT_ARCH(${OUTPUT_ARCH})
124 ${RELOCATING+ENTRY(${ENTRY})}
126 ${RELOCATING+${LIB_SEARCH_DIRS}}
127 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
128 ${RELOCATING+${MEMORY_DEF}}
135 } ${RELOCATING+ > ${STARTUP_MEMORY}}
139 KEEP (*crt0.o(.text.__startup))
140 } ${RELOCATING+ > ${STARTUP_MEMORY}}
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) }
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) }
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.*}) }
178 .jcr : { KEEP (*(.jcr)) } ${RELOCATING+> ${TEXT_MEMORY}}
179 .eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ${TEXT_MEMORY}}
180 .gcc_except_table : { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } ${RELOCATING+> ${TEXT_MEMORY}}
181 .plt : { *(.plt) } ${RELOCATING+> ${TEXT_MEMORY}}
184 ${RELOCATING+${JLI_START_TABLE}}
185 ${RELOCATING+jlitab*.o:(.jlitab*)}
186 *(.jlitab${RELOCATING+*})
187 } ${RELOCATING+> ${TEXT_MEMORY}}
189 .rodata ${RELOCATING-0} :
191 *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)}
192 } ${RELOCATING+> ${TEXT_MEMORY}}
194 .rodata1 ${RELOCATING-0} : { *(.rodata1) } ${RELOCATING+> ${TEXT_MEMORY}}
196 .init ${RELOCATING-0} :
198 ${RELOCATING+${INIT_START}}
199 KEEP (*(SORT_NONE(.init)))
200 ${RELOCATING+${INIT_END}}
201 } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
203 .text ${RELOCATING-0} :
205 ${RELOCATING+${TEXT_START_SYMBOLS}}
207 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
208 /* .gnu.warning sections are handled specially by elf32.em. */
211 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
213 } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
215 .fini ${RELOCATING-0} :
217 ${RELOCATING+${FINI_START}}
218 KEEP (*(SORT_NONE(.fini)))
219 ${RELOCATING+${FINI_END}}
221 ${RELOCATING+PROVIDE (__etext = .);}
222 ${RELOCATING+PROVIDE (_etext = .);}
223 ${RELOCATING+PROVIDE (etext = .);}
224 } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
226 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
228 /* Start of the data section image in ROM. */
229 ${RELOCATING+__data_image = .;}
230 ${RELOCATING+PROVIDE (__data_image = .);}
232 .data ${RELOCATING-0} :
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 */
239 ${RELOCATING+${DATA_START_SYMBOLS}}
240 ${RELOCATING+*(.data.* .gnu.linkonce.d.*)}
241 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
243 } ${RELOCATING+ > ${DATA_MEMORY}}
246 ${RELOCATING+${CTOR}}
247 ${RELOCATING+${DTOR}}
249 ${RELOCATING+${SDATA}}
250 ${RELOCATING+${SDATA2}}
251 ${RELOCATING+${SBSS}}
252 ${RELOCATING+${SBSS2}}
253 .bss ${RELOCATING-0} :
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});}
262 ${RELOCATING+_end = .;}
263 ${RELOCATING+PROVIDE (end = .);}
264 } ${RELOCATING+ > ${DATA_MEMORY}}
266 /* Global data not cleared after reset. */
267 .noinit ${RELOCATING-0}:
270 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
271 ${RELOCATING+ PROVIDE (__start_heap = .) ; }
272 } ${RELOCATING+ > ${DATA_MEMORY}}
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) }
283 .comment 0 : { *(.comment) }
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. */
290 .debug 0 : { *(.debug) }
291 .line 0 : { *(.line) }
293 /* GNU DWARF 1 extensions */
294 .debug_srcinfo 0 : { *(.debug_srcinfo) }
295 .debug_sfnames 0 : { *(.debug_sfnames) }
297 /* DWARF 1.1 and DWARF 2 */
298 .debug_aranges 0 : { *(.debug_aranges) }
299 .debug_pubnames 0 : { *(.debug_pubnames) }
302 .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*}) }
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) }
311 .debug_pubtypes 0 : { *(.debug_pubtypes) }
312 .debug_ranges 0 : { *(.debug_ranges) }
314 /* DWARF Extension. */
315 .debug_macro 0 : { *(.debug_macro) }
317 /* ARC Extension Sections */
318 .arcextmap 0 : { *(.gnu.linkonce.arcextmap.*) }