1 /* Default linker script, for normal executables */
2 /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
3 Copying and distribution of this script, with or without modification,
4 are permitted in any medium without royalty provided the copyright
5 notice and this notice are preserved. */
6 OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
8 __TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : 128K;
9 __DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : 0xff00;
10 __EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : 64K;
11 __FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 1K;
12 __LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : 1K;
13 __SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : 1K;
14 __USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) ? __USER_SIGNATURE_REGION_LENGTH__ : 1K;
17 /* With keymap section
19 * TODO: should be as below
20 * Flash Map of AT90USB(128KB)
21 * +------------+ 0x0000
24 * | .init0-9 | > text region
28 * |------------| _etext
30 * | .bss | > data region
33 * |------------| 0x1D800
34 * | .keymap | > keymap region(2KB)
35 * |------------| 0x1E000
37 * +------------+ 0x1FFFF
39 * FIXME: Use this To fit to ATMega32U4 unimap address
40 * Flash Map of AT90USB(128KB)
41 * +------------+ 0x0000
44 * | .init0-9 | > text region
48 * |------------| _etext
50 * | .bss | > data region
53 * |------------| 0x6800
54 * | .keymap | > keymap region(2KB)
55 * |------------| 0x7000
58 * |------------| 0x1E000
60 * +------------+ 0x1FFFF
62 text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__
63 keymap (rw!x) : ORIGIN = 0x6800, LENGTH = 2K
64 data (rw!x) : ORIGIN = 0x800100, LENGTH = __DATA_REGION_LENGTH__
65 eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__
66 fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
67 lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
68 signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
69 user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__
73 /* Read-only sections, merged into text segment: */
75 .dynsym : { *(.dynsym) }
76 .dynstr : { *(.dynstr) }
77 .gnu.version : { *(.gnu.version) }
78 .gnu.version_d : { *(.gnu.version_d) }
79 .gnu.version_r : { *(.gnu.version_r) }
80 .rel.init : { *(.rel.init) }
81 .rela.init : { *(.rela.init) }
86 *(.rel.gnu.linkonce.t*)
92 *(.rela.gnu.linkonce.t*)
94 .rel.fini : { *(.rel.fini) }
95 .rela.fini : { *(.rela.fini) }
100 *(.rel.gnu.linkonce.r*)
106 *(.rela.gnu.linkonce.r*)
112 *(.rel.gnu.linkonce.d*)
118 *(.rela.gnu.linkonce.d*)
120 .rel.ctors : { *(.rel.ctors) }
121 .rela.ctors : { *(.rela.ctors) }
122 .rel.dtors : { *(.rel.dtors) }
123 .rela.dtors : { *(.rela.dtors) }
124 .rel.got : { *(.rel.got) }
125 .rela.got : { *(.rela.got) }
126 .rel.bss : { *(.rel.bss) }
127 .rela.bss : { *(.rela.bss) }
128 .rel.plt : { *(.rel.plt) }
129 .rela.plt : { *(.rela.plt) }
130 /* Internal text space or external memory. */
135 /* For data that needs to reside in the lower 64k of progmem. */
137 /* PR 13812: Placing the trampolines here gives a better chance
138 that they will be in range of the code that uses them. */
140 __trampolines_start = . ;
141 /* The jump trampolines for the 16-bit limited relocs will reside here. */
144 __trampolines_end = . ;
145 /* avr-libc expects these data to reside in lower 64K. */
146 *libprintf_flt.a:*(.progmem.data)
147 *libc.a:*(.progmem.data)
150 /* For future tablejump instruction arrays for 3 byte pc devices.
151 We don't relax jump/call instructions within these sections. */
154 /* For code that needs to reside in the lower 128k progmem. */
163 KEEP(SORT(*)(.ctors))
164 KEEP(SORT(*)(.dtors))
165 /* From this point on, we don't bother about wether the insns are
166 below or above the 16 bits boundary. */
167 *(.init0) /* Start here after reset. */
171 *(.init2) /* Clear __zero_reg__, set up stack pointer. */
175 *(.init4) /* Initialize data and BSS. */
179 *(.init6) /* C++ constructors. */
185 *(.init9) /* Call main(). */
191 *(.fini9) /* _exit() starts here. */
197 *(.fini6) /* C++ destructors. */
209 *(.fini0) /* Infinite loop after program termination. */
215 PROVIDE (__data_start = .) ;
219 *(.rodata) /* We need to include .rodata here if gcc is used */
220 *(.rodata*) /* with -fdata-sections. */
224 PROVIDE (__data_end = .) ;
226 .bss ADDR(.data) + SIZEOF (.data) : AT (ADDR (.bss))
228 PROVIDE (__bss_start = .) ;
232 PROVIDE (__bss_end = .) ;
234 __data_load_start = LOADADDR(.data);
235 __data_load_end = __data_load_start + SIZEOF(.data);
236 /* Global data not cleared after reset. */
237 .noinit ADDR(.bss) + SIZEOF (.bss) : AT (ADDR (.noinit))
239 PROVIDE (__noinit_start = .) ;
241 PROVIDE (__noinit_end = .) ;
243 PROVIDE (__heap_start = .) ;
245 /* keymap region is located at end of flash
246 * .fn_actions Fn actions definitions
247 * .keymaps Mapping layers
251 PROVIDE(__keymap_start = .) ;
252 *(.keymap.fn_actions) /* 32*actions = 64bytes */
254 *(.keymap.keymaps) /* rest of .keymap section */
256 /* . = ALIGN(0x800); */ /* keymap section takes 2KB- */
257 } > keymap = 0x00 /* zero fill */
260 /* See .data above... */
281 KEEP(*(.user_signatures*))
283 /* Stabs debugging sections. */
284 .stab 0 : { *(.stab) }
285 .stabstr 0 : { *(.stabstr) }
286 .stab.excl 0 : { *(.stab.excl) }
287 .stab.exclstr 0 : { *(.stab.exclstr) }
288 .stab.index 0 : { *(.stab.index) }
289 .stab.indexstr 0 : { *(.stab.indexstr) }
290 .comment 0 : { *(.comment) }
291 .note.gnu.build-id : { *(.note.gnu.build-id) }
292 /* DWARF debug sections.
293 Symbols in the DWARF debugging sections are relative to the beginning
294 of the section so we begin them at 0. */
296 .debug 0 : { *(.debug) }
297 .line 0 : { *(.line) }
298 /* GNU DWARF 1 extensions */
299 .debug_srcinfo 0 : { *(.debug_srcinfo) }
300 .debug_sfnames 0 : { *(.debug_sfnames) }
301 /* DWARF 1.1 and DWARF 2 */
302 .debug_aranges 0 : { *(.debug_aranges) }
303 .debug_pubnames 0 : { *(.debug_pubnames) }
305 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
306 .debug_abbrev 0 : { *(.debug_abbrev) }
307 .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
308 .debug_frame 0 : { *(.debug_frame) }
309 .debug_str 0 : { *(.debug_str) }
310 .debug_loc 0 : { *(.debug_loc) }
311 .debug_macinfo 0 : { *(.debug_macinfo) }
312 /* SGI/MIPS DWARF 2 extensions */
313 .debug_weaknames 0 : { *(.debug_weaknames) }
314 .debug_funcnames 0 : { *(.debug_funcnames) }
315 .debug_typenames 0 : { *(.debug_typenames) }
316 .debug_varnames 0 : { *(.debug_varnames) }
318 .debug_pubtypes 0 : { *(.debug_pubtypes) }
319 .debug_ranges 0 : { *(.debug_ranges) }
320 /* DWARF Extension. */
321 .debug_macro 0 : { *(.debug_macro) }