1 # Copyright (C) 2014-2025 Free Software Foundation, Inc.
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.
7 # Unusual variables checked by this code:
8 # NOP - four byte opcode for no-op (defaults to none)
9 # NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
11 # HAVE_NOINIT - Include a .noinit output section in the script.
12 # HAVE_PERSISTENT - Include a .persistent output section in the script.
13 # HAVE_DT_RELR - Include a .relr.dyn output section in the script.
14 # SMALL_DATA_CTOR - .ctors contains small data.
15 # SMALL_DATA_DTOR - .dtors contains small data.
16 # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
17 # INITIAL_READONLY_SECTIONS - at start of text segment
18 # OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
19 # (e.g., .PARISC.milli)
20 # OTHER_TEXT_SECTIONS - these get put in .text when relocating
21 # INITIAL_READWRITE_SECTIONS - at start of data segment (after relro)
22 # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
23 # (e.g., .PARISC.global)
24 # OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
25 # (e.g. PPC32 .fixup, .got[12])
26 # OTHER_RELRO_SECTIONS_2 - as above, but after .dynamic in text segment
27 # OTHER_BSS_SECTIONS - other than .bss .sbss ...
28 # ATTRS_SECTIONS - at the end
29 # OTHER_SECTIONS - at the end
30 # EXECUTABLE_SYMBOLS - symbols that must be defined for an
31 # executable (e.g., _DYNAMIC_LINK)
32 # TEXT_START_ADDR - the first byte of the text segment, after any
34 # TEXT_BASE_ADDRESS - the first byte of the text segment.
35 # TEXT_START_SYMBOLS - symbols that appear at the start of the
37 # DATA_START_SYMBOLS - symbols that appear at the start of the
39 # DATA_END_SYMBOLS - symbols that appear at the end of the
40 # writeable data sections.
41 # OTHER_GOT_SYMBOLS - symbols defined just before .got.
42 # OTHER_GOT_SECTIONS - sections just after .got.
43 # OTHER_PLT_SECTIONS - sections just after .plt.
44 # OTHER_SDATA_SECTIONS - sections just after .sdata.
45 # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
46 # .bss section besides __bss_start.
47 # PLT_NEXT_DATA - .plt next to data segment when .plt is in text segment.
48 # DATA_PLT - .plt should be in data segment, not text segment.
49 # PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
50 # BSS_PLT - .plt should be in bss segment
51 # NO_REL_RELOCS - Don't include .rel.* sections in script
52 # NO_RELA_RELOCS - Don't include .rela.* sections in script
53 # NON_ALLOC_DYN - Place dynamic sections after data segment.
54 # TEXT_DYNAMIC - .dynamic in text segment, not data segment.
55 # EMBEDDED - whether this is for an embedded system.
56 # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
57 # start address of shared library.
58 # INPUT_FILES - INPUT command of files to always include
59 # WRITABLE_RODATA - if set, the .rodata section should be writable
60 # INIT_START, INIT_END - statements just before and just after
61 # combination of .init sections.
62 # FINI_START, FINI_END - statements just before and just after
63 # combination of .fini sections.
64 # STACK_ADDR - start of a .stack section.
65 # OTHER_SYMBOLS - symbols to place right at the end of the script.
66 # ETEXT_NAME - name of a symbol for the end of the text section,
68 # ETEXT_LAST_IN_RODATA_SEGMENT - emit ETEXT_NAME after all sections in
69 # the read-only data segment (which may or may not be equal to
70 # the code segment), instead of after just the code parts.
71 # SEPARATE_CODE - if set, .text and similar sections containing
72 # actual machine instructions must be in wholly disjoint
73 # pages from any other data, including headers
74 # SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
75 # so that .got can be in the RELRO area. It should be set to
76 # the number of bytes in the beginning of .got.plt which can be
77 # in the RELRO area as well.
78 # USER_LABEL_PREFIX - prefix to add to user-visible symbols.
79 # RODATA_NAME, SDATA_NAME, SBSS_NAME, BSS_NAME - base parts of names
80 # for standard sections, without initial "." or suffixes.
81 # SYMBOL_ABI_ALIGNMENT - minimum alignment in bytes which needs to be
82 # applied to every symbol definition
83 # ALL_TEXT_BEFORE_RO - put all code sections before read-only
86 # When adding sections, do note that the names of some sections are used
87 # when specifying the start address of the next.
90 # Many sections come in three flavours. There is the 'real' section,
91 # like ".data". Then there are the per-procedure or per-variable
92 # sections, generated by -ffunction-sections and -fdata-sections in GCC,
93 # and useful for --gc-sections, which for a variable "foo" might be
94 # ".data.foo". Then there are the linkonce sections, for which the linker
95 # eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
96 # The exact correspondences are:
98 # Section Linkonce section
99 # .text .gnu.linkonce.t.foo
100 # .rodata .gnu.linkonce.r.foo
101 # .data .gnu.linkonce.d.foo
102 # .bss .gnu.linkonce.b.foo
103 # .sdata .gnu.linkonce.s.foo
104 # .sbss .gnu.linkonce.sb.foo
105 # .sdata2 .gnu.linkonce.s2.foo
106 # .sbss2 .gnu.linkonce.sb2.foo
107 # .debug_info .gnu.linkonce.wi.foo
108 # .tdata .gnu.linkonce.td.foo
109 # .tbss .gnu.linkonce.tb.foo
110 # .lrodata .gnu.linkonce.lr.foo
111 # .ldata .gnu.linkonce.l.foo
112 # .lbss .gnu.linkonce.lb.foo
113 # .noinit .gnu.linkonce.n.foo
114 # .persistent .gnu.linkonce.p.foo
116 # Each of these can also have corresponding .rel.* and .rela.* sections.
118 # ------------------------------------------------------------------------
119 # The multiple forms of conditional shell script syntax that are used in
120 # this file can be confusing, so here is a quick explanation of how they
123 # The following all mean "if foo is defined then do/insert <stuff>":
125 # test -z "$foo" || <stuff>
126 # test -n "$foo" && <stuff>
127 # if test -n "$foo"; then <stuff>
128 # if [ -n "$foo" ]; then <stuff>
131 # Whereas the following all mean "if foo is undefined then do/insert <stuff>":
133 # test -n "$foo" || <stuff>
134 # test -z "$foo" && <stuff>
135 # if test -z "$foo"; then <stuff>
136 # if [ -z "$foo" ]; then <stuff>
139 # If multiple symbols are tested together then they operate as an IOR for
140 # positive tests and a NOR for negative tests. ie, the following all do
141 # <stuff> if either or both of <foo> and <bar> are defined:
143 # test -z "$foo$bar" || <stuff>
144 # test -n "$foo$bar" && <stuff>
145 # if test -n "$foo$bar"; then <stuff>
147 # Whilst the following only do <stuff> if neither <foo> nor <bar> are defined:
149 # test -n "$foo$bar" || <stuff>
150 # if -z "$foo$bar"; then <stuff>
151 # test -z "$foo$bar" && <stuff>
154 # foo=${foo-${bar-${baz}}}
156 # If foo is defined, leave it unchanged. Otherwise if bar is defined
157 # then set foo equal to bar, otherwise set foo equal to baz.
158 # ------------------------------------------------------------------------
160 if test -n "$NOP"; then
166 test -n "$CREATE_SHLIB$CREATE_PIE" && CREATE_PIC=" "
167 test -z "$RODATA_NAME" && RODATA_NAME=rodata
168 test -z "$SDATA_NAME" && SDATA_NAME=sdata
169 test -z "$SBSS_NAME" && SBSS_NAME=sbss
170 test -z "$BSS_NAME" && BSS_NAME=bss
171 test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start
172 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
173 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
174 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
175 test -z "${ELFSIZE}" && ELFSIZE=32
176 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
177 test "$LD_FLAG" = "N" && DATA_ADDR=.
178 test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext
179 test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
180 test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
182 if test -z "$DATA_SEGMENT_ALIGN"; then
183 test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
184 test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
185 DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
186 DATA_SEGMENT_RELRO_END=""
188 if test -n "${COMMONPAGESIZE}"; then
189 if test "${SEGMENT_SIZE}" != "${MAXPAGESIZE}"; then
190 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); \
191 . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
193 DATA_SEGMENT_ALIGN="DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
195 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
196 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
200 if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
201 INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
204 if test -z "$PLT"; then
205 IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
206 PLT=".plt ${RELOCATING-0} : { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} }
207 ${IREL_IN_PLT-$IPLT}"
210 test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=
212 if test -z "$GOT"; then
213 if test -z "$SEPARATE_GOTPLT"; then
214 GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt) *(.igot.plt)} *(.got)${RELOCATING+ *(.igot)} }"
216 GOT=".got ${RELOCATING-0} : { *(.got)${RELOCATING+ *(.igot)} }"
217 GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }"
223 if [ -z "${SYMBOL_ABI_ALIGNMENT}" ]; then
224 echo "${USER_LABEL_PREFIX}$1 = ."
226 echo "${USER_LABEL_PREFIX}$1 = ALIGN(${SYMBOL_ABI_ALIGNMENT})"
230 REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }"
231 RELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }"
232 REL_IPLT=".rel.iplt ${RELOCATING-0} :
234 ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN ($(def_symbol "__rel_iplt_start"));}}
236 ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN ($(def_symbol "__rel_iplt_end"));}}
238 RELA_IPLT=".rela.iplt ${RELOCATING-0} :
240 ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN ($(def_symbol "__rela_iplt_start"));}}
242 ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN ($(def_symbol "__rela_iplt_end"));}}
244 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
245 RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
246 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.*) }"
247 DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
248 if test -z "${NO_SMALL_DATA}"; then
249 SBSS=".${SBSS_NAME} ${RELOCATING-0} :
251 ${RELOCATING+${SBSS_START_SYMBOLS}}
252 ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)}
253 ${RELOCATING+*(.dyn${SBSS_NAME})}
254 *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*})
255 ${RELOCATING+*(.scommon)}
256 ${RELOCATING+${SBSS_END_SYMBOLS}}
258 SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }"
259 SDATA="/* We want the small data sections together, so single-instruction offsets
260 can access them all, and initialized data all before uninitialized, so
261 we can shorten the on-disk segment size. */
262 .${SDATA_NAME} ${RELOCATING-0} :
264 ${RELOCATING+${SDATA_START_SYMBOLS}}
265 ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)}
266 *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*})
268 SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} :
270 ${RELOCATING+${SDATA2_START_SYMBOLS}}
271 *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*})
273 REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) }
274 .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }"
275 REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) }
276 .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }"
277 REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) }
278 .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }"
279 REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) }
280 .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }"
285 if test -z "${SDATA_GOT}${DATA_GOT}"; then
286 if test -n "${NO_SMALL_DATA}"; then
291 if test -z "${SDATA_GOT}${DATA_GOT}"; then
292 if test -z "${NO_SMALL_DATA}"; then
297 test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
299 test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
300 .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
301 .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
302 .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
303 .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
304 .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
305 .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
307 if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
308 SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
309 SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
310 CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors"
311 DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors"
313 SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
314 SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
318 CTOR=".ctors ${CONSTRUCTING-0} :
320 ${CONSTRUCTING+${CTOR_START}}
321 /* gcc uses crtbegin.o to find the start of
322 the constructors, so we make sure it is
323 first. Because this is a wildcard, it
324 doesn't matter if the user does not
325 actually link against crtbegin.o; the
326 linker won't look for a file to match a
327 wildcard. The wildcard also means that it
328 doesn't matter which directory crtbegin.o
331 KEEP (*crtbegin.o(.ctors))
332 KEEP (*crtbegin?.o(.ctors))
334 /* We don't want to include the .ctor section from
335 the crtend.o file until after the sorted ctors.
336 The .ctor section from the crtend file contains the
337 end of ctors marker and it must be last */
339 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
340 KEEP (*(SORT(.ctors.*)))
342 ${CONSTRUCTING+${CTOR_END}}
344 DTOR=".dtors ${CONSTRUCTING-0} :
346 ${CONSTRUCTING+${DTOR_START}}
347 KEEP (*crtbegin.o(.dtors))
348 KEEP (*crtbegin?.o(.dtors))
349 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
350 KEEP (*(SORT(.dtors.*)))
352 ${CONSTRUCTING+${DTOR_END}}
355 TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
356 SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
358 # Don't bother with separate code segment when there are data sections
359 # between .plt and .text.
360 if test -z "$TINY_READONLY_SECTION"; then
363 ALL_TEXT_BEFORE_RO=" "
365 TEXT_SEGMENT_ALIGN=". = ALIGN(${MAXPAGESIZE});"
369 TEXT_SEGMENT_ALIGN=". = ALIGN(${MAXPAGESIZE});"
374 if [ -z "$SEPARATE_CODE" ]; then
375 SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS"
380 # If this is for an embedded system, don't add SIZEOF_HEADERS.
381 if [ -z "$EMBEDDED" ]; then
382 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}"
384 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
387 # ===========================================================================
388 # Functions for generating parts of the linker script
390 # Helper function for putting comments into scripts.
391 # Useful when trying to track down script composition problems.
393 # emit_comment "a message"
394 # wherever necessary.
403 align_to_default_symbol_alignment()
406 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
410 align_to_default_section_alignment()
413 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
420 /* Copyright (C) 2014-2025 Free Software Foundation, Inc.
422 Copying and distribution of this script, with or without modification,
423 are permitted in any medium without royalty provided the copyright
424 notice and this notice are preserved. */
426 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}")
427 OUTPUT_ARCH(${OUTPUT_ARCH})
428 ${RELOCATING+ENTRY(${ENTRY})}
430 ${RELOCATING+${LIB_SEARCH_DIRS}}
431 ${RELOCATING+${CREATE_SHLIB-${EXECUTABLE_SYMBOLS}}}
432 ${RELOCATING+${INPUT_FILES}}
433 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
434 if gld -r is used and the intermediate file has sections starting
435 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
436 bug. But for now assigning the zero vmas works. */}
443 ${INITIAL_READONLY_SECTIONS}
449 if test "${HAVE_NOINIT}" != "yes"; then
453 /* This section contains data that is not initialized during load,
454 or during the application's initialization sequence. */
455 .noinit ${RELOCATING-0} (NOLOAD) : ${RELOCATING+ALIGN(${ALIGNMENT})}
457 ${RELOCATING+PROVIDE (__noinit_start = .);}
458 *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*})
459 $(align_to_default_symbol_alignment)
460 ${RELOCATING+PROVIDE (__noinit_end = .);}
467 if test "${HAVE_PERSISTENT}" != "yes"; then
471 /* This section contains data that is initialized during load,
472 but not during the application's initialization sequence. */
473 .persistent ${RELOCATING-0} : ${RELOCATING+ALIGN(${ALIGNMENT})}
475 ${RELOCATING+PROVIDE (__persistent_start = .);}
476 *(.persistent${RELOCATING+ .persistent.* .gnu.linkonce.p.*})
477 $(align_to_default_symbol_alignment)
478 ${RELOCATING+PROVIDE (__persistent_end = .);}
483 emit_executable_start()
486 ${RELOCATING+${SEPARATE_TEXT-/* Read-only sections, merged into text segment: */}}
488 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR});
489 . = ${TEXT_BASE_ADDRESS};}}}
491 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
493 ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR});
494 . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
496 /* Place the build-id as close to the ELF headers as possible. This
497 maximises the chance the build-id will be present in core files,
498 which GDB can then use to locate the associated debuginfo file. */
499 .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
505 test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
506 test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
508 cat > ldscripts/dyntmp.$$ <<EOF
509 ${TEXT_DYNAMIC+${DYNAMIC}}
510 .hash ${RELOCATING-0} : { *(.hash) }
511 .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) }
512 .dynsym ${RELOCATING-0} : { *(.dynsym) }
513 .dynstr ${RELOCATING-0} : { *(.dynstr) }
514 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
515 .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
516 .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
519 if [ "x$COMBRELOC" = x ]; then
520 COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
522 COMBRELOCCAT="cat > $COMBRELOC"
525 eval $COMBRELOCCAT <<EOF
526 ${INITIAL_RELOC_SECTIONS}
527 .rel.init ${RELOCATING-0} : { *(.rel.init) }
528 .rela.init ${RELOCATING-0} : { *(.rela.init) }
529 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
530 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
531 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
532 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
533 .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) }
534 .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) }
535 ${OTHER_READONLY_RELOC_SECTIONS}
536 .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) }
537 .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) }
538 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
539 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
540 ${OTHER_READWRITE_RELOC_SECTIONS}
541 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
542 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
543 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
544 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
545 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
546 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
547 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
548 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
549 .rel.got ${RELOCATING-0} : { *(.rel.got) }
550 .rela.got ${RELOCATING-0} : { *(.rela.got) }
551 ${OTHER_GOT_RELOC_SECTIONS}
556 .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) }
557 .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) }
559 ${IREL_IN_PLT+$REL_IFUNC}
560 ${IREL_IN_PLT+$RELA_IFUNC}
561 ${IREL_IN_PLT-$REL_IPLT}
562 ${IREL_IN_PLT-$RELA_IPLT}
565 if [ -n "$COMBRELOC" ]; then
566 cat >> ldscripts/dyntmp.$$ <<EOF
567 .rel.dyn ${RELOCATING-0} :
571 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
573 cat >> ldscripts/dyntmp.$$ <<EOF
575 .rela.dyn ${RELOCATING-0} :
579 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
581 cat >> ldscripts/dyntmp.$$ <<EOF
587 cat >> ldscripts/dyntmp.$$ <<EOF
588 .rel.plt ${RELOCATING-0} :
591 ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN ($(def_symbol "__rel_iplt_start"));}}}
592 ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}}
593 ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN ($(def_symbol "__rel_iplt_end"));}}}
595 .rela.plt ${RELOCATING-0} :
598 ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN ($(def_symbol "__rela_iplt_start"));}}}
599 ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}}
600 ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN ($(def_symbol "__rela_iplt_end"));}}}
602 ${OTHER_PLT_RELOC_SECTIONS}
605 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
606 cat ldscripts/dyntmp.$$
608 if test -z "${NO_REL_RELOCS}"; then
609 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$
611 if test -z "${NO_RELA_RELOCS}"; then
612 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$
616 rm -f ldscripts/dyntmp.$$
618 if test -n "${HAVE_DT_RELR}"; then
619 echo " .relr.dyn : { *(.relr.dyn) }"
625 if test -n "$TEXT_SEGMENT_ALIGN"; then
627 ${RELOCATING+/* Align the text segment. */}
628 ${RELOCATING+${TEXT_SEGMENT_ALIGN}}
636 /* Start of the executable code region. */
637 .init ${RELOCATING-0}${RELOCATING+${INIT_ADDR}} :
639 ${RELOCATING+${INIT_START}}
640 KEEP (*(SORT_NONE(.init)))
641 ${RELOCATING+${INIT_END}}
644 ${TEXT_PLT+${PLT_NEXT_DATA-${PLT} ${OTHER_PLT_SECTIONS}}}
646 ${TINY_READONLY_SECTION}
648 .text ${RELOCATING-0} :
650 ${RELOCATING+${TEXT_START_SYMBOLS}}
651 ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)}
652 ${RELOCATING+*(.text.exit .text.exit.*)}
653 ${RELOCATING+*(.text.startup .text.startup.*)}
654 ${RELOCATING+*(.text.hot .text.hot.*)}
655 ${RELOCATING+*(SORT(.text.sorted.*))}
656 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
657 /* .gnu.warning sections are handled specially by elf.em. */
659 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
662 .fini ${RELOCATING-0}${RELOCATING+${FINI_ADDR}} :
664 ${RELOCATING+${FINI_START}}
665 KEEP (*(SORT_NONE(.fini)))
666 ${RELOCATING+${FINI_END}}
671 emit_text_end_symbols()
674 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT-PROVIDE (__${ETEXT_NAME} = .);}}
675 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT-PROVIDE (_${ETEXT_NAME} = .);}}
676 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT-PROVIDE (${ETEXT_NAME} = .);}}
683 /* Start of the Read Only Data region. */
686 if test -n "${SEPARATE_CODE}${SEPARATE_TEXT}"; then
688 if test -n "${RODATA_ADDR}"; then
689 RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
691 RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
692 RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})"
695 if test -n "${SHLIB_RODATA_ADDR}"; then
696 SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
698 SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
699 SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
703 ${RELOCATING+/* Adjust the address for the rodata segment. We want to adjust up to
704 the same address within the page on the next page up. */
705 ${CREATE_SHLIB-${CREATE_PIE-. = ${RODATA_ADDR};}}
706 ${CREATE_SHLIB+. = ${SHLIB_RODATA_ADDR};}
707 ${CREATE_PIE+. = ${SHLIB_RODATA_ADDR};}}
715 ${WRITABLE_RODATA-${RODATA}}
716 .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) }
717 ${CREATE_SHLIB-${SDATA2}}
718 ${CREATE_SHLIB-${SBSS2}}
719 ${OTHER_READONLY_SECTIONS}
720 .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr)${RELOCATING+ *(.eh_frame_entry .eh_frame_entry.*)} }
721 .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame))${RELOCATING+ *(.eh_frame.*)} }
722 .sframe ${RELOCATING-0} : ONLY_IF_RO { *(.sframe)${RELOCATING+ *(.sframe.*)} }
723 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
724 .gnu_extab ${RELOCATING-0} : ONLY_IF_RO { *(.gnu_extab*) }
726 /* These sections are generated by the Sun/Oracle C++ compiler. */
727 .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges${RELOCATING+*}) }
729 ${TEXT_PLT+${PLT_NEXT_DATA+${PLT} ${OTHER_PLT_SECTIONS}}}
731 /* Various note sections. Placed here so that they are always included
732 in the read-only segment and not treated as orphan sections. The
733 current orphan handling algorithm does place note sections after R/O
734 data, but this is not guaranteed to always be the case. */
735 .note.build-id : { *(.note.build-id) } ${RELOCATING+${REGION}}
736 .note.GNU-stack : { *(.note.GNU-stack) } ${RELOCATING+${REGION}}
737 .note.gnu-property : { *(.note.gnu-property) } ${RELOCATING+${REGION}}
738 .note.ABI-tag : { *(.note.ABI-tag) } ${RELOCATING+${REGION}}
739 .note.package : { *(.note.package) } ${RELOCATING+${REGION}}
740 .note.dlopen : { *(.note.dlopen) } ${RELOCATING+${REGION}}
741 .note.netbsd.ident : { *(.note.netbsd.ident) } ${RELOCATING+${REGION}}
742 .note.openbsd.ident : { *(.note.openbsd.ident) } ${RELOCATING+${REGION}}
744 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (__${ETEXT_NAME} = .);}}
745 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (_${ETEXT_NAME} = .);}}
746 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (${ETEXT_NAME} = .);}}
753 /* Start of the Read Write Data region. */
754 ${RELOCATING+/* Adjust the address for the data segment. We want to adjust up to
755 the same address within the page on the next page up. */}
756 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
757 ${CREATE_SHLIB+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}
758 ${CREATE_PIE+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}
762 emit_init_fini_arrays()
767 ${CREATE_SHLIB-PROVIDE_HIDDEN ($(def_symbol "__preinit_array_start"));}
768 KEEP (*(.preinit_array))
769 ${CREATE_SHLIB-PROVIDE_HIDDEN ($(def_symbol "__preinit_array_end"));}
774 ${CREATE_SHLIB-PROVIDE_HIDDEN ($(def_symbol "__init_array_start"));}
776 KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY}))
777 ${CREATE_SHLIB-PROVIDE_HIDDEN ($(def_symbol "__init_array_end"));}
782 ${CREATE_SHLIB-PROVIDE_HIDDEN ($(def_symbol "__fini_array_start"));}
784 KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY}))
785 ${CREATE_SHLIB-PROVIDE_HIDDEN ($(def_symbol "__fini_array_end"));}
793 /* Exception handling. */
794 .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame))${RELOCATING+ *(.eh_frame.*)} }
795 .sframe ${RELOCATING-0} : ONLY_IF_RW { *(.sframe)${RELOCATING+ *(.sframe.*)} }
796 .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) }
797 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
798 .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges${RELOCATING+*}) }
800 /* Thread Local Storage sections. */
801 .tdata ${RELOCATING-0} :
803 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN ($(def_symbol "__tdata_start"));}}
804 *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*})
806 .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
808 ${RELOCATING+$(emit_init_fini_arrays)}
810 ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
811 ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
813 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
815 ${RELOCATING+${DATARELRO}}
816 ${OTHER_RELRO_SECTIONS}
817 ${TEXT_DYNAMIC-${DYNAMIC}}
818 ${OTHER_RELRO_SECTIONS_2}
819 ${DATA_GOT+${RELRO_NOW+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}}
820 ${DATA_GOT+${RELRO_NOW+${GOT}}}
821 ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
822 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
823 ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
824 ${INITIAL_READWRITE_SECTIONS}
825 ${DATA_SDATA+${SDATA}}
826 ${DATA_SDATA+${OTHER_SDATA_SECTIONS}}
827 ${DATA_SDATA+${SBSS}}
828 ${DATA_GOT+${RELRO_NOW-${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}}
829 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
830 ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
832 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
834 .data ${RELOCATING-0}${RELOCATING+${DATA_SECTION_ALIGNMENT}} :
836 ${RELOCATING+${DATA_START_SYMBOLS}}
837 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
838 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
841 .data1 ${RELOCATING-0} : { *(.data1) }
843 ${WRITABLE_RODATA+${RODATA}}
844 ${OTHER_READWRITE_SECTIONS}
846 ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
847 ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
848 ${SDATA_GOT+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}
850 ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}}
853 ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
855 ${DATA_SDATA-${SDATA}}
856 ${DATA_SDATA-${OTHER_SDATA_SECTIONS}}
858 ${RELOCATING+${SYMBOL_ABI_ALIGNMENT+. = ALIGN(${SYMBOL_ABI_ALIGNMENT});}}
859 ${RELOCATING+${DATA_END_SYMBOLS-${CREATE_SHLIB+PROVIDE (}$(def_symbol "_edata")${CREATE_SHLIB+)};
860 PROVIDE ($(def_symbol "edata"));}}
864 ${RELOCATING+. = ALIGN(ALIGNOF(NEXT_SECTION));}
865 ${RELOCATING+${CREATE_SHLIB+PROVIDE (}$(def_symbol "__bss_start")${CREATE_SHLIB+)};}
866 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
868 ${DATA_SDATA-${SBSS}}
870 .${BSS_NAME} ${RELOCATING-0} :
872 ${RELOCATING+*(.dynbss)}
873 *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*})
874 ${RELOCATING+*(COMMON)}
875 /* Align here to ensure that in the common case of there only being one
876 type of .bss section, the section occupies space up to _end.
877 Align after .bss to ensure correct alignment even if the
878 .bss section disappears because there are no input sections.
879 FIXME: Why do we need it? When there is no .bss section, we do not
880 pad the .data section. */
881 $(align_to_default_section_alignment)
884 ${OTHER_BSS_SECTIONS}
888 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
892 $(align_to_default_symbol_alignment)
898 LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});"
899 SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});"
902 /* Start of the Large Data region. */
903 ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}}
904 ${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}
905 ${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}
911 if test "${LARGE_SECTIONS}" != "yes"; then
915 if test "$1" = "0"; then
916 if test -n "${LARGE_BSS_AFTER_BSS}"; then
920 if test -z "${LARGE_BSS_AFTER_BSS}"; then
926 .lbss ${RELOCATING-0} :
928 ${RELOCATING+*(.dynlbss)}
929 *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
930 ${RELOCATING+*(LARGE_COMMON)}
937 if test "${LARGE_SECTIONS}" != "yes"; then
942 .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
944 *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
947 .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
949 *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
950 $(align_to_default_section_alignment)
960 ${RELOCATING+${OTHER_END_SYMBOLS}}
962 ${RELOCATING+${END_SYMBOLS-${CREATE_SHLIB+PROVIDE (}$(def_symbol "_end")${CREATE_SHLIB+)};
963 PROVIDE ($(def_symbol "end"));}}
965 ${RELOCATING+${DATA_SEGMENT_END}}
972 /* Start of the Tiny Data region. */
980 if test -z "${STACK_ADDR}"; then
986 .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
988 ${RELOCATING+$(def_symbol "_stack");}
990 ${RELOCATING+${STACK_SENTINEL}}
997 source_sh $srcdir/scripttempl/misc-sections.sc
998 source_sh $srcdir/scripttempl/DWARF.sc
1003 ${RELOCATING+${OTHER_SYMBOLS}}
1004 ${RELOCATING+${DISCARDED}}
1008 # ===========================================================================
1018 emit_executable_start
1020 #------Early Read Only Data -----------------------------------------------
1022 if test -z "${ALL_TEXT_BEFORE_RO}"; then
1023 # We are allowed to put R/O sections before code sections.
1024 # Doing so either puts read only data into the code segment, if the data
1025 # and code sections are contiguous, or creates a data segment followed by
1026 # a code segment, followed by another data segment (for read/write data).
1027 # Having three segments like this makes the binary bigger, which is a
1028 # problem for some scenarios, eg containers. On the other hand, having
1029 # data in an executable code segment means that it might provide an
1030 # avenue of attack for bad actors, which is a security risk.
1032 test -n "${SEPARATE_CODE}" || emit_early_ro
1033 test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn
1035 # We only need the alignment if we have emitted some sections.
1036 if test -z "${SEPARATE_CODE}"; then
1038 elif test -z "${NON_ALLOC_DYN}${SEPARATE_CODE}"; then
1043 #------Executable Code ----------------------------------------------------
1045 # We do not invoke "align_text" here as doing so will increase the file
1046 # size. Normally having the text segment at the start of the file will
1047 # automatically mean that it is aligned and if we have emitted any R/O
1048 # sections due to the code above, then extra alignment will have already
1052 emit_text_end_symbols
1054 # FIXME: We emit the text segment alignment operations again here.
1055 # (If they are defined). It is not clear why we do this.
1059 #------Read Only Data -----------------------------------------------------
1063 # If we have not already emitted the early read only data sections then do
1064 # so now. Also if the dynamic section has not already been emitted and we
1065 # can put it into the data segment, then do that here as well.
1067 if test -n "${ALL_TEXT_BEFORE_RO}"; then
1068 test -n "${SEPARATE_CODE}" || emit_early_ro
1069 test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn
1071 test -z "${SEPARATE_CODE}" || emit_early_ro
1072 test -z "${SEPARATE_CODE}" || emit_dyn
1074 # Now emit the rest of the read only data.
1078 #------Read Write Data ----------------------------------------------------
1086 align_to_default_symbol_alignment
1089 # FIXME: Should the tiny data sections appear before the end symbols ?
1093 #------Miscellaneous ------------------------------------------------------
1097 test -z "${NON_ALLOC_DYN}" || emit_dyn