]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/xstormy16.sc
Fix typo in f7f2534e
[thirdparty/binutils-gdb.git] / ld / scripttempl / xstormy16.sc
CommitLineData
93fbbb04
GK
1#
2# Unusual variables checked by this code:
3# NOP - two byte opcode for no-op (defaults to 0)
4# INITIAL_READONLY_SECTIONS - at start of text segment
5# OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
6# (e.g., .PARISC.milli)
7# OTHER_TEXT_SECTIONS - these get put in .text when relocating
8# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
9# (e.g., .PARISC.global)
93fbbb04
GK
10# OTHER_SECTIONS - at the end
11# EXECUTABLE_SYMBOLS - symbols that must be defined for an
12# executable (e.g., _DYNAMIC_LINK)
13# TEXT_START_SYMBOLS - symbols that appear at the start of the
14# .text section.
15# DATA_START_SYMBOLS - symbols that appear at the start of the
16# .data section.
17# OTHER_GOT_SYMBOLS - symbols defined just before .got.
18# OTHER_GOT_SECTIONS - sections just after .got and .sdata.
19# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
20# .bss section besides __bss_start.
21# INPUT_FILES - INPUT command of files to always include
22# INIT_START, INIT_END - statements just before and just after
23# combination of .init sections.
24# FINI_START, FINI_END - statements just before and just after
25# combination of .fini sections.
26#
27# When adding sections, do note that the names of some sections are used
28# when specifying the start address of the next.
29#
30
31# Many sections come in three flavours. There is the 'real' section,
32# like ".data". Then there are the per-procedure or per-variable
33# sections, generated by -ffunction-sections and -fdata-sections in GCC,
34# and useful for --gc-sections, which for a variable "foo" might be
35# ".data.foo". Then there are the linkonce sections, for which the linker
36# eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
37# The exact correspondences are:
38#
39# Section Linkonce section
40# .text .gnu.linkonce.t.foo
41# .rodata .gnu.linkonce.r.foo
42# .data .gnu.linkonce.d.foo
43# .bss .gnu.linkonce.b.foo
44# .sdata .gnu.linkonce.s.foo
45# .sbss .gnu.linkonce.sb.foo
46# .sdata2 .gnu.linkonce.s2.foo
47# .sbss2 .gnu.linkonce.sb2.foo
48#
49# Each of these can also have corresponding .rel.* and .rela.* sections.
50
51test -z "$ENTRY" && ENTRY=_start
52test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
53test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
54if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
55test -z "${ELFSIZE}" && ELFSIZE=32
56test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
ec2d9b29 57CTOR=".ctors ${CONSTRUCTING-0} :
93fbbb04
GK
58 {
59 ${CONSTRUCTING+${CTOR_START}}
60 /* gcc uses crtbegin.o to find the start of
61 the constructors, so we make sure it is
62 first. Because this is a wildcard, it
63 doesn't matter if the user does not
64 actually link against crtbegin.o; the
65 linker won't look for a file to match a
66 wildcard. The wildcard also means that it
67 doesn't matter which directory crtbegin.o
68 is in. */
69
40cf2291
AM
70 KEEP (*crtbegin.o(.ctors))
71 KEEP (*crtbegin?.o(.ctors))
93fbbb04
GK
72
73 /* We don't want to include the .ctor section from
bd6791bc 74 the crtend.o file until after the sorted ctors.
93fbbb04
GK
75 The .ctor section from the crtend file contains the
76 end of ctors marker and it must be last */
77
40cf2291 78 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
93fbbb04
GK
79 KEEP (*(SORT(.ctors.*)))
80 KEEP (*(.ctors))
81 ${CONSTRUCTING+${CTOR_END}}
82 } > ROM"
83
ec2d9b29 84DTOR=" .dtors ${CONSTRUCTING-0} :
93fbbb04
GK
85 {
86 ${CONSTRUCTING+${DTOR_START}}
40cf2291
AM
87 KEEP (*crtbegin.o(.dtors))
88 KEEP (*crtbegin?.o(.dtors))
89 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
93fbbb04
GK
90 KEEP (*(SORT(.dtors.*)))
91 KEEP (*(.dtors))
92 ${CONSTRUCTING+${DTOR_END}}
93 } > ROM"
94
95cat <<EOF
96OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
97 "${LITTLE_OUTPUT_FORMAT}")
98OUTPUT_ARCH(${OUTPUT_ARCH})
b34c1498 99${RELOCATING+ENTRY(${ENTRY})}
93fbbb04
GK
100
101${RELOCATING+${LIB_SEARCH_DIRS}}
102${RELOCATING+${EXECUTABLE_SYMBOLS}}
103${RELOCATING+${INPUT_FILES}}
ec2d9b29
AM
104${RELOCATING- /* For some reason, the Solaris linker makes bad executables
105 if gld -r is used and the intermediate file has sections starting
106 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
107 bug. But for now assigning the zero vmas works. */}
93fbbb04
GK
108
109/* There are two memory regions we care about, one from 0 through 0x7F00
110 that is RAM and one from 0x8000 up which is ROM. */
111MEMORY
112{
113 RAM (w) : ORIGIN = 0, LENGTH = 0x7F00
114 ROM (!w) : ORIGIN = 0x8000, LENGTH = 0xFF8000
115}
116
117SECTIONS
118{
ec2d9b29 119 .data ${RELOCATING-0} :
93fbbb04 120 {
517ed485
NC
121 ${RELOCATING+__rdata = .;}
122 ${RELOCATING+__data = .;}
93fbbb04
GK
123 ${RELOCATING+${DATA_START_SYMBOLS}}
124 *(.data)
125 ${RELOCATING+*(.data.*)}
126 ${RELOCATING+*(.gnu.linkonce.d.*)}
127 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
128 } > RAM
129 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
130 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
131 ${RELOCATING+${OTHER_GOT_SECTIONS}}
132 ${RELOCATING+_edata = .;}
133 ${RELOCATING+PROVIDE (edata = .);}
134 ${RELOCATING+__bss_start = .;}
135 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
ec2d9b29 136 .bss ${RELOCATING-0} :
93fbbb04
GK
137 {
138 *(.dynbss)
139 *(.bss)
140 ${RELOCATING+*(.bss.*)}
141 ${RELOCATING+*(.gnu.linkonce.b.*)}
142 *(COMMON)
143 /* Align here to ensure that the .bss section occupies space up to
144 _end. Align after .bss to ensure correct alignment even if the
145 .bss section disappears because there are no input sections. */
146 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
147 } > RAM
827a1c67 148 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
93fbbb04 149 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
827a1c67 150 ${RELOCATING+${OTHER_END_SYMBOLS}}
93fbbb04 151 ${RELOCATING+_end = .;}
da1f2fec 152 ${RELOCATING+__stack = .;}
93fbbb04
GK
153 ${RELOCATING+PROVIDE (end = .);}
154
155 /* Read-only sections in ROM. */
ec2d9b29 156 .int_vec ${RELOCATING-0} : { *(.int_vec) } ${RELOCATING+> ROM}
93fbbb04 157
ec2d9b29 158 .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} } ${RELOCATING+> ROM}
93fbbb04
GK
159 ${RELOCATING+${CTOR}}
160 ${RELOCATING+${DTOR}}
1ee7cf4c
NC
161 .jcr : { KEEP (*(.jcr)) } ${RELOCATING+> ROM}
162 .eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ROM}
ec51c381 163 .gcc_except_table : { *(.gcc_except_table) *(.gcc_except_table.*) } ${RELOCATING+> ROM}
1ee7cf4c 164 .plt : { *(.plt) } ${RELOCATING+> ROM}
93fbbb04 165
ec2d9b29 166 .text ${RELOCATING-0} :
93fbbb04
GK
167 {
168 ${RELOCATING+${TEXT_START_SYMBOLS}}
169 *(.text)
170 ${RELOCATING+*(.text.*)}
171 *(.stub)
172 /* .gnu.warning sections are handled specially by elf32.em. */
173 *(.gnu.warning)
174 ${RELOCATING+*(.gnu.linkonce.t.*)}
175 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
1ee7cf4c 176 } ${RELOCATING+> ROM =${NOP-0}}
ec2d9b29 177 .init ${RELOCATING-0} :
93fbbb04
GK
178 {
179 ${RELOCATING+${INIT_START}}
180 KEEP (*(.init))
181 ${RELOCATING+${INIT_END}}
1ee7cf4c 182 } ${RELOCATING+> ROM =${NOP-0}}
ec2d9b29 183 .fini ${RELOCATING-0} :
93fbbb04
GK
184 {
185 ${RELOCATING+${FINI_START}}
186 KEEP (*(.fini))
187 ${RELOCATING+${FINI_END}}
1ee7cf4c 188 } ${RELOCATING+> ROM =${NOP-0}}
93fbbb04
GK
189 ${RELOCATING+PROVIDE (__etext = .);}
190 ${RELOCATING+PROVIDE (_etext = .);}
191 ${RELOCATING+PROVIDE (etext = .);}
192 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
193
194
195 /* Stabs debugging sections. */
196 .stab 0 : { *(.stab) }
197 .stabstr 0 : { *(.stabstr) }
198 .stab.excl 0 : { *(.stab.excl) }
199 .stab.exclstr 0 : { *(.stab.exclstr) }
200 .stab.index 0 : { *(.stab.index) }
201 .stab.indexstr 0 : { *(.stab.indexstr) }
202
203 .comment 0 : { *(.comment) }
204
ceb0a680
NC
205EOF
206
d061dfac 207. $srcdir/scripttempl/DWARF.sc
2a995fc1 208
ceb0a680 209cat <<EOF
93fbbb04
GK
210 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
211
212 /* These must appear regardless of ${RELOCATING}. */
213 ${OTHER_SECTIONS}
214}
215EOF