1# 2# Unusual variables checked by this code: 3# NOP - four byte opcode for no-op (defaults to 0) 4# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not 5# empty. 6# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... 7# (e.g., .PARISC.milli) 8# When adding sections, do note that the names of some sections are used 9# when specifying the start address of the next. 10# 11test -z "$ENTRY" && ENTRY=start 12test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} 13test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} 14# If we request a big endian toolchain, give a big endian linker 15test -z "$GOT" && GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) } ${RELOCATING+ > ${DATA_MEMORY}}" 16test "${ARC_ENDIAN}" = "big" && OUTPUT_FORMAT=${BIG_OUTPUT_FORMAT} 17if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi 18test -z "${ELFSIZE}" && ELFSIZE=32 19test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" 20test "$LD_FLAG" = "N" && DATA_ADDR=. 21 22CTOR=".ctors ${CONSTRUCTING-0} : 23 { 24 ${CONSTRUCTING+${CTOR_START}} 25 /* gcc uses crtbegin.o to find the start of 26 the constructors, so we make sure it is 27 first. Because this is a wildcard, it 28 doesn't matter if the user does not 29 actually link against crtbegin.o; the 30 linker won't look for a file to match a 31 wildcard. The wildcard also means that it 32 doesn't matter which directory crtbegin.o 33 is in. */ 34 35 KEEP (*crtbegin*.o(.ctors)) 36 37 /* We don't want to include the .ctor section from 38 from the crtend.o file until after the sorted ctors. 39 The .ctor section from the crtend file contains the 40 end of ctors marker and it must be last */ 41 42 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) 43 KEEP (*(SORT(.ctors.*))) 44 KEEP (*(.ctors)) 45 ${CONSTRUCTING+${CTOR_END}} 46 } ${RELOCATING+ > ${DATA_MEMORY}}" 47DTOR=".dtors ${CONSTRUCTING-0} : 48 { 49 ${CONSTRUCTING+${DTOR_START}} 50 KEEP (*crtbegin*.o(.dtors)) 51 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) 52 KEEP (*(SORT(.dtors.*))) 53 KEEP (*(.dtors)) 54 ${CONSTRUCTING+${DTOR_END}} 55 } ${RELOCATING+ > ${DATA_MEMORY}}" 56 57IVT=" 58 /* If the 'ivtbase_addr' symbol is defined, it indicates the base address of 59 the interrupt vectors. See description of INT_VECTOR_BASE register. */ 60 61 .ivt DEFINED (ivtbase_addr) ? ivtbase_addr : 0x00 : 62 { 63 ${RELOCATING+ PROVIDE (__ivtbase_addr = .); } 64 KEEP (*(.ivt)); 65 } ${RELOCATING+ > ${STARTUP_MEMORY}}" 66 67if test -z "${NO_SMALL_DATA}"; then 68 SBSS=".sbss ${RELOCATING-0} : 69 { 70 ${RELOCATING+PROVIDE (__sbss_start = .);} 71 ${RELOCATING+PROVIDE (___sbss_start = .);} 72 *(.dynsbss) 73 *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) 74 *(.scommon) 75 ${RELOCATING+PROVIDE (__sbss_end = .);} 76 ${RELOCATING+PROVIDE (___sbss_end = .);} 77 } ${RELOCATING+ > ${SDATA_MEMORY}}" 78 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) } ${RELOCATING+ > ${SDATA_MEMORY}}" 79 SDATA="/* We want the small data sections together, so single-instruction offsets 80 can access them all, and initialized data all before uninitialized, so 81 we can shorten the on-disk segment size. */ 82 .sdata ${RELOCATING-0} : 83 { 84 ${RELOCATING+${SDATA_START_SYMBOLS}} 85 *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*}) 86 87 ${RELOCATING+_edata = .;} 88 ${RELOCATING+PROVIDE (edata = .);} 89 } ${RELOCATING+ > ${SDATA_MEMORY}}" 90 SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) } ${RELOCATING+ > ${SDATA_MEMORY}}" 91 REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) } 92 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }" 93 REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) } 94 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }" 95 REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) } 96 .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }" 97 REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) } 98 .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }" 99fi 100 101# 102# We provide two emulations: a fixed on that defines some memory banks 103# and a configurable one that includes a user provided memory definition. 104# 105case $GENERIC_BOARD in 106 yes|1|YES) 107 MEMORY_DEF=" 108/* Get memory banks definition from some user configuration file. 109 This file must be located in some linker directory (search path 110 with -L<dir>). See fixed memory banks emulation script. */ 111INCLUDE memory.x; 112" 113 ;; 114 *) 115MEMORY_DEF=" 116/* Fixed definition of the available memory banks. 117 See generic emulation script for a user defined configuration. */ 118MEMORY 119{ 120 ICCM : ORIGIN = 0x00000000, LENGTH = ${ICCM_SIZE} 121 DCCM : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE} 122} 123" 124 ;; 125esac 126 127cat <<EOF 128OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}") 129OUTPUT_ARCH(${OUTPUT_ARCH}) 130${RELOCATING+ENTRY(${ENTRY})} 131 132${RELOCATING+${LIB_SEARCH_DIRS}} 133${RELOCATING+${EXECUTABLE_SYMBOLS}} 134${RELOCATING+${MEMORY_DEF}} 135 136SECTIONS 137{ 138 ${RELOCATING+${IVT}} 139 140 /* Read-only sections, merged into text segment: */ 141 ${TEXT_DYNAMIC+${DYNAMIC}} 142 .hash ${RELOCATING-0} : { *(.hash) } 143 .dynsym ${RELOCATING-0} : { *(.dynsym) } 144 .dynstr ${RELOCATING-0} : { *(.dynstr) } 145 .gnu.version ${RELOCATING-0} : { *(.gnu.version) } 146 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } 147 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } 148 149 .rel.init ${RELOCATING-0} : { *(.rel.init) } 150 .rela.init ${RELOCATING-0} : { *(.rela.init) } 151 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) } 152 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) } 153 .rel.fini ${RELOCATING-0} : { *(.rel.fini) } 154 .rela.fini ${RELOCATING-0} : { *(.rela.fini) } 155 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) } 156 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) } 157 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) } 158 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) } 159 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) } 160 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) } 161 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) } 162 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) } 163 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } 164 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } 165 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } 166 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } 167 .rel.got ${RELOCATING-0} : { *(.rel.got) } 168 .rela.got ${RELOCATING-0} : { *(.rela.got) } 169 ${REL_SDATA} 170 ${REL_SBSS} 171 ${REL_SDATA2} 172 ${REL_SBSS2} 173 .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) } 174 .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) } 175 176 .text ${RELOCATING-0} : 177 { 178 ${RELOCATING+${TEXT_START_SYMBOLS}} 179 180 ${RELOCATING+ . = ALIGN(4);} 181 ${RELOCATING+${INIT_START}} 182 KEEP (*(SORT_NONE(.init))) 183 ${RELOCATING+${INIT_END}} 184 185 /* Start here after reset. */ 186 ${RELOCATING+ . = ALIGN(4);} 187 KEEP (*crt0.o(.text.__startup)) 188 189 /* Remaining code. */ 190 ${RELOCATING+ . = ALIGN(4);} 191 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) 192 /* .gnu.warning sections are handled specially by elf.em. */ 193 *(.gnu.warning) 194 195 ${RELOCATING+${OTHER_TEXT_SECTIONS}} 196 197 } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0} 198 199 .fini ${RELOCATING-0} : 200 { 201 ${RELOCATING+${FINI_START}} 202 KEEP (*(SORT_NONE(.fini))) 203 ${RELOCATING+${FINI_END}} 204 205 ${RELOCATING+PROVIDE (__etext = .);} 206 ${RELOCATING+PROVIDE (_etext = .);} 207 ${RELOCATING+PROVIDE (etext = .);} 208 } ${RELOCATING+ > ${TEXT_MEMORY}} =${NOP-0} 209 210 .jcr ${RELOCATING-0} : 211 { 212 KEEP (*(.jcr)) 213 } ${RELOCATING+> ${TEXT_MEMORY}} 214 215 .eh_frame ${RELOCATING-0} : 216 { 217 KEEP (*(.eh_frame)) 218 } ${RELOCATING+> ${TEXT_MEMORY}} 219 220 .gcc_except_table ${RELOCATING-0} : 221 { 222 *(.gcc_except_table) *(.gcc_except_table.*) 223 } ${RELOCATING+> ${TEXT_MEMORY}} 224 225 .plt ${RELOCATING-0} : 226 { 227 *(.plt) 228 } ${RELOCATING+> ${TEXT_MEMORY}} 229 230 .jlitab ${RELOCATING-0} : 231 { 232 ${RELOCATING+${JLI_START_TABLE}} 233 jlitab*.o:(.jlitab*) *(.jlitab*) 234 } ${RELOCATING+> ${TEXT_MEMORY}} 235 236 .rodata ${RELOCATING-0} : 237 { 238 *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} 239 } ${RELOCATING+> ${TEXT_MEMORY}} 240 241 .rodata1 ${RELOCATING-0} : { *(.rodata1) } ${RELOCATING+> ${TEXT_MEMORY}} 242 243 ${RELOCATING+${OTHER_READONLY_SECTIONS}} 244 245 /* Start of the data section image in ROM. */ 246 ${RELOCATING+__data_image = .;} 247 ${RELOCATING+PROVIDE (__data_image = .);} 248 249 .data ${RELOCATING-0} : 250 { 251 ${RELOCATING+ PROVIDE (__data_start = .) ; } 252 /* --gc-sections will delete empty .data. This leads to wrong start 253 addresses for subsequent sections because -Tdata= from the command 254 line will have no effect, see PR13697. Thus, keep .data */ 255 KEEP (*(.data)) 256 ${RELOCATING+${DATA_START_SYMBOLS}} 257 ${RELOCATING+*(.data.* .gnu.linkonce.d.*)} 258 ${CONSTRUCTING+SORT(CONSTRUCTORS)} 259 260 } ${RELOCATING+ > ${DATA_MEMORY}} 261 262 ${GOT} 263 ${RELOCATING+${CTOR}} 264 ${RELOCATING+${DTOR}} 265 266 ${RELOCATING+${SDATA}} 267 ${RELOCATING+${SDATA2}} 268 ${RELOCATING+${SBSS}} 269 ${RELOCATING+${SBSS2}} 270 .bss ${RELOCATING-0} : 271 { 272 ${RELOCATING+*(.dynbss)} 273 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) 274 ${RELOCATING+*(COMMON) 275 /* Align here to ensure that the .bss section occupies space up to 276 _end. Align after .bss to ensure correct alignment even if the 277 .bss section disappears because there are no input sections. */ 278 . = ALIGN(${ALIGNMENT});} 279 ${RELOCATING+_end = .;} 280 ${RELOCATING+PROVIDE (end = .);} 281 } ${RELOCATING+ > ${DATA_MEMORY}} 282 283 /* Global data not cleared after reset. */ 284 .noinit ${RELOCATING-0}: 285 { 286 *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*}) 287 ${RELOCATING+. = ALIGN(${ALIGNMENT});} 288 ${RELOCATING+ PROVIDE (__start_heap = .) ; } 289 } ${RELOCATING+ > ${DATA_MEMORY}} 290 291 ${RELOCATING+ PROVIDE (__stack_top = (ORIGIN (${DATA_MEMORY}) + LENGTH (${DATA_MEMORY}) - 1) & -4);} 292 ${RELOCATING+ PROVIDE (__end_heap = ORIGIN (${DATA_MEMORY}) + LENGTH (${DATA_MEMORY}) - 1);} 293 294 /* Stabs debugging sections. */ 295 .stab 0 : { *(.stab) } 296 .stabstr 0 : { *(.stabstr) } 297 .stab.excl 0 : { *(.stab.excl) } 298 .stab.exclstr 0 : { *(.stab.exclstr) } 299 .stab.index 0 : { *(.stab.index) } 300 .stab.indexstr 0 : { *(.stab.indexstr) } 301 302 .comment 0 : { *(.comment) } 303 .note.gnu.build-id : { *(.note.gnu.build-id) } 304EOF 305 306. $srcdir/scripttempl/DWARF.sc 307 308cat <<EOF 309 /* ARC Extension Sections */ 310 .arcextmap 0 : { *(.arcextmap.*) } 311} 312EOF 313