1 # Copyright (C) 2014-2017 Free Software Foundation, Inc.
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.
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
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).
19 /* Copyright (C) 2014-2017 Free Software Foundation, Inc.
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. */
25 OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
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;
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;}
38 text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__
39 data (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__
40 ${EEPROM_LENGTH+ eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__}
41 $FUSE_NAME (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
42 lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
43 signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
44 ${USER_SIGNATURE_LENGTH+ user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__}
49 /* Read-only sections, merged into text segment: */
50 ${TEXT_DYNAMIC+${DYNAMIC}}
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) }
58 .rel.init ${RELOCATING-0} : { *(.rel.init) }
59 .rela.init ${RELOCATING-0} : { *(.rela.init) }
60 .rel.text ${RELOCATING-0} :
63 ${RELOCATING+*(.rel.text.*)}
64 ${RELOCATING+*(.rel.gnu.linkonce.t*)}
66 .rela.text ${RELOCATING-0} :
69 ${RELOCATING+*(.rela.text.*)}
70 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
72 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
73 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
74 .rel.rodata ${RELOCATING-0} :
77 ${RELOCATING+*(.rel.rodata.*)}
78 ${RELOCATING+*(.rel.gnu.linkonce.r*)}
80 .rela.rodata ${RELOCATING-0} :
83 ${RELOCATING+*(.rela.rodata.*)}
84 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
86 .rel.data ${RELOCATING-0} :
89 ${RELOCATING+*(.rel.data.*)}
90 ${RELOCATING+*(.rel.gnu.linkonce.d*)}
92 .rela.data ${RELOCATING-0} :
95 ${RELOCATING+*(.rela.data.*)}
96 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
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) }
109 /* Internal text space or external memory. */
110 .text ${RELOCATING-0} :
115 /* For data that needs to reside in the lower 64k of progmem. */
116 ${RELOCATING+ *(.progmem.gcc*)}
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);}
121 ${CONSTRUCTING+ __trampolines_start = . ; }
122 /* The jump trampolines for the 16-bit limited relocs will reside here. */
124 ${RELOCATING+ *(.trampolines*)}
125 ${CONSTRUCTING+ __trampolines_end = . ; }
127 /* avr-libc expects these data to reside in lower 64K. */
128 ${RELOCATING+ *libprintf_flt.a:*(.progmem.data)}
129 ${RELOCATING+ *libc.a:*(.progmem.data)}
131 ${RELOCATING+ *(.progmem*)}
133 ${RELOCATING+. = ALIGN(2);}
135 /* For code that needs to reside in the lower 128k progmem. */
137 ${RELOCATING+ *(.lowtext*)}
139 ${CONSTRUCTING+ __ctors_start = . ; }
140 ${CONSTRUCTING+ *(.ctors) }
141 ${CONSTRUCTING+ __ctors_end = . ; }
142 ${CONSTRUCTING+ __dtors_start = . ; }
143 ${CONSTRUCTING+ *(.dtors) }
144 ${CONSTRUCTING+ __dtors_end = . ; }
145 KEEP(SORT(*)(.ctors))
146 KEEP(SORT(*)(.dtors))
148 /* From this point on, we don't bother about wether the insns are
149 below or above the 16 bits boundary. */
150 *(.init0) /* Start here after reset. */
154 *(.init2) /* Clear __zero_reg__, set up stack pointer. */
158 *(.init4) /* Initialize data and BSS. */
162 *(.init6) /* C++ constructors. */
168 *(.init9) /* Call main(). */
171 ${RELOCATING+. = ALIGN(2);}
172 ${RELOCATING+ *(.text.*)}
173 ${RELOCATING+. = ALIGN(2);}
174 *(.fini9) /* _exit() starts here. */
180 *(.fini6) /* C++ destructors. */
192 *(.fini0) /* Infinite loop after program termination. */
195 /* For code that needs not to reside in the lower progmem. */
197 ${RELOCATING+ *(.hightext*)}
199 ${RELOCATING+. = ALIGN(2);}
201 /* For tablejump instruction arrays. We don't relax
202 JMP / CALL instructions within these sections. */
204 ${RELOCATING+ *(.jumptables*)}
206 ${RELOCATING+ _etext = . ; }
207 } ${RELOCATING+ > text}
210 # Devices like ATtiny816 allow to read from flash memory by means of LD*
211 # instructions provided we add an offset of __RODATA_PM_OFFSET__ to the
214 if test -n "$RODATA_PM_OFFSET"; then
216 .rodata ${RELOCATING+ ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__ } ${RELOCATING-0} :
219 ${RELOCATING+ *(.rodata*)}
221 } ${RELOCATING+AT> text}
226 .data ${RELOCATING-0} :
228 ${RELOCATING+ PROVIDE (__data_start = .) ; }
230 ${RELOCATING+ *(.data*)}
234 # Classical devices that don't show flash memory in the SRAM address space
235 # need .rodata to be part of .data because the compiler will use LD*
236 # instructions and LD* cannot access flash.
238 if test -z "$RODATA_PM_OFFSET"; then
240 *(.rodata) /* We need to include .rodata here if gcc is used */
241 ${RELOCATING+ *(.rodata*)} /* with -fdata-sections. */
247 ${RELOCATING+. = ALIGN(2);}
248 ${RELOCATING+ _edata = . ; }
249 ${RELOCATING+ PROVIDE (__data_end = .) ; }
250 } ${RELOCATING+ > data ${RELOCATING+AT> text}}
252 .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
254 ${RELOCATING+ PROVIDE (__bss_start = .) ; }
256 ${RELOCATING+ *(.bss*)}
258 ${RELOCATING+ PROVIDE (__bss_end = .) ; }
259 } ${RELOCATING+ > data}
261 ${RELOCATING+ __data_load_start = LOADADDR(.data); }
262 ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); }
264 /* Global data not cleared after reset. */
265 .noinit ${RELOCATING+ ADDR(.bss) + SIZEOF (.bss)} ${RELOCATING-0}: ${RELOCATING+ AT (ADDR (.noinit))}
267 ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
269 ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
270 ${RELOCATING+ _end = . ; }
271 ${RELOCATING+ PROVIDE (__heap_start = .) ; }
272 } ${RELOCATING+ > data}
275 if test -n "${EEPROM_LENGTH}"; then
278 .eeprom ${RELOCATING-0}:
280 /* See .data above... */
282 ${RELOCATING+ __eeprom_end = . ; }
283 } ${RELOCATING+ > eeprom}
287 if test "$FUSE_NAME" = "fuse" ; then
290 .fuse ${RELOCATING-0}:
296 } ${RELOCATING+ > fuse}
302 .lock ${RELOCATING-0}:
305 } ${RELOCATING+ > lock}
307 .signature ${RELOCATING-0}:
310 } ${RELOCATING+ > signature}
313 if test "$FUSE_NAME" = "config" ; then
316 .config ${RELOCATING-0}:
319 } ${RELOCATING+ > config}
325 /* Stabs debugging sections. */
326 .stab 0 : { *(.stab) }
327 .stabstr 0 : { *(.stabstr) }
328 .stab.excl 0 : { *(.stab.excl) }
329 .stab.exclstr 0 : { *(.stab.exclstr) }
330 .stab.index 0 : { *(.stab.index) }
331 .stab.indexstr 0 : { *(.stab.indexstr) }
332 .comment 0 : { *(.comment) }
333 .note.gnu.build-id : { *(.note.gnu.build-id) }
336 . $srcdir/scripttempl/DWARF.sc