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