Move location of .jumptables section and add .hightext section to AVR linker script.
[deliverable/binutils-gdb.git] / ld / scripttempl / avr.sc
1 # Copyright (C) 2014-2017 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
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
18 cat <<EOF
19 /* Copyright (C) 2014-2017 Free Software Foundation, Inc.
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
25 OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
26 OUTPUT_ARCH(${ARCH})
27
28 __TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : $TEXT_LENGTH;
29 __DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : $DATA_LENGTH;
30 ${EEPROM_LENGTH+__EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : $EEPROM_LENGTH;}
31 __FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : $FUSE_LENGTH;
32 __LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : $LOCK_LENGTH;
33 __SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : $SIGNATURE_LENGTH;
34 ${USER_SIGNATURE_LENGTH+__USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) ? __USER_SIGNATURE_REGION_LENGTH__ : $USER_SIGNATURE_LENGTH;}
35 ${RODATA_PM_OFFSET+__RODATA_PM_OFFSET__ = DEFINED(__RODATA_PM_OFFSET__) ? __RODATA_PM_OFFSET__ : $RODATA_PM_OFFSET;}
36 MEMORY
37 {
38 text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__
39 data (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__
40 ${EEPROM_LENGTH+ eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__}
41 $FUSE_NAME (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
42 lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
43 signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
44 ${USER_SIGNATURE_LENGTH+ user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__}
45 }
46
47 SECTIONS
48 {
49 /* Read-only sections, merged into text segment: */
50 ${TEXT_DYNAMIC+${DYNAMIC}}
51 .hash ${RELOCATING-0} : { *(.hash) }
52 .dynsym ${RELOCATING-0} : { *(.dynsym) }
53 .dynstr ${RELOCATING-0} : { *(.dynstr) }
54 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
55 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
56 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
57
58 .rel.init ${RELOCATING-0} : { *(.rel.init) }
59 .rela.init ${RELOCATING-0} : { *(.rela.init) }
60 .rel.text ${RELOCATING-0} :
61 {
62 *(.rel.text)
63 ${RELOCATING+*(.rel.text.*)}
64 ${RELOCATING+*(.rel.gnu.linkonce.t*)}
65 }
66 .rela.text ${RELOCATING-0} :
67 {
68 *(.rela.text)
69 ${RELOCATING+*(.rela.text.*)}
70 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
71 }
72 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
73 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
74 .rel.rodata ${RELOCATING-0} :
75 {
76 *(.rel.rodata)
77 ${RELOCATING+*(.rel.rodata.*)}
78 ${RELOCATING+*(.rel.gnu.linkonce.r*)}
79 }
80 .rela.rodata ${RELOCATING-0} :
81 {
82 *(.rela.rodata)
83 ${RELOCATING+*(.rela.rodata.*)}
84 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
85 }
86 .rel.data ${RELOCATING-0} :
87 {
88 *(.rel.data)
89 ${RELOCATING+*(.rel.data.*)}
90 ${RELOCATING+*(.rel.gnu.linkonce.d*)}
91 }
92 .rela.data ${RELOCATING-0} :
93 {
94 *(.rela.data)
95 ${RELOCATING+*(.rela.data.*)}
96 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
97 }
98 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
99 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
100 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
101 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
102 .rel.got ${RELOCATING-0} : { *(.rel.got) }
103 .rela.got ${RELOCATING-0} : { *(.rela.got) }
104 .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
105 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
106 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
107 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
108
109 /* Internal text space or external memory. */
110 .text ${RELOCATING-0} :
111 {
112 *(.vectors)
113 KEEP(*(.vectors))
114
115 /* For data that needs to reside in the lower 64k of progmem. */
116 ${RELOCATING+ *(.progmem.gcc*)}
117
118 /* PR 13812: Placing the trampolines here gives a better chance
119 that they will be in range of the code that uses them. */
120 ${RELOCATING+. = ALIGN(2);}
121 ${CONSTRUCTING+ __trampolines_start = . ; }
122 /* The jump trampolines for the 16-bit limited relocs will reside here. */
123 *(.trampolines)
124 ${RELOCATING+ *(.trampolines*)}
125 ${CONSTRUCTING+ __trampolines_end = . ; }
126
127 /* avr-libc expects these data to reside in lower 64K. */
128 ${RELOCATING+ *libprintf_flt.a:*(.progmem.data)}
129 ${RELOCATING+ *libc.a:*(.progmem.data)}
130
131 ${RELOCATING+ *(.progmem*)}
132
133 ${RELOCATING+. = ALIGN(2);}
134
135 /* For code that needs to reside in the lower 128k progmem. */
136 *(.lowtext)
137 ${RELOCATING+ *(.lowtext*)}
138
139 ${CONSTRUCTING+ __ctors_start = . ; }
140 ${CONSTRUCTING+ *(.ctors) }
141 ${CONSTRUCTING+ __ctors_end = . ; }
142 ${CONSTRUCTING+ __dtors_start = . ; }
143 ${CONSTRUCTING+ *(.dtors) }
144 ${CONSTRUCTING+ __dtors_end = . ; }
145 KEEP(SORT(*)(.ctors))
146 KEEP(SORT(*)(.dtors))
147
148 /* From this point on, we don't bother about wether the insns are
149 below or above the 16 bits boundary. */
150 *(.init0) /* Start here after reset. */
151 KEEP (*(.init0))
152 *(.init1)
153 KEEP (*(.init1))
154 *(.init2) /* Clear __zero_reg__, set up stack pointer. */
155 KEEP (*(.init2))
156 *(.init3)
157 KEEP (*(.init3))
158 *(.init4) /* Initialize data and BSS. */
159 KEEP (*(.init4))
160 *(.init5)
161 KEEP (*(.init5))
162 *(.init6) /* C++ constructors. */
163 KEEP (*(.init6))
164 *(.init7)
165 KEEP (*(.init7))
166 *(.init8)
167 KEEP (*(.init8))
168 *(.init9) /* Call main(). */
169 KEEP (*(.init9))
170 *(.text)
171 ${RELOCATING+. = ALIGN(2);}
172 ${RELOCATING+ *(.text.*)}
173 ${RELOCATING+. = ALIGN(2);}
174 *(.fini9) /* _exit() starts here. */
175 KEEP (*(.fini9))
176 *(.fini8)
177 KEEP (*(.fini8))
178 *(.fini7)
179 KEEP (*(.fini7))
180 *(.fini6) /* C++ destructors. */
181 KEEP (*(.fini6))
182 *(.fini5)
183 KEEP (*(.fini5))
184 *(.fini4)
185 KEEP (*(.fini4))
186 *(.fini3)
187 KEEP (*(.fini3))
188 *(.fini2)
189 KEEP (*(.fini2))
190 *(.fini1)
191 KEEP (*(.fini1))
192 *(.fini0) /* Infinite loop after program termination. */
193 KEEP (*(.fini0))
194
195 /* For code that needs not to reside in the lower progmem. */
196 *(.hightext)
197 ${RELOCATING+ *(.hightext*)}
198
199 ${RELOCATING+. = ALIGN(2);}
200
201 /* For tablejump instruction arrays. We don't relax
202 JMP / CALL instructions within these sections. */
203 *(.jumptables)
204 ${RELOCATING+ *(.jumptables*)}
205
206 ${RELOCATING+ _etext = . ; }
207 } ${RELOCATING+ > text}
208 EOF
209
210 # Devices like ATtiny816 allow to read from flash memory by means of LD*
211 # instructions provided we add an offset of __RODATA_PM_OFFSET__ to the
212 # flash addresses.
213
214 if test -n "$RODATA_PM_OFFSET"; then
215 cat <<EOF
216 .rodata ${RELOCATING+ ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__ } ${RELOCATING-0} :
217 {
218 *(.rodata)
219 ${RELOCATING+ *(.rodata*)}
220 *(.gnu.linkonce.r*)
221 } ${RELOCATING+AT> text}
222 EOF
223 fi
224
225 cat <<EOF
226 .data ${RELOCATING-0} :
227 {
228 ${RELOCATING+ PROVIDE (__data_start = .) ; }
229 *(.data)
230 ${RELOCATING+ *(.data*)}
231 *(.gnu.linkonce.d*)
232 EOF
233
234 # Classical devices that don't show flash memory in the SRAM address space
235 # need .rodata to be part of .data because the compiler will use LD*
236 # instructions and LD* cannot access flash.
237
238 if test -z "$RODATA_PM_OFFSET"; then
239 cat <<EOF
240 *(.rodata) /* We need to include .rodata here if gcc is used */
241 ${RELOCATING+ *(.rodata*)} /* with -fdata-sections. */
242 *(.gnu.linkonce.r*)
243 EOF
244 fi
245
246 cat <<EOF
247 ${RELOCATING+. = ALIGN(2);}
248 ${RELOCATING+ _edata = . ; }
249 ${RELOCATING+ PROVIDE (__data_end = .) ; }
250 } ${RELOCATING+ > data ${RELOCATING+AT> text}}
251
252 .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
253 {
254 ${RELOCATING+ PROVIDE (__bss_start = .) ; }
255 *(.bss)
256 ${RELOCATING+ *(.bss*)}
257 *(COMMON)
258 ${RELOCATING+ PROVIDE (__bss_end = .) ; }
259 } ${RELOCATING+ > data}
260
261 ${RELOCATING+ __data_load_start = LOADADDR(.data); }
262 ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); }
263
264 /* Global data not cleared after reset. */
265 .noinit ${RELOCATING+ ADDR(.bss) + SIZEOF (.bss)} ${RELOCATING-0}: ${RELOCATING+ AT (ADDR (.noinit))}
266 {
267 ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
268 *(.noinit*)
269 ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
270 ${RELOCATING+ _end = . ; }
271 ${RELOCATING+ PROVIDE (__heap_start = .) ; }
272 } ${RELOCATING+ > data}
273 EOF
274
275 if test -n "${EEPROM_LENGTH}"; then
276 cat <<EOF
277
278 .eeprom ${RELOCATING-0}:
279 {
280 /* See .data above... */
281 KEEP(*(.eeprom*))
282 ${RELOCATING+ __eeprom_end = . ; }
283 } ${RELOCATING+ > eeprom}
284 EOF
285 fi
286
287 if test "$FUSE_NAME" = "fuse" ; then
288 cat <<EOF
289
290 .fuse ${RELOCATING-0}:
291 {
292 KEEP(*(.fuse))
293 KEEP(*(.lfuse))
294 KEEP(*(.hfuse))
295 KEEP(*(.efuse))
296 } ${RELOCATING+ > fuse}
297 EOF
298 fi
299
300 cat <<EOF
301
302 .lock ${RELOCATING-0}:
303 {
304 KEEP(*(.lock*))
305 } ${RELOCATING+ > lock}
306
307 .signature ${RELOCATING-0}:
308 {
309 KEEP(*(.signature*))
310 } ${RELOCATING+ > signature}
311 EOF
312
313 if test "$FUSE_NAME" = "config" ; then
314 cat <<EOF
315
316 .config ${RELOCATING-0}:
317 {
318 KEEP(*(.config*))
319 } ${RELOCATING+ > config}
320 EOF
321 fi
322
323 cat <<EOF
324
325 /* Stabs debugging sections. */
326 .stab 0 : { *(.stab) }
327 .stabstr 0 : { *(.stabstr) }
328 .stab.excl 0 : { *(.stab.excl) }
329 .stab.exclstr 0 : { *(.stab.exclstr) }
330 .stab.index 0 : { *(.stab.index) }
331 .stab.indexstr 0 : { *(.stab.indexstr) }
332 .comment 0 : { *(.comment) }
333 .note.gnu.build-id : { *(.note.gnu.build-id) }
334 EOF
335
336 . $srcdir/scripttempl/DWARF.sc
337
338 cat <<EOF
339 }
340 EOF
This page took 0.038619 seconds and 5 git commands to generate.