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}}"
58 /* If the 'ivtbase_addr' symbol is defined, it indicates the base address of
59 the interrupt vectors. See description of INT_VECTOR_BASE register. */
61 .ivt DEFINED (ivtbase_addr) ? ivtbase_addr : ORIGIN(${STARTUP_MEMORY}) :
63 ${RELOCATING+ PROVIDE (__ivtbase_addr = .); }
65 } ${RELOCATING+ > ${STARTUP_MEMORY}}"
67 if test -z "${NO_SMALL_DATA}"; then
68 SBSS=".sbss ${RELOCATING-0} :
70 ${RELOCATING+PROVIDE (__sbss_start = .);}
71 ${RELOCATING+PROVIDE (___sbss_start = .);}
73 *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
75 ${RELOCATING+PROVIDE (__sbss_end = .);}
76 ${RELOCATING+PROVIDE (___sbss_end = .);}
77 } ${RELOCATING+ > ${SDATA_MEMORY}}"
78 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) } ${RELOCATING+ > ${SDATA_MEMORY}}"
79 SDATA="/* We want the small data sections together, so single-instruction offsets
80 can access them all, and initialized data all before uninitialized, so
81 we can shorten the on-disk segment size. */
82 .sdata ${RELOCATING-0} :
84 ${RELOCATING+${SDATA_START_SYMBOLS}}
85 *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
87 ${RELOCATING+_edata = .;}
88 ${RELOCATING+PROVIDE (edata = .);}
89 } ${RELOCATING+ > ${SDATA_MEMORY}}"
90 SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) } ${RELOCATING+ > ${SDATA_MEMORY}}"
91 REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
92 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
93 REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
94 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
95 REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
96 .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
97 REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
98 .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
102 # We provide two emulations: a fixed on that defines some memory banks
103 # and a configurable one that includes a user provided memory definition.
105 case $GENERIC_BOARD in
107 test -z "$MEMORY_FILE" && MEMORY_FILE="memory.x"
109 /* Get memory banks definition from some user configuration file.
110 This file must be located in some linker directory (search path
111 with -L<dir>). See fixed memory banks emulation script. */
112 INCLUDE ${MEMORY_FILE};
117 __TEXT_REGION_ORIGIN__ = DEFINED(__TEXT_REGION_ORIGIN__) ? __TEXT_REGION_ORIGIN__ : 0x00;
118 __TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : ${ICCM_SIZE};
119 __DATA_REGION_ORIGIN__ = DEFINED(__DATA_REGION_ORIGIN__) ? __DATA_REGION_ORIGIN__ : ${RAM_START_ADDR};
120 __DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : ${RAM_SIZE};
124 ICCM : ORIGIN = __TEXT_REGION_ORIGIN__, LENGTH = __TEXT_REGION_LENGTH__
125 DCCM : ORIGIN = __DATA_REGION_ORIGIN__, LENGTH = __DATA_REGION_LENGTH__
132 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}")
133 OUTPUT_ARCH(${OUTPUT_ARCH})
134 ${RELOCATING+ENTRY(${ENTRY})}
136 ${RELOCATING+${LIB_SEARCH_DIRS}}
137 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
138 ${RELOCATING+${MEMORY_DEF}}
144 /* Read-only sections, merged into text segment: */
145 ${TEXT_DYNAMIC+${DYNAMIC}}
146 .hash ${RELOCATING-0} : { *(.hash) }
147 .dynsym ${RELOCATING-0} : { *(.dynsym) }
148 .dynstr ${RELOCATING-0} : { *(.dynstr) }
149 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
150 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
151 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
153 .rel.init ${RELOCATING-0} : { *(.rel.init) }
154 .rela.init ${RELOCATING-0} : { *(.rela.init) }
155 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
156 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
157 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
158 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
159 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
160 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
161 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
162 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
163 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
164 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
165 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
166 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
167 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
168 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
169 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
170 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
171 .rel.got ${RELOCATING-0} : { *(.rel.got) }
172 .rela.got ${RELOCATING-0} : { *(.rela.got) }
177 .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
178 .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
180 .text ${RELOCATING-0} :
182 ${RELOCATING+${TEXT_START_SYMBOLS}}
184 ${RELOCATING+ . = ALIGN(4);}
185 ${RELOCATING+${INIT_START}}
186 KEEP (*(SORT_NONE(.init)))
187 ${RELOCATING+${INIT_END}}
189 /* Start here after reset. */
190 ${RELOCATING+ . = ALIGN(4);}
191 KEEP (*crt0.o(.text.__startup))
193 /* Remaining code. */
194 ${RELOCATING+ . = ALIGN(4);}
195 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
196 /* .gnu.warning sections are handled specially by elf.em. */
199 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
201 } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
203 .fini ${RELOCATING-0} :
205 ${RELOCATING+${FINI_START}}
206 KEEP (*(SORT_NONE(.fini)))
207 ${RELOCATING+${FINI_END}}
209 ${RELOCATING+PROVIDE (__etext = .);}
210 ${RELOCATING+PROVIDE (_etext = .);}
211 ${RELOCATING+PROVIDE (etext = .);}
212 } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
214 .jcr ${RELOCATING-0} :
217 } ${RELOCATING+> ${TEXT_MEMORY}}
219 .eh_frame ${RELOCATING-0} :
222 } ${RELOCATING+> ${TEXT_MEMORY}}
224 .gcc_except_table ${RELOCATING-0} :
226 *(.gcc_except_table) *(.gcc_except_table.*)
227 } ${RELOCATING+> ${TEXT_MEMORY}}
229 .plt ${RELOCATING-0} :
232 } ${RELOCATING+> ${TEXT_MEMORY}}
234 .jlitab ${RELOCATING-0} :
236 ${RELOCATING+${JLI_START_TABLE}}
237 jlitab*.o:(.jlitab*) *(.jlitab*)
238 } ${RELOCATING+> ${TEXT_MEMORY}}
240 .rodata ${RELOCATING-0} :
242 *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)}
243 } ${RELOCATING+> ${TEXT_MEMORY}}
245 .rodata1 ${RELOCATING-0} : { *(.rodata1) } ${RELOCATING+> ${TEXT_MEMORY}}
247 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
249 /* Start of the data section image in ROM. */
250 ${RELOCATING+__data_image = .;}
251 ${RELOCATING+PROVIDE (__data_image = .);}
253 .data ${RELOCATING-0} :
255 ${RELOCATING+ PROVIDE (__data_start = .) ; }
256 /* --gc-sections will delete empty .data. This leads to wrong start
257 addresses for subsequent sections because -Tdata= from the command
258 line will have no effect, see PR13697. Thus, keep .data */
260 ${RELOCATING+${DATA_START_SYMBOLS}}
261 ${RELOCATING+*(.data.* .gnu.linkonce.d.*)}
262 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
264 } ${RELOCATING+ > ${DATA_MEMORY}}
267 ${RELOCATING+${CTOR}}
268 ${RELOCATING+${DTOR}}
270 ${RELOCATING+${SDATA}}
271 ${RELOCATING+${SDATA2}}
272 ${RELOCATING+${SBSS}}
273 ${RELOCATING+${SBSS2}}
274 .bss ${RELOCATING-0} :
276 ${RELOCATING+*(.dynbss)}
277 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
278 ${RELOCATING+*(COMMON)
279 /* Align here to ensure that the .bss section occupies space up to
280 _end. Align after .bss to ensure correct alignment even if the
281 .bss section disappears because there are no input sections. */
282 . = ALIGN(${ALIGNMENT});}
283 ${RELOCATING+_end = .;}
284 ${RELOCATING+PROVIDE (end = .);}
285 } ${RELOCATING+ > ${DATA_MEMORY}}
287 /* Global data not cleared after reset. */
288 .noinit ${RELOCATING-0}:
290 *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*})
291 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
292 ${RELOCATING+ PROVIDE (__start_heap = .) ; }
293 } ${RELOCATING+ > ${DATA_MEMORY}}
295 ${RELOCATING+ PROVIDE (__stack_top = (ORIGIN (${DATA_MEMORY}) + LENGTH (${DATA_MEMORY}) - 1) & -4);}
296 ${RELOCATING+ PROVIDE (__end_heap = ORIGIN (${DATA_MEMORY}) + LENGTH (${DATA_MEMORY}) - 1);}
298 .note.gnu.build-id : { *(.note.gnu.build-id) }
301 source_sh $srcdir/scripttempl/misc-sections.sc
302 source_sh $srcdir/scripttempl/DWARF.sc
305 /* ARC Extension Sections */
306 .arcextmap 0 : { *(.arcextmap.*) }