| 1 | # Adapted from mips.sc |
| 2 | # These variables may be overridden by the emulation file. The |
| 3 | # defaults are appropriate for a DECstation running Ultrix. |
| 4 | test -z "$ENTRY" && ENTRY=_start |
| 5 | |
| 6 | #test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x0" |
| 7 | |
| 8 | CTOR=".ctors ${CONSTRUCTING-0} : |
| 9 | { |
| 10 | ${CONSTRUCTING+${CTOR_START}} |
| 11 | /* gcc uses crtbegin.o to find the start of |
| 12 | the constructors, so we make sure it is |
| 13 | first. Because this is a wildcard, it |
| 14 | doesn't matter if the user does not |
| 15 | actually link against crtbegin.o; the |
| 16 | linker won't look for a file to match a |
| 17 | wildcard. The wildcard also means that it |
| 18 | doesn't matter which directory crtbegin.o |
| 19 | is in. */ |
| 20 | |
| 21 | KEEP (*crtbegin.o(.ctors)) |
| 22 | |
| 23 | /* We don't want to include the .ctor section from |
| 24 | from 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) .ctors)) |
| 29 | KEEP (*(SORT(.ctors.*))) |
| 30 | KEEP (*(.ctors)) |
| 31 | ${CONSTRUCTING+${CTOR_END}} |
| 32 | }" |
| 33 | |
| 34 | DTOR=" .dtors ${CONSTRUCTING-0} : |
| 35 | { |
| 36 | ${CONSTRUCTING+${DTOR_START}} |
| 37 | KEEP (*crtbegin.o(.dtors)) |
| 38 | KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) |
| 39 | KEEP (*(SORT(.dtors.*))) |
| 40 | KEEP (*(.dtors)) |
| 41 | ${CONSTRUCTING+${DTOR_END}} |
| 42 | }" |
| 43 | |
| 44 | cat <<EOF |
| 45 | OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", |
| 46 | "${LITTLE_OUTPUT_FORMAT}") |
| 47 | /*${LIB_SEARCH_DIRS}*/ |
| 48 | ${RELOCATING+${LIB_SEARCH_DIRS}} |
| 49 | |
| 50 | ${RELOCATING+ENTRY (${ENTRY})} |
| 51 | |
| 52 | _TEXT_START_ADDR = DEFINED(_TEXT_START_ADDR) ? _TEXT_START_ADDR : 0x50; |
| 53 | _HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x0; |
| 54 | _STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400; |
| 55 | |
| 56 | SECTIONS |
| 57 | { |
| 58 | .vectors.reset 0x0 : { KEEP (*(.vectors.reset)) } = 0 |
| 59 | .vectors.sw_exception 0x8 : { KEEP (*(.vectors.sw_exception)) } = 0 |
| 60 | .vectors.interrupt 0x10 : { KEEP (*(.vectors.interrupt)) } = 0 |
| 61 | .vectors.debug_sw_break 0x18 : { KEEP (*(.vectors.debug_sw_break)) } = 0 |
| 62 | .vectors.hw_exception 0x20 : { KEEP (*(.vectors.hw_exception)) } = 0 |
| 63 | |
| 64 | ${RELOCATING+. = _TEXT_START_ADDR;} |
| 65 | |
| 66 | ${RELOCATING+ _ftext = .;} |
| 67 | .text : { |
| 68 | ${RELOCATING+*(.text)} |
| 69 | ${RELOCATING+*(.text.*)} |
| 70 | ${RELOCATING+*(.gnu.linkonce.t.*)} |
| 71 | } |
| 72 | ${RELOCATING+ _etext = .;} |
| 73 | |
| 74 | .init : { KEEP (*(.init)) } =0 |
| 75 | .fini : { KEEP (*(.fini)) } =0 |
| 76 | |
| 77 | ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);} |
| 78 | ${RELOCATING+PROVIDE (___CTOR_LIST__ = .);} |
| 79 | ${RELOCATING+${CTOR}} |
| 80 | ${RELOCATING+PROVIDE (__CTOR_END__ = .);} |
| 81 | ${RELOCATING+PROVIDE (___CTOR_END__ = .);} |
| 82 | |
| 83 | ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);} |
| 84 | ${RELOCATING+PROVIDE (___DTOR_LIST__ = .);} |
| 85 | ${RELOCATING+${DTOR}} |
| 86 | ${RELOCATING+PROVIDE (__DTOR_END__ = .);} |
| 87 | ${RELOCATING+PROVIDE (___DTOR_END__ = .);} |
| 88 | |
| 89 | ${RELOCATING+ . = ALIGN(4);} |
| 90 | ${RELOCATING+ _frodata = . ;} |
| 91 | .rodata : { |
| 92 | ${RELOCATING+*(.rodata)} |
| 93 | ${RELOCATING+*(.rodata.*)} |
| 94 | ${RELOCATING+*(.gnu.linkonce.r.*)} |
| 95 | ${CONSTRUCTING+CONSTRUCTORS}; /* Is this needed? */ |
| 96 | } |
| 97 | ${RELOCATING+ _erodata = .;} |
| 98 | |
| 99 | /* Alignments by 8 to ensure that _SDA2_BASE_ on a word boundary */ |
| 100 | /* Note that .sdata2 and .sbss2 must be contiguous */ |
| 101 | ${RELOCATING+. = ALIGN(8);} |
| 102 | ${RELOCATING+ _ssrw = .;} |
| 103 | .sdata2 : { |
| 104 | ${RELOCATING+*(.sdata2)} |
| 105 | ${RELOCATING+*(.sdata2.*)} |
| 106 | ${RELOCATING+*(.gnu.linkonce.s2.*)} |
| 107 | } |
| 108 | ${RELOCATING+. = ALIGN(4);} |
| 109 | .sbss2 : { |
| 110 | ${RELOCATING+PROVIDE (__sbss2_start = .);} |
| 111 | ${RELOCATING+*(.sbss2)} |
| 112 | ${RELOCATING+*(.sbss2.*)} |
| 113 | ${RELOCATING+*(.gnu.linkonce.sb2.*)} |
| 114 | ${RELOCATING+PROVIDE (__sbss2_end = .);} |
| 115 | } |
| 116 | ${RELOCATING+. = ALIGN(8);} |
| 117 | ${RELOCATING+ _essrw = .;} |
| 118 | ${RELOCATING+ _ssrw_size = _essrw - _ssrw;} |
| 119 | ${RELOCATING+ PROVIDE (_SDA2_BASE_ = _ssrw + (_ssrw_size / 2 ));} |
| 120 | |
| 121 | ${RELOCATING+ . = ALIGN(4);} |
| 122 | ${RELOCATING+ _fdata = .;} |
| 123 | .data : { |
| 124 | ${RELOCATING+*(.data)} |
| 125 | ${RELOCATING+*(.gnu.linkonce.d.*)} |
| 126 | ${CONSTRUCTING+CONSTRUCTORS}; /* Is this needed? */ |
| 127 | } |
| 128 | ${RELOCATING+ _edata = . ;} |
| 129 | |
| 130 | /* Added to handle pic code */ |
| 131 | .got : { |
| 132 | ${RELOCATING+*(.got)} |
| 133 | } |
| 134 | |
| 135 | .got1 : { |
| 136 | ${RELOCATING+*(.got1)} |
| 137 | } |
| 138 | |
| 139 | .got2 : { |
| 140 | ${RELOCATING+*(.got2)} |
| 141 | } |
| 142 | |
| 143 | /* Added by Sathya to handle C++ exceptions */ |
| 144 | .eh_frame : { |
| 145 | ${RELOCATING+*(.eh_frame)} |
| 146 | } |
| 147 | |
| 148 | .jcr : { |
| 149 | ${RELOCATING+*(.jcr)} |
| 150 | } |
| 151 | |
| 152 | .gcc_except_table : { |
| 153 | ${RELOCATING+*(.gcc_except_table)} |
| 154 | } |
| 155 | |
| 156 | /* Alignments by 8 to ensure that _SDA_BASE_ on a word boundary */ |
| 157 | /* Note that .sdata and .sbss must be contiguous */ |
| 158 | ${RELOCATING+. = ALIGN(8);} |
| 159 | ${RELOCATING+ _ssro = .;} |
| 160 | .sdata : { |
| 161 | ${RELOCATING+*(.sdata)} |
| 162 | ${RELOCATING+*(.sdata.*)} |
| 163 | ${RELOCATING+*(.gnu.linkonce.s.*)} |
| 164 | } |
| 165 | ${RELOCATING+. = ALIGN(4);} |
| 166 | .sbss : { |
| 167 | ${RELOCATING+PROVIDE (__sbss_start = .);} |
| 168 | ${RELOCATING+*(.sbss)} |
| 169 | ${RELOCATING+*(.sbss.*)} |
| 170 | ${RELOCATING+*(.gnu.linkonce.sb.*)} |
| 171 | ${RELOCATING+PROVIDE (__sbss_end = .);} |
| 172 | } |
| 173 | ${RELOCATING+. = ALIGN(8);} |
| 174 | ${RELOCATING+ _essro = .;} |
| 175 | ${RELOCATING+ _ssro_size = _essro - _ssro;} |
| 176 | ${RELOCATING+PROVIDE (_SDA_BASE_ = _ssro + (_ssro_size / 2 ));} |
| 177 | |
| 178 | ${RELOCATING+ . = ALIGN(4);} |
| 179 | ${RELOCATING+ _fbss = .;} |
| 180 | .bss : { |
| 181 | ${RELOCATING+PROVIDE (__bss_start = .);} |
| 182 | ${RELOCATING+*(.bss)} |
| 183 | ${RELOCATING+*(.bss.*)} |
| 184 | ${RELOCATING+*(.gnu.linkonce.b.*)} |
| 185 | ${RELOCATING+*(COMMON)} |
| 186 | ${RELOCATING+. = ALIGN(4);} |
| 187 | |
| 188 | ${RELOCATING+PROVIDE (__bss_end = .);} |
| 189 | |
| 190 | } |
| 191 | |
| 192 | ${RELOCATING+ . = ALIGN(4);} |
| 193 | |
| 194 | .heap : { |
| 195 | ${RELOCATING+ _heap = .;} |
| 196 | ${RELOCATING+ _heap_start = .;} |
| 197 | ${RELOCATING+ . += _HEAP_SIZE;} |
| 198 | ${RELOCATING+ _heap_end = .;} |
| 199 | } |
| 200 | |
| 201 | ${RELOCATING+ . = ALIGN(4);} |
| 202 | |
| 203 | .stack : { |
| 204 | ${RELOCATING+ _stack_end = .;} |
| 205 | ${RELOCATING+ . += _STACK_SIZE;} |
| 206 | ${RELOCATING+ . = ALIGN(8);} |
| 207 | ${RELOCATING+ _stack = .;} |
| 208 | ${RELOCATING+ _end = .;} |
| 209 | } |
| 210 | |
| 211 | .tdata : { |
| 212 | ${RELOCATING+*(.tdata)} |
| 213 | ${RELOCATING+*(.tdata.*)} |
| 214 | ${RELOCATING+*(.gnu.linkonce.td.*)} |
| 215 | } |
| 216 | .tbss : { |
| 217 | ${RELOCATING+*(.tbss)} |
| 218 | ${RELOCATING+*(.tbss.*)} |
| 219 | ${RELOCATING+*(.gnu.linkonce.tb.*)} |
| 220 | } |
| 221 | } |
| 222 | EOF |