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