Applied Stephane Carrez <Stephane.Carrez@worldnet.fr> patches to add support
[deliverable/binutils-gdb.git] / ld / scripttempl / elfm68hc12.sc
1 #
2 # Unusual variables checked by this code:
3 # NOP - two byte opcode for no-op (defaults to 0)
4 # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
5 # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
6 # (e.g., .PARISC.global)
7 # OTHER_SECTIONS - at the end
8 # EXECUTABLE_SYMBOLS - symbols that must be defined for an
9 # executable (e.g., _DYNAMIC_LINK)
10 # TEXT_START_SYMBOLS - symbols that appear at the start of the
11 # .text section.
12 # DATA_START_SYMBOLS - symbols that appear at the start of the
13 # .data section.
14 # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
15 # .bss section besides __bss_start.
16 # EMBEDDED - whether this is for an embedded system.
17 #
18 # When adding sections, do note that the names of some sections are used
19 # when specifying the start address of the next.
20 #
21 test -z "$ENTRY" && ENTRY=_start
22 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
23 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
24 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
25 test "$LD_FLAG" = "N" && DATA_ADDR=.
26
27 CTOR=".ctors ${CONSTRUCTING-0} :
28 {
29 ${CONSTRUCTING+ __CTOR_LIST__ = .; }
30 ${CONSTRUCTING+${CTOR_START}}
31 *(.ctors)
32 /* We don't want to include the .ctor section from
33 from the crtend.o file until after the sorted ctors.
34 The .ctor section from the crtend file contains the
35 end of ctors marker and it must be last
36
37 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
38 KEEP (*(SORT(.ctors.*)))
39 KEEP (*(.ctors)) */
40
41 ${CONSTRUCTING+${CTOR_END}}
42 ${CONSTRUCTING+ __CTOR_END__ = .; }
43 } ${RELOCATING+ > ${DATA_MEMORY}}"
44
45 DTOR=" .dtors ${CONSTRUCTING-0} :
46 {
47 ${CONSTRUCTING+ __DTOR_LIST__ = .; }
48 *(.dtors)
49 /*
50 KEEP (*crtbegin.o(.dtors))
51 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
52 KEEP (*(SORT(.dtors.*)))
53 KEEP (*(.dtors)) */
54 ${CONSTRUCTING+ __DTOR_END__ = .; }
55 } ${RELOCATING+ > ${DATA_MEMORY}}"
56
57
58 VECTORS="
59 /* If the 'vectors_addr' symbol is defined, it indicates the start address
60 of interrupt vectors. This depends on the 68HC11 operating mode:
61
62 Addr
63 Single chip 0xffc0
64 Extended mode 0xffc0
65 Bootstrap 0x00c0
66 Test 0xbfc0
67
68 In general, the vectors address is 0xffc0. This can be overriden
69 with the '-defsym vectors_addr=0xbfc0' ld option.
70
71 Note: for the bootstrap mode, the interrupt vectors are at 0xbfc0 but
72 they are redirected to 0x00c0 by the internal PROM. Application's vectors
73 must also consist of jump instructions (see Motorola's manual). */
74
75 PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0);
76 .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 :
77 {
78 *(.vectors)
79 }"
80
81 #
82 # We provide two emulations: a fixed on that defines some memory banks
83 # and a configurable one that includes a user provided memory definition.
84 #
85 case $GENERIC_BOARD in
86 yes|1|YES)
87 MEMORY_DEF="
88 /* Get memory banks definition from some user configuration file.
89 This file must be located in some linker directory (search path
90 with -L<dir>). See fixed memory banks emulation script. */
91 INCLUDE memory.x;
92 "
93 ;;
94 *)
95 MEMORY_DEF="
96 /* Fixed definition of the available memory banks.
97 See generic emulation script for a user defined configuration. */
98 MEMORY
99 {
100 page0 (rwx) : ORIGIN = 0x0, LENGTH = 256
101 text (rx) : ORIGIN = ${ROM_START_ADDR}, LENGTH = ${ROM_SIZE}
102 data : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
103 }
104
105 /* Setup the stack on the top of the data memory bank. */
106 PROVIDE (_stack = ${RAM_START_ADDR} + ${RAM_SIZE} - 1);
107 "
108 ;;
109 esac
110
111 STARTUP_CODE="
112 /* Startup code. */
113 *(.install0) /* Section should setup the stack pointer. */
114 *(.install1) /* Place holder for applications. */
115 *(.install2) /* Optional installation of data sections in RAM. */
116 *(.install3) /* Place holder for applications. */
117 *(.install4) /* Section that calls the main. */
118 "
119
120 PRE_COMPUTE_DATA_SIZE="
121 /* SCz: this does not work yet... This is supposed to force the loading
122 of _map_data.o (from libgcc.a) when the .data section is not empty.
123 By doing so, this should bring the code that copies the .data section
124 from ROM to RAM at init time.
125
126 ___pre_comp_data_size = SIZEOF(.data);
127 __install_data_sections = ___pre_comp_data_size > 0 ?
128 __map_data_sections : 0;
129 */
130 "
131
132 INSTALL_RELOC="
133 .install0 0 : { *(.install0) }
134 .install1 0 : { *(.install1) }
135 .install2 0 : { *(.install2) }
136 .install3 0 : { *(.install3) }
137 .install4 0 : { *(.install4) }
138 "
139
140 BSS_DATA_RELOC="
141 .data1 0 : { *(.data1) }
142
143 /* We want the small data sections together, so single-instruction offsets
144 can access them all, and initialized data all before uninitialized, so
145 we can shorten the on-disk segment size. */
146 .sdata 0 : { *(.sdata) }
147 .sbss 0 : { *(.sbss) }
148 .scommon 0 : { *(.scommon) }
149 "
150
151 cat <<EOF
152 ${RELOCATING+/* Linker script for 68HC12 executable (PROM). */}
153 ${RELOCATING-/* Linker script for 68HC12 object file (ld -r). */}
154
155 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
156 "${LITTLE_OUTPUT_FORMAT}")
157 OUTPUT_ARCH(${OUTPUT_ARCH})
158 ENTRY(${ENTRY})
159
160 ${RELOCATING+${LIB_SEARCH_DIRS}}
161 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
162 ${RELOCATING+${MEMORY_DEF}}
163
164 SECTIONS
165 {
166 .hash ${RELOCATING-0} : { *(.hash) }
167 .dynsym ${RELOCATING-0} : { *(.dynsym) }
168 .dynstr ${RELOCATING-0} : { *(.dynstr) }
169 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
170 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
171 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
172
173 .rela.text ${RELOCATING-0} : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
174 .rela.data ${RELOCATING-0} : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
175 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
176 .rela.stext ${RELOCATING-0} : { *(.rela.stest) }
177 .rela.etext ${RELOCATING-0} : { *(.rela.etest) }
178 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
179 .rela.edata ${RELOCATING-0} : { *(.rela.edata) }
180 .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) }
181 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) }
182 .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) }
183 .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) }
184 .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) }
185 .rela.got ${RELOCATING-0} : { *(.rela.got) }
186 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
187 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
188 .rela.init ${RELOCATING-0} : { *(.rela.init) }
189 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
190 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
191 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
192
193 .rel.data ${RELOCATING-0} : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
194 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
195 .rel.stext ${RELOCATING-0} : { *(.rel.stest) }
196 .rel.etext ${RELOCATING-0} : { *(.rel.etest) }
197 .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) }
198 .rel.edata ${RELOCATING-0} : { *(.rel.edata) }
199 .rel.sbss ${RELOCATING-0} : { *(.rel.sbss) }
200 .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) }
201 .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) }
202 .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) }
203 .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) }
204 .rel.got ${RELOCATING-0} : { *(.rel.got) }
205 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
206 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
207 .rel.init ${RELOCATING-0} : { *(.rel.init) }
208 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
209 .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
210 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
211
212 /* Concatenate .page0 sections. Put them in the page0 memory bank
213 unless we are creating a relocatable file. */
214 .page0 :
215 {
216 *(.page0)
217 } ${RELOCATING+ > page0}
218
219 /* Start of text section. */
220 .stext ${RELOCATING-0} :
221 {
222 *(.stext)
223 } ${RELOCATING+ > ${TEXT_MEMORY}}
224
225 .init ${RELOCATING-0} :
226 {
227 *(.init)
228 } ${RELOCATING+=${NOP-0}}
229
230 ${RELOCATING-${INSTALL_RELOC}}
231
232 .text ${RELOCATING-0}:
233 {
234 /* Put startup code at beginning so that _start keeps same address. */
235 ${RELOCATING+${STARTUP_CODE}}
236
237 ${RELOCATING+*(.init)}
238 *(.text)
239 *(.fini)
240 /* .gnu.warning sections are handled specially by elf32.em. */
241 *(.gnu.warning)
242 *(.gnu.linkonce.t*)
243
244 ${RELOCATING+_etext = .;}
245 ${RELOCATING+PROVIDE (etext = .);}
246
247 } ${RELOCATING+ > ${TEXT_MEMORY}}
248
249 .eh_frame ${RELOCATING-0} :
250 {
251 *(.eh_frame)
252 } ${RELOCATING+ > ${TEXT_MEMORY}}
253
254 .rodata ${RELOCATING-0} :
255 {
256 *(.rodata)
257 *(.gnu.linkonce.r*)
258 } ${RELOCATING+ > ${TEXT_MEMORY}}
259
260 .rodata1 ${RELOCATING-0} :
261 {
262 *(.rodata1)
263 } ${RELOCATING+ > ${TEXT_MEMORY}}
264
265 /* Start of the data section image in ROM. */
266 ${RELOCATING+__data_image = .;}
267 ${RELOCATING+PROVIDE (__data_image = .);}
268
269 /* All read-only sections that normally go in PROM must be above.
270 We construct the DATA image section in PROM at end of all these
271 read-only sections. The data image must be copied at init time.
272 Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */
273 .data ${RELOCATING-0} : ${RELOCATING+AT (__data_image)}
274 {
275 ${RELOCATING+__data_section_start = .;}
276 ${RELOCATING+PROVIDE (__data_section_start = .);}
277
278 ${RELOCATING+${DATA_START_SYMBOLS}}
279 ${RELOCATING+*(.sdata)}
280 *(.data)
281 ${RELOCATING+*(.data1)}
282 *(.gnu.linkonce.d*)
283 ${CONSTRUCTING+CONSTRUCTORS}
284
285 ${RELOCATING+_edata = .;}
286 ${RELOCATING+PROVIDE (edata = .);}
287 } ${RELOCATING+ > ${DATA_MEMORY}}
288
289 ${RELOCATING+__data_section_size = SIZEOF(.data);}
290 ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));}
291 ${RELOCATING+__data_image_end = __data_image + __data_section_size;}
292
293 ${RELOCATING+${PRE_COMPUTE_DATA_SIZE}}
294
295 /* .install ${RELOCATING-0}:
296 {
297 . = _data_image_end;
298 } ${RELOCATING+ > ${TEXT_MEMORY}} */
299
300 /* Relocation for some bss and data sections. */
301 ${RELOCATING-${BSS_DATA_RELOC}}
302
303 .bss ${RELOCATING-0} :
304 {
305 ${RELOCATING+__bss_start = .;}
306 ${RELOCATING+*(.sbss)}
307 ${RELOCATING+*(.scommon)}
308
309 *(.dynbss)
310 *(.bss)
311 *(COMMON)
312 ${RELOCATING+PROVIDE (_end = .);}
313 } ${RELOCATING+ > ${DATA_MEMORY}}
314
315 ${RELOCATING+${CTOR}}
316 ${RELOCATING+${DTOR}}
317
318 ${RELOCATING+${VECTORS}}
319
320 /* Stabs debugging sections. */
321 .stab 0 : { *(.stab) }
322 .stabstr 0 : { *(.stabstr) }
323 .stab.excl 0 : { *(.stab.excl) }
324 .stab.exclstr 0 : { *(.stab.exclstr) }
325 .stab.index 0 : { *(.stab.index) }
326 .stab.indexstr 0 : { *(.stab.indexstr) }
327
328 .comment 0 : { *(.comment) }
329
330 /* DWARF debug sections.
331 Symbols in the DWARF debugging sections are relative to the beginning
332 of the section so we begin them at 0.
333 Treatment of DWARF debug section must be at end of the linker
334 script to avoid problems when there are undefined symbols. It's necessary
335 to avoid that the DWARF section is relocated before such undefined
336 symbols are found. */
337
338 /* DWARF 1 */
339 .debug 0 : { *(.debug) }
340 .line 0 : { *(.line) }
341
342 /* GNU DWARF 1 extensions */
343 .debug_srcinfo 0 : { *(.debug_srcinfo) }
344 .debug_sfnames 0 : { *(.debug_sfnames) }
345
346 /* DWARF 1.1 and DWARF 2 */
347 .debug_aranges 0 : { *(.debug_aranges) }
348 .debug_pubnames 0 : { *(.debug_pubnames) }
349
350 /* DWARF 2 */
351 .debug_info 0 : { *(.debug_info) }
352 .debug_abbrev 0 : { *(.debug_abbrev) }
353 .debug_line 0 : { *(.debug_line) }
354 .debug_frame 0 : { *(.debug_frame) }
355 .debug_str 0 : { *(.debug_str) }
356 .debug_loc 0 : { *(.debug_loc) }
357 .debug_macinfo 0 : { *(.debug_macinfo) }
358 }
359 EOF
This page took 0.065434 seconds and 4 git commands to generate.