1 | /* Copyright (c) 2013-2015 Red Hat, Inc. All rights reserved. |
---|
2 | |
---|
3 | This copyrighted material is made available to anyone wishing to use, modify, |
---|
4 | copy, or redistribute it subject to the terms and conditions of the BSD |
---|
5 | License. This program is distributed in the hope that it will be useful, |
---|
6 | but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties |
---|
7 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license |
---|
8 | is available at http://www.opensource.org/licenses. Any Red Hat trademarks that |
---|
9 | are incorporated in the source code or documentation are not subject to the BSD |
---|
10 | License and may only be used or replicated with the express permission of |
---|
11 | Red Hat, Inc. */ |
---|
12 | |
---|
13 | /* Default linker script, for normal MSP430 executables. */ |
---|
14 | |
---|
15 | OUTPUT_ARCH(msp430) |
---|
16 | ENTRY(_start) |
---|
17 | |
---|
18 | INCLUDE intr_vectors.ld |
---|
19 | |
---|
20 | MEMORY |
---|
21 | { |
---|
22 | RAM (w) : ORIGIN = 0x00500, LENGTH = 0x0eb00 |
---|
23 | } |
---|
24 | |
---|
25 | SECTIONS |
---|
26 | { |
---|
27 | .resetvec : |
---|
28 | { |
---|
29 | *(.resetvec) |
---|
30 | } > VECT31 |
---|
31 | |
---|
32 | .rodata : |
---|
33 | { |
---|
34 | . = ALIGN(2); |
---|
35 | *(.plt) |
---|
36 | . = ALIGN(2); |
---|
37 | *(.lower.rodata.* .lower.rodata) |
---|
38 | . = ALIGN(2); |
---|
39 | *(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*) |
---|
40 | . = ALIGN(2); |
---|
41 | *(.either.rodata.* .either.rodata) |
---|
42 | . = ALIGN(2); |
---|
43 | *(.rodata1) |
---|
44 | |
---|
45 | KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) |
---|
46 | PROVIDE (__preinit_array_start = .); |
---|
47 | KEEP (*(.preinit_array)) |
---|
48 | PROVIDE (__preinit_array_end = .); |
---|
49 | PROVIDE (__init_array_start = .); |
---|
50 | KEEP (*(SORT(.init_array.*))) |
---|
51 | KEEP (*(.init_array)) |
---|
52 | PROVIDE (__init_array_end = .); |
---|
53 | PROVIDE (__fini_array_start = .); |
---|
54 | KEEP (*(.fini_array)) |
---|
55 | KEEP (*(SORT(.fini_array.*))) |
---|
56 | PROVIDE (__fini_array_end = .); |
---|
57 | |
---|
58 | } > RAM |
---|
59 | |
---|
60 | /* Note: This is a separate .rodata section for sections which are |
---|
61 | read only but which older linkers treat as read-write. |
---|
62 | This prevents older linkers from marking the entire .rodata |
---|
63 | section as read-write. */ |
---|
64 | .rodata2 : |
---|
65 | { |
---|
66 | . = ALIGN(2); |
---|
67 | *(.eh_frame_hdr) |
---|
68 | KEEP (*(.eh_frame)) |
---|
69 | |
---|
70 | /* gcc uses crtbegin.o to find the start of the constructors, so |
---|
71 | we make sure it is first. Because this is a wildcard, it |
---|
72 | doesn't matter if the user does not actually link against |
---|
73 | crtbegin.o; the linker won't look for a file to match a |
---|
74 | wildcard. The wildcard also means that it doesn't matter which |
---|
75 | directory crtbegin.o is in. */ |
---|
76 | KEEP (*crtbegin*.o(.ctors)) |
---|
77 | |
---|
78 | /* We don't want to include the .ctor section from from the |
---|
79 | crtend.o file until after the sorted ctors. The .ctor section |
---|
80 | from the crtend file contains the end of ctors marker and it |
---|
81 | must be last */ |
---|
82 | KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors)) |
---|
83 | KEEP (*(SORT(.ctors.*))) |
---|
84 | KEEP (*(.ctors)) |
---|
85 | |
---|
86 | KEEP (*crtbegin*.o(.dtors)) |
---|
87 | KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors)) |
---|
88 | KEEP (*(SORT(.dtors.*))) |
---|
89 | KEEP (*(.dtors)) |
---|
90 | } > RAM |
---|
91 | |
---|
92 | .text : |
---|
93 | { |
---|
94 | . = ALIGN(2); |
---|
95 | PROVIDE (_start = .); |
---|
96 | KEEP (*(SORT(.crt_*))) |
---|
97 | *(.lowtext) |
---|
98 | *(.lower.text.* .lower.text) |
---|
99 | *(.text .stub .text.* .gnu.linkonce.t.* .text:*) |
---|
100 | *(.either.text.* .either.text) |
---|
101 | KEEP (*(.text.*personality*)) |
---|
102 | /* .gnu.warning sections are handled specially by elf32.em. */ |
---|
103 | *(.gnu.warning) |
---|
104 | *(.interp .hash .dynsym .dynstr .gnu.version*) |
---|
105 | PROVIDE (__etext = .); |
---|
106 | PROVIDE (_etext = .); |
---|
107 | PROVIDE (etext = .); |
---|
108 | . = ALIGN(2); |
---|
109 | KEEP (*(.init)) |
---|
110 | KEEP (*(.fini)) |
---|
111 | KEEP (*(.tm_clone_table)) |
---|
112 | } > RAM |
---|
113 | |
---|
114 | .data : |
---|
115 | { |
---|
116 | . = ALIGN(2); |
---|
117 | PROVIDE (__datastart = .); |
---|
118 | |
---|
119 | *(.lower.data.* .lower.data) |
---|
120 | |
---|
121 | *(.data .data.* .gnu.linkonce.d.*) |
---|
122 | |
---|
123 | *(.either.data.* .either.data) |
---|
124 | |
---|
125 | KEEP (*(.jcr)) |
---|
126 | *(.data.rel.ro.local) *(.data.rel.ro*) |
---|
127 | *(.dynamic) |
---|
128 | |
---|
129 | KEEP (*(.gnu.linkonce.d.*personality*)) |
---|
130 | SORT(CONSTRUCTORS) |
---|
131 | *(.data1) |
---|
132 | *(.got.plt) *(.got) |
---|
133 | |
---|
134 | /* We want the small data sections together, so single-instruction offsets |
---|
135 | can access them all, and initialized data all before uninitialized, so |
---|
136 | we can shorten the on-disk segment size. */ |
---|
137 | . = ALIGN(2); |
---|
138 | *(.sdata .sdata.* .gnu.linkonce.s.* D_2 D_1) |
---|
139 | |
---|
140 | . = ALIGN(2); |
---|
141 | _edata = .; |
---|
142 | PROVIDE (edata = .); |
---|
143 | PROVIDE (__dataend = .); |
---|
144 | } > RAM |
---|
145 | |
---|
146 | /* Note that crt0 assumes this is a multiple of two; all the |
---|
147 | start/stop symbols are also assumed word-aligned. */ |
---|
148 | PROVIDE(__romdatastart = LOADADDR(.data)); |
---|
149 | PROVIDE (__romdatacopysize = SIZEOF(.data)); |
---|
150 | |
---|
151 | .bss : |
---|
152 | { |
---|
153 | . = ALIGN(2); |
---|
154 | PROVIDE (__bssstart = .); |
---|
155 | *(.lower.bss.* .lower.bss) |
---|
156 | *(.dynbss) |
---|
157 | *(.sbss .sbss.*) |
---|
158 | *(.bss .bss.* .gnu.linkonce.b.*) |
---|
159 | *(.either.bss.* .either.bss) |
---|
160 | . = ALIGN(2); |
---|
161 | *(COMMON) |
---|
162 | . = ALIGN(2); |
---|
163 | PROVIDE (__bssend = .); |
---|
164 | } > RAM |
---|
165 | PROVIDE (__bsssize = SIZEOF(.bss)); |
---|
166 | |
---|
167 | /* This section contains data that is not initialised during load |
---|
168 | *or* application reset. */ |
---|
169 | .noinit (NOLOAD) : |
---|
170 | { |
---|
171 | . = ALIGN(2); |
---|
172 | PROVIDE (__noinit_start = .); |
---|
173 | *(.noinit) |
---|
174 | . = ALIGN(2); |
---|
175 | PROVIDE (__noinit_end = .); |
---|
176 | } > RAM |
---|
177 | |
---|
178 | /* This section is intended to contain data that *is* initialised during load |
---|
179 | but *not* on application reset. Normally the section would be stored in |
---|
180 | FLASH RAM, but this is not available here. We just have to hope that the |
---|
181 | programmer knows what they are doing. */ |
---|
182 | .persistent : |
---|
183 | { |
---|
184 | . = ALIGN(2); |
---|
185 | PROVIDE (__persistent_start = .); |
---|
186 | *(.persistent) |
---|
187 | . = ALIGN(2); |
---|
188 | PROVIDE (__persistent_end = .); |
---|
189 | } > RAM |
---|
190 | |
---|
191 | _end = .; |
---|
192 | PROVIDE (end = .); |
---|
193 | |
---|
194 | /* The __stack_size value of 0x100 is just a guess, but since it is |
---|
195 | PROVIDEd the user can override it on the command line. It has to be |
---|
196 | set here, rather than inside the .stack section, as symbols defined |
---|
197 | inside sections are only evaluated during the final phase of the link, |
---|
198 | long after the ASSERT is checked. An ASSERT referencing a PROVIDED but |
---|
199 | not yet evaluated symbol will automatically fail. |
---|
200 | |
---|
201 | FIXME: It would be nice if this value could be automatically set via |
---|
202 | gcc's -fstack-usage command line option somehow. */ |
---|
203 | PROVIDE (__stack_size = 0x100); |
---|
204 | |
---|
205 | .stack (ORIGIN (RAM) + LENGTH(RAM)) : |
---|
206 | { |
---|
207 | PROVIDE (__stack = .); |
---|
208 | *(.stack) |
---|
209 | |
---|
210 | /* Linker section checking ignores empty sections like |
---|
211 | this one so we have to have our own test here. */ |
---|
212 | /* FIXME: This test is triggering erroneously. I have not figured |
---|
213 | out why yet, but I am disabling it for now as it prevents the |
---|
214 | gcc testsuite from working. */ |
---|
215 | /* ASSERT (__stack > (_end + __stack_size), |
---|
216 | "Error: Too much data - no room left for the stack"); */ |
---|
217 | } |
---|
218 | |
---|
219 | /* Make sure that .upper sections are not used without -mlarge support. */ |
---|
220 | .upper : |
---|
221 | { |
---|
222 | *(.upper.rodata.* .upper.rodata) |
---|
223 | *(.upper.data.* .upper.data) |
---|
224 | *(.upper.bss.* .upper.bss) |
---|
225 | *(.upper.text.* .upper.text) |
---|
226 | ASSERT (SIZEOF(.upper) == 0, "This MCU does not support high memory"); |
---|
227 | } |
---|
228 | |
---|
229 | /* The rest are all not normally part of the runtime image. */ |
---|
230 | |
---|
231 | .MSP430.attributes 0 : |
---|
232 | { |
---|
233 | KEEP (*(.MSP430.attributes)) |
---|
234 | KEEP (*(.gnu.attributes)) |
---|
235 | KEEP (*(__TI_build_attributes)) |
---|
236 | } |
---|
237 | |
---|
238 | /* Stabs debugging sections. */ |
---|
239 | .stab 0 : { *(.stab) } |
---|
240 | .stabstr 0 : { *(.stabstr) } |
---|
241 | .stab.excl 0 : { *(.stab.excl) } |
---|
242 | .stab.exclstr 0 : { *(.stab.exclstr) } |
---|
243 | .stab.index 0 : { *(.stab.index) } |
---|
244 | .stab.indexstr 0 : { *(.stab.indexstr) } |
---|
245 | .comment 0 : { *(.comment) } |
---|
246 | /* DWARF debug sections. |
---|
247 | Symbols in the DWARF debugging sections are relative to the beginning |
---|
248 | of the section so we begin them at 0. */ |
---|
249 | /* DWARF 1. */ |
---|
250 | .debug 0 : { *(.debug) } |
---|
251 | .line 0 : { *(.line) } |
---|
252 | /* GNU DWARF 1 extensions. */ |
---|
253 | .debug_srcinfo 0 : { *(.debug_srcinfo) } |
---|
254 | .debug_sfnames 0 : { *(.debug_sfnames) } |
---|
255 | /* DWARF 1.1 and DWARF 2. */ |
---|
256 | .debug_aranges 0 : { *(.debug_aranges) } |
---|
257 | .debug_pubnames 0 : { *(.debug_pubnames) } |
---|
258 | /* DWARF 2 */ |
---|
259 | .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } |
---|
260 | .debug_abbrev 0 : { *(.debug_abbrev) } |
---|
261 | .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } |
---|
262 | .debug_frame 0 : { *(.debug_frame) } |
---|
263 | .debug_str 0 : { *(.debug_str) } |
---|
264 | .debug_loc 0 : { *(.debug_loc) } |
---|
265 | .debug_macinfo 0 : { *(.debug_macinfo) } |
---|
266 | /* SGI/MIPS DWARF 2 extensions. */ |
---|
267 | .debug_weaknames 0 : { *(.debug_weaknames) } |
---|
268 | .debug_funcnames 0 : { *(.debug_funcnames) } |
---|
269 | .debug_typenames 0 : { *(.debug_typenames) } |
---|
270 | .debug_varnames 0 : { *(.debug_varnames) } |
---|
271 | /* DWARF 3. */ |
---|
272 | .debug_pubtypes 0 : { *(.debug_pubtypes) } |
---|
273 | .debug_ranges 0 : { *(.debug_ranges) } |
---|
274 | /* DWARF Extension. */ |
---|
275 | .debug_macro 0 : { *(.debug_macro) } |
---|
276 | |
---|
277 | /DISCARD/ : { *(.note.GNU-stack) } |
---|
278 | } |
---|