elfarcv2.sc revision 1.1.1.4 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.1.3 christos test -z "$GOT" && GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) } ${RELOCATING+ > ${DATA_MEMORY}}"
16 1.1.1.4 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.2 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.1.3 christos IVT="
58 1.1.1.3 christos /* If the 'ivtbase_addr' symbol is defined, it indicates the base address of
59 1.1.1.3 christos the interrupt vectors. See description of INT_VECTOR_BASE register. */
60 1.1.1.3 christos
61 1.1.1.3 christos .ivt DEFINED (ivtbase_addr) ? ivtbase_addr : 0x00 :
62 1.1.1.3 christos {
63 1.1.1.3 christos ${RELOCATING+ PROVIDE (__ivtbase_addr = .); }
64 1.1.1.3 christos KEEP (*(.ivt));
65 1.1.1.3 christos } ${RELOCATING+ > ${STARTUP_MEMORY}}"
66 1.1.1.3 christos
67 1.1 christos if test -z "${NO_SMALL_DATA}"; then
68 1.1 christos SBSS=".sbss ${RELOCATING-0} :
69 1.1 christos {
70 1.1 christos ${RELOCATING+PROVIDE (__sbss_start = .);}
71 1.1 christos ${RELOCATING+PROVIDE (___sbss_start = .);}
72 1.1 christos *(.dynsbss)
73 1.1 christos *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
74 1.1 christos *(.scommon)
75 1.1 christos ${RELOCATING+PROVIDE (__sbss_end = .);}
76 1.1 christos ${RELOCATING+PROVIDE (___sbss_end = .);}
77 1.1 christos } ${RELOCATING+ > ${SDATA_MEMORY}}"
78 1.1 christos SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) } ${RELOCATING+ > ${SDATA_MEMORY}}"
79 1.1 christos SDATA="/* We want the small data sections together, so single-instruction offsets
80 1.1 christos can access them all, and initialized data all before uninitialized, so
81 1.1 christos we can shorten the on-disk segment size. */
82 1.1 christos .sdata ${RELOCATING-0} :
83 1.1 christos {
84 1.1 christos ${RELOCATING+${SDATA_START_SYMBOLS}}
85 1.1 christos *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
86 1.1 christos
87 1.1 christos ${RELOCATING+_edata = .;}
88 1.1 christos ${RELOCATING+PROVIDE (edata = .);}
89 1.1 christos } ${RELOCATING+ > ${SDATA_MEMORY}}"
90 1.1 christos SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) } ${RELOCATING+ > ${SDATA_MEMORY}}"
91 1.1 christos REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
92 1.1 christos .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
93 1.1 christos REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
94 1.1 christos .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
95 1.1 christos REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
96 1.1 christos .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
97 1.1 christos REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
98 1.1 christos .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
99 1.1 christos fi
100 1.1 christos
101 1.1 christos #
102 1.1 christos # We provide two emulations: a fixed on that defines some memory banks
103 1.1 christos # and a configurable one that includes a user provided memory definition.
104 1.1 christos #
105 1.1 christos case $GENERIC_BOARD in
106 1.1 christos yes|1|YES)
107 1.1 christos MEMORY_DEF="
108 1.1 christos /* Get memory banks definition from some user configuration file.
109 1.1 christos This file must be located in some linker directory (search path
110 1.1 christos with -L<dir>). See fixed memory banks emulation script. */
111 1.1 christos INCLUDE memory.x;
112 1.1 christos "
113 1.1 christos ;;
114 1.1 christos *)
115 1.1 christos MEMORY_DEF="
116 1.1 christos /* Fixed definition of the available memory banks.
117 1.1 christos See generic emulation script for a user defined configuration. */
118 1.1 christos MEMORY
119 1.1 christos {
120 1.1 christos ICCM : ORIGIN = 0x00000000, LENGTH = ${ICCM_SIZE}
121 1.1 christos DCCM : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
122 1.1 christos }
123 1.1 christos "
124 1.1 christos ;;
125 1.1 christos esac
126 1.1 christos
127 1.1 christos cat <<EOF
128 1.1 christos OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}")
129 1.1 christos OUTPUT_ARCH(${OUTPUT_ARCH})
130 1.1 christos ${RELOCATING+ENTRY(${ENTRY})}
131 1.1 christos
132 1.1 christos ${RELOCATING+${LIB_SEARCH_DIRS}}
133 1.1 christos ${RELOCATING+${EXECUTABLE_SYMBOLS}}
134 1.1 christos ${RELOCATING+${MEMORY_DEF}}
135 1.1 christos
136 1.1 christos SECTIONS
137 1.1 christos {
138 1.1.1.3 christos ${RELOCATING+${IVT}}
139 1.1 christos
140 1.1 christos /* Read-only sections, merged into text segment: */
141 1.1 christos ${TEXT_DYNAMIC+${DYNAMIC}}
142 1.1 christos .hash ${RELOCATING-0} : { *(.hash) }
143 1.1 christos .dynsym ${RELOCATING-0} : { *(.dynsym) }
144 1.1 christos .dynstr ${RELOCATING-0} : { *(.dynstr) }
145 1.1 christos .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
146 1.1 christos .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
147 1.1 christos .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
148 1.1 christos
149 1.1 christos .rel.init ${RELOCATING-0} : { *(.rel.init) }
150 1.1 christos .rela.init ${RELOCATING-0} : { *(.rela.init) }
151 1.1 christos .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
152 1.1 christos .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
153 1.1 christos .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
154 1.1 christos .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
155 1.1 christos .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
156 1.1 christos .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
157 1.1 christos .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
158 1.1 christos .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
159 1.1 christos .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
160 1.1 christos .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
161 1.1 christos .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
162 1.1 christos .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
163 1.1 christos .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
164 1.1 christos .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
165 1.1 christos .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
166 1.1 christos .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
167 1.1 christos .rel.got ${RELOCATING-0} : { *(.rel.got) }
168 1.1 christos .rela.got ${RELOCATING-0} : { *(.rela.got) }
169 1.1 christos ${REL_SDATA}
170 1.1 christos ${REL_SBSS}
171 1.1 christos ${REL_SDATA2}
172 1.1 christos ${REL_SBSS2}
173 1.1 christos .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
174 1.1 christos .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
175 1.1 christos
176 1.1.1.3 christos .text ${RELOCATING-0} :
177 1.1 christos {
178 1.1.1.3 christos ${RELOCATING+${TEXT_START_SYMBOLS}}
179 1.1 christos
180 1.1.1.3 christos ${RELOCATING+ . = ALIGN(4);}
181 1.1 christos ${RELOCATING+${INIT_START}}
182 1.1.1.3 christos KEEP (*(SORT_NONE(.init)))
183 1.1 christos ${RELOCATING+${INIT_END}}
184 1.1 christos
185 1.1.1.3 christos /* Start here after reset. */
186 1.1.1.3 christos ${RELOCATING+ . = ALIGN(4);}
187 1.1.1.3 christos KEEP (*crt0.o(.text.__startup))
188 1.1 christos
189 1.1.1.3 christos /* Remaining code. */
190 1.1.1.3 christos ${RELOCATING+ . = ALIGN(4);}
191 1.1 christos *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
192 1.1.1.3 christos /* .gnu.warning sections are handled specially by elf.em. */
193 1.1 christos *(.gnu.warning)
194 1.1 christos
195 1.1 christos ${RELOCATING+${OTHER_TEXT_SECTIONS}}
196 1.1 christos
197 1.1 christos } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
198 1.1 christos
199 1.1 christos .fini ${RELOCATING-0} :
200 1.1 christos {
201 1.1 christos ${RELOCATING+${FINI_START}}
202 1.1.1.3 christos KEEP (*(SORT_NONE(.fini)))
203 1.1 christos ${RELOCATING+${FINI_END}}
204 1.1 christos
205 1.1 christos ${RELOCATING+PROVIDE (__etext = .);}
206 1.1 christos ${RELOCATING+PROVIDE (_etext = .);}
207 1.1 christos ${RELOCATING+PROVIDE (etext = .);}
208 1.1 christos } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0}
209 1.1 christos
210 1.1.1.3 christos .jcr ${RELOCATING-0} :
211 1.1.1.3 christos {
212 1.1.1.3 christos KEEP (*(.jcr))
213 1.1.1.3 christos } ${RELOCATING+> ${TEXT_MEMORY}}
214 1.1.1.3 christos
215 1.1.1.3 christos .eh_frame ${RELOCATING-0} :
216 1.1.1.3 christos {
217 1.1.1.3 christos KEEP (*(.eh_frame))
218 1.1.1.3 christos } ${RELOCATING+> ${TEXT_MEMORY}}
219 1.1.1.3 christos
220 1.1.1.3 christos .gcc_except_table ${RELOCATING-0} :
221 1.1.1.3 christos {
222 1.1.1.3 christos *(.gcc_except_table) *(.gcc_except_table.*)
223 1.1.1.3 christos } ${RELOCATING+> ${TEXT_MEMORY}}
224 1.1.1.3 christos
225 1.1.1.3 christos .plt ${RELOCATING-0} :
226 1.1.1.3 christos {
227 1.1.1.3 christos *(.plt)
228 1.1.1.3 christos } ${RELOCATING+> ${TEXT_MEMORY}}
229 1.1.1.3 christos
230 1.1.1.3 christos .jlitab ${RELOCATING-0} :
231 1.1.1.3 christos {
232 1.1.1.3 christos ${RELOCATING+${JLI_START_TABLE}}
233 1.1.1.3 christos jlitab*.o:(.jlitab*) *(.jlitab*)
234 1.1.1.3 christos } ${RELOCATING+> ${TEXT_MEMORY}}
235 1.1.1.3 christos
236 1.1.1.3 christos .rodata ${RELOCATING-0} :
237 1.1.1.3 christos {
238 1.1.1.3 christos *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)}
239 1.1.1.3 christos } ${RELOCATING+> ${TEXT_MEMORY}}
240 1.1.1.3 christos
241 1.1.1.3 christos .rodata1 ${RELOCATING-0} : { *(.rodata1) } ${RELOCATING+> ${TEXT_MEMORY}}
242 1.1.1.3 christos
243 1.1 christos ${RELOCATING+${OTHER_READONLY_SECTIONS}}
244 1.1 christos
245 1.1 christos /* Start of the data section image in ROM. */
246 1.1 christos ${RELOCATING+__data_image = .;}
247 1.1 christos ${RELOCATING+PROVIDE (__data_image = .);}
248 1.1 christos
249 1.1 christos .data ${RELOCATING-0} :
250 1.1 christos {
251 1.1 christos ${RELOCATING+ PROVIDE (__data_start = .) ; }
252 1.1 christos /* --gc-sections will delete empty .data. This leads to wrong start
253 1.1 christos addresses for subsequent sections because -Tdata= from the command
254 1.1 christos line will have no effect, see PR13697. Thus, keep .data */
255 1.1 christos KEEP (*(.data))
256 1.1 christos ${RELOCATING+${DATA_START_SYMBOLS}}
257 1.1.1.3 christos ${RELOCATING+*(.data.* .gnu.linkonce.d.*)}
258 1.1 christos ${CONSTRUCTING+SORT(CONSTRUCTORS)}
259 1.1 christos
260 1.1 christos } ${RELOCATING+ > ${DATA_MEMORY}}
261 1.1 christos
262 1.1 christos ${GOT}
263 1.1 christos ${RELOCATING+${CTOR}}
264 1.1 christos ${RELOCATING+${DTOR}}
265 1.1 christos
266 1.1 christos ${RELOCATING+${SDATA}}
267 1.1 christos ${RELOCATING+${SDATA2}}
268 1.1 christos ${RELOCATING+${SBSS}}
269 1.1 christos ${RELOCATING+${SBSS2}}
270 1.1 christos .bss ${RELOCATING-0} :
271 1.1 christos {
272 1.1.1.3 christos ${RELOCATING+*(.dynbss)}
273 1.1.1.3 christos *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
274 1.1.1.3 christos ${RELOCATING+*(COMMON)
275 1.1.1.3 christos /* Align here to ensure that the .bss section occupies space up to
276 1.1.1.3 christos _end. Align after .bss to ensure correct alignment even if the
277 1.1.1.3 christos .bss section disappears because there are no input sections. */
278 1.1.1.3 christos . = ALIGN(${ALIGNMENT});}
279 1.1 christos ${RELOCATING+_end = .;}
280 1.1 christos ${RELOCATING+PROVIDE (end = .);}
281 1.1 christos } ${RELOCATING+ > ${DATA_MEMORY}}
282 1.1 christos
283 1.1 christos /* Global data not cleared after reset. */
284 1.1 christos .noinit ${RELOCATING-0}:
285 1.1 christos {
286 1.1.1.4 christos *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*})
287 1.1 christos ${RELOCATING+. = ALIGN(${ALIGNMENT});}
288 1.1 christos ${RELOCATING+ PROVIDE (__start_heap = .) ; }
289 1.1 christos } ${RELOCATING+ > ${DATA_MEMORY}}
290 1.1 christos
291 1.1.1.3 christos ${RELOCATING+ PROVIDE (__stack_top = (ORIGIN (${DATA_MEMORY}) + LENGTH (${DATA_MEMORY}) - 1) & -4);}
292 1.1.1.3 christos ${RELOCATING+ PROVIDE (__end_heap = ORIGIN (${DATA_MEMORY}) + LENGTH (${DATA_MEMORY}) - 1);}
293 1.1 christos
294 1.1 christos /* Stabs debugging sections. */
295 1.1 christos .stab 0 : { *(.stab) }
296 1.1 christos .stabstr 0 : { *(.stabstr) }
297 1.1 christos .stab.excl 0 : { *(.stab.excl) }
298 1.1 christos .stab.exclstr 0 : { *(.stab.exclstr) }
299 1.1 christos .stab.index 0 : { *(.stab.index) }
300 1.1 christos .stab.indexstr 0 : { *(.stab.indexstr) }
301 1.1 christos
302 1.1 christos .comment 0 : { *(.comment) }
303 1.1.1.3 christos .note.gnu.build-id : { *(.note.gnu.build-id) }
304 1.1.1.3 christos EOF
305 1.1 christos
306 1.1.1.3 christos . $srcdir/scripttempl/DWARF.sc
307 1.1 christos
308 1.1.1.3 christos cat <<EOF
309 1.1 christos /* ARC Extension Sections */
310 1.1.1.3 christos .arcextmap 0 : { *(.arcextmap.*) }
311 1.1 christos }
312 1.1 christos EOF
313