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