Commit | Line | Data |
---|---|---|
219d1afa | 1 | # Copyright (C) 2014-2018 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. | |
252b5132 RH |
6 | # |
7 | # Unusual variables checked by this code: | |
b7761f11 | 8 | # NOP - four byte opcode for no-op (defaults to none) |
48459341 L |
9 | # NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not |
10 | # empty. | |
951e9133 L |
11 | # SMALL_DATA_CTOR - .ctors contains small data. |
12 | # SMALL_DATA_DTOR - .dtors contains small data. | |
252b5132 RH |
13 | # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start |
14 | # INITIAL_READONLY_SECTIONS - at start of text segment | |
15 | # OTHER_READONLY_SECTIONS - other than .text .init .rodata ... | |
16 | # (e.g., .PARISC.milli) | |
17 | # OTHER_TEXT_SECTIONS - these get put in .text when relocating | |
1bbce132 | 18 | # INITIAL_READWRITE_SECTIONS - at start of data segment (after relro) |
252b5132 RH |
19 | # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... |
20 | # (e.g., .PARISC.global) | |
8c37241b JJ |
21 | # OTHER_RELRO_SECTIONS - other than .data.rel.ro ... |
22 | # (e.g. PPC32 .fixup, .got[12]) | |
3e2b0f31 | 23 | # OTHER_RELRO_SECTIONS_2 - as above, but after .dynamic in text segment |
e9f53129 | 24 | # OTHER_BSS_SECTIONS - other than .bss .sbss ... |
104d59d1 | 25 | # ATTRS_SECTIONS - at the end |
252b5132 RH |
26 | # OTHER_SECTIONS - at the end |
27 | # EXECUTABLE_SYMBOLS - symbols that must be defined for an | |
28 | # executable (e.g., _DYNAMIC_LINK) | |
ba916c8a MM |
29 | # TEXT_START_ADDR - the first byte of the text segment, after any |
30 | # headers. | |
31 | # TEXT_BASE_ADDRESS - the first byte of the text segment. | |
252b5132 RH |
32 | # TEXT_START_SYMBOLS - symbols that appear at the start of the |
33 | # .text section. | |
34 | # DATA_START_SYMBOLS - symbols that appear at the start of the | |
35 | # .data section. | |
eac338cf PB |
36 | # DATA_END_SYMBOLS - symbols that appear at the end of the |
37 | # writeable data sections. | |
252b5132 | 38 | # OTHER_GOT_SYMBOLS - symbols defined just before .got. |
5253f23b | 39 | # OTHER_GOT_SECTIONS - sections just after .got. |
ce3ad333 | 40 | # OTHER_PLT_SECTIONS - sections just after .plt. |
5253f23b | 41 | # OTHER_SDATA_SECTIONS - sections just after .sdata. |
252b5132 RH |
42 | # OTHER_BSS_SYMBOLS - symbols that appear at the start of the |
43 | # .bss section besides __bss_start. | |
1bbce132 | 44 | # PLT_NEXT_DATA - .plt next to data segment when .plt is in text segment. |
252b5132 | 45 | # DATA_PLT - .plt should be in data segment, not text segment. |
b71a5181 | 46 | # PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement. |
6c86c541 | 47 | # BSS_PLT - .plt should be in bss segment |
485cf679 AM |
48 | # NO_REL_RELOCS - Don't include .rel.* sections in script |
49 | # NO_RELA_RELOCS - Don't include .rela.* sections in script | |
50 | # NON_ALLOC_DYN - Place dynamic sections after data segment. | |
252b5132 | 51 | # TEXT_DYNAMIC - .dynamic in text segment, not data segment. |
5a68afcf | 52 | # EMBEDDED - whether this is for an embedded system. |
252b5132 RH |
53 | # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set |
54 | # start address of shared library. | |
55 | # INPUT_FILES - INPUT command of files to always include | |
a8e53fb0 | 56 | # WRITABLE_RODATA - if set, the .rodata section should be writable |
904ecb2d | 57 | # INIT_START, INIT_END - statements just before and just after |
6c19b93b | 58 | # combination of .init sections. |
904ecb2d | 59 | # FINI_START, FINI_END - statements just before and just after |
6c19b93b | 60 | # combination of .fini sections. |
465bc359 | 61 | # STACK_ADDR - start of a .stack section. |
827a1c67 | 62 | # OTHER_SYMBOLS - symbols to place right at the end of the script. |
eac338cf PB |
63 | # ETEXT_NAME - name of a symbol for the end of the text section, |
64 | # normally etext. | |
5a68afcf RM |
65 | # SEPARATE_CODE - if set, .text and similar sections containing |
66 | # actual machine instructions must be in wholly disjoint | |
67 | # pages from any other data, including headers | |
8c37241b JJ |
68 | # SEPARATE_GOTPLT - if set, .got.plt should be separate output section, |
69 | # so that .got can be in the RELRO area. It should be set to | |
70 | # the number of bytes in the beginning of .got.plt which can be | |
71 | # in the RELRO area as well. | |
a817dba3 | 72 | # USER_LABEL_PREFIX - prefix to add to user-visible symbols. |
349e935b JM |
73 | # RODATA_NAME, SDATA_NAME, SBSS_NAME, BSS_NAME - base parts of names |
74 | # for standard sections, without initial "." or suffixes. | |
252b5132 RH |
75 | # |
76 | # When adding sections, do note that the names of some sections are used | |
77 | # when specifying the start address of the next. | |
78 | # | |
79 | ||
d73e9da0 AS |
80 | # Many sections come in three flavours. There is the 'real' section, |
81 | # like ".data". Then there are the per-procedure or per-variable | |
82 | # sections, generated by -ffunction-sections and -fdata-sections in GCC, | |
83 | # and useful for --gc-sections, which for a variable "foo" might be | |
84 | # ".data.foo". Then there are the linkonce sections, for which the linker | |
85 | # eliminates duplicates, which are named like ".gnu.linkonce.d.foo". | |
86 | # The exact correspondences are: | |
87 | # | |
88 | # Section Linkonce section | |
89 | # .text .gnu.linkonce.t.foo | |
90 | # .rodata .gnu.linkonce.r.foo | |
91 | # .data .gnu.linkonce.d.foo | |
92 | # .bss .gnu.linkonce.b.foo | |
93 | # .sdata .gnu.linkonce.s.foo | |
94 | # .sbss .gnu.linkonce.sb.foo | |
95 | # .sdata2 .gnu.linkonce.s2.foo | |
96 | # .sbss2 .gnu.linkonce.sb2.foo | |
465bc359 | 97 | # .debug_info .gnu.linkonce.wi.foo |
13ae64f3 JJ |
98 | # .tdata .gnu.linkonce.td.foo |
99 | # .tbss .gnu.linkonce.tb.foo | |
3b22753a L |
100 | # .lrodata .gnu.linkonce.lr.foo |
101 | # .ldata .gnu.linkonce.l.foo | |
102 | # .lbss .gnu.linkonce.lb.foo | |
d73e9da0 AS |
103 | # |
104 | # Each of these can also have corresponding .rel.* and .rela.* sections. | |
9ac4db9c | 105 | |
b7761f11 L |
106 | if test -n "$NOP"; then |
107 | FILL="=$NOP" | |
108 | else | |
109 | FILL= | |
110 | fi | |
111 | ||
349e935b JM |
112 | test -z "$RODATA_NAME" && RODATA_NAME=rodata |
113 | test -z "$SDATA_NAME" && SDATA_NAME=sdata | |
114 | test -z "$SBSS_NAME" && SBSS_NAME=sbss | |
115 | test -z "$BSS_NAME" && BSS_NAME=bss | |
8d17e044 | 116 | test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start |
252b5132 RH |
117 | test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} |
118 | test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
119 | if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi | |
120 | test -z "${ELFSIZE}" && ELFSIZE=32 | |
121 | test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" | |
122 | test "$LD_FLAG" = "N" && DATA_ADDR=. | |
8d17e044 | 123 | test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext |
8c37241b | 124 | test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT |
104d59d1 | 125 | test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }" |
f5657270 AM |
126 | if test -z "$DATA_SEGMENT_ALIGN"; then |
127 | test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE="" | |
128 | test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE="" | |
129 | DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" | |
130 | DATA_SEGMENT_RELRO_END="" | |
131 | DATA_SEGMENT_END="" | |
132 | if test -n "${COMMONPAGESIZE}"; then | |
133 | if test "${SEGMENT_SIZE}" != "${MAXPAGESIZE}"; then | |
134 | DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" | |
135 | else | |
136 | DATA_SEGMENT_ALIGN="DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" | |
137 | fi | |
138 | DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" | |
139 | DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" | |
6c1aca3e | 140 | fi |
2d20f7bf | 141 | fi |
5a8e7be2 | 142 | if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then |
ec2d9b29 | 143 | INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" |
5a8e7be2 | 144 | fi |
0cf7d72c | 145 | if test -z "$PLT"; then |
ec2d9b29 AM |
146 | IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }" |
147 | PLT=".plt ${RELOCATING-0} : { *(.plt)${IREL_IN_PLT+ *(.iplt)} } | |
8dfab6dd | 148 | ${IREL_IN_PLT-$IPLT}" |
0cf7d72c | 149 | fi |
1bbce132 | 150 | test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT= |
8c37241b JJ |
151 | if test -z "$GOT"; then |
152 | if test -z "$SEPARATE_GOTPLT"; then | |
ec2d9b29 | 153 | GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }" |
8c37241b | 154 | else |
ec2d9b29 AM |
155 | GOT=".got ${RELOCATING-0} : { *(.got) *(.igot) }" |
156 | GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) }" | |
8c37241b JJ |
157 | fi |
158 | fi | |
ec2d9b29 AM |
159 | REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }" |
160 | RELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }" | |
161 | REL_IPLT=".rel.iplt ${RELOCATING-0} : | |
8dfab6dd AM |
162 | { |
163 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}} | |
164 | *(.rel.iplt) | |
165 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}} | |
166 | }" | |
ec2d9b29 | 167 | RELA_IPLT=".rela.iplt ${RELOCATING-0} : |
8dfab6dd AM |
168 | { |
169 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}} | |
170 | *(.rela.iplt) | |
171 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}} | |
172 | }" | |
ec2d9b29 | 173 | DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" |
349e935b | 174 | RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }" |
18bbc1c5 | 175 | 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.*) }" |
032b94c5 | 176 | DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" |
48459341 | 177 | if test -z "${NO_SMALL_DATA}"; then |
349e935b | 178 | SBSS=".${SBSS_NAME} ${RELOCATING-0} : |
48459341 | 179 | { |
046183de | 180 | ${RELOCATING+${SBSS_START_SYMBOLS}} |
349e935b JM |
181 | ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)} |
182 | *(.dyn${SBSS_NAME}) | |
183 | *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*}) | |
48459341 | 184 | *(.scommon) |
046183de | 185 | ${RELOCATING+${SBSS_END_SYMBOLS}} |
48459341 | 186 | }" |
349e935b | 187 | SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }" |
48459341 L |
188 | SDATA="/* We want the small data sections together, so single-instruction offsets |
189 | can access them all, and initialized data all before uninitialized, so | |
190 | we can shorten the on-disk segment size. */ | |
5a68afcf | 191 | .${SDATA_NAME} ${RELOCATING-0} : |
48459341 L |
192 | { |
193 | ${RELOCATING+${SDATA_START_SYMBOLS}} | |
349e935b JM |
194 | ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)} |
195 | *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*}) | |
48459341 | 196 | }" |
349e935b | 197 | SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} : |
046183de AM |
198 | { |
199 | ${RELOCATING+${SDATA2_START_SYMBOLS}} | |
349e935b | 200 | *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*}) |
046183de | 201 | }" |
349e935b JM |
202 | REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) } |
203 | .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }" | |
204 | REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) } | |
205 | .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }" | |
206 | REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) } | |
207 | .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }" | |
208 | REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) } | |
209 | .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }" | |
8c37241b JJ |
210 | else |
211 | NO_SMALL_DATA=" " | |
48459341 | 212 | fi |
23283c1b | 213 | if test -z "${SDATA_GOT}${DATA_GOT}"; then |
0cf7d72c AM |
214 | if test -n "${NO_SMALL_DATA}"; then |
215 | DATA_GOT=" " | |
216 | fi | |
217 | fi | |
23283c1b | 218 | if test -z "${SDATA_GOT}${DATA_GOT}"; then |
0cf7d72c AM |
219 | if test -z "${NO_SMALL_DATA}"; then |
220 | SDATA_GOT=" " | |
221 | fi | |
222 | fi | |
8c37241b | 223 | test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" " |
9599dfb1 | 224 | test "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" |
ec2d9b29 AM |
225 | .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) } |
226 | .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) } | |
227 | .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) } | |
228 | .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) } | |
229 | .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) } | |
230 | .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }" | |
134960cc | 231 | test "${LARGE_SECTIONS}" = "yes" && LARGE_BSS=" |
ec2d9b29 | 232 | .lbss ${RELOCATING-0} : |
9599dfb1 AM |
233 | { |
234 | *(.dynlbss) | |
235 | *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) | |
236 | *(LARGE_COMMON) | |
1bc214ba L |
237 | }" |
238 | test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" | |
ec2d9b29 | 239 | .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : |
9599dfb1 AM |
240 | { |
241 | *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*}) | |
242 | } | |
ec2d9b29 | 243 | .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : |
9599dfb1 AM |
244 | { |
245 | *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) | |
e0a3af22 | 246 | ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} |
9599dfb1 | 247 | }" |
8b6f4cd3 L |
248 | PREINIT_ARRAY=".preinit_array ${RELOCATING-0} : |
249 | { | |
250 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} | |
251 | KEEP (*(.preinit_array)) | |
252 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} | |
253 | }" | |
02ecc8e9 L |
254 | if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then |
255 | SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" | |
256 | SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" | |
7c00cf68 AM |
257 | CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" |
258 | DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" | |
02ecc8e9 L |
259 | else |
260 | SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" | |
261 | SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" | |
262 | CTORS_IN_INIT_ARRAY= | |
263 | DTORS_IN_FINI_ARRAY= | |
264 | fi | |
3cff7cc7 JZ |
265 | INIT_ARRAY=".init_array ${RELOCATING-0} : |
266 | { | |
576ee33a | 267 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} |
02ecc8e9 | 268 | ${SORT_INIT_ARRAY} |
7c00cf68 | 269 | KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY})) |
576ee33a | 270 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} |
3cff7cc7 JZ |
271 | }" |
272 | FINI_ARRAY=".fini_array ${RELOCATING-0} : | |
273 | { | |
274 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} | |
02ecc8e9 | 275 | ${SORT_FINI_ARRAY} |
7c00cf68 | 276 | KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY})) |
3cff7cc7 JZ |
277 | ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} |
278 | }" | |
5a68afcf | 279 | CTOR=".ctors ${CONSTRUCTING-0} : |
252b5132 RH |
280 | { |
281 | ${CONSTRUCTING+${CTOR_START}} | |
282 | /* gcc uses crtbegin.o to find the start of | |
283 | the constructors, so we make sure it is | |
284 | first. Because this is a wildcard, it | |
285 | doesn't matter if the user does not | |
286 | actually link against crtbegin.o; the | |
287 | linker won't look for a file to match a | |
288 | wildcard. The wildcard also means that it | |
289 | doesn't matter which directory crtbegin.o | |
290 | is in. */ | |
291 | ||
40cf2291 AM |
292 | KEEP (*crtbegin.o(.ctors)) |
293 | KEEP (*crtbegin?.o(.ctors)) | |
252b5132 RH |
294 | |
295 | /* We don't want to include the .ctor section from | |
bd6791bc | 296 | the crtend.o file until after the sorted ctors. |
252b5132 RH |
297 | The .ctor section from the crtend file contains the |
298 | end of ctors marker and it must be last */ | |
299 | ||
40cf2291 | 300 | KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) |
252b5132 RH |
301 | KEEP (*(SORT(.ctors.*))) |
302 | KEEP (*(.ctors)) | |
303 | ${CONSTRUCTING+${CTOR_END}} | |
304 | }" | |
ec2d9b29 | 305 | DTOR=".dtors ${CONSTRUCTING-0} : |
252b5132 RH |
306 | { |
307 | ${CONSTRUCTING+${DTOR_START}} | |
40cf2291 AM |
308 | KEEP (*crtbegin.o(.dtors)) |
309 | KEEP (*crtbegin?.o(.dtors)) | |
310 | KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) | |
252b5132 RH |
311 | KEEP (*(SORT(.dtors.*))) |
312 | KEEP (*(.dtors)) | |
313 | ${CONSTRUCTING+${DTOR_END}} | |
314 | }" | |
74dc9032 | 315 | STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : |
465bc359 | 316 | { |
8d17e044 | 317 | ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;} |
465bc359 | 318 | *(.stack) |
74dc9032 | 319 | ${RELOCATING+${STACK_SENTINEL}} |
465bc359 | 320 | }" |
252b5132 | 321 | |
258795f5 L |
322 | TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" |
323 | SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" | |
324 | ||
47acac12 L |
325 | # Don't bother with separate code segment when there are data sections |
326 | # between .plt and .text. | |
327 | if test -z "$TINY_READONLY_SECTION"; then | |
328 | case "$LD_FLAG" in | |
329 | *textonly*) | |
330 | SEPARATE_TEXT=yes | |
331 | TEXT_SEGMENT_ALIGN=". = ALIGN(${MAXPAGESIZE});" | |
332 | ;; | |
333 | esac | |
334 | fi | |
335 | ||
5a68afcf RM |
336 | if [ -z "$SEPARATE_CODE" ]; then |
337 | SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS" | |
338 | else | |
339 | SIZEOF_HEADERS_CODE= | |
340 | fi | |
341 | ||
985743c7 | 342 | # If this is for an embedded system, don't add SIZEOF_HEADERS. |
252b5132 | 343 | if [ -z "$EMBEDDED" ]; then |
5a68afcf | 344 | test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}" |
252b5132 RH |
345 | else |
346 | test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" | |
347 | fi | |
348 | ||
349 | cat <<EOF | |
219d1afa | 350 | /* Copyright (C) 2014-2018 Free Software Foundation, Inc. |
985743c7 NC |
351 | |
352 | Copying and distribution of this script, with or without modification, | |
353 | are permitted in any medium without royalty provided the copyright | |
354 | notice and this notice are preserved. */ | |
355 | ||
252b5132 RH |
356 | OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", |
357 | "${LITTLE_OUTPUT_FORMAT}") | |
358 | OUTPUT_ARCH(${OUTPUT_ARCH}) | |
ac69cbc6 | 359 | ${RELOCATING+ENTRY(${ENTRY})} |
252b5132 RH |
360 | |
361 | ${RELOCATING+${LIB_SEARCH_DIRS}} | |
252b5132 RH |
362 | ${RELOCATING+${EXECUTABLE_SYMBOLS}} |
363 | ${RELOCATING+${INPUT_FILES}} | |
ec2d9b29 AM |
364 | ${RELOCATING- /* For some reason, the Solaris linker makes bad executables |
365 | if gld -r is used and the intermediate file has sections starting | |
366 | at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld | |
367 | bug. But for now assigning the zero vmas works. */} | |
252b5132 RH |
368 | |
369 | SECTIONS | |
370 | { | |
371 | /* Read-only sections, merged into text segment: */ | |
c6d3b05f | 372 | ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} |
5a68afcf | 373 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} |
11cba4ac | 374 | ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} |
5a68afcf RM |
375 | EOF |
376 | ||
377 | emit_early_ro() | |
378 | { | |
379 | cat <<EOF | |
252b5132 | 380 | ${INITIAL_READONLY_SECTIONS} |
cd714b79 | 381 | .note.gnu.build-id : { *(.note.gnu.build-id) } |
485cf679 | 382 | EOF |
5a68afcf RM |
383 | } |
384 | ||
385 | test -n "${SEPARATE_CODE}" || emit_early_ro | |
485cf679 AM |
386 | |
387 | test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN | |
388 | test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC= | |
389 | cat > ldscripts/dyntmp.$$ <<EOF | |
252b5132 | 390 | ${TEXT_DYNAMIC+${DYNAMIC}} |
ec2d9b29 AM |
391 | .hash ${RELOCATING-0} : { *(.hash) } |
392 | .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) } | |
393 | .dynsym ${RELOCATING-0} : { *(.dynsym) } | |
394 | .dynstr ${RELOCATING-0} : { *(.dynstr) } | |
395 | .gnu.version ${RELOCATING-0} : { *(.gnu.version) } | |
396 | .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) } | |
397 | .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) } | |
db6751f2 | 398 | EOF |
485cf679 | 399 | |
db6751f2 | 400 | if [ "x$COMBRELOC" = x ]; then |
485cf679 | 401 | COMBRELOCCAT="cat >> ldscripts/dyntmp.$$" |
db6751f2 JJ |
402 | else |
403 | COMBRELOCCAT="cat > $COMBRELOC" | |
404 | fi | |
405 | eval $COMBRELOCCAT <<EOF | |
829da898 | 406 | ${INITIAL_RELOC_SECTIONS} |
ec2d9b29 AM |
407 | .rel.init ${RELOCATING-0} : { *(.rel.init) } |
408 | .rela.init ${RELOCATING-0} : { *(.rela.init) } | |
409 | .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } | |
410 | .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } | |
411 | .rel.fini ${RELOCATING-0} : { *(.rel.fini) } | |
412 | .rela.fini ${RELOCATING-0} : { *(.rela.fini) } | |
349e935b JM |
413 | .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) } |
414 | .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) } | |
9e4141bc | 415 | ${OTHER_READONLY_RELOC_SECTIONS} |
18bbc1c5 CC |
416 | .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) } |
417 | .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) } | |
ec2d9b29 AM |
418 | .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } |
419 | .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } | |
349e935b | 420 | ${OTHER_READWRITE_RELOC_SECTIONS} |
ec2d9b29 AM |
421 | .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } |
422 | .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } | |
423 | .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } | |
424 | .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } | |
425 | .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } | |
426 | .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } | |
427 | .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } | |
428 | .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } | |
429 | .rel.got ${RELOCATING-0} : { *(.rel.got) } | |
430 | .rela.got ${RELOCATING-0} : { *(.rela.got) } | |
9e4141bc | 431 | ${OTHER_GOT_RELOC_SECTIONS} |
48459341 L |
432 | ${REL_SDATA} |
433 | ${REL_SBSS} | |
434 | ${REL_SDATA2} | |
435 | ${REL_SBSS2} | |
349e935b JM |
436 | .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) } |
437 | .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) } | |
827a1c67 | 438 | ${REL_LARGE} |
8dfab6dd AM |
439 | ${IREL_IN_PLT+$REL_IFUNC} |
440 | ${IREL_IN_PLT+$RELA_IFUNC} | |
441 | ${IREL_IN_PLT-$REL_IPLT} | |
442 | ${IREL_IN_PLT-$RELA_IPLT} | |
db6751f2 | 443 | EOF |
485cf679 | 444 | |
db6751f2 | 445 | if [ -n "$COMBRELOC" ]; then |
485cf679 | 446 | cat >> ldscripts/dyntmp.$$ <<EOF |
ec2d9b29 | 447 | .rel.dyn ${RELOCATING-0} : |
db6751f2 JJ |
448 | { |
449 | EOF | |
6c19b93b | 450 | sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ |
485cf679 | 451 | cat >> ldscripts/dyntmp.$$ <<EOF |
db6751f2 | 452 | } |
ec2d9b29 | 453 | .rela.dyn ${RELOCATING-0} : |
db6751f2 JJ |
454 | { |
455 | EOF | |
6c19b93b | 456 | sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$ |
485cf679 | 457 | cat >> ldscripts/dyntmp.$$ <<EOF |
db6751f2 JJ |
458 | } |
459 | EOF | |
460 | fi | |
485cf679 AM |
461 | |
462 | cat >> ldscripts/dyntmp.$$ <<EOF | |
ec2d9b29 | 463 | .rel.plt ${RELOCATING-0} : |
3aa14d16 L |
464 | { |
465 | *(.rel.plt) | |
8dfab6dd AM |
466 | ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}} |
467 | ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}} | |
468 | ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}} | |
3aa14d16 | 469 | } |
ec2d9b29 | 470 | .rela.plt ${RELOCATING-0} : |
3aa14d16 L |
471 | { |
472 | *(.rela.plt) | |
8dfab6dd AM |
473 | ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}} |
474 | ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}} | |
475 | ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}} | |
3aa14d16 | 476 | } |
9e673ad1 | 477 | ${OTHER_PLT_RELOC_SECTIONS} |
485cf679 | 478 | EOF |
9e4141bc | 479 | |
5a68afcf RM |
480 | emit_dyn() |
481 | { | |
485cf679 AM |
482 | if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then |
483 | cat ldscripts/dyntmp.$$ | |
484 | else | |
485 | if test -z "${NO_REL_RELOCS}"; then | |
6c19b93b | 486 | sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$ |
485cf679 AM |
487 | fi |
488 | if test -z "${NO_RELA_RELOCS}"; then | |
6c19b93b | 489 | sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$ |
485cf679 AM |
490 | fi |
491 | fi | |
492 | rm -f ldscripts/dyntmp.$$ | |
5a68afcf RM |
493 | } |
494 | ||
495 | test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn | |
485cf679 AM |
496 | |
497 | cat <<EOF | |
47acac12 L |
498 | ${RELOCATING+${TEXT_SEGMENT_ALIGN}} |
499 | ||
d9d11c36 | 500 | .init ${RELOCATING-0}${RELOCATING+${INIT_ADDR}} : |
5a68afcf | 501 | { |
53db15ed | 502 | ${RELOCATING+${INIT_START}} |
b2e4da5a | 503 | KEEP (*(SORT_NONE(.init))) |
53db15ed | 504 | ${RELOCATING+${INIT_END}} |
b7761f11 | 505 | } ${FILL} |
4ab10e93 | 506 | |
ce3ad333 | 507 | ${TEXT_PLT+${PLT_NEXT_DATA-${PLT} ${OTHER_PLT_SECTIONS}}} |
ecc49060 | 508 | ${TINY_READONLY_SECTION} |
ec2d9b29 | 509 | .text ${RELOCATING-0} : |
252b5132 RH |
510 | { |
511 | ${RELOCATING+${TEXT_START_SYMBOLS}} | |
1de778ed | 512 | ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)} |
add44f8d AM |
513 | ${RELOCATING+*(.text.exit .text.exit.*)} |
514 | ${RELOCATING+*(.text.startup .text.startup.*)} | |
515 | ${RELOCATING+*(.text.hot .text.hot.*)} | |
465bc359 | 516 | *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) |
252b5132 RH |
517 | /* .gnu.warning sections are handled specially by elf32.em. */ |
518 | *(.gnu.warning) | |
252b5132 | 519 | ${RELOCATING+${OTHER_TEXT_SECTIONS}} |
b7761f11 | 520 | } ${FILL} |
d9d11c36 | 521 | .fini ${RELOCATING-0}${RELOCATING+${FINI_ADDR}} : |
904ecb2d | 522 | { |
53db15ed | 523 | ${RELOCATING+${FINI_START}} |
b2e4da5a | 524 | KEEP (*(SORT_NONE(.fini))) |
53db15ed | 525 | ${RELOCATING+${FINI_END}} |
b7761f11 | 526 | } ${FILL} |
eac338cf PB |
527 | ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} |
528 | ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} | |
529 | ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);} | |
47acac12 | 530 | ${RELOCATING+${TEXT_SEGMENT_ALIGN}} |
5a68afcf RM |
531 | EOF |
532 | ||
47acac12 | 533 | if test -n "${SEPARATE_CODE}${SEPARATE_TEXT}"; then |
9d5777a3 RM |
534 | if test -n "${RODATA_ADDR}"; then |
535 | RODATA_ADDR="\ | |
536 | SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS" | |
537 | else | |
34d56033 | 538 | RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" |
9d5777a3 RM |
539 | RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})" |
540 | fi | |
541 | if test -n "${SHLIB_RODATA_ADDR}"; then | |
542 | SHLIB_RODATA_ADDR="\ | |
543 | SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS" | |
544 | else | |
9d5777a3 | 545 | SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" |
6bd0a312 | 546 | SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})" |
9d5777a3 | 547 | fi |
5a68afcf RM |
548 | cat <<EOF |
549 | /* Adjust the address for the rodata segment. We want to adjust up to | |
550 | the same address within the page on the next page up. */ | |
9d5777a3 RM |
551 | ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR};}}} |
552 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}} | |
553 | ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}} | |
5a68afcf | 554 | EOF |
47acac12 L |
555 | if test -n "${SEPARATE_CODE}"; then |
556 | emit_early_ro | |
557 | emit_dyn | |
558 | fi | |
5a68afcf RM |
559 | fi |
560 | ||
561 | cat <<EOF | |
a8e53fb0 | 562 | ${WRITABLE_RODATA-${RODATA}} |
349e935b | 563 | .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) } |
6c86c541 GK |
564 | ${CREATE_SHLIB-${SDATA2}} |
565 | ${CREATE_SHLIB-${SBSS2}} | |
465bc359 | 566 | ${OTHER_READONLY_SECTIONS} |
2f0c68f2 CM |
567 | .eh_frame_hdr : { *(.eh_frame_hdr) ${RELOCATING+*(.eh_frame_entry .eh_frame_entry.*)} } |
568 | .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} } | |
ed0d9c71 NC |
569 | .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table |
570 | .gcc_except_table.*) } | |
2f0c68f2 | 571 | .gnu_extab ${RELOCATING-0} : ONLY_IF_RO { *(.gnu_extab*) } |
ed0d9c71 NC |
572 | /* These sections are generated by the Sun/Oracle C++ compiler. */ |
573 | .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges | |
574 | .exception_ranges*) } | |
ce3ad333 | 575 | ${TEXT_PLT+${PLT_NEXT_DATA+${PLT} ${OTHER_PLT_SECTIONS}}} |
252b5132 RH |
576 | |
577 | /* Adjust the address for the data segment. We want to adjust up to | |
578 | the same address within the page on the next page up. */ | |
9203ba99 | 579 | ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} |
2d20f7bf | 580 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} |
9203ba99 | 581 | ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} |
252b5132 | 582 | |
8c37241b | 583 | /* Exception handling */ |
2f0c68f2 CM |
584 | .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} } |
585 | .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) } | |
ec2d9b29 | 586 | .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } |
ed0d9c71 | 587 | .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } |
8c37241b JJ |
588 | |
589 | /* Thread Local Storage sections */ | |
ec2d9b29 AM |
590 | .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } |
591 | .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } | |
8c37241b | 592 | |
8b6f4cd3 | 593 | ${RELOCATING+${PREINIT_ARRAY}} |
3cff7cc7 JZ |
594 | ${RELOCATING+${INIT_ARRAY}} |
595 | ${RELOCATING+${FINI_ARRAY}} | |
951e9133 L |
596 | ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} |
597 | ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} | |
ec2d9b29 | 598 | .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } |
8c37241b JJ |
599 | |
600 | ${RELOCATING+${DATARELRO}} | |
601 | ${OTHER_RELRO_SECTIONS} | |
602 | ${TEXT_DYNAMIC-${DYNAMIC}} | |
3e2b0f31 | 603 | ${OTHER_RELRO_SECTIONS_2} |
23283c1b | 604 | ${DATA_GOT+${RELRO_NOW+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}} |
0cf7d72c AM |
605 | ${DATA_GOT+${RELRO_NOW+${GOT}}} |
606 | ${DATA_GOT+${RELRO_NOW+${GOTPLT}}} | |
607 | ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}} | |
8c37241b | 608 | ${RELOCATING+${DATA_SEGMENT_RELRO_END}} |
1bbce132 | 609 | ${INITIAL_READWRITE_SECTIONS} |
23283c1b AM |
610 | ${DATA_SDATA+${SDATA}} |
611 | ${DATA_SDATA+${OTHER_SDATA_SECTIONS}} | |
5ad18f16 | 612 | ${DATA_SDATA+${SBSS}} |
23283c1b | 613 | ${DATA_GOT+${RELRO_NOW-${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}} |
0cf7d72c AM |
614 | ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}} |
615 | ${DATA_GOT+${RELRO_NOW-${GOTPLT}}} | |
8c37241b | 616 | |
b71a5181 | 617 | ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}} |
8c37241b | 618 | |
ec2d9b29 | 619 | .data ${RELOCATING-0} : |
252b5132 RH |
620 | { |
621 | ${RELOCATING+${DATA_START_SYMBOLS}} | |
465bc359 | 622 | *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) |
252b5132 RH |
623 | ${CONSTRUCTING+SORT(CONSTRUCTORS)} |
624 | } | |
ec2d9b29 | 625 | .data1 ${RELOCATING-0} : { *(.data1) } |
a8e53fb0 | 626 | ${WRITABLE_RODATA+${RODATA}} |
465bc359 | 627 | ${OTHER_READWRITE_SECTIONS} |
951e9133 L |
628 | ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}} |
629 | ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}} | |
23283c1b | 630 | ${SDATA_GOT+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}} |
d2667025 | 631 | ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}} |
0cf7d72c AM |
632 | ${SDATA_GOT+${GOT}} |
633 | ${SDATA_GOT+${OTHER_GOT_SECTIONS}} | |
23283c1b AM |
634 | ${DATA_SDATA-${SDATA}} |
635 | ${DATA_SDATA-${OTHER_SDATA_SECTIONS}} | |
a817dba3 | 636 | ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}} |
d2667025 | 637 | ${RELOCATING+. = .;} |
8d17e044 | 638 | ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;} |
252b5132 | 639 | ${RELOCATING+${OTHER_BSS_SYMBOLS}} |
5ad18f16 | 640 | ${DATA_SDATA-${SBSS}} |
6c86c541 | 641 | ${BSS_PLT+${PLT}} |
349e935b | 642 | .${BSS_NAME} ${RELOCATING-0} : |
252b5132 | 643 | { |
09a1b0e9 | 644 | ${RELOCATING+*(.dynbss)} |
349e935b | 645 | *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*}) |
252b5132 RH |
646 | *(COMMON) |
647 | /* Align here to ensure that the .bss section occupies space up to | |
648 | _end. Align after .bss to ensure correct alignment even if the | |
3b22753a L |
649 | .bss section disappears because there are no input sections. |
650 | FIXME: Why do we need it? When there is no .bss section, we don't | |
651 | pad the .data section. */ | |
e0a3af22 | 652 | ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} |
252b5132 | 653 | } |
e9f53129 | 654 | ${OTHER_BSS_SECTIONS} |
134960cc | 655 | ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}} |
827a1c67 AM |
656 | ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} |
657 | ${RELOCATING+. = ALIGN(${ALIGNMENT});} | |
0d705e9f AM |
658 | EOF |
659 | ||
660 | LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});" | |
661 | SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});" | |
662 | ||
74dc9032 | 663 | cat <<EOF |
0d705e9f AM |
664 | ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}} |
665 | ${RELOCATING+${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}} | |
666 | ${RELOCATING+${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}} | |
3b22753a | 667 | ${LARGE_SECTIONS} |
134960cc | 668 | ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}} |
252b5132 | 669 | ${RELOCATING+. = ALIGN(${ALIGNMENT});} |
9f4fb502 | 670 | ${RELOCATING+${OTHER_END_SYMBOLS}} |
a817dba3 | 671 | ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}} |
2d13d8c5 | 672 | ${RELOCATING+${DATA_SEGMENT_END}} |
74dc9032 AM |
673 | ${TINY_DATA_SECTION} |
674 | ${TINY_BSS_SECTION} | |
675 | ${STACK_ADDR+${STACK}} | |
485cf679 | 676 | EOF |
252b5132 | 677 | |
5a68afcf | 678 | test -z "${NON_ALLOC_DYN}" || emit_dyn |
485cf679 AM |
679 | |
680 | cat <<EOF | |
252b5132 | 681 | /* Stabs debugging sections. */ |
465bc359 AM |
682 | .stab 0 : { *(.stab) } |
683 | .stabstr 0 : { *(.stabstr) } | |
684 | .stab.excl 0 : { *(.stab.excl) } | |
685 | .stab.exclstr 0 : { *(.stab.exclstr) } | |
686 | .stab.index 0 : { *(.stab.index) } | |
252b5132 RH |
687 | .stab.indexstr 0 : { *(.stab.indexstr) } |
688 | ||
465bc359 | 689 | .comment 0 : { *(.comment) } |
252b5132 | 690 | |
ceb0a680 NC |
691 | EOF |
692 | ||
d061dfac | 693 | . $srcdir/scripttempl/DWARF.sc |
ceb0a680 NC |
694 | |
695 | cat <<EOF | |
104d59d1 | 696 | ${ATTRS_SECTIONS} |
252b5132 | 697 | ${OTHER_SECTIONS} |
827a1c67 | 698 | ${RELOCATING+${OTHER_SYMBOLS}} |
1c68693b | 699 | ${RELOCATING+${DISCARDED}} |
252b5132 RH |
700 | } |
701 | EOF |