Commit | Line | Data |
---|---|---|
82704155 | 1 | # Copyright (C) 2014-2019 Free Software Foundation, Inc. |
6c19b93b | 2 | # |
985743c7 NC |
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 | ||
35c08157 KLC |
7 | # This file is variant of elf.sc. For nds32, because the data will be |
8 | # classified into different sections according to their size, this script | |
9 | # describe these sections map. The order is ".sdata_d, .sdata_w, .sdata_h, | |
10 | # .sdata_b, , sdata_f, .sbss_f, .sbss_b, .sbss_h, .sbss_w, .sbss_d". In | |
11 | # this order we do not have to consider the alignment issue between these | |
12 | # sections. | |
13 | ||
14 | if test -n "$NOP"; then | |
15 | FILL="=$NOP" | |
16 | else | |
17 | FILL= | |
18 | fi | |
19 | ||
20 | test -z "$RODATA_NAME" && RODATA_NAME=rodata | |
21 | test -z "$SDATA_NAME" && SDATA_NAME=sdata | |
22 | test -z "$SBSS_NAME" && SBSS_NAME=sbss | |
23 | test -z "$BSS_NAME" && BSS_NAME=bss | |
24 | test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start | |
25 | test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
26 | test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
27 | if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi | |
28 | test -z "${ELFSIZE}" && ELFSIZE=32 | |
29 | test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" | |
30 | test "$LD_FLAG" = "N" && DATA_ADDR=. | |
31 | test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext | |
32 | test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" | |
33 | test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" | |
34 | test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT | |
35 | test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" | |
36 | DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" | |
37 | DATA_SEGMENT_RELRO_END="" | |
38 | DATA_SEGMENT_END="" | |
39 | if test -n "${COMMONPAGESIZE}"; then | |
40 | DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" | |
41 | DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" | |
42 | DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" | |
43 | fi | |
44 | if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then | |
45 | INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" | |
46 | fi | |
47 | if test -z "$PLT"; then | |
48 | IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }" | |
2bf2bf23 | 49 | PLT=".plt ${RELOCATING-0} : { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} } |
35c08157 KLC |
50 | ${IREL_IN_PLT-$IPLT}" |
51 | fi | |
52 | test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT= | |
53 | if test -z "$GOT"; then | |
54 | if test -z "$SEPARATE_GOTPLT"; then | |
2bf2bf23 | 55 | GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt) *(.igot.plt)} *(.got)${RELOCATING+ *(.igot)} }" |
35c08157 | 56 | else |
2bf2bf23 AM |
57 | GOT=".got ${RELOCATING-0} : { *(.got)${RELOCATING+ *(.igot)} }" |
58 | GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }" | |
35c08157 KLC |
59 | fi |
60 | fi | |
61 | REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }" | |
62 | RELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }" | |
63 | REL_IPLT=".rel.iplt ${RELOCATING-0} : | |
64 | { | |
65 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}} | |
66 | *(.rel.iplt) | |
67 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}} | |
68 | }" | |
69 | RELA_IPLT=".rela.iplt ${RELOCATING-0} : | |
70 | { | |
71 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}} | |
72 | *(.rela.iplt) | |
73 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}} | |
74 | }" | |
75 | DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" | |
76 | RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }" | |
77 | DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }" | |
78 | DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" | |
79 | if test -z "${NO_SMALL_DATA}"; then | |
80 | SBSS=".sbss_b ${RELOCATING-0} : | |
81 | { | |
82 | *(.sbss_b${RELOCATING+ .sbss_b.*}) | |
2bf2bf23 | 83 | ${RELOCATING+*(.scommon_b .scommon_b.*)} |
35c08157 KLC |
84 | ${RELOCATING+. = ALIGN(2);} |
85 | } | |
86 | .sbss_h ${RELOCATING-0} : | |
87 | { | |
88 | *(.sbss_h${RELOCATING+ .sbss_h.*}) | |
2bf2bf23 | 89 | ${RELOCATING+*(.scommon_h .scommon_h.*)} |
35c08157 KLC |
90 | ${RELOCATING+. = ALIGN(4);} |
91 | } | |
92 | .sbss_w ${RELOCATING-0} : | |
93 | { | |
94 | *(.sbss_w${RELOCATING+ .sbss_w.*}) | |
2bf2bf23 | 95 | ${RELOCATING+*(.scommon_w .scommon_w.*) |
35c08157 KLC |
96 | *(.dynsbss) |
97 | *(.scommon) | |
2bf2bf23 | 98 | . = ALIGN(8);} |
35c08157 KLC |
99 | } |
100 | .sbss_d ${RELOCATING-0} : | |
101 | { | |
102 | *(.sbss_d${RELOCATING+ .sbss_d.*}) | |
2bf2bf23 | 103 | ${RELOCATING+*(.scommon_d .scommon_d.*)} |
35c08157 KLC |
104 | ${RELOCATING+PROVIDE (__sbss_end = .);} |
105 | ${RELOCATING+PROVIDE (___sbss_end = .);} | |
106 | }" | |
107 | SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }" | |
108 | SDATA="/* We want the small data sections together, so single-instruction offsets | |
109 | can access them all, and initialized data all before uninitialized, so | |
110 | we can shorten the on-disk segment size. */ | |
111 | .${SDATA_NAME} ${RELOCATING-0} : | |
112 | { | |
113 | ${RELOCATING+${SDATA_START_SYMBOLS}} | |
114 | ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)} | |
115 | *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*}) | |
116 | } | |
117 | .sdata_d ${RELOCATING-0} : | |
118 | { | |
119 | *(.sdata_d${RELOCATING+ .sdata_d.*}) | |
120 | } | |
121 | .sdata_w ${RELOCATING-0} : | |
122 | { | |
123 | *(.sdata_w${RELOCATING+ .sdata_w.*}) | |
124 | } | |
125 | .sdata_h ${RELOCATING-0} : | |
126 | { | |
127 | *(.sdata_h${RELOCATING+ .sdata_h.*}) | |
128 | } | |
129 | .sdata_b ${RELOCATING-0} : | |
130 | { | |
131 | *(.sdata_b${RELOCATING+ .sdata_b.*}) | |
132 | } | |
133 | .sdata_f ${RELOCATING-0} : | |
134 | { | |
135 | *(.sdata_f${RELOCATING+ .sdata_f.*}) | |
136 | }" | |
137 | SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} : | |
138 | { | |
139 | ${RELOCATING+${SDATA2_START_SYMBOLS}} | |
140 | *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*}) | |
141 | }" | |
142 | REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) } | |
143 | .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }" | |
144 | REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) } | |
145 | .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }" | |
146 | REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) } | |
147 | .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }" | |
148 | REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) } | |
149 | .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }" | |
150 | else | |
151 | NO_SMALL_DATA=" " | |
152 | fi | |
153 | if test -z "${DATA_GOT}"; then | |
154 | if test -n "${NO_SMALL_DATA}"; then | |
155 | DATA_GOT=" " | |
156 | fi | |
157 | fi | |
158 | if test -z "${SDATA_GOT}"; then | |
159 | if test -z "${NO_SMALL_DATA}"; then | |
160 | SDATA_GOT=" " | |
161 | fi | |
162 | fi | |
163 | test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " | |
164 | test "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" | |
165 | .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) } | |
166 | .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) } | |
167 | .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) } | |
168 | .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } | |
169 | .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } | |
170 | .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" | |
171 | test "${LARGE_SECTIONS}" = "yes" && LARGE_BSS=" | |
172 | .lbss ${RELOCATING-0} : | |
173 | { | |
174 | *(.dynlbss) | |
175 | *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) | |
176 | *(LARGE_COMMON) | |
177 | }" | |
178 | test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" | |
179 | .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : | |
180 | { | |
181 | *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*}) | |
182 | } | |
183 | .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : | |
184 | { | |
185 | *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) | |
186 | ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} | |
187 | }" | |
188 | if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then | |
189 | SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" | |
190 | SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" | |
191 | CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" | |
192 | DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" | |
193 | else | |
194 | SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" | |
195 | SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" | |
196 | CTORS_IN_INIT_ARRAY= | |
197 | DTORS_IN_FINI_ARRAY= | |
198 | fi | |
199 | INIT_ARRAY=".init_array ${RELOCATING-0} : | |
200 | { | |
201 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} | |
202 | ${SORT_INIT_ARRAY} | |
203 | KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY})) | |
204 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} | |
205 | }" | |
206 | FINI_ARRAY=".fini_array ${RELOCATING-0} : | |
207 | { | |
208 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} | |
209 | ${SORT_FINI_ARRAY} | |
210 | KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY})) | |
211 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} | |
212 | }" | |
213 | CTOR=".ctors ${CONSTRUCTING-0} : | |
214 | { | |
215 | ${CONSTRUCTING+${CTOR_START}} | |
216 | /* gcc uses crtbegin.o to find the start of | |
217 | the constructors, so we make sure it is | |
218 | first. Because this is a wildcard, it | |
219 | doesn't matter if the user does not | |
220 | actually link against crtbegin.o; the | |
221 | linker won't look for a file to match a | |
222 | wildcard. The wildcard also means that it | |
223 | doesn't matter which directory crtbegin.o | |
224 | is in. */ | |
225 | ||
226 | KEEP (*crtbegin.o(.ctors)) | |
227 | KEEP (*crtbegin?.o(.ctors)) | |
228 | ||
229 | /* We don't want to include the .ctor section from | |
230 | the crtend.o file until after the sorted ctors. | |
231 | The .ctor section from the crtend file contains the | |
232 | end of ctors marker and it must be last */ | |
233 | ||
234 | KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) | |
235 | KEEP (*(SORT(.ctors.*))) | |
236 | KEEP (*(.ctors)) | |
237 | ${CONSTRUCTING+${CTOR_END}} | |
238 | }" | |
239 | DTOR=".dtors ${CONSTRUCTING-0} : | |
240 | { | |
241 | ${CONSTRUCTING+${DTOR_START}} | |
242 | KEEP (*crtbegin.o(.dtors)) | |
243 | KEEP (*crtbegin?.o(.dtors)) | |
244 | KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) | |
245 | KEEP (*(SORT(.dtors.*))) | |
246 | KEEP (*(.dtors)) | |
247 | ${CONSTRUCTING+${DTOR_END}} | |
248 | }" | |
74dc9032 | 249 | STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : |
35c08157 KLC |
250 | { |
251 | ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;} | |
252 | *(.stack) | |
74dc9032 | 253 | ${RELOCATING+${STACK_SENTINEL}} |
35c08157 KLC |
254 | }" |
255 | ||
256 | TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" | |
257 | SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" | |
258 | ||
259 | if [ -z "$SEPARATE_CODE" ]; then | |
260 | SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS" | |
261 | else | |
262 | SIZEOF_HEADERS_CODE= | |
263 | fi | |
264 | ||
985743c7 | 265 | # If this is for an embedded system, don't add SIZEOF_HEADERS. |
35c08157 KLC |
266 | if [ -z "$EMBEDDED" ]; then |
267 | test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}" | |
268 | NDS32_INIT="" | |
269 | else | |
270 | test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" | |
271 | NDS32_INIT=".nds32_init : { KEEP(*(.nds32_init)) }" | |
272 | fi | |
273 | ||
274 | cat <<EOF | |
82704155 | 275 | /* Copyright (C) 2014-2019 Free Software Foundation, Inc. |
985743c7 NC |
276 | |
277 | Copying and distribution of this script, with or without modification, | |
278 | are permitted in any medium without royalty provided the copyright | |
279 | notice and this notice are preserved. */ | |
280 | ||
35c08157 KLC |
281 | OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", |
282 | "${LITTLE_OUTPUT_FORMAT}") | |
283 | OUTPUT_ARCH(${OUTPUT_ARCH}) | |
284 | ${RELOCATING+ENTRY(${ENTRY})} | |
285 | ||
286 | ${RELOCATING+${LIB_SEARCH_DIRS}} | |
287 | ${RELOCATING+${EXECUTABLE_SYMBOLS}} | |
288 | ${RELOCATING+${INPUT_FILES}} | |
289 | ${RELOCATING- /* For some reason, the Solaris linker makes bad executables | |
290 | if gld -r is used and the intermediate file has sections starting | |
291 | at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld | |
292 | bug. But for now assigning the zero vmas works. */} | |
293 | ||
294 | SECTIONS | |
295 | { | |
296 | /* Read-only sections, merged into text segment: */ | |
297 | ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} | |
298 | /* Sections saved crt0 and crt1. */ | |
299 | ${NDS32_INIT} | |
300 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} | |
301 | ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} | |
302 | EOF | |
303 | ||
304 | emit_early_ro() | |
305 | { | |
306 | cat <<EOF | |
307 | ${INITIAL_READONLY_SECTIONS} | |
c2e86386 | 308 | .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) } |
35c08157 KLC |
309 | EOF |
310 | } | |
311 | ||
312 | test -n "${SEPARATE_CODE}" || emit_early_ro | |
313 | ||
314 | test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN | |
315 | test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC= | |
316 | cat > ldscripts/dyntmp.$$ <<EOF | |
317 | ${TEXT_DYNAMIC+${DYNAMIC}} | |
318 | .hash ${RELOCATING-0} : { *(.hash) } | |
319 | .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) } | |
320 | .dynsym ${RELOCATING-0} : { *(.dynsym) } | |
321 | .dynstr ${RELOCATING-0} : { *(.dynstr) } | |
322 | .gnu.version ${RELOCATING-0} : { *(.gnu.version) } | |
323 | .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } | |
324 | .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } | |
325 | EOF | |
326 | ||
327 | if [ "x$COMBRELOC" = x ]; then | |
328 | COMBRELOCCAT="cat >> ldscripts/dyntmp.$$" | |
329 | else | |
330 | COMBRELOCCAT="cat > $COMBRELOC" | |
331 | fi | |
332 | eval $COMBRELOCCAT <<EOF | |
333 | ${INITIAL_RELOC_SECTIONS} | |
334 | .rel.init ${RELOCATING-0} : { *(.rel.init) } | |
335 | .rela.init ${RELOCATING-0} : { *(.rela.init) } | |
336 | .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } | |
337 | .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } | |
338 | .rel.fini ${RELOCATING-0} : { *(.rel.fini) } | |
339 | .rela.fini ${RELOCATING-0} : { *(.rela.fini) } | |
340 | .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) } | |
341 | .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) } | |
342 | ${OTHER_READONLY_RELOC_SECTIONS} | |
343 | .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) } | |
344 | .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) } | |
345 | .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } | |
346 | .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } | |
347 | ${OTHER_READWRITE_RELOC_SECTIONS} | |
348 | .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } | |
349 | .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } | |
350 | .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } | |
351 | .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } | |
352 | .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } | |
353 | .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } | |
354 | .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } | |
355 | .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } | |
356 | .rel.got ${RELOCATING-0} : { *(.rel.got) } | |
357 | .rela.got ${RELOCATING-0} : { *(.rela.got) } | |
358 | ${OTHER_GOT_RELOC_SECTIONS} | |
359 | ${REL_SDATA} | |
360 | ${REL_SBSS} | |
361 | ${REL_SDATA2} | |
362 | ${REL_SBSS2} | |
363 | .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) } | |
364 | .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) } | |
365 | ${REL_LARGE} | |
366 | ${IREL_IN_PLT+$REL_IFUNC} | |
367 | ${IREL_IN_PLT+$RELA_IFUNC} | |
368 | ${IREL_IN_PLT-$REL_IPLT} | |
369 | ${IREL_IN_PLT-$RELA_IPLT} | |
370 | EOF | |
371 | ||
372 | if [ -n "$COMBRELOC" ]; then | |
373 | cat >> ldscripts/dyntmp.$$ <<EOF | |
374 | .rel.dyn ${RELOCATING-0} : | |
375 | { | |
376 | EOF | |
6c19b93b | 377 | sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ |
35c08157 KLC |
378 | cat >> ldscripts/dyntmp.$$ <<EOF |
379 | } | |
380 | .rela.dyn ${RELOCATING-0} : | |
381 | { | |
382 | EOF | |
6c19b93b | 383 | sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ |
35c08157 KLC |
384 | cat >> ldscripts/dyntmp.$$ <<EOF |
385 | } | |
386 | EOF | |
387 | fi | |
388 | ||
389 | cat >> ldscripts/dyntmp.$$ <<EOF | |
390 | .rel.plt ${RELOCATING-0} : | |
391 | { | |
392 | *(.rel.plt) | |
393 | ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}} | |
394 | ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}} | |
395 | ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}} | |
396 | } | |
397 | .rela.plt ${RELOCATING-0} : | |
398 | { | |
399 | *(.rela.plt) | |
400 | ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}} | |
401 | ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}} | |
402 | ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}} | |
403 | } | |
404 | ${OTHER_PLT_RELOC_SECTIONS} | |
405 | EOF | |
406 | ||
407 | emit_dyn() | |
408 | { | |
409 | if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then | |
410 | cat ldscripts/dyntmp.$$ | |
411 | else | |
412 | if test -z "${NO_REL_RELOCS}"; then | |
6c19b93b | 413 | sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$ |
35c08157 KLC |
414 | fi |
415 | if test -z "${NO_RELA_RELOCS}"; then | |
6c19b93b | 416 | sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$ |
35c08157 KLC |
417 | fi |
418 | fi | |
419 | rm -f ldscripts/dyntmp.$$ | |
420 | } | |
421 | ||
422 | test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn | |
423 | ||
424 | cat <<EOF | |
425 | .init ${RELOCATING-0} : | |
426 | { | |
427 | ${RELOCATING+${INIT_START}} | |
428 | KEEP (*(SORT_NONE(.init))) | |
429 | ${RELOCATING+${INIT_END}} | |
430 | } ${FILL} | |
431 | ||
432 | ${TEXT_PLT+${PLT_NEXT_DATA-${PLT}}} | |
433 | ${TINY_READONLY_SECTION} | |
434 | .text ${RELOCATING-0} : | |
435 | { | |
436 | ${RELOCATING+${TEXT_START_SYMBOLS}} | |
437 | ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)} | |
438 | ${RELOCATING+*(.text.exit .text.exit.*)} | |
439 | ${RELOCATING+*(.text.startup .text.startup.*)} | |
440 | ${RELOCATING+*(.text.hot .text.hot.*)} | |
441 | *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) | |
075a2b89 | 442 | /* .gnu.warning sections are handled specially by elf.em. */ |
35c08157 KLC |
443 | *(.gnu.warning) |
444 | ${RELOCATING+${OTHER_TEXT_SECTIONS}} | |
445 | } ${FILL} | |
446 | .fini ${RELOCATING-0} : | |
447 | { | |
448 | ${RELOCATING+${FINI_START}} | |
449 | KEEP (*(SORT_NONE(.fini))) | |
450 | ${RELOCATING+${FINI_END}} | |
451 | } ${FILL} | |
452 | ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} | |
453 | ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} | |
454 | ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} | |
455 | EOF | |
456 | ||
457 | if test -n "${SEPARATE_CODE}"; then | |
458 | if test -n "${RODATA_ADDR}"; then | |
459 | RODATA_ADDR="\ | |
460 | SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS" | |
461 | else | |
462 | RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" | |
463 | RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})" | |
464 | fi | |
465 | if test -n "${SHLIB_RODATA_ADDR}"; then | |
466 | SHLIB_RODATA_ADDR="\ | |
467 | SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS" | |
468 | else | |
469 | SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})" | |
470 | SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" | |
471 | fi | |
472 | cat <<EOF | |
473 | /* Adjust the address for the rodata segment. We want to adjust up to | |
474 | the same address within the page on the next page up. */ | |
475 | ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR};}}} | |
476 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}} | |
477 | ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}} | |
478 | EOF | |
479 | emit_early_ro | |
480 | emit_dyn | |
481 | fi | |
482 | ||
483 | cat <<EOF | |
484 | ${WRITABLE_RODATA-${RODATA}} | |
485 | .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) } | |
486 | ${CREATE_SHLIB-${SDATA2}} | |
487 | ${CREATE_SHLIB-${SBSS2}} | |
488 | ${OTHER_READONLY_SECTIONS} | |
c2e86386 | 489 | .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr) } |
35c08157 | 490 | .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) } |
2bf2bf23 | 491 | .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } |
35c08157 | 492 | /* These sections are generated by the Sun/Oracle C++ compiler. */ |
2bf2bf23 | 493 | .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges${RELOCATING+*}) } |
35c08157 KLC |
494 | ${TEXT_PLT+${PLT_NEXT_DATA+${PLT}}} |
495 | ||
496 | /* Adjust the address for the data segment. We want to adjust up to | |
497 | the same address within the page on the next page up. */ | |
498 | ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} | |
499 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} | |
500 | ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} | |
501 | ||
502 | /* Exception handling */ | |
503 | .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) } | |
2bf2bf23 AM |
504 | .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } |
505 | .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges${RELOCATING+*}) } | |
35c08157 KLC |
506 | |
507 | /* Thread Local Storage sections */ | |
508 | .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } | |
509 | .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } | |
510 | ||
511 | .preinit_array ${RELOCATING-0} : | |
512 | { | |
513 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} | |
514 | KEEP (*(.preinit_array)) | |
515 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} | |
516 | } | |
517 | ${RELOCATING+${INIT_ARRAY}} | |
518 | ${RELOCATING+${FINI_ARRAY}} | |
519 | ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} | |
520 | ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} | |
521 | .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } | |
522 | ||
523 | ${RELOCATING+${DATARELRO}} | |
524 | ${OTHER_RELRO_SECTIONS} | |
525 | ${TEXT_DYNAMIC-${DYNAMIC}} | |
526 | ${DATA_GOT+${RELRO_NOW+${GOT}}} | |
527 | ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} | |
528 | ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} | |
529 | ${RELOCATING+${DATA_SEGMENT_RELRO_END}} | |
530 | ${INITIAL_READWRITE_SECTIONS} | |
531 | ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} | |
532 | ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} | |
533 | ||
534 | ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} | |
535 | ||
536 | /* For _SDA_BASE_ aligment. */ | |
537 | ${RELOCATING+. = ALIGN(4);} | |
538 | ||
539 | .data ${RELOCATING-0} : | |
540 | { | |
541 | ${RELOCATING+${DATA_START_SYMBOLS}} | |
542 | *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) | |
543 | ${CONSTRUCTING+SORT(CONSTRUCTORS)} | |
544 | } | |
545 | .data1 ${RELOCATING-0} : { *(.data1) } | |
546 | ${WRITABLE_RODATA+${RODATA}} | |
547 | ${OTHER_READWRITE_SECTIONS} | |
548 | ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}} | |
549 | ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}} | |
550 | ${RELOCATING+. = ALIGN(4);} | |
551 | ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}} | |
552 | ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}} | |
553 | ${SDATA_GOT+${GOT}} | |
554 | ${SDATA_GOT+${OTHER_GOT_SECTIONS}} | |
555 | ${SDATA} | |
556 | ${OTHER_SDATA_SECTIONS} | |
557 | ${RELOCATING+. = ALIGN(4);} | |
558 | ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}} | |
559 | ${RELOCATING+. = .;} | |
560 | ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;} | |
561 | ${RELOCATING+${OTHER_BSS_SYMBOLS}} | |
562 | ${SBSS} | |
563 | ${BSS_PLT+${PLT}} | |
564 | .${BSS_NAME} ${RELOCATING-0} : | |
565 | { | |
2bf2bf23 | 566 | ${RELOCATING+*(.dyn${BSS_NAME})} |
35c08157 | 567 | *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*}) |
2bf2bf23 | 568 | ${RELOCATING+*(COMMON) |
35c08157 KLC |
569 | /* Align here to ensure that the .bss section occupies space up to |
570 | _end. Align after .bss to ensure correct alignment even if the | |
571 | .bss section disappears because there are no input sections. | |
2bf2bf23 | 572 | FIXME: Why do we need it? When there is no .bss section, we do not |
35c08157 | 573 | pad the .data section. */ |
2bf2bf23 | 574 | . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} |
35c08157 KLC |
575 | } |
576 | ${OTHER_BSS_SECTIONS} | |
577 | ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}} | |
578 | ${RELOCATING+_end = .;} | |
579 | ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} | |
580 | ${RELOCATING+. = ALIGN(${ALIGNMENT});} | |
581 | EOF | |
582 | ||
583 | LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});" | |
584 | SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});" | |
585 | ||
586 | cat <<EOF | |
587 | ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}} | |
588 | ${RELOCATING+${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}} | |
589 | ${RELOCATING+${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}} | |
590 | ${LARGE_SECTIONS} | |
591 | ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}} | |
592 | ${RELOCATING+. = ALIGN(${ALIGNMENT});} | |
593 | ${RELOCATING+${OTHER_END_SYMBOLS}} | |
594 | ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}} | |
595 | ${RELOCATING+${DATA_SEGMENT_END}} | |
74dc9032 AM |
596 | ${TINY_DATA_SECTION} |
597 | ${TINY_BSS_SECTION} | |
598 | ${STACK_ADDR+${STACK}} | |
35c08157 KLC |
599 | EOF |
600 | ||
601 | test -z "${NON_ALLOC_DYN}" || emit_dyn | |
602 | ||
603 | cat <<EOF | |
604 | /* Stabs debugging sections. */ | |
605 | .stab 0 : { *(.stab) } | |
606 | .stabstr 0 : { *(.stabstr) } | |
607 | .stab.excl 0 : { *(.stab.excl) } | |
608 | .stab.exclstr 0 : { *(.stab.exclstr) } | |
609 | .stab.index 0 : { *(.stab.index) } | |
610 | .stab.indexstr 0 : { *(.stab.indexstr) } | |
611 | ||
612 | .comment 0 : { *(.comment) } | |
613 | ||
614 | EOF | |
615 | ||
616 | . $srcdir/scripttempl/DWARF.sc | |
617 | ||
618 | cat <<EOF | |
35c08157 KLC |
619 | ${ATTRS_SECTIONS} |
620 | ${OTHER_SECTIONS} | |
621 | ${RELOCATING+${OTHER_SYMBOLS}} | |
622 | ${RELOCATING+${DISCARDED}} | |
623 | } | |
624 | EOF |