1# Copyright (C) 2014-2022 Free Software Foundation, Inc. 2# 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 7CTOR=".ctors ${CONSTRUCTING-0} : 8 { 9 ${CONSTRUCTING+ __CTOR_LIST__ = .; } 10 /* gcc uses crtbegin.o to find the start of 11 the constructors, so we make sure it is 12 first. Because this is a wildcard, it 13 doesn't matter if the user does not 14 actually link against crtbegin.o; the 15 linker won't look for a file to match a 16 wildcard. The wildcard also means that it 17 doesn't matter which directory crtbegin.o 18 is in. */ 19 20 KEEP (*crtbegin.o(.ctors)) 21 KEEP (*crtbegin?.o(.ctors)) 22 23 /* We don't want to include the .ctor section from 24 the crtend.o file until after the sorted ctors. 25 The .ctor section from the crtend file contains the 26 end of ctors marker and it must be last */ 27 28 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .ctors)) 29 KEEP (*(SORT(.ctors.*))) 30 KEEP (*(.ctors)) 31 ${CONSTRUCTING+ __CTOR_END__ = .; } 32 } ${RELOCATING+ > ${DATA_MEMORY}}" 33 34DTOR=" .dtors ${CONSTRUCTING-0} : 35 { 36 ${CONSTRUCTING+ __DTOR_LIST__ = .; } 37 KEEP (*crtbegin.o(.dtors)) 38 KEEP (*crtbegin?.o(.dtors)) 39 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors)) 40 KEEP (*(SORT(.dtors.*))) 41 KEEP (*(.dtors)) 42 ${CONSTRUCTING+ __DTOR_END__ = .; } 43 } ${RELOCATING+ > ${DATA_MEMORY}}" 44 45cat <<EOF 46/* Copyright (C) 2014-2022 Free Software Foundation, Inc. 47 48 Copying and distribution of this script, with or without modification, 49 are permitted in any medium without royalty provided the copyright 50 notice and this notice are preserved. */ 51 52OUTPUT_FORMAT("${OUTPUT_FORMAT}") 53OUTPUT_ARCH(${ARCH}) 54 55EOF 56 57test -n "${RELOCATING}" && cat <<EOF 58MEMORY 59{ 60 text ${TEXT_DEF_SECTION} : ORIGIN = ${TEXT_START_ADDR}, LENGTH = ${TEXT_SIZE} 61 data ${DATA_DEF_SECTION} : ORIGIN = ${DATA_START_ADDR}, LENGTH = ${DATA_SIZE} 62 emem ${EMEM_DEF_SECTION} : ORIGIN = ${EMEM_START_ADDR}, LENGTH = ${EMEM_SIZE} 63 eit : ORIGIN = ${EIT_START_ADDR}, LENGTH = ${EIT_SIZE} 64} 65 66EOF 67 68cat <<EOF 69SECTIONS 70{ 71 /* Read-only sections, merged into text segment: */ 72 ${TEXT_DYNAMIC+${DYNAMIC}} 73 .hash ${RELOCATING-0} : { *(.hash) } 74 .dynsym ${RELOCATING-0} : { *(.dynsym) } 75 .dynstr ${RELOCATING-0} : { *(.dynstr) } 76 .gnu.version ${RELOCATING-0} : { *(.gnu.version) } 77 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } 78 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } 79 80 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.gnu.linkonce.t*}) } 81 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.gnu.linkonce.t*}) } 82 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.gnu.linkonce.d*}) } 83 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.gnu.linkonce.d*}) } 84 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.gnu.linkonce.r*}) } 85 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.gnu.linkonce.r*}) } 86 .rel.stext ${RELOCATING-0} : { *(.rel.stest) } 87 .rela.stext ${RELOCATING-0} : { *(.rela.stest) } 88 .rel.etext ${RELOCATING-0} : { *(.rel.etest) } 89 .rela.etext ${RELOCATING-0} : { *(.rela.etest) } 90 .rel.sdata ${RELOCATING-0} : { *(.rel.sdata) } 91 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) } 92 .rel.edata ${RELOCATING-0} : { *(.rel.edata) } 93 .rela.edata ${RELOCATING-0} : { *(.rela.edata) } 94 .rel.eit_v ${RELOCATING-0} : { *(.rel.eit_v) } 95 .rela.eit_v ${RELOCATING-0} : { *(.rela.eit_v) } 96 .rel.sbss ${RELOCATING-0} : { *(.rel.sbss) } 97 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) } 98 .rel.ebss ${RELOCATING-0} : { *(.rel.ebss) } 99 .rela.ebss ${RELOCATING-0} : { *(.rela.ebss) } 100 .rel.srodata ${RELOCATING-0} : { *(.rel.srodata) } 101 .rela.srodata ${RELOCATING-0} : { *(.rela.srodata) } 102 .rel.erodata ${RELOCATING-0} : { *(.rel.erodata) } 103 .rela.erodata ${RELOCATING-0} : { *(.rela.erodata) } 104 .rel.got ${RELOCATING-0} : { *(.rel.got) } 105 .rela.got ${RELOCATING-0} : { *(.rela.got) } 106 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } 107 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } 108 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } 109 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } 110 .rel.init ${RELOCATING-0} : { *(.rel.init) } 111 .rela.init ${RELOCATING-0} : { *(.rela.init) } 112 .rel.fini ${RELOCATING-0} : { *(.rel.fini) } 113 .rela.fini ${RELOCATING-0} : { *(.rela.fini) } 114 .rel.bss ${RELOCATING-0} : { *(.rel.bss) } 115 .rela.bss ${RELOCATING-0} : { *(.rela.bss) } 116 .rel.plt ${RELOCATING-0} : { *(.rel.plt) } 117 .rela.plt ${RELOCATING-0} : { *(.rela.plt) } 118 119 .init ${RELOCATING-0} : { KEEP (*(SORT_NONE(.init))) } =${NOP-0} 120 ${DATA_PLT-${PLT}} 121 122 /* Internal text space */ 123 .stext ${RELOCATING-0} : { *(.stext) } ${RELOCATING+ > text} 124 125 /* Internal text space or external memory */ 126 .text : 127 { 128 *(.text) 129 ${RELOCATING+*(.gnu.linkonce.t*) 130 KEEP (*(SORT_NONE(.fini))) 131 _etext = . ;} 132 } ${RELOCATING+ > ${TEXT_MEMORY}} 133 134 /* Internal data space */ 135 .srodata ${RELOCATING-0} : { *(.srodata) } ${RELOCATING+ > data} 136 .sdata ${RELOCATING-0} : { *(.sdata) } ${RELOCATING+ > data} 137 138 /* Internal data space or external memory */ 139 .rodata ${RELOCATING-0} : { *(.rodata) } ${RELOCATING+ > ${DATA_MEMORY}} 140 141 /* C++ exception support. */ 142 .eh_frame ${RELOCATING-0} : { KEEP (*(.eh_frame)) } ${RELOCATING+ > ${DATA_MEMORY}} 143 .gcc_except_table ${RELOCATING-0} : { *(.gcc_except_table) } ${RELOCATING+ > ${DATA_MEMORY}} 144 145 /* Java class registration support. */ 146 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } ${RELOCATING+ >${DATA_MEMORY}} 147 148 ${RELOCATING+${CTOR}} 149 ${RELOCATING+${DTOR}} 150 151 .data ${RELOCATING-0} : 152 { 153 *(.data) 154 ${RELOCATING+*(.gnu.linkonce.d*)} 155 ${CONSTRUCTING+CONSTRUCTORS} 156 ${RELOCATING+ _edata = . ; } 157 } ${RELOCATING+ > ${DATA_MEMORY}} 158 159 /* External memory */ 160 .etext ${RELOCATING-0} : 161 { 162 ${RELOCATING+ PROVIDE (__etext_start = .) ; } 163 *(.etext) 164 ${RELOCATING+ PROVIDE (__etext_end = .) ; } 165 } ${RELOCATING+ > emem} 166 167 .erodata ${RELOCATING-0} : { *(.erodata) } ${RELOCATING+ > emem} 168 .edata ${RELOCATING-0} : { *(.edata) } ${RELOCATING+ > emem} 169 170 .sbss ${RELOCATING-0} : 171 { 172 ${RELOCATING+ PROVIDE (__sbss_start = .) ; } 173 *(.sbss) 174 ${RELOCATING+ PROVIDE (__sbss_end = .) ; } 175 } ${RELOCATING+ > data} 176 177 .ebss ${RELOCATING-0} : 178 { 179 ${RELOCATING+ PROVIDE (__ebss_start = .) ; } 180 *(.ebss) 181 ${RELOCATING+ PROVIDE (__ebss_end = .) ; } 182 } ${RELOCATING+ > data} 183 184 .bss ${RELOCATING-0} : 185 { 186 ${RELOCATING+ PROVIDE (__bss_start = .) ; } 187 *(.bss) 188 ${RELOCATING+*(COMMON)} 189 ${RELOCATING+ PROVIDE (__bss_end = .) ; } 190 ${RELOCATING+ _end = . ; } 191 } ${RELOCATING+ > ${DATA_MEMORY}} 192 193 .eit_v ${RELOCATING-0} : 194 { 195 ${RELOCATING+ PROVIDE (__eit_start = .) ; } 196 *(.eit_v) 197 ${RELOCATING+ PROVIDE (__eit_end = .) ; } 198 } ${RELOCATING+ > eit} 199 200 /* Stabs debugging sections. */ 201 .stab 0 : { *(.stab) } 202 .stabstr 0 : { *(.stabstr) } 203 .stab.excl 0 : { *(.stab.excl) } 204 .stab.exclstr 0 : { *(.stab.exclstr) } 205 .stab.index 0 : { *(.stab.index) } 206 .stab.indexstr 0 : { *(.stab.indexstr) } 207 208 .comment 0 : { *(.comment) } 209 210EOF 211 212. $srcdir/scripttempl/DWARF.sc 213 214cat <<EOF 215 ${RELOCATING+PROVIDE (__stack = ${STACK_START_ADDR});} 216} 217EOF 218 219 220 221