elfd10v.sc revision 1.9 1 1.9 christos # Copyright (C) 2014-2024 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.9 christos /* Copyright (C) 2014-2024 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.1 christos .text ${RELOCATING+${TEXT_START_ADDR}} :
106 1.1 christos {
107 1.7 christos ${RELOCATING+${TEXT_START_SYMBOLS}
108 1.1 christos KEEP (*(SORT_NONE(.init)))
109 1.1 christos KEEP (*(SORT_NONE(.init.*)))
110 1.1 christos KEEP (*(SORT_NONE(.fini)))
111 1.7 christos KEEP (*(SORT_NONE(.fini.*)))}
112 1.1 christos *(.text)
113 1.7 christos ${RELOCATING+*(.text.*)}
114 1.7 christos /* .gnu.warning sections are handled specially by elf.em. */
115 1.1 christos *(.gnu.warning)
116 1.7 christos ${RELOCATING+*(.gnu.linkonce.t*)
117 1.7 christos _etext = .;
118 1.7 christos PROVIDE (etext = .);}
119 1.1 christos } ${RELOCATING+ >INSN} =${NOP-0}
120 1.1 christos
121 1.1 christos .rodata ${RELOCATING+${READONLY_START_ADDR}} : {
122 1.1 christos *(.rodata)
123 1.7 christos ${RELOCATING+*(.gnu.linkonce.r*)
124 1.7 christos *(.rodata.*)}
125 1.1 christos } ${RELOCATING+ >DATA}
126 1.1 christos
127 1.1 christos .rodata1 ${RELOCATING-0} : {
128 1.1 christos *(.rodata1)
129 1.7 christos ${RELOCATING+*(.rodata1.*)}
130 1.1 christos } ${RELOCATING+ >DATA}
131 1.1 christos
132 1.1 christos .data ${RELOCATING-0} :
133 1.1 christos {
134 1.1 christos ${RELOCATING+${DATA_START_SYMBOLS}}
135 1.1 christos *(.data)
136 1.7 christos ${RELOCATING+*(.data.*)
137 1.7 christos *(.gnu.linkonce.d*)}
138 1.1 christos ${CONSTRUCTING+CONSTRUCTORS}
139 1.1 christos } ${RELOCATING+ >DATA}
140 1.1 christos
141 1.1 christos .data1 ${RELOCATING-0} : {
142 1.1 christos *(.data1)
143 1.7 christos ${RELOCATING+*(.data1.*)}
144 1.1 christos } ${RELOCATING+ >DATA}
145 1.1 christos
146 1.1 christos ${RELOCATING+${CTOR} >DATA}
147 1.1 christos ${RELOCATING+${DTOR} >DATA}
148 1.1 christos
149 1.1 christos /* We want the small data sections together, so single-instruction offsets
150 1.1 christos can access them all, and initialized data all before uninitialized, so
151 1.1 christos we can shorten the on-disk segment size. */
152 1.1 christos .sdata ${RELOCATING-0} : {
153 1.1 christos *(.sdata)
154 1.7 christos ${RELOCATING+*(.sdata.*)}
155 1.1 christos } ${RELOCATING+ >DATA}
156 1.1 christos
157 1.1 christos ${RELOCATING+_edata = .;}
158 1.1 christos ${RELOCATING+PROVIDE (edata = .);}
159 1.9 christos ${RELOCATING+. = ALIGN(ALIGNOF(NEXT_SECTION));}
160 1.1 christos ${RELOCATING+__bss_start = .;}
161 1.7 christos .sbss ${RELOCATING-0} : { *(.sbss)${RELOCATING+ *(.scommon)} } ${RELOCATING+ >DATA}
162 1.1 christos .bss ${RELOCATING-0} :
163 1.1 christos {
164 1.7 christos ${RELOCATING+*(.dynbss)
165 1.7 christos *(.dynbss.*)}
166 1.1 christos *(.bss)
167 1.7 christos ${RELOCATING+*(.bss.*)
168 1.7 christos *(COMMON)}
169 1.1 christos } ${RELOCATING+ >DATA}
170 1.1 christos
171 1.1 christos ${RELOCATING+_end = . ;}
172 1.1 christos ${RELOCATING+PROVIDE (end = .);}
173 1.1 christos
174 1.1 christos ${RELOCATING+$STACK}
175 1.1 christos
176 1.3 christos EOF
177 1.3 christos
178 1.9 christos source_sh $srcdir/scripttempl/misc-sections.sc
179 1.9 christos source_sh $srcdir/scripttempl/DWARF.sc
180 1.3 christos
181 1.3 christos cat <<EOF
182 1.1 christos }
183 1.1 christos EOF
184