imuboard/mk: use linker script
[fpv.git] / common / avr51.x
1 /* Default linker script, for normal executables */
2 OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
3 OUTPUT_ARCH(avr:51)
4 MEMORY
5 {
6   text   (rx)   : ORIGIN = 0, LENGTH = 128K
7   data   (rw!x) : ORIGIN = 0x800100, LENGTH = 0xff00
8   eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
9   fuse      (rw!x) : ORIGIN = 0x820000, LENGTH = 1K
10   lock      (rw!x) : ORIGIN = 0x830000, LENGTH = 1K
11   signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K
12   user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = 1K
13 }
14 SECTIONS
15 {
16   /* Read-only sections, merged into text segment: */
17   .hash          : { *(.hash)           }
18   .dynsym        : { *(.dynsym)         }
19   .dynstr        : { *(.dynstr)         }
20   .gnu.version   : { *(.gnu.version)    }
21   .gnu.version_d   : { *(.gnu.version_d)        }
22   .gnu.version_r   : { *(.gnu.version_r)        }
23   .rel.init      : { *(.rel.init)               }
24   .rela.init     : { *(.rela.init)      }
25   .rel.text      :
26     {
27       *(.rel.text)
28       *(.rel.text.*)
29       *(.rel.gnu.linkonce.t*)
30     }
31   .rela.text     :
32     {
33       *(.rela.text)
34       *(.rela.text.*)
35       *(.rela.gnu.linkonce.t*)
36     }
37   .rel.fini      : { *(.rel.fini)               }
38   .rela.fini     : { *(.rela.fini)      }
39   .rel.rodata    :
40     {
41       *(.rel.rodata)
42       *(.rel.rodata.*)
43       *(.rel.gnu.linkonce.r*)
44     }
45   .rela.rodata   :
46     {
47       *(.rela.rodata)
48       *(.rela.rodata.*)
49       *(.rela.gnu.linkonce.r*)
50     }
51   .rel.data      :
52     {
53       *(.rel.data)
54       *(.rel.data.*)
55       *(.rel.gnu.linkonce.d*)
56     }
57   .rela.data     :
58     {
59       *(.rela.data)
60       *(.rela.data.*)
61       *(.rela.gnu.linkonce.d*)
62     }
63   .rel.ctors     : { *(.rel.ctors)      }
64   .rela.ctors    : { *(.rela.ctors)     }
65   .rel.dtors     : { *(.rel.dtors)      }
66   .rela.dtors    : { *(.rela.dtors)     }
67   .rel.got       : { *(.rel.got)                }
68   .rela.got      : { *(.rela.got)               }
69   .rel.bss       : { *(.rel.bss)                }
70   .rela.bss      : { *(.rela.bss)               }
71   .rel.plt       : { *(.rel.plt)                }
72   .rela.plt      : { *(.rela.plt)               }
73   /* Internal text space or external memory.  */
74   .text   :
75   {
76     *(.vectors)
77     KEEP(*(.vectors))
78     . = 256 + ALIGN(256); /* placeholder for misc microb infos */
79     /* For data that needs to reside in the lower 64k of progmem.  */
80      *(.progmem.gcc*)
81     /* PR 13812: Placing the trampolines here gives a better chance
82        that they will be in range of the code that uses them.  */
83     . = ALIGN(2);
84      __trampolines_start = . ;
85     /* The jump trampolines for the 16-bit limited relocs will reside here.  */
86     *(.trampolines)
87      *(.trampolines*)
88      __trampolines_end = . ;
89      *(.progmem*)
90     . = ALIGN(2);
91     /* For future tablejump instruction arrays for 3 byte pc devices.
92        We don't relax jump/call instructions within these sections.  */
93     *(.jumptables)
94      *(.jumptables*)
95     /* For code that needs to reside in the lower 128k progmem.  */
96     *(.lowtext)
97      *(.lowtext*)
98      __ctors_start = . ;
99      *(.ctors)
100      __ctors_end = . ;
101      __dtors_start = . ;
102      *(.dtors)
103      __dtors_end = . ;
104     KEEP(SORT(*)(.ctors))
105     KEEP(SORT(*)(.dtors))
106     /* From this point on, we don't bother about wether the insns are
107        below or above the 16 bits boundary.  */
108     *(.init0)  /* Start here after reset.  */
109     KEEP (*(.init0))
110     *(.init1)
111     KEEP (*(.init1))
112     *(.init2)  /* Clear __zero_reg__, set up stack pointer.  */
113     KEEP (*(.init2))
114     *(.init3)
115     KEEP (*(.init3))
116     *(.init4)  /* Initialize data and BSS.  */
117     KEEP (*(.init4))
118     *(.init5)
119     KEEP (*(.init5))
120     *(.init6)  /* C++ constructors.  */
121     KEEP (*(.init6))
122     *(.init7)
123     KEEP (*(.init7))
124     *(.init8)
125     KEEP (*(.init8))
126     *(.init9)  /* Call main().  */
127     KEEP (*(.init9))
128     *(.text)
129     . = ALIGN(2);
130      *(.text.*)
131     . = ALIGN(2);
132     *(.fini9)  /* _exit() starts here.  */
133     KEEP (*(.fini9))
134     *(.fini8)
135     KEEP (*(.fini8))
136     *(.fini7)
137     KEEP (*(.fini7))
138     *(.fini6)  /* C++ destructors.  */
139     KEEP (*(.fini6))
140     *(.fini5)
141     KEEP (*(.fini5))
142     *(.fini4)
143     KEEP (*(.fini4))
144     *(.fini3)
145     KEEP (*(.fini3))
146     *(.fini2)
147     KEEP (*(.fini2))
148     *(.fini1)
149     KEEP (*(.fini1))
150     *(.fini0)  /* Infinite loop after program termination.  */
151     KEEP (*(.fini0))
152      _etext = . ;
153   }  > text
154   .data          :
155   {
156      PROVIDE (__data_start = .) ;
157     *(.data)
158      *(.data*)
159     *(.rodata)  /* We need to include .rodata here if gcc is used */
160      *(.rodata*) /* with -fdata-sections.  */
161     *(.gnu.linkonce.d*)
162     . = ALIGN(2);
163      _edata = . ;
164      PROVIDE (__data_end = .) ;
165   }  > data AT> text
166   .bss  ADDR(.data) + SIZEOF (.data)   : AT (ADDR (.bss))
167   {
168      PROVIDE (__bss_start = .) ;
169     *(.bss)
170      *(.bss*)
171     *(COMMON)
172      PROVIDE (__bss_end = .) ;
173   }  > data
174    __data_load_start = LOADADDR(.data);
175    __data_load_end = __data_load_start + SIZEOF(.data);
176   /* Global data not cleared after reset.  */
177   .noinit  :
178   {
179      PROVIDE (__noinit_start = .) ;
180     *(.noinit*)
181      PROVIDE (__noinit_end = .) ;
182      _end = . ;
183      PROVIDE (__heap_start = .) ;
184   }  > data
185   .eeprom  :
186   {
187     /* See .data above...  */
188     KEEP(*(.eeprom*))
189      __eeprom_end = . ;
190   }  > eeprom
191   .fuse  :
192   {
193     KEEP(*(.fuse))
194     KEEP(*(.lfuse))
195     KEEP(*(.hfuse))
196     KEEP(*(.efuse))
197   }  > fuse
198   .lock  :
199   {
200     KEEP(*(.lock*))
201   }  > lock
202   .signature  :
203   {
204     KEEP(*(.signature*))
205   }  > signature
206   .user_signatures  :
207   {
208     KEEP(*(.user_signatures*))
209   }  > user_signatures
210   /* Stabs debugging sections.  */
211   .stab 0 : { *(.stab) }
212   .stabstr 0 : { *(.stabstr) }
213   .stab.excl 0 : { *(.stab.excl) }
214   .stab.exclstr 0 : { *(.stab.exclstr) }
215   .stab.index 0 : { *(.stab.index) }
216   .stab.indexstr 0 : { *(.stab.indexstr) }
217   .comment 0 : { *(.comment) }
218   .note.gnu.build-id : { *(.note.gnu.build-id) }
219   /* DWARF debug sections.
220      Symbols in the DWARF debugging sections are relative to the beginning
221      of the section so we begin them at 0.  */
222   /* DWARF 1 */
223   .debug          0 : { *(.debug) }
224   .line           0 : { *(.line) }
225   /* GNU DWARF 1 extensions */
226   .debug_srcinfo  0 : { *(.debug_srcinfo) }
227   .debug_sfnames  0 : { *(.debug_sfnames) }
228   /* DWARF 1.1 and DWARF 2 */
229   .debug_aranges  0 : { *(.debug_aranges) }
230   .debug_pubnames 0 : { *(.debug_pubnames) }
231   /* DWARF 2 */
232   .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
233   .debug_abbrev   0 : { *(.debug_abbrev) }
234   .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end ) }
235   .debug_frame    0 : { *(.debug_frame) }
236   .debug_str      0 : { *(.debug_str) }
237   .debug_loc      0 : { *(.debug_loc) }
238   .debug_macinfo  0 : { *(.debug_macinfo) }
239   /* SGI/MIPS DWARF 2 extensions */
240   .debug_weaknames 0 : { *(.debug_weaknames) }
241   .debug_funcnames 0 : { *(.debug_funcnames) }
242   .debug_typenames 0 : { *(.debug_typenames) }
243   .debug_varnames  0 : { *(.debug_varnames) }
244   /* DWARF 3 */
245   .debug_pubtypes 0 : { *(.debug_pubtypes) }
246   .debug_ranges   0 : { *(.debug_ranges) }
247   /* DWARF Extension.  */
248   .debug_macro    0 : { *(.debug_macro) }
249 }