Remove arm-epoc-pe support
[deliverable/binutils-gdb.git] / ld / scripttempl / avr.sc
CommitLineData
219d1afa 1# Copyright (C) 2014-2018 Free Software Foundation, Inc.
6c19b93b 2#
985743c7
NC
3# Copying and distribution of this file, with or without modification,
4# are permitted in any medium without royalty provided the copyright
5# notice and this notice are preserved.
6
f4203b2b
JL
7# RODATA_PM_OFFSET
8# If empty, .rodata sections will be part of .data. This is for
9# devices where it is not possible to use LD* instructions to read
10# from flash.
11#
12# If non-empty, .rodata is not part of .data and the .rodata
13# objects are assigned addresses at an offest of RODATA_PM_OFFSET.
14# This is for devices that feature reading from flash by means of
15# LD* instructions, provided the addresses are offset by
16# __RODATA_PM_OFFSET__ (which defaults to RODATA_PM_OFFSET).
17
7c8bf1e8 18cat <<EOF
219d1afa 19/* Copyright (C) 2014-2018 Free Software Foundation, Inc.
985743c7
NC
20
21 Copying and distribution of this script, with or without modification,
22 are permitted in any medium without royalty provided the copyright
23 notice and this notice are preserved. */
24
7c8bf1e8
MM
25OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
26OUTPUT_ARCH(${ARCH})
27
cb072816
SKS
28__TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : $TEXT_LENGTH;
29__DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : $DATA_LENGTH;
6490dc67
GJL
30${EEPROM_LENGTH+__EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : $EEPROM_LENGTH;}
31__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : $FUSE_LENGTH;
32__LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : $LOCK_LENGTH;
33__SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : $SIGNATURE_LENGTH;
34${USER_SIGNATURE_LENGTH+__USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) ? __USER_SIGNATURE_REGION_LENGTH__ : $USER_SIGNATURE_LENGTH;}
35${RODATA_PM_OFFSET+__RODATA_PM_OFFSET__ = DEFINED(__RODATA_PM_OFFSET__) ? __RODATA_PM_OFFSET__ : $RODATA_PM_OFFSET;}
7c8bf1e8
MM
36MEMORY
37{
cb072816
SKS
38 text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__
39 data (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__
6490dc67
GJL
40${EEPROM_LENGTH+ eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__}
41 $FUSE_NAME (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
cb072816
SKS
42 lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
43 signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
6490dc67 44${USER_SIGNATURE_LENGTH+ user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__}
7c8bf1e8
MM
45}
46
47SECTIONS
48{
49 /* Read-only sections, merged into text segment: */
50 ${TEXT_DYNAMIC+${DYNAMIC}}
ec2d9b29
AM
51 .hash ${RELOCATING-0} : { *(.hash) }
52 .dynsym ${RELOCATING-0} : { *(.dynsym) }
53 .dynstr ${RELOCATING-0} : { *(.dynstr) }
54 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
55 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
56 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
57
58 .rel.init ${RELOCATING-0} : { *(.rel.init) }
59 .rela.init ${RELOCATING-0} : { *(.rela.init) }
60 .rel.text ${RELOCATING-0} :
7c8bf1e8
MM
61 {
62 *(.rel.text)
63 ${RELOCATING+*(.rel.text.*)}
64 ${RELOCATING+*(.rel.gnu.linkonce.t*)}
65 }
ec2d9b29 66 .rela.text ${RELOCATING-0} :
7c8bf1e8
MM
67 {
68 *(.rela.text)
69 ${RELOCATING+*(.rela.text.*)}
70 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
71 }
ec2d9b29
AM
72 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
73 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
74 .rel.rodata ${RELOCATING-0} :
7c8bf1e8
MM
75 {
76 *(.rel.rodata)
77 ${RELOCATING+*(.rel.rodata.*)}
78 ${RELOCATING+*(.rel.gnu.linkonce.r*)}
79 }
ec2d9b29 80 .rela.rodata ${RELOCATING-0} :
7c8bf1e8
MM
81 {
82 *(.rela.rodata)
83 ${RELOCATING+*(.rela.rodata.*)}
84 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
85 }
ec2d9b29 86 .rel.data ${RELOCATING-0} :
7c8bf1e8
MM
87 {
88 *(.rel.data)
89 ${RELOCATING+*(.rel.data.*)}
90 ${RELOCATING+*(.rel.gnu.linkonce.d*)}
91 }
ec2d9b29 92 .rela.data ${RELOCATING-0} :
7c8bf1e8
MM
93 {
94 *(.rela.data)
95 ${RELOCATING+*(.rela.data.*)}
96 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
97 }
ec2d9b29
AM
98 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
99 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
100 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
101 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
102 .rel.got ${RELOCATING-0} : { *(.rel.got) }
103 .rela.got ${RELOCATING-0} : { *(.rela.got) }
104 .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
105 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
106 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
107 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
7c8bf1e8 108
28c9d252 109 /* Internal text space or external memory. */
ec2d9b29 110 .text ${RELOCATING-0} :
7c8bf1e8 111 {
0c9b4fee 112 *(.vectors)
df406460 113 KEEP(*(.vectors))
0c9b4fee 114
28c9d252 115 /* For data that needs to reside in the lower 64k of progmem. */
8c661d24 116 ${RELOCATING+ *(.progmem.gcc*)}
28c9d252 117
861319c9
NC
118 /* PR 13812: Placing the trampolines here gives a better chance
119 that they will be in range of the code that uses them. */
120 ${RELOCATING+. = ALIGN(2);}
28c9d252
NC
121 ${CONSTRUCTING+ __trampolines_start = . ; }
122 /* The jump trampolines for the 16-bit limited relocs will reside here. */
123 *(.trampolines)
8c661d24 124 ${RELOCATING+ *(.trampolines*)}
28c9d252
NC
125 ${CONSTRUCTING+ __trampolines_end = . ; }
126
1bdc036f
SKS
127 /* avr-libc expects these data to reside in lower 64K. */
128 ${RELOCATING+ *libprintf_flt.a:*(.progmem.data)}
129 ${RELOCATING+ *libc.a:*(.progmem.data)}
130
f726cc1c 131 ${RELOCATING+ *(.progmem.*)}
6c19b93b 132
778ee4a6
NC
133 ${RELOCATING+. = ALIGN(2);}
134
28c9d252
NC
135 /* For code that needs to reside in the lower 128k progmem. */
136 *(.lowtext)
8c661d24 137 ${RELOCATING+ *(.lowtext*)}
28c9d252 138
0c9b4fee
MM
139 ${CONSTRUCTING+ __ctors_start = . ; }
140 ${CONSTRUCTING+ *(.ctors) }
141 ${CONSTRUCTING+ __ctors_end = . ; }
142 ${CONSTRUCTING+ __dtors_start = . ; }
143 ${CONSTRUCTING+ *(.dtors) }
144 ${CONSTRUCTING+ __dtors_end = . ; }
df406460
NC
145 KEEP(SORT(*)(.ctors))
146 KEEP(SORT(*)(.dtors))
0c9b4fee 147
28c9d252
NC
148 /* From this point on, we don't bother about wether the insns are
149 below or above the 16 bits boundary. */
0c9b4fee 150 *(.init0) /* Start here after reset. */
df406460 151 KEEP (*(.init0))
0c9b4fee 152 *(.init1)
df406460 153 KEEP (*(.init1))
0c9b4fee 154 *(.init2) /* Clear __zero_reg__, set up stack pointer. */
df406460 155 KEEP (*(.init2))
0c9b4fee 156 *(.init3)
df406460 157 KEEP (*(.init3))
0c9b4fee 158 *(.init4) /* Initialize data and BSS. */
df406460 159 KEEP (*(.init4))
0c9b4fee 160 *(.init5)
df406460 161 KEEP (*(.init5))
0c9b4fee 162 *(.init6) /* C++ constructors. */
df406460 163 KEEP (*(.init6))
0c9b4fee 164 *(.init7)
df406460 165 KEEP (*(.init7))
0c9b4fee 166 *(.init8)
df406460 167 KEEP (*(.init8))
0c9b4fee 168 *(.init9) /* Call main(). */
df406460 169 KEEP (*(.init9))
7c8bf1e8
MM
170 *(.text)
171 ${RELOCATING+. = ALIGN(2);}
865acd35 172 ${RELOCATING+ *(.text.*)}
7c8bf1e8 173 ${RELOCATING+. = ALIGN(2);}
0c9b4fee 174 *(.fini9) /* _exit() starts here. */
df406460 175 KEEP (*(.fini9))
0c9b4fee 176 *(.fini8)
df406460 177 KEEP (*(.fini8))
0c9b4fee 178 *(.fini7)
df406460 179 KEEP (*(.fini7))
0c9b4fee 180 *(.fini6) /* C++ destructors. */
df406460 181 KEEP (*(.fini6))
0c9b4fee 182 *(.fini5)
df406460 183 KEEP (*(.fini5))
0c9b4fee 184 *(.fini4)
df406460 185 KEEP (*(.fini4))
0c9b4fee 186 *(.fini3)
df406460 187 KEEP (*(.fini3))
0c9b4fee 188 *(.fini2)
df406460 189 KEEP (*(.fini2))
0c9b4fee 190 *(.fini1)
df406460 191 KEEP (*(.fini1))
0c9b4fee 192 *(.fini0) /* Infinite loop after program termination. */
df406460 193 KEEP (*(.fini0))
4c0b797e
GJL
194
195 /* For code that needs not to reside in the lower progmem. */
196 *(.hightext)
197 ${RELOCATING+ *(.hightext*)}
198
f726cc1c
GJL
199 ${RELOCATING+ *(.progmemx.*)}
200
4c0b797e
GJL
201 ${RELOCATING+. = ALIGN(2);}
202
203 /* For tablejump instruction arrays. We don't relax
204 JMP / CALL instructions within these sections. */
205 *(.jumptables)
206 ${RELOCATING+ *(.jumptables*)}
207
7c8bf1e8
MM
208 ${RELOCATING+ _etext = . ; }
209 } ${RELOCATING+ > text}
f4203b2b
JL
210EOF
211
212# Devices like ATtiny816 allow to read from flash memory by means of LD*
213# instructions provided we add an offset of __RODATA_PM_OFFSET__ to the
214# flash addresses.
7c8bf1e8 215
f4203b2b
JL
216if test -n "$RODATA_PM_OFFSET"; then
217 cat <<EOF
218 .rodata ${RELOCATING+ ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__ } ${RELOCATING-0} :
219 {
220 *(.rodata)
221 ${RELOCATING+ *(.rodata*)}
222 *(.gnu.linkonce.r*)
223 } ${RELOCATING+AT> text}
224EOF
225fi
226
227cat <<EOF
5ed365b4 228 .data ${RELOCATING-0} :
7c8bf1e8
MM
229 {
230 ${RELOCATING+ PROVIDE (__data_start = .) ; }
b4841801 231 *(.data)
8c661d24 232 ${RELOCATING+ *(.data*)}
f4203b2b
JL
233 *(.gnu.linkonce.d*)
234EOF
235
236# Classical devices that don't show flash memory in the SRAM address space
237# need .rodata to be part of .data because the compiler will use LD*
238# instructions and LD* cannot access flash.
239
240if test -z "$RODATA_PM_OFFSET"; then
241 cat <<EOF
df406460 242 *(.rodata) /* We need to include .rodata here if gcc is used */
865acd35 243 ${RELOCATING+ *(.rodata*)} /* with -fdata-sections. */
f4203b2b
JL
244 *(.gnu.linkonce.r*)
245EOF
246fi
247
248cat <<EOF
7c8bf1e8
MM
249 ${RELOCATING+. = ALIGN(2);}
250 ${RELOCATING+ _edata = . ; }
0c9b4fee 251 ${RELOCATING+ PROVIDE (__data_end = .) ; }
5ed365b4 252 } ${RELOCATING+ > data ${RELOCATING+AT> text}}
7c8bf1e8 253
b4841801 254 .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
7c8bf1e8
MM
255 {
256 ${RELOCATING+ PROVIDE (__bss_start = .) ; }
257 *(.bss)
865acd35 258 ${RELOCATING+ *(.bss*)}
7c8bf1e8
MM
259 *(COMMON)
260 ${RELOCATING+ PROVIDE (__bss_end = .) ; }
0c9b4fee
MM
261 } ${RELOCATING+ > data}
262
263 ${RELOCATING+ __data_load_start = LOADADDR(.data); }
264 ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); }
265
266 /* Global data not cleared after reset. */
7585b2b8 267 .noinit ${RELOCATING+ ADDR(.bss) + SIZEOF (.bss)} ${RELOCATING-0}: ${RELOCATING+ AT (ADDR (.noinit))}
0c9b4fee
MM
268 {
269 ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
270 *(.noinit*)
271 ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
7c8bf1e8 272 ${RELOCATING+ _end = . ; }
0c9b4fee 273 ${RELOCATING+ PROVIDE (__heap_start = .) ; }
7c8bf1e8 274 } ${RELOCATING+ > data}
6490dc67
GJL
275EOF
276
277if test -n "${EEPROM_LENGTH}"; then
278cat <<EOF
7c8bf1e8 279
ec2d9b29 280 .eeprom ${RELOCATING-0}:
7c8bf1e8 281 {
b176ded1
NC
282 /* See .data above... */
283 KEEP(*(.eeprom*))
7c8bf1e8
MM
284 ${RELOCATING+ __eeprom_end = . ; }
285 } ${RELOCATING+ > eeprom}
6490dc67
GJL
286EOF
287fi
288
289if test "$FUSE_NAME" = "fuse" ; then
290cat <<EOF
7c8bf1e8 291
ef844a53
EW
292 .fuse ${RELOCATING-0}:
293 {
294 KEEP(*(.fuse))
295 KEEP(*(.lfuse))
296 KEEP(*(.hfuse))
297 KEEP(*(.efuse))
298 } ${RELOCATING+ > fuse}
6490dc67
GJL
299EOF
300fi
301
302cat <<EOF
ef844a53
EW
303
304 .lock ${RELOCATING-0}:
305 {
306 KEEP(*(.lock*))
307 } ${RELOCATING+ > lock}
308
309 .signature ${RELOCATING-0}:
310 {
311 KEEP(*(.signature*))
312 } ${RELOCATING+ > signature}
6490dc67
GJL
313EOF
314
315if test "$FUSE_NAME" = "config" ; then
316cat <<EOF
317
318 .config ${RELOCATING-0}:
319 {
320 KEEP(*(.config*))
321 } ${RELOCATING+ > config}
322EOF
323fi
324
325cat <<EOF
ef844a53 326
7c8bf1e8
MM
327 /* Stabs debugging sections. */
328 .stab 0 : { *(.stab) }
329 .stabstr 0 : { *(.stabstr) }
330 .stab.excl 0 : { *(.stab.excl) }
331 .stab.exclstr 0 : { *(.stab.exclstr) }
332 .stab.index 0 : { *(.stab.index) }
333 .stab.indexstr 0 : { *(.stab.indexstr) }
6c19b93b 334 .comment 0 : { *(.comment) }
2cfa18a9 335 .note.gnu.build-id : { *(.note.gnu.build-id) }
ceb0a680 336EOF
2a995fc1 337
d061dfac 338. $srcdir/scripttempl/DWARF.sc
2a995fc1 339
ceb0a680 340cat <<EOF
7c8bf1e8
MM
341}
342EOF
This page took 0.716104 seconds and 4 git commands to generate.