Commit | Line | Data |
---|---|---|
7ba29e2a | 1 | # Adapted from mips.sc |
985743c7 | 2 | # |
219d1afa | 3 | # Copyright (C) 2014-2018 Free Software Foundation, Inc. |
6c19b93b | 4 | # |
985743c7 NC |
5 | # Copying and distribution of this file, with or without modification, |
6 | # are permitted in any medium without royalty provided the copyright | |
7 | # notice and this notice are preserved. | |
8 | # | |
7ba29e2a NC |
9 | # These variables may be overridden by the emulation file. The |
10 | # defaults are appropriate for a DECstation running Ultrix. | |
985743c7 | 11 | |
7ba29e2a NC |
12 | test -z "$ENTRY" && ENTRY=_start |
13 | ||
14 | #test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x0" | |
15 | ||
6c19b93b | 16 | CTOR=".ctors ${CONSTRUCTING-0} : |
7ba29e2a NC |
17 | { |
18 | ${CONSTRUCTING+${CTOR_START}} | |
19 | /* gcc uses crtbegin.o to find the start of | |
20 | the constructors, so we make sure it is | |
21 | first. Because this is a wildcard, it | |
22 | doesn't matter if the user does not | |
23 | actually link against crtbegin.o; the | |
24 | linker won't look for a file to match a | |
25 | wildcard. The wildcard also means that it | |
26 | doesn't matter which directory crtbegin.o | |
27 | is in. */ | |
28 | ||
29 | KEEP (*crtbegin.o(.ctors)) | |
30 | ||
31 | /* We don't want to include the .ctor section from | |
32 | from the crtend.o file until after the sorted ctors. | |
33 | The .ctor section from the crtend file contains the | |
34 | end of ctors marker and it must be last */ | |
35 | ||
36 | KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) | |
37 | KEEP (*(SORT(.ctors.*))) | |
38 | KEEP (*(.ctors)) | |
39 | ${CONSTRUCTING+${CTOR_END}} | |
40 | }" | |
41 | ||
ec2d9b29 | 42 | DTOR=" .dtors ${CONSTRUCTING-0} : |
7ba29e2a NC |
43 | { |
44 | ${CONSTRUCTING+${DTOR_START}} | |
45 | KEEP (*crtbegin.o(.dtors)) | |
46 | KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) | |
47 | KEEP (*(SORT(.dtors.*))) | |
48 | KEEP (*(.dtors)) | |
49 | ${CONSTRUCTING+${DTOR_END}} | |
50 | }" | |
51 | ||
52 | cat <<EOF | |
219d1afa | 53 | /* Copyright (C) 2014-2018 Free Software Foundation, Inc. |
985743c7 NC |
54 | |
55 | Copying and distribution of this script, with or without modification, | |
56 | are permitted in any medium without royalty provided the copyright | |
57 | notice and this notice are preserved. */ | |
58 | ||
7ba29e2a NC |
59 | OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", |
60 | "${LITTLE_OUTPUT_FORMAT}") | |
61 | /*${LIB_SEARCH_DIRS}*/ | |
62 | ${RELOCATING+${LIB_SEARCH_DIRS}} | |
63 | ||
596d6d91 | 64 | ${RELOCATING+ENTRY (${ENTRY})} |
7ba29e2a | 65 | |
2bf2bf23 | 66 | ${RELOCATING+_TEXT_START_ADDR = DEFINED(_TEXT_START_ADDR) ? _TEXT_START_ADDR : 0x50; |
7ba29e2a | 67 | _HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x0; |
2bf2bf23 | 68 | _STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400;} |
7ba29e2a NC |
69 | |
70 | SECTIONS | |
71 | { | |
72 | .vectors.reset 0x0 : { KEEP (*(.vectors.reset)) } = 0 | |
73 | .vectors.sw_exception 0x8 : { KEEP (*(.vectors.sw_exception)) } = 0 | |
74 | .vectors.interrupt 0x10 : { KEEP (*(.vectors.interrupt)) } = 0 | |
75 | .vectors.debug_sw_break 0x18 : { KEEP (*(.vectors.debug_sw_break)) } = 0 | |
76 | .vectors.hw_exception 0x20 : { KEEP (*(.vectors.hw_exception)) } = 0 | |
77 | ||
78 | ${RELOCATING+. = _TEXT_START_ADDR;} | |
79 | ||
80 | ${RELOCATING+ _ftext = .;} | |
81 | .text : { | |
2bf2bf23 | 82 | *(.text) |
7ba29e2a NC |
83 | ${RELOCATING+*(.text.*)} |
84 | ${RELOCATING+*(.gnu.linkonce.t.*)} | |
85 | } | |
86 | ${RELOCATING+ _etext = .;} | |
87 | ||
88 | .init : { KEEP (*(.init)) } =0 | |
89 | .fini : { KEEP (*(.fini)) } =0 | |
90 | ||
91 | ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);} | |
92 | ${RELOCATING+PROVIDE (___CTOR_LIST__ = .);} | |
93 | ${RELOCATING+${CTOR}} | |
94 | ${RELOCATING+PROVIDE (__CTOR_END__ = .);} | |
95 | ${RELOCATING+PROVIDE (___CTOR_END__ = .);} | |
96 | ||
97 | ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);} | |
98 | ${RELOCATING+PROVIDE (___DTOR_LIST__ = .);} | |
99 | ${RELOCATING+${DTOR}} | |
100 | ${RELOCATING+PROVIDE (__DTOR_END__ = .);} | |
101 | ${RELOCATING+PROVIDE (___DTOR_END__ = .);} | |
102 | ||
103 | ${RELOCATING+ . = ALIGN(4);} | |
104 | ${RELOCATING+ _frodata = . ;} | |
105 | .rodata : { | |
2bf2bf23 | 106 | *(.rodata) |
7ba29e2a NC |
107 | ${RELOCATING+*(.rodata.*)} |
108 | ${RELOCATING+*(.gnu.linkonce.r.*)} | |
2bf2bf23 | 109 | ${CONSTRUCTING+CONSTRUCTORS;} /* Is this needed? */ |
7ba29e2a NC |
110 | } |
111 | ${RELOCATING+ _erodata = .;} | |
112 | ||
113 | /* Alignments by 8 to ensure that _SDA2_BASE_ on a word boundary */ | |
114 | /* Note that .sdata2 and .sbss2 must be contiguous */ | |
115 | ${RELOCATING+. = ALIGN(8);} | |
116 | ${RELOCATING+ _ssrw = .;} | |
117 | .sdata2 : { | |
2bf2bf23 | 118 | *(.sdata2) |
7ba29e2a NC |
119 | ${RELOCATING+*(.sdata2.*)} |
120 | ${RELOCATING+*(.gnu.linkonce.s2.*)} | |
121 | } | |
122 | ${RELOCATING+. = ALIGN(4);} | |
123 | .sbss2 : { | |
6c19b93b | 124 | ${RELOCATING+PROVIDE (__sbss2_start = .);} |
2bf2bf23 | 125 | *(.sbss2) |
7ba29e2a NC |
126 | ${RELOCATING+*(.sbss2.*)} |
127 | ${RELOCATING+*(.gnu.linkonce.sb2.*)} | |
128 | ${RELOCATING+PROVIDE (__sbss2_end = .);} | |
129 | } | |
130 | ${RELOCATING+. = ALIGN(8);} | |
131 | ${RELOCATING+ _essrw = .;} | |
132 | ${RELOCATING+ _ssrw_size = _essrw - _ssrw;} | |
133 | ${RELOCATING+ PROVIDE (_SDA2_BASE_ = _ssrw + (_ssrw_size / 2 ));} | |
134 | ||
135 | ${RELOCATING+ . = ALIGN(4);} | |
136 | ${RELOCATING+ _fdata = .;} | |
137 | .data : { | |
2bf2bf23 | 138 | *(.data) |
7ba29e2a | 139 | ${RELOCATING+*(.gnu.linkonce.d.*)} |
2bf2bf23 | 140 | ${CONSTRUCTING+CONSTRUCTORS;} /* Is this needed? */ |
7ba29e2a NC |
141 | } |
142 | ${RELOCATING+ _edata = . ;} | |
6c19b93b | 143 | |
7ba29e2a | 144 | /* Added to handle pic code */ |
6c19b93b | 145 | .got : { |
2bf2bf23 | 146 | *(.got) |
7ba29e2a NC |
147 | } |
148 | ||
6c19b93b | 149 | .got1 : { |
2bf2bf23 | 150 | *(.got1) |
7ba29e2a NC |
151 | } |
152 | ||
6c19b93b | 153 | .got2 : { |
2bf2bf23 | 154 | *(.got2) |
7ba29e2a NC |
155 | } |
156 | ||
157 | /* Added by Sathya to handle C++ exceptions */ | |
6c19b93b | 158 | .eh_frame : { |
2bf2bf23 | 159 | *(.eh_frame) |
7ba29e2a | 160 | } |
6c19b93b AM |
161 | |
162 | .jcr : { | |
2bf2bf23 | 163 | *(.jcr) |
7ba29e2a NC |
164 | } |
165 | ||
6c19b93b | 166 | .gcc_except_table : { |
2bf2bf23 | 167 | *(.gcc_except_table) |
7ba29e2a NC |
168 | } |
169 | ||
170 | /* Alignments by 8 to ensure that _SDA_BASE_ on a word boundary */ | |
171 | /* Note that .sdata and .sbss must be contiguous */ | |
172 | ${RELOCATING+. = ALIGN(8);} | |
173 | ${RELOCATING+ _ssro = .;} | |
174 | .sdata : { | |
2bf2bf23 | 175 | *(.sdata) |
7ba29e2a NC |
176 | ${RELOCATING+*(.sdata.*)} |
177 | ${RELOCATING+*(.gnu.linkonce.s.*)} | |
178 | } | |
179 | ${RELOCATING+. = ALIGN(4);} | |
180 | .sbss : { | |
6c19b93b | 181 | ${RELOCATING+PROVIDE (__sbss_start = .);} |
2bf2bf23 | 182 | *(.sbss) |
7ba29e2a NC |
183 | ${RELOCATING+*(.sbss.*)} |
184 | ${RELOCATING+*(.gnu.linkonce.sb.*)} | |
185 | ${RELOCATING+PROVIDE (__sbss_end = .);} | |
186 | } | |
187 | ${RELOCATING+. = ALIGN(8);} | |
188 | ${RELOCATING+ _essro = .;} | |
189 | ${RELOCATING+ _ssro_size = _essro - _ssro;} | |
190 | ${RELOCATING+PROVIDE (_SDA_BASE_ = _ssro + (_ssro_size / 2 ));} | |
191 | ||
192 | ${RELOCATING+ . = ALIGN(4);} | |
193 | ${RELOCATING+ _fbss = .;} | |
194 | .bss : { | |
6c19b93b | 195 | ${RELOCATING+PROVIDE (__bss_start = .);} |
2bf2bf23 | 196 | *(.bss) |
7ba29e2a NC |
197 | ${RELOCATING+*(.bss.*)} |
198 | ${RELOCATING+*(.gnu.linkonce.b.*)} | |
199 | ${RELOCATING+*(COMMON)} | |
2edab91c | 200 | ${RELOCATING+. = ALIGN(. != 0 ? 4 : 1);} |
6c19b93b | 201 | |
7ba29e2a | 202 | ${RELOCATING+PROVIDE (__bss_end = .);} |
7ba29e2a NC |
203 | } |
204 | ||
205 | ${RELOCATING+ . = ALIGN(4);} | |
206 | ||
207 | .heap : { | |
208 | ${RELOCATING+ _heap = .;} | |
209 | ${RELOCATING+ _heap_start = .;} | |
210 | ${RELOCATING+ . += _HEAP_SIZE;} | |
211 | ${RELOCATING+ _heap_end = .;} | |
6c19b93b | 212 | } |
7ba29e2a NC |
213 | |
214 | ${RELOCATING+ . = ALIGN(4);} | |
215 | ||
216 | .stack : { | |
217 | ${RELOCATING+ _stack_end = .;} | |
218 | ${RELOCATING+ . += _STACK_SIZE;} | |
2edab91c | 219 | ${RELOCATING+ . = ALIGN(. != 0 ? 8 : 1);} |
7ba29e2a NC |
220 | ${RELOCATING+ _stack = .;} |
221 | ${RELOCATING+ _end = .;} | |
222 | } | |
223 | ||
6c19b93b | 224 | .tdata : { |
2bf2bf23 | 225 | *(.tdata) |
7ba29e2a NC |
226 | ${RELOCATING+*(.tdata.*)} |
227 | ${RELOCATING+*(.gnu.linkonce.td.*)} | |
228 | } | |
6c19b93b | 229 | .tbss : { |
2bf2bf23 | 230 | *(.tbss) |
7ba29e2a NC |
231 | ${RELOCATING+*(.tbss.*)} |
232 | ${RELOCATING+*(.gnu.linkonce.tb.*)} | |
233 | } | |
234 | } | |
235 | EOF |