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