1 | /* |
---|
2 | * Declare some sizes. |
---|
3 | */ |
---|
4 | _RamBase = DEFINED(_RamBase) ? _RamBase : 0x200000; |
---|
5 | _RamSize = DEFINED(_RamSize) ? _RamSize : 0x800000; |
---|
6 | _HeapSize = DEFINED(_HeapSize) ? _HeapSize : 0x0; |
---|
7 | _StackSize = DEFINED(_StackSize) ? _StackSize : 0x1000; |
---|
8 | |
---|
9 | |
---|
10 | /* Default linker script, for normal executables */ |
---|
11 | OUTPUT_FORMAT("elf32-m32c", "elf32-m32c", |
---|
12 | "elf32-m32c") |
---|
13 | OUTPUT_ARCH(m32c) |
---|
14 | ENTRY(_start) |
---|
15 | STARTUP(start.o) |
---|
16 | /* Do we need any of these for elf? |
---|
17 | __DYNAMIC = 0; */ |
---|
18 | MEMORY { |
---|
19 | RAM (w) : ORIGIN = 0x200000, LENGTH = 0x800000 |
---|
20 | VEC (r) : ORIGIN = 0xffffdc, LENGTH = 32 |
---|
21 | RESETVEC (r) : ORIGIN = 0xfffffc, LENGTH = 4 |
---|
22 | } |
---|
23 | SECTIONS |
---|
24 | { |
---|
25 | /* There are three cases we care about: First, RW data that must be |
---|
26 | in the low 64k. This will always be copied from ROM. Second, RO |
---|
27 | data that must be in the low 64k. This may be copied from ROM if |
---|
28 | the ROM is above 64k. Third, anything that does not need to be |
---|
29 | in the first 64k. Chips normally only have two memory regions; |
---|
30 | low ram and either high or low rom. We map the low rom needs |
---|
31 | into one of the actual regions. */ |
---|
32 | |
---|
33 | /* .text goes first so the rom image of ram data will follow it. */ |
---|
34 | .text : |
---|
35 | { |
---|
36 | *(.text .stub .text.* .gnu.linkonce.t.*) |
---|
37 | KEEP (*(.text.*personality*)) |
---|
38 | /* .gnu.warning sections are handled specially by elf32.em. */ |
---|
39 | *(.gnu.warning) |
---|
40 | *(.interp .hash .dynsym .dynstr .gnu.version*) |
---|
41 | PROVIDE (__etext = .); |
---|
42 | PROVIDE (_etext = .); |
---|
43 | PROVIDE (etext = .); |
---|
44 | . = ALIGN(2); |
---|
45 | } > RAM =0 |
---|
46 | |
---|
47 | /* rodata will either be part of data, or will be in low rom. So we |
---|
48 | might be spanning it, or we might not. This lets us include it |
---|
49 | in our calculations when appropriate. */ |
---|
50 | |
---|
51 | .rodata : { |
---|
52 | . = ALIGN(2); |
---|
53 | *(.plt) |
---|
54 | KEEP (*(.init)) |
---|
55 | KEEP (*(.fini)) |
---|
56 | *(.rodata .rodata.* .gnu.linkonce.r.*) |
---|
57 | KEEP (*(SORT(.rtemsroset.*))) |
---|
58 | *(.rodata1) |
---|
59 | *(.eh_frame_hdr) |
---|
60 | KEEP (*(.eh_frame)) |
---|
61 | KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) |
---|
62 | . = ALIGN(2); |
---|
63 | PROVIDE(__romdatastart = .); /* IF_ROROM */ |
---|
64 | } > RAM |
---|
65 | |
---|
66 | .tdata : { |
---|
67 | __TLS_Data_begin = .; |
---|
68 | *(.tdata .tdata.* .gnu.linkonce.td.*) |
---|
69 | __TLS_Data_end = .; |
---|
70 | } > RAM |
---|
71 | .tbss : { |
---|
72 | __TLS_BSS_begin = .; |
---|
73 | *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) |
---|
74 | __TLS_BSS_end = .; |
---|
75 | } > RAM |
---|
76 | __TLS_Data_size = __TLS_Data_end - __TLS_Data_begin; |
---|
77 | __TLS_Data_begin = __TLS_Data_size != 0 ? __TLS_Data_begin : __TLS_BSS_begin; |
---|
78 | __TLS_Data_end = __TLS_Data_size != 0 ? __TLS_Data_end : __TLS_BSS_begin; |
---|
79 | __TLS_BSS_size = __TLS_BSS_end - __TLS_BSS_begin; |
---|
80 | __TLS_Size = __TLS_BSS_end - __TLS_Data_begin; |
---|
81 | __TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss)); |
---|
82 | |
---|
83 | .data : { |
---|
84 | . = ALIGN(32 / 8); |
---|
85 | PROVIDE (__datastart = .); /* IF_ROROM */ |
---|
86 | PROVIDE (__preinit_array_start = .); |
---|
87 | KEEP (*(.preinit_array)) |
---|
88 | PROVIDE (__preinit_array_end = .); |
---|
89 | PROVIDE (__init_array_start = .); |
---|
90 | KEEP (*(.init_array)) |
---|
91 | PROVIDE (__init_array_end = .); |
---|
92 | PROVIDE (__fini_array_start = .); |
---|
93 | KEEP (*(.fini_array)) |
---|
94 | PROVIDE (__fini_array_end = .); |
---|
95 | |
---|
96 | /* gcc uses crtbegin.o to find the start of |
---|
97 | the constructors, so we make sure it is |
---|
98 | first. Because this is a wildcard, it |
---|
99 | doesn't matter if the user does not |
---|
100 | actually link against crtbegin.o; the |
---|
101 | linker won't look for a file to match a |
---|
102 | wildcard. The wildcard also means that it |
---|
103 | doesn't matter which directory crtbegin.o |
---|
104 | is in. */ |
---|
105 | KEEP (*crtbegin*.o(.ctors)) |
---|
106 | /* We don't want to include the .ctor section from |
---|
107 | from the crtend.o file until after the sorted ctors. |
---|
108 | The .ctor section from the crtend file contains the |
---|
109 | end of ctors marker and it must be last */ |
---|
110 | KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors)) |
---|
111 | KEEP (*(SORT(.ctors.*))) |
---|
112 | KEEP (*(.ctors)) |
---|
113 | |
---|
114 | KEEP (*crtbegin*.o(.dtors)) |
---|
115 | KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors)) |
---|
116 | KEEP (*(SORT(.dtors.*))) |
---|
117 | KEEP (*(.dtors)) |
---|
118 | |
---|
119 | KEEP (*(.jcr)) |
---|
120 | *(.data.rel.ro.local) *(.data.rel.ro*) |
---|
121 | *(.dynamic) |
---|
122 | |
---|
123 | *(.data .data.* .gnu.linkonce.d.*) |
---|
124 | KEEP (*(SORT(.rtemsrwset.*))) |
---|
125 | KEEP (*(.gnu.linkonce.d.*personality*)) |
---|
126 | SORT(CONSTRUCTORS) |
---|
127 | *(.data1) |
---|
128 | *(.got.plt) *(.got) |
---|
129 | |
---|
130 | . = ALIGN(2); |
---|
131 | _edata = .; |
---|
132 | PROVIDE (edata = .); |
---|
133 | PROVIDE (__dataend = .); |
---|
134 | } > RAM |
---|
135 | |
---|
136 | /* Note that __romdatacopysize may be ZERO for the simulator, which |
---|
137 | knows how to intialize RAM directly. It should ONLY be used for |
---|
138 | copying data from ROM to RAM; if you need to know the size of the |
---|
139 | data section, subtract the end symbol from the start symbol. */ |
---|
140 | /* Note that crt0 assumes this is even; all the start/stop symbols |
---|
141 | are also assumed word-aligned. */ |
---|
142 | PROVIDE (__romdatacopysize = 0); |
---|
143 | |
---|
144 | .bss : { |
---|
145 | . = ALIGN(2); |
---|
146 | PROVIDE (__bssstart = .); |
---|
147 | *(.dynbss) |
---|
148 | *(.bss .bss.* .gnu.linkonce.b.*) |
---|
149 | *(COMMON) |
---|
150 | . = ALIGN(2); |
---|
151 | PROVIDE (__bssend = .); |
---|
152 | _end = .; |
---|
153 | PROVIDE (end = .); |
---|
154 | } > RAM |
---|
155 | PROVIDE (__bsssize = 0); |
---|
156 | . = ALIGN(16); |
---|
157 | |
---|
158 | . += _StackSize; |
---|
159 | PROVIDE (__stack = .); |
---|
160 | |
---|
161 | .rtemsstack (NOLOAD) : { |
---|
162 | *(SORT(.rtemsstack.*)) |
---|
163 | } > RAM |
---|
164 | |
---|
165 | PROVIDE (_WorkAreaBase = .); |
---|
166 | . = 0xa00000; |
---|
167 | PROVIDE (_WorkAreaEnd = .); |
---|
168 | PROVIDE (_WorkAreaSize = _WorkAreaEnd - _WorkAreaBase); |
---|
169 | |
---|
170 | /* |
---|
171 | .stack (0x200000 + 0x800000 - 2) : |
---|
172 | { |
---|
173 | PROVIDE (__stack = .); |
---|
174 | *(.stack) |
---|
175 | } |
---|
176 | */ |
---|
177 | |
---|
178 | .vec : { |
---|
179 | *(.vec) |
---|
180 | } > VEC |
---|
181 | .resetvec : { |
---|
182 | *(.resetvec) |
---|
183 | } > RESETVEC |
---|
184 | |
---|
185 | /* The rest are all not normally part of the runtime image. */ |
---|
186 | |
---|
187 | /* Stabs debugging sections. */ |
---|
188 | .stab 0 : { *(.stab) } |
---|
189 | .stabstr 0 : { *(.stabstr) } |
---|
190 | .stab.excl 0 : { *(.stab.excl) } |
---|
191 | .stab.exclstr 0 : { *(.stab.exclstr) } |
---|
192 | .stab.index 0 : { *(.stab.index) } |
---|
193 | .stab.indexstr 0 : { *(.stab.indexstr) } |
---|
194 | .comment 0 : { *(.comment) } |
---|
195 | /* DWARF debug sections. |
---|
196 | Symbols in the DWARF debugging sections are relative to the beginning |
---|
197 | of the section so we begin them at 0. */ |
---|
198 | /* DWARF 1 */ |
---|
199 | .debug 0 : { *(.debug) } |
---|
200 | .line 0 : { *(.line) } |
---|
201 | /* GNU DWARF 1 extensions */ |
---|
202 | .debug_srcinfo 0 : { *(.debug_srcinfo) } |
---|
203 | .debug_sfnames 0 : { *(.debug_sfnames) } |
---|
204 | /* DWARF 1.1 and DWARF 2 */ |
---|
205 | .debug_aranges 0 : { *(.debug_aranges) } |
---|
206 | .debug_pubnames 0 : { *(.debug_pubnames) } |
---|
207 | /* DWARF 2 */ |
---|
208 | .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } |
---|
209 | .debug_abbrev 0 : { *(.debug_abbrev) } |
---|
210 | .debug_line 0 : { *(.debug_line) } |
---|
211 | .debug_frame 0 : { *(.debug_frame) } |
---|
212 | .debug_str 0 : { *(.debug_str) } |
---|
213 | .debug_loc 0 : { *(.debug_loc) } |
---|
214 | .debug_macinfo 0 : { *(.debug_macinfo) } |
---|
215 | /* SGI/MIPS DWARF 2 extensions */ |
---|
216 | .debug_weaknames 0 : { *(.debug_weaknames) } |
---|
217 | .debug_funcnames 0 : { *(.debug_funcnames) } |
---|
218 | .debug_typenames 0 : { *(.debug_typenames) } |
---|
219 | .debug_varnames 0 : { *(.debug_varnames) } |
---|
220 | /DISCARD/ : { *(.note.GNU-stack) } |
---|
221 | } |
---|