1# Copyright (C) 2014-2016 Free Software Foundation, Inc. 2# 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 7cat <<EOF 8/* Copyright (C) 2014-2016 Free Software Foundation, Inc. 9 10 Copying and distribution of this script, with or without modification, 11 are permitted in any medium without royalty provided the copyright 12 notice and this notice are preserved. */ 13 14OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}") 15OUTPUT_ARCH(${ARCH}) 16 17__TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : $TEXT_LENGTH; 18__DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : $DATA_LENGTH; 19__EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : 64K; 20__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 1K; 21__LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : 1K; 22__SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : 1K; 23__USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) ? __USER_SIGNATURE_REGION_LENGTH__ : 1K; 24 25MEMORY 26{ 27 text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__ 28 data (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__ 29 eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__ 30 fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__ 31 lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__ 32 signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__ 33 user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__ 34} 35 36SECTIONS 37{ 38 /* Read-only sections, merged into text segment: */ 39 ${TEXT_DYNAMIC+${DYNAMIC}} 40 .hash ${RELOCATING-0} : { *(.hash) } 41 .dynsym ${RELOCATING-0} : { *(.dynsym) } 42 .dynstr ${RELOCATING-0} : { *(.dynstr) } 43 .gnu.version ${RELOCATING-0} : { *(.gnu.version) } 44 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } 45 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } 46 47 .rel.init ${RELOCATING-0} : { *(.rel.init) } 48 .rela.init ${RELOCATING-0} : { *(.rela.init) } 49 .rel.text ${RELOCATING-0} : 50 { 51 *(.rel.text) 52 ${RELOCATING+*(.rel.text.*)} 53 ${RELOCATING+*(.rel.gnu.linkonce.t*)} 54 } 55 .rela.text ${RELOCATING-0} : 56 { 57 *(.rela.text) 58 ${RELOCATING+*(.rela.text.*)} 59 ${RELOCATING+*(.rela.gnu.linkonce.t*)} 60 } 61 .rel.fini ${RELOCATING-0} : { *(.rel.fini) } 62 .rela.fini ${RELOCATING-0} : { *(.rela.fini) } 63 .rel.rodata ${RELOCATING-0} : 64 { 65 *(.rel.rodata) 66 ${RELOCATING+*(.rel.rodata.*)} 67 ${RELOCATING+*(.rel.gnu.linkonce.r*)} 68 } 69 .rela.rodata ${RELOCATING-0} : 70 { 71 *(.rela.rodata) 72 ${RELOCATING+*(.rela.rodata.*)} 73 ${RELOCATING+*(.rela.gnu.linkonce.r*)} 74 } 75 .rel.data ${RELOCATING-0} : 76 { 77 *(.rel.data) 78 ${RELOCATING+*(.rel.data.*)} 79 ${RELOCATING+*(.rel.gnu.linkonce.d*)} 80 } 81 .rela.data ${RELOCATING-0} : 82 { 83 *(.rela.data) 84 ${RELOCATING+*(.rela.data.*)} 85 ${RELOCATING+*(.rela.gnu.linkonce.d*)} 86 } 87 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } 88 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } 89 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } 90 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } 91 .rel.got ${RELOCATING-0} : { *(.rel.got) } 92 .rela.got ${RELOCATING-0} : { *(.rela.got) } 93 .rel.bss ${RELOCATING-0} : { *(.rel.bss) } 94 .rela.bss ${RELOCATING-0} : { *(.rela.bss) } 95 .rel.plt ${RELOCATING-0} : { *(.rel.plt) } 96 .rela.plt ${RELOCATING-0} : { *(.rela.plt) } 97 98 /* Internal text space or external memory. */ 99 .text ${RELOCATING-0} : 100 { 101 *(.vectors) 102 KEEP(*(.vectors)) 103 104 /* For data that needs to reside in the lower 64k of progmem. */ 105 ${RELOCATING+ *(.progmem.gcc*)} 106 107 /* PR 13812: Placing the trampolines here gives a better chance 108 that they will be in range of the code that uses them. */ 109 ${RELOCATING+. = ALIGN(2);} 110 ${CONSTRUCTING+ __trampolines_start = . ; } 111 /* The jump trampolines for the 16-bit limited relocs will reside here. */ 112 *(.trampolines) 113 ${RELOCATING+ *(.trampolines*)} 114 ${CONSTRUCTING+ __trampolines_end = . ; } 115 116 /* avr-libc expects these data to reside in lower 64K. */ 117 ${RELOCATING+ *libprintf_flt.a:*(.progmem.data)} 118 ${RELOCATING+ *libc.a:*(.progmem.data)} 119 120 ${RELOCATING+ *(.progmem*)} 121 122 ${RELOCATING+. = ALIGN(2);} 123 124 /* For future tablejump instruction arrays for 3 byte pc devices. 125 We don't relax jump/call instructions within these sections. */ 126 *(.jumptables) 127 ${RELOCATING+ *(.jumptables*)} 128 129 /* For code that needs to reside in the lower 128k progmem. */ 130 *(.lowtext) 131 ${RELOCATING+ *(.lowtext*)} 132 133 ${CONSTRUCTING+ __ctors_start = . ; } 134 ${CONSTRUCTING+ *(.ctors) } 135 ${CONSTRUCTING+ __ctors_end = . ; } 136 ${CONSTRUCTING+ __dtors_start = . ; } 137 ${CONSTRUCTING+ *(.dtors) } 138 ${CONSTRUCTING+ __dtors_end = . ; } 139 KEEP(SORT(*)(.ctors)) 140 KEEP(SORT(*)(.dtors)) 141 142 /* From this point on, we don't bother about wether the insns are 143 below or above the 16 bits boundary. */ 144 *(.init0) /* Start here after reset. */ 145 KEEP (*(.init0)) 146 *(.init1) 147 KEEP (*(.init1)) 148 *(.init2) /* Clear __zero_reg__, set up stack pointer. */ 149 KEEP (*(.init2)) 150 *(.init3) 151 KEEP (*(.init3)) 152 *(.init4) /* Initialize data and BSS. */ 153 KEEP (*(.init4)) 154 *(.init5) 155 KEEP (*(.init5)) 156 *(.init6) /* C++ constructors. */ 157 KEEP (*(.init6)) 158 *(.init7) 159 KEEP (*(.init7)) 160 *(.init8) 161 KEEP (*(.init8)) 162 *(.init9) /* Call main(). */ 163 KEEP (*(.init9)) 164 *(.text) 165 ${RELOCATING+. = ALIGN(2);} 166 ${RELOCATING+ *(.text.*)} 167 ${RELOCATING+. = ALIGN(2);} 168 *(.fini9) /* _exit() starts here. */ 169 KEEP (*(.fini9)) 170 *(.fini8) 171 KEEP (*(.fini8)) 172 *(.fini7) 173 KEEP (*(.fini7)) 174 *(.fini6) /* C++ destructors. */ 175 KEEP (*(.fini6)) 176 *(.fini5) 177 KEEP (*(.fini5)) 178 *(.fini4) 179 KEEP (*(.fini4)) 180 *(.fini3) 181 KEEP (*(.fini3)) 182 *(.fini2) 183 KEEP (*(.fini2)) 184 *(.fini1) 185 KEEP (*(.fini1)) 186 *(.fini0) /* Infinite loop after program termination. */ 187 KEEP (*(.fini0)) 188 ${RELOCATING+ _etext = . ; } 189 } ${RELOCATING+ > text} 190 191 .data ${RELOCATING-0} : 192 { 193 ${RELOCATING+ PROVIDE (__data_start = .) ; } 194 *(.data) 195 ${RELOCATING+ *(.data*)} 196 *(.rodata) /* We need to include .rodata here if gcc is used */ 197 ${RELOCATING+ *(.rodata*)} /* with -fdata-sections. */ 198 *(.gnu.linkonce.d*) 199 ${RELOCATING+. = ALIGN(2);} 200 ${RELOCATING+ _edata = . ; } 201 ${RELOCATING+ PROVIDE (__data_end = .) ; } 202 } ${RELOCATING+ > data ${RELOCATING+AT> text}} 203 204 .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))} 205 { 206 ${RELOCATING+ PROVIDE (__bss_start = .) ; } 207 *(.bss) 208 ${RELOCATING+ *(.bss*)} 209 *(COMMON) 210 ${RELOCATING+ PROVIDE (__bss_end = .) ; } 211 } ${RELOCATING+ > data} 212 213 ${RELOCATING+ __data_load_start = LOADADDR(.data); } 214 ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); } 215 216 /* Global data not cleared after reset. */ 217 .noinit ${RELOCATING+ ADDR(.bss) + SIZEOF (.bss)} ${RELOCATING-0}: ${RELOCATING+ AT (ADDR (.noinit))} 218 { 219 ${RELOCATING+ PROVIDE (__noinit_start = .) ; } 220 *(.noinit*) 221 ${RELOCATING+ PROVIDE (__noinit_end = .) ; } 222 ${RELOCATING+ _end = . ; } 223 ${RELOCATING+ PROVIDE (__heap_start = .) ; } 224 } ${RELOCATING+ > data} 225 226 .eeprom ${RELOCATING-0}: 227 { 228 /* See .data above... */ 229 KEEP(*(.eeprom*)) 230 ${RELOCATING+ __eeprom_end = . ; } 231 } ${RELOCATING+ > eeprom} 232 233 .fuse ${RELOCATING-0}: 234 { 235 KEEP(*(.fuse)) 236 KEEP(*(.lfuse)) 237 KEEP(*(.hfuse)) 238 KEEP(*(.efuse)) 239 } ${RELOCATING+ > fuse} 240 241 .lock ${RELOCATING-0}: 242 { 243 KEEP(*(.lock*)) 244 } ${RELOCATING+ > lock} 245 246 .signature ${RELOCATING-0}: 247 { 248 KEEP(*(.signature*)) 249 } ${RELOCATING+ > signature} 250 251 /* Stabs debugging sections. */ 252 .stab 0 : { *(.stab) } 253 .stabstr 0 : { *(.stabstr) } 254 .stab.excl 0 : { *(.stab.excl) } 255 .stab.exclstr 0 : { *(.stab.exclstr) } 256 .stab.index 0 : { *(.stab.index) } 257 .stab.indexstr 0 : { *(.stab.indexstr) } 258 .comment 0 : { *(.comment) } 259 .note.gnu.build-id : { *(.note.gnu.build-id) } 260EOF 261 262. $srcdir/scripttempl/DWARF.sc 263 264cat <<EOF 265} 266EOF 267