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