elfarcv2.sc revision 1.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 christos 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 christos
183 1.1 christos .rodata ${RELOCATING-0} :
184 1.1 christos {
185 1.1 christos *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)}
186 1.1 christos } ${RELOCATING+> ${TEXT_MEMORY}}
187 1.1 christos
188 1.1 christos .rodata1 ${RELOCATING-0} : { *(.rodata1) } ${RELOCATING+> ${TEXT_MEMORY}}
189 1.1 christos
190 1.1 christos .init ${RELOCATING-0} :
191 1.1 christos {
192 1.1 christos ${RELOCATING+${INIT_START}}
193 1.1 christos KEEP (*(.init))
194 1.1 christos ${RELOCATING+${INIT_END}}
195 1.1 christos } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
196 1.1 christos
197 1.1 christos .text ${RELOCATING-0} :
198 1.1 christos {
199 1.1 christos ${RELOCATING+${TEXT_START_SYMBOLS}}
200 1.1 christos
201 1.1 christos *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
202 1.1 christos /* .gnu.warning sections are handled specially by elf32.em. */
203 1.1 christos *(.gnu.warning)
204 1.1 christos
205 1.1 christos ${RELOCATING+${OTHER_TEXT_SECTIONS}}
206 1.1 christos
207 1.1 christos } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
208 1.1 christos
209 1.1 christos .fini ${RELOCATING-0} :
210 1.1 christos {
211 1.1 christos ${RELOCATING+${FINI_START}}
212 1.1 christos KEEP (*(.fini))
213 1.1 christos ${RELOCATING+${FINI_END}}
214 1.1 christos
215 1.1 christos ${RELOCATING+PROVIDE (__etext = .);}
216 1.1 christos ${RELOCATING+PROVIDE (_etext = .);}
217 1.1 christos ${RELOCATING+PROVIDE (etext = .);}
218 1.1 christos } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
219 1.1 christos
220 1.1 christos ${RELOCATING+${OTHER_READONLY_SECTIONS}}
221 1.1 christos
222 1.1 christos /* Start of the data section image in ROM. */
223 1.1 christos ${RELOCATING+__data_image = .;}
224 1.1 christos ${RELOCATING+PROVIDE (__data_image = .);}
225 1.1 christos
226 1.1 christos .data ${RELOCATING-0} :
227 1.1 christos {
228 1.1 christos ${RELOCATING+ PROVIDE (__data_start = .) ; }
229 1.1 christos /* --gc-sections will delete empty .data. This leads to wrong start
230 1.1 christos addresses for subsequent sections because -Tdata= from the command
231 1.1 christos line will have no effect, see PR13697. Thus, keep .data */
232 1.1 christos KEEP (*(.data))
233 1.1 christos ${RELOCATING+${DATA_START_SYMBOLS}}
234 1.1 christos *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
235 1.1 christos ${CONSTRUCTING+SORT(CONSTRUCTORS)}
236 1.1 christos
237 1.1 christos } ${RELOCATING+ > ${DATA_MEMORY}}
238 1.1 christos
239 1.1 christos ${GOT}
240 1.1 christos ${RELOCATING+${CTOR}}
241 1.1 christos ${RELOCATING+${DTOR}}
242 1.1 christos
243 1.1 christos ${RELOCATING+${SDATA}}
244 1.1 christos ${RELOCATING+${SDATA2}}
245 1.1 christos ${RELOCATING+${SBSS}}
246 1.1 christos ${RELOCATING+${SBSS2}}
247 1.1 christos .bss ${RELOCATING-0} :
248 1.1 christos {
249 1.1 christos *(.dynbss)
250 1.1 christos *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
251 1.1 christos *(COMMON)
252 1.1 christos /* Align here to ensure that the .bss section occupies space up to
253 1.1 christos _end. Align after .bss to ensure correct alignment even if the
254 1.1 christos .bss section disappears because there are no input sections. */
255 1.1 christos ${RELOCATING+. = ALIGN(${ALIGNMENT});}
256 1.1 christos ${RELOCATING+_end = .;}
257 1.1 christos ${RELOCATING+PROVIDE (end = .);}
258 1.1 christos } ${RELOCATING+ > ${DATA_MEMORY}}
259 1.1 christos
260 1.1 christos /* Global data not cleared after reset. */
261 1.1 christos .noinit ${RELOCATING-0}:
262 1.1 christos {
263 1.1 christos *(.noinit*)
264 1.1 christos ${RELOCATING+. = ALIGN(${ALIGNMENT});}
265 1.1 christos ${RELOCATING+ PROVIDE (__start_heap = .) ; }
266 1.1 christos } ${RELOCATING+ > ${DATA_MEMORY}}
267 1.1 christos
268 1.1 christos
269 1.1 christos /* Stabs debugging sections. */
270 1.1 christos .stab 0 : { *(.stab) }
271 1.1 christos .stabstr 0 : { *(.stabstr) }
272 1.1 christos .stab.excl 0 : { *(.stab.excl) }
273 1.1 christos .stab.exclstr 0 : { *(.stab.exclstr) }
274 1.1 christos .stab.index 0 : { *(.stab.index) }
275 1.1 christos .stab.indexstr 0 : { *(.stab.indexstr) }
276 1.1 christos
277 1.1 christos .comment 0 : { *(.comment) }
278 1.1 christos
279 1.1 christos /* DWARF debug sections.
280 1.1 christos Symbols in the DWARF debugging sections are relative to the beginning
281 1.1 christos of the section so we begin them at 0. */
282 1.1 christos
283 1.1 christos /* DWARF 1 */
284 1.1 christos .debug 0 : { *(.debug) }
285 1.1 christos .line 0 : { *(.line) }
286 1.1 christos
287 1.1 christos /* GNU DWARF 1 extensions */
288 1.1 christos .debug_srcinfo 0 : { *(.debug_srcinfo) }
289 1.1 christos .debug_sfnames 0 : { *(.debug_sfnames) }
290 1.1 christos
291 1.1 christos /* DWARF 1.1 and DWARF 2 */
292 1.1 christos .debug_aranges 0 : { *(.debug_aranges) }
293 1.1 christos .debug_pubnames 0 : { *(.debug_pubnames) }
294 1.1 christos
295 1.1 christos /* DWARF 2 */
296 1.1 christos .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
297 1.1 christos .debug_abbrev 0 : { *(.debug_abbrev) }
298 1.1 christos .debug_line 0 : { *(.debug_line) }
299 1.1 christos .debug_frame 0 : { *(.debug_frame) }
300 1.1 christos .debug_str 0 : { *(.debug_str) }
301 1.1 christos .debug_loc 0 : { *(.debug_loc) }
302 1.1 christos .debug_macinfo 0 : { *(.debug_macinfo) }
303 1.1 christos
304 1.1 christos /* DWARF 3 */
305 1.1 christos .debug_pubtypes 0 : { *(.debug_pubtypes) }
306 1.1 christos .debug_ranges 0 : { *(.debug_ranges) }
307 1.1 christos
308 1.1 christos /* DWARF Extension. */
309 1.1 christos .debug_macro 0 : { *(.debug_macro) }
310 1.1 christos
311 1.1 christos /* ARC Extension Sections */
312 1.1 christos .arcextmap 0 : { *(.gnu.linkonce.arcextmap.*) }
313 1.1 christos }
314 1.1 christos EOF
315