1 1.10 christos # Copyright (C) 2014-2025 Free Software Foundation, Inc. 2 1.6 christos # 3 1.3 christos # Copying and distribution of this file, with or without modification, 4 1.3 christos # are permitted in any medium without royalty provided the copyright 5 1.3 christos # notice and this notice are preserved. 6 1.3 christos 7 1.1 christos test -z "$ENTRY" && ENTRY=_start 8 1.1 christos test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} 9 1.1 christos test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} 10 1.1 christos if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi 11 1.1 christos test "$LD_FLAG" = "N" && DATA_ADDR=. 12 1.6 christos INTERP=".interp ${RELOCATING-0} : { *(.interp) }" 13 1.6 christos PLT=".plt ${RELOCATING-0} : { *(.plt) }" 14 1.1 christos 15 1.1 christos 16 1.6 christos CTOR=".ctors ${CONSTRUCTING-0} : 17 1.1 christos { 18 1.1 christos ${CONSTRUCTING+${CTOR_START}} 19 1.1 christos /* gcc uses crtbegin.o to find the start of 20 1.1 christos the constructors, so we make sure it is 21 1.1 christos first. Because this is a wildcard, it 22 1.1 christos doesn't matter if the user does not 23 1.1 christos actually link against crtbegin.o; the 24 1.1 christos linker won't look for a file to match a 25 1.1 christos wildcard. The wildcard also means that it 26 1.1 christos doesn't matter which directory crtbegin.o 27 1.1 christos is in. */ 28 1.1 christos 29 1.1 christos KEEP (*crtbegin.o(.ctors)) 30 1.1 christos KEEP (*crtbegin?.o(.ctors)) 31 1.1 christos 32 1.1 christos /* We don't want to include the .ctor section from 33 1.1 christos the crtend.o file until after the sorted ctors. 34 1.1 christos The .ctor section from the crtend file contains the 35 1.1 christos end of ctors marker and it must be last */ 36 1.1 christos 37 1.1 christos KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .ctors)) 38 1.1 christos KEEP (*(SORT(.ctors.*))) 39 1.1 christos KEEP (*(.ctors)) 40 1.1 christos ${CONSTRUCTING+${CTOR_END}} 41 1.1 christos }" 42 1.1 christos 43 1.1 christos DTOR=" .dtors ${CONSTRUCTING-0} : 44 1.1 christos { 45 1.1 christos ${CONSTRUCTING+${DTOR_START}} 46 1.1 christos KEEP (*crtbegin.o(.dtors)) 47 1.1 christos KEEP (*crtbegin?.o(.dtors)) 48 1.1 christos KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors)) 49 1.1 christos KEEP (*(SORT(.dtors.*))) 50 1.1 christos KEEP (*(.dtors)) 51 1.1 christos ${CONSTRUCTING+${DTOR_END}} 52 1.1 christos }" 53 1.1 christos 54 1.1 christos STACK=" .stack : { _stack = .; *(.stack) } >STACK " 55 1.1 christos 56 1.1 christos # if this is for an embedded system, don't add SIZEOF_HEADERS. 57 1.1 christos if [ -z "$EMBEDDED" ]; then 58 1.1 christos test -z "${READONLY_BASE_ADDRESS}" && READONLY_BASE_ADDRESS="${READONLY_START_ADDR} + SIZEOF_HEADERS" 59 1.1 christos else 60 1.1 christos test -z "${READONLY_BASE_ADDRESS}" && READONLY_BASE_ADDRESS="${READONLY_START_ADDR}" 61 1.1 christos fi 62 1.1 christos 63 1.1 christos cat <<EOF 64 1.10 christos /* Copyright (C) 2014-2025 Free Software Foundation, Inc. 65 1.3 christos 66 1.3 christos Copying and distribution of this script, with or without modification, 67 1.3 christos are permitted in any medium without royalty provided the copyright 68 1.3 christos notice and this notice are preserved. */ 69 1.3 christos 70 1.1 christos OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", 71 1.1 christos "${LITTLE_OUTPUT_FORMAT}") 72 1.1 christos OUTPUT_ARCH(${OUTPUT_ARCH}) 73 1.7 christos EOF 74 1.7 christos 75 1.7 christos test -n "${RELOCATING}" && cat <<EOF 76 1.7 christos ENTRY(${ENTRY}) 77 1.1 christos 78 1.7 christos ${LIB_SEARCH_DIRS} 79 1.7 christos /* Do we need any of these for elf? 80 1.7 christos __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */ 81 1.7 christos ${EXECUTABLE_SYMBOLS} 82 1.1 christos 83 1.1 christos MEMORY 84 1.1 christos { 85 1.1 christos /* These are the values for the D10V-TS3 board. 86 1.1 christos There are other memory regions available on 87 1.1 christos the TS3 (eg ROM, FLASH, etc) but these are not 88 1.1 christos used by this script. */ 89 1.6 christos 90 1.1 christos INSN : org = 0x01000000, len = 256K 91 1.1 christos DATA : org = 0x02000000, len = 48K 92 1.1 christos 93 1.1 christos /* This is a fake memory region at the top of the 94 1.1 christos on-chip RAM, used as the start of the 95 1.1 christos (descending) stack. */ 96 1.6 christos 97 1.1 christos STACK : org = 0x0200BFFC, len = 4 98 1.1 christos } 99 1.1 christos 100 1.7 christos EOF 101 1.7 christos 102 1.7 christos cat <<EOF 103 1.1 christos SECTIONS 104 1.1 christos { 105 1.10 christos /* PR 32100: GDB makes use of the fact that the .note.gnu.build-id 106 1.10 christos section is typically placed next to the ELF headers. */ 107 1.10 christos .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) } ${RELOCATING+ >INSN} 108 1.10 christos 109 1.1 christos .text ${RELOCATING+${TEXT_START_ADDR}} : 110 1.1 christos { 111 1.7 christos ${RELOCATING+${TEXT_START_SYMBOLS} 112 1.1 christos KEEP (*(SORT_NONE(.init))) 113 1.1 christos KEEP (*(SORT_NONE(.init.*))) 114 1.1 christos KEEP (*(SORT_NONE(.fini))) 115 1.7 christos KEEP (*(SORT_NONE(.fini.*)))} 116 1.1 christos *(.text) 117 1.7 christos ${RELOCATING+*(.text.*)} 118 1.7 christos /* .gnu.warning sections are handled specially by elf.em. */ 119 1.1 christos *(.gnu.warning) 120 1.7 christos ${RELOCATING+*(.gnu.linkonce.t*) 121 1.7 christos _etext = .; 122 1.7 christos PROVIDE (etext = .);} 123 1.1 christos } ${RELOCATING+ >INSN} =${NOP-0} 124 1.1 christos 125 1.1 christos .rodata ${RELOCATING+${READONLY_START_ADDR}} : { 126 1.1 christos *(.rodata) 127 1.7 christos ${RELOCATING+*(.gnu.linkonce.r*) 128 1.7 christos *(.rodata.*)} 129 1.1 christos } ${RELOCATING+ >DATA} 130 1.1 christos 131 1.1 christos .rodata1 ${RELOCATING-0} : { 132 1.1 christos *(.rodata1) 133 1.7 christos ${RELOCATING+*(.rodata1.*)} 134 1.1 christos } ${RELOCATING+ >DATA} 135 1.1 christos 136 1.1 christos .data ${RELOCATING-0} : 137 1.1 christos { 138 1.1 christos ${RELOCATING+${DATA_START_SYMBOLS}} 139 1.1 christos *(.data) 140 1.7 christos ${RELOCATING+*(.data.*) 141 1.7 christos *(.gnu.linkonce.d*)} 142 1.1 christos ${CONSTRUCTING+CONSTRUCTORS} 143 1.1 christos } ${RELOCATING+ >DATA} 144 1.1 christos 145 1.1 christos .data1 ${RELOCATING-0} : { 146 1.1 christos *(.data1) 147 1.7 christos ${RELOCATING+*(.data1.*)} 148 1.1 christos } ${RELOCATING+ >DATA} 149 1.1 christos 150 1.1 christos ${RELOCATING+${CTOR} >DATA} 151 1.1 christos ${RELOCATING+${DTOR} >DATA} 152 1.1 christos 153 1.1 christos /* We want the small data sections together, so single-instruction offsets 154 1.1 christos can access them all, and initialized data all before uninitialized, so 155 1.1 christos we can shorten the on-disk segment size. */ 156 1.1 christos .sdata ${RELOCATING-0} : { 157 1.1 christos *(.sdata) 158 1.7 christos ${RELOCATING+*(.sdata.*)} 159 1.1 christos } ${RELOCATING+ >DATA} 160 1.1 christos 161 1.1 christos ${RELOCATING+_edata = .;} 162 1.1 christos ${RELOCATING+PROVIDE (edata = .);} 163 1.9 christos ${RELOCATING+. = ALIGN(ALIGNOF(NEXT_SECTION));} 164 1.1 christos ${RELOCATING+__bss_start = .;} 165 1.7 christos .sbss ${RELOCATING-0} : { *(.sbss)${RELOCATING+ *(.scommon)} } ${RELOCATING+ >DATA} 166 1.1 christos .bss ${RELOCATING-0} : 167 1.1 christos { 168 1.7 christos ${RELOCATING+*(.dynbss) 169 1.7 christos *(.dynbss.*)} 170 1.1 christos *(.bss) 171 1.7 christos ${RELOCATING+*(.bss.*) 172 1.7 christos *(COMMON)} 173 1.1 christos } ${RELOCATING+ >DATA} 174 1.1 christos 175 1.1 christos ${RELOCATING+_end = . ;} 176 1.1 christos ${RELOCATING+PROVIDE (end = .);} 177 1.1 christos 178 1.1 christos ${RELOCATING+$STACK} 179 1.1 christos 180 1.3 christos EOF 181 1.3 christos 182 1.10 christos source_sh $srcdir/scripttempl/misc-sections.sc DATA 183 1.9 christos source_sh $srcdir/scripttempl/DWARF.sc 184 1.3 christos 185 1.3 christos cat <<EOF 186 1.1 christos } 187 1.1 christos EOF 188