]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/avrtiny.sc
AVR: Allow the start address of the .text section to be set by --section-start.
[thirdparty/binutils-gdb.git] / ld / scripttempl / avrtiny.sc
CommitLineData
6f2750fe 1# Copyright (C) 2014-2016 Free Software Foundation, Inc.
985743c7
NC
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
f36e8886 7cat <<EOF
6f2750fe 8/* Copyright (C) 2014-2016 Free Software Foundation, Inc.
985743c7
NC
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
f36e8886
BS
14OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
15OUTPUT_ARCH(${ARCH})
16
cb072816
SKS
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__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 2;
20__LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : 2;
21__SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : 4;
22
f36e8886
BS
23MEMORY
24{
cb072816
SKS
25 text (rx) : ORIGIN = $TEXT_ORIGIN, LENGTH = __TEXT_REGION_LENGTH__
26 data (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DATA_REGION_LENGTH__
f36e8886
BS
27
28 /* Provide offsets for config, lock and signature to match
29 production file format. Ignore offsets in datasheet. */
30
cb072816
SKS
31 config (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
32 lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
33 signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
f36e8886
BS
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. */
0e03d18a 99 .text ${RELOCATING-0} :
f36e8886
BS
100 {
101 *(.vectors)
102 KEEP(*(.vectors))
103
104 /* For data that needs to reside in the lower 64k of progmem. */
51b26797 105 ${RELOCATING+ *(.progmem.gcc*)}
f36e8886 106
51b26797
DC
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);}
f36e8886
BS
110 ${CONSTRUCTING+ __trampolines_start = . ; }
111 /* The jump trampolines for the 16-bit limited relocs will reside here. */
112 *(.trampolines)
51b26797 113 ${RELOCATING+ *(.trampolines*)}
f36e8886
BS
114 ${CONSTRUCTING+ __trampolines_end = . ; }
115
51b26797
DC
116 ${RELOCATING+ *(.progmem*)}
117
118 ${RELOCATING+. = ALIGN(2);}
119
f36e8886
BS
120 /* For future tablejump instruction arrays for 3 byte pc devices.
121 We don't relax jump/call instructions within these sections. */
122 *(.jumptables)
51b26797 123 ${RELOCATING+ *(.jumptables*)}
f36e8886
BS
124
125 /* For code that needs to reside in the lower 128k progmem. */
126 *(.lowtext)
51b26797 127 ${RELOCATING+ *(.lowtext*)}
f36e8886
BS
128
129 ${CONSTRUCTING+ __ctors_start = . ; }
130 ${CONSTRUCTING+ *(.ctors) }
131 ${CONSTRUCTING+ __ctors_end = . ; }
132 ${CONSTRUCTING+ __dtors_start = . ; }
133 ${CONSTRUCTING+ *(.dtors) }
134 ${CONSTRUCTING+ __dtors_end = . ; }
135 KEEP(SORT(*)(.ctors))
136 KEEP(SORT(*)(.dtors))
137
138 /* From this point on, we don't bother about wether the insns are
139 below or above the 16 bits boundary. */
140 *(.init0) /* Start here after reset. */
141 KEEP (*(.init0))
142 *(.init1)
143 KEEP (*(.init1))
144 *(.init2) /* Clear __zero_reg__, set up stack pointer. */
145 KEEP (*(.init2))
146 *(.init3)
147 KEEP (*(.init3))
148 *(.init4) /* Initialize data and BSS. */
149 KEEP (*(.init4))
150 *(.init5)
151 KEEP (*(.init5))
152 *(.init6) /* C++ constructors. */
153 KEEP (*(.init6))
154 *(.init7)
155 KEEP (*(.init7))
156 *(.init8)
157 KEEP (*(.init8))
158 *(.init9) /* Call main(). */
159 KEEP (*(.init9))
160 *(.text)
161 ${RELOCATING+. = ALIGN(2);}
51b26797 162 ${RELOCATING+ *(.text.*)}
f36e8886
BS
163 ${RELOCATING+. = ALIGN(2);}
164 *(.fini9) /* _exit() starts here. */
165 KEEP (*(.fini9))
166 *(.fini8)
167 KEEP (*(.fini8))
168 *(.fini7)
169 KEEP (*(.fini7))
170 *(.fini6) /* C++ destructors. */
171 KEEP (*(.fini6))
172 *(.fini5)
173 KEEP (*(.fini5))
174 *(.fini4)
175 KEEP (*(.fini4))
176 *(.fini3)
177 KEEP (*(.fini3))
178 *(.fini2)
179 KEEP (*(.fini2))
180 *(.fini1)
181 KEEP (*(.fini1))
182 *(.fini0) /* Infinite loop after program termination. */
183 KEEP (*(.fini0))
184 ${RELOCATING+ _etext = . ; }
185 } ${RELOCATING+ > text}
186
51b26797 187 .data ${RELOCATING-0} :
f36e8886
BS
188 {
189 ${RELOCATING+ PROVIDE (__data_start = .) ; }
190 *(.data)
51b26797 191 ${RELOCATING+ *(.data*)}
f36e8886 192 *(.rodata) /* We need to include .rodata here if gcc is used */
51b26797 193 ${RELOCATING+ *(.rodata*)} /* with -fdata-sections. */
f36e8886
BS
194 *(.gnu.linkonce.d*)
195 ${RELOCATING+. = ALIGN(2);}
196 ${RELOCATING+ _edata = . ; }
197 ${RELOCATING+ PROVIDE (__data_end = .) ; }
51b26797 198 } ${RELOCATING+ > data ${RELOCATING+AT> text}}
f36e8886 199
51b26797 200 .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
f36e8886
BS
201 {
202 ${RELOCATING+ PROVIDE (__bss_start = .) ; }
203 *(.bss)
51b26797 204 ${RELOCATING+ *(.bss*)}
f36e8886
BS
205 *(COMMON)
206 ${RELOCATING+ PROVIDE (__bss_end = .) ; }
207 } ${RELOCATING+ > data}
208
209 ${RELOCATING+ __data_load_start = LOADADDR(.data); }
210 ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); }
211
212 /* Global data not cleared after reset. */
7585b2b8 213 .noinit ${RELOCATING+ ADDR(.bss) + SIZEOF (.bss)} ${RELOCATING-0} : ${RELOCATING+ AT (ADDR (.noinit))}
f36e8886
BS
214 {
215 ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
216 *(.noinit*)
217 ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
218 ${RELOCATING+ _end = . ; }
219 ${RELOCATING+ PROVIDE (__heap_start = .) ; }
220 } ${RELOCATING+ > data}
221
222 .lock ${RELOCATING-0}:
223 {
224 KEEP(*(.lock*))
225 } ${RELOCATING+ > lock}
226
227 .signature ${RELOCATING-0}:
228 {
229 KEEP(*(.signature*))
230 } ${RELOCATING+ > signature}
231
232 .config ${RELOCATING-0}:
233 {
234 KEEP(*(.config*))
235 } ${RELOCATING+ > config}
236
237 /* Stabs debugging sections. */
238 .stab 0 : { *(.stab) }
239 .stabstr 0 : { *(.stabstr) }
240 .stab.excl 0 : { *(.stab.excl) }
241 .stab.exclstr 0 : { *(.stab.exclstr) }
242 .stab.index 0 : { *(.stab.index) }
243 .stab.indexstr 0 : { *(.stab.indexstr) }
244 .comment 0 : { *(.comment) }
51b26797
DC
245 .note.gnu.build-id : { *(.note.gnu.build-id) }
246EOF
f36e8886 247
51b26797 248. $srcdir/scripttempl/DWARF.sc
f36e8886 249
51b26797 250cat <<EOF
f36e8886
BS
251}
252EOF