1 # Copyright (C) 2014-2023 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-2023 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}")
29 test -n "${RELOCATING}" && cat <<EOF
30 __TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : $TEXT_LENGTH;
31 __DATA_REGION_ORIGIN__ = DEFINED(__DATA_REGION_ORIGIN__) ? __DATA_REGION_ORIGIN__ : $DATA_ORIGIN;
32 __DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : $DATA_LENGTH;
34 ${EEPROM_LENGTH+__EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : $EEPROM_LENGTH;}
35 __FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : $FUSE_LENGTH;
36 __LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : $LOCK_LENGTH;
37 __SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : $SIGNATURE_LENGTH;
38 ${USER_SIGNATURE_LENGTH+__USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) ? __USER_SIGNATURE_REGION_LENGTH__ : $USER_SIGNATURE_LENGTH;}
39 ${RODATA_PM_OFFSET+__RODATA_PM_OFFSET__ = DEFINED(__RODATA_PM_OFFSET__) ? __RODATA_PM_OFFSET__ : $RODATA_PM_OFFSET;}
42 text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__
43 data (rw!x) : ORIGIN = __DATA_REGION_ORIGIN__, LENGTH = __DATA_REGION_LENGTH__
44 ${EEPROM_LENGTH+ eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__}
45 $FUSE_NAME (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
46 lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
47 signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
48 ${USER_SIGNATURE_LENGTH+ user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__}
55 /* Read-only sections, merged into text segment: */
56 ${TEXT_DYNAMIC+${DYNAMIC}}
57 .hash ${RELOCATING-0} : { *(.hash) }
58 .dynsym ${RELOCATING-0} : { *(.dynsym) }
59 .dynstr ${RELOCATING-0} : { *(.dynstr) }
60 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
61 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
62 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
64 .rel.init ${RELOCATING-0} : { *(.rel.init) }
65 .rela.init ${RELOCATING-0} : { *(.rela.init) }
66 .rel.text ${RELOCATING-0} :
69 ${RELOCATING+*(.rel.text.*)}
70 ${RELOCATING+*(.rel.gnu.linkonce.t*)}
72 .rela.text ${RELOCATING-0} :
75 ${RELOCATING+*(.rela.text.*)}
76 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
78 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
79 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
80 .rel.rodata ${RELOCATING-0} :
83 ${RELOCATING+*(.rel.rodata.*)}
84 ${RELOCATING+*(.rel.gnu.linkonce.r*)}
86 .rela.rodata ${RELOCATING-0} :
89 ${RELOCATING+*(.rela.rodata.*)}
90 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
92 .rel.data ${RELOCATING-0} :
95 ${RELOCATING+*(.rel.data.*)}
96 ${RELOCATING+*(.rel.gnu.linkonce.d*)}
98 .rela.data ${RELOCATING-0} :
101 ${RELOCATING+*(.rela.data.*)}
102 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
104 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
105 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
106 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
107 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
108 .rel.got ${RELOCATING-0} : { *(.rel.got) }
109 .rela.got ${RELOCATING-0} : { *(.rela.got) }
110 .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
111 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
112 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
113 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
115 /* Internal text space or external memory. */
116 .text ${RELOCATING-0} :
118 ${RELOCATING+*(.vectors)
121 /* For data that needs to reside in the lower 64k of progmem. */
124 /* PR 13812: Placing the trampolines here gives a better chance
125 that they will be in range of the code that uses them. */
127 __trampolines_start = . ;
128 /* The jump trampolines for the 16-bit limited relocs will reside here. */
131 __trampolines_end = . ;
133 /* avr-libc expects these data to reside in lower 64K. */
134 *libprintf_flt.a:*(.progmem.data)
135 *libc.a:*(.progmem.data)
141 /* For code that needs to reside in the lower 128k progmem. */
145 ${CONSTRUCTING+ __ctors_start = . ; }
146 ${CONSTRUCTING+ *(.ctors) }
147 ${CONSTRUCTING+ __ctors_end = . ; }
148 ${CONSTRUCTING+ __dtors_start = . ; }
149 ${CONSTRUCTING+ *(.dtors) }
150 ${CONSTRUCTING+ __dtors_end = . ; }
151 ${RELOCATING+KEEP(SORT(*)(.ctors))
152 KEEP(SORT(*)(.dtors))
154 /* From this point on, we do not bother about whether the insns are
155 below or above the 16 bits boundary. */
156 *(.init0) /* Start here after reset. */
160 *(.init2) /* Clear __zero_reg__, set up stack pointer. */
164 *(.init4) /* Initialize data and BSS. */
168 *(.init6) /* C++ constructors. */
174 *(.init9) /* Call main(). */
177 ${RELOCATING+. = ALIGN(2);
180 *(.fini9) /* _exit() starts here. */
186 *(.fini6) /* C++ destructors. */
198 *(.fini0) /* Infinite loop after program termination. */
201 /* For code that needs not to reside in the lower progmem. */
209 /* For tablejump instruction arrays. We do not relax
210 JMP / CALL instructions within these sections. */
215 } ${RELOCATING+ > text}
218 # Devices like ATtiny816 allow to read from flash memory by means of LD*
219 # instructions provided we add an offset of __RODATA_PM_OFFSET__ to the
222 if test -n "$RODATA_PM_OFFSET"; then
224 .rodata ${RELOCATING+ ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__ } ${RELOCATING-0} :
227 ${RELOCATING+ *(.rodata*)
229 } ${RELOCATING+AT> text}
234 .data ${RELOCATING-0} :
236 ${RELOCATING+ PROVIDE (__data_start = .) ; }
238 ${RELOCATING+ *(.data*)
242 # Classical devices that don't show flash memory in the SRAM address space
243 # need .rodata to be part of .data because the compiler will use LD*
244 # instructions and LD* cannot access flash.
246 if test -z "$RODATA_PM_OFFSET" && test -n "${RELOCATING}"; then
248 *(.rodata) /* We need to include .rodata here if gcc is used */
249 *(.rodata*) /* with -fdata-sections. */
255 ${RELOCATING+. = ALIGN(2);}
256 ${RELOCATING+ _edata = . ; }
257 ${RELOCATING+ PROVIDE (__data_end = .) ; }
258 } ${RELOCATING+ > data ${RELOCATING+AT> text}}
260 .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
262 ${RELOCATING+ PROVIDE (__bss_start = .) ; }
264 ${RELOCATING+ *(.bss*)}
265 ${RELOCATING+ *(COMMON)}
266 ${RELOCATING+ PROVIDE (__bss_end = .) ; }
267 } ${RELOCATING+ > data}
269 ${RELOCATING+ __data_load_start = LOADADDR(.data); }
270 ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); }
272 /* Global data not cleared after reset. */
273 .noinit ${RELOCATING+ ADDR(.bss) + SIZEOF (.bss)} ${RELOCATING-0}: ${RELOCATING+ AT (ADDR (.noinit))}
275 ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
276 *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*})
277 ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
278 ${RELOCATING+ _end = . ; }
279 ${RELOCATING+ PROVIDE (__heap_start = .) ; }
280 } ${RELOCATING+ > data}
283 if test -n "${EEPROM_LENGTH}"; then
286 .eeprom ${RELOCATING-0}:
288 /* See .data above... */
290 ${RELOCATING+ __eeprom_end = . ; }
291 } ${RELOCATING+ > eeprom}
295 if test "$FUSE_NAME" = "fuse" ; then
298 .fuse ${RELOCATING-0}:
301 ${RELOCATING+KEEP(*(.lfuse))
304 } ${RELOCATING+ > fuse}
310 .lock ${RELOCATING-0}:
313 } ${RELOCATING+ > lock}
315 .signature ${RELOCATING-0}:
318 } ${RELOCATING+ > signature}
321 if test "$FUSE_NAME" = "config" ; then
324 .config ${RELOCATING-0}:
327 } ${RELOCATING+ > config}
331 source_sh $srcdir/scripttempl/misc-sections.sc
334 .note.gnu.build-id ${RELOCATING-0} : { *(.note.gnu.build-id) }
337 source_sh $srcdir/scripttempl/DWARF.sc