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