* scripttempl/elf.sc (.rel.sdata): Combine all the sdata relocs
[deliverable/binutils-gdb.git] / ld / scripttempl / elf.sc
1 #
2 # Unusual variables checked by this code:
3 # NOP - two byte opcode for no-op (defaults to 0)
4 # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
5 # INITIAL_READONLY_SECTIONS - at start of text segment
6 # OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
7 # (e.g., .PARISC.milli)
8 # OTHER_TEXT_SECTIONS - these get put in .text when relocating
9 # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
10 # (e.g., .PARISC.global)
11 # OTHER_BSS_SECTIONS - other than .bss .sbss ...
12 # OTHER_SECTIONS - at the end
13 # EXECUTABLE_SYMBOLS - symbols that must be defined for an
14 # executable (e.g., _DYNAMIC_LINK)
15 # TEXT_START_SYMBOLS - symbols that appear at the start of the
16 # .text section.
17 # DATA_START_SYMBOLS - symbols that appear at the start of the
18 # .data section.
19 # OTHER_GOT_SYMBOLS - symbols defined just before .got.
20 # OTHER_GOT_SECTIONS - sections just after .got and .sdata.
21 # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
22 # .bss section besides __bss_start.
23 # DATA_PLT - .plt should be in data segment, not text segment.
24 # TEXT_DYNAMIC - .dynamic in text segment, not data segment.
25 # EMBEDDED - whether this is for an embedded system.
26 # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
27 # start address of shared library.
28 # INPUT_FILES - INPUT command of files to always include
29 # WRITABLE_RODATA - if set, the .rodata section should be writable
30 # INIT_START, INIT_END - statements just before and just after
31 # combination of .init sections.
32 # FINI_START, FINI_END - statements just before and just after
33 # combination of .fini sections.
34 #
35 # When adding sections, do note that the names of some sections are used
36 # when specifying the start address of the next.
37 #
38
39 test -z "$ENTRY" && ENTRY=_start
40 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
41 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
42 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
43 test -z "${ELFSIZE}" && ELFSIZE=32
44 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
45 test "$LD_FLAG" = "N" && DATA_ADDR=.
46 INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
47 PLT=".plt ${RELOCATING-0} : { *(.plt) }"
48 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
49 RODATA=".rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r*)} }"
50 CTOR=".ctors ${CONSTRUCTING-0} :
51 {
52 ${CONSTRUCTING+${CTOR_START}}
53 /* gcc uses crtbegin.o to find the start of
54 the constructors, so we make sure it is
55 first. Because this is a wildcard, it
56 doesn't matter if the user does not
57 actually link against crtbegin.o; the
58 linker won't look for a file to match a
59 wildcard. The wildcard also means that it
60 doesn't matter which directory crtbegin.o
61 is in. */
62
63 KEEP (*crtbegin.o(.ctors))
64
65 /* We don't want to include the .ctor section from
66 from the crtend.o file until after the sorted ctors.
67 The .ctor section from the crtend file contains the
68 end of ctors marker and it must be last */
69
70 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
71 KEEP (*(SORT(.ctors.*)))
72 KEEP (*(.ctors))
73 ${CONSTRUCTING+${CTOR_END}}
74 }"
75
76 DTOR=" .dtors ${CONSTRUCTING-0} :
77 {
78 ${CONSTRUCTING+${DTOR_START}}
79 KEEP (*crtbegin.o(.dtors))
80 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
81 KEEP (*(SORT(.dtors.*)))
82 KEEP (*(.dtors))
83 ${CONSTRUCTING+${DTOR_END}}
84 }"
85
86 # if this is for an embedded system, don't add SIZEOF_HEADERS.
87 if [ -z "$EMBEDDED" ]; then
88 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
89 else
90 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
91 fi
92
93 cat <<EOF
94 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
95 "${LITTLE_OUTPUT_FORMAT}")
96 OUTPUT_ARCH(${OUTPUT_ARCH})
97 ENTRY(${ENTRY})
98
99 ${RELOCATING+${LIB_SEARCH_DIRS}}
100 ${RELOCATING+/* Do we need any of these for elf?
101 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
102 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
103 ${RELOCATING+${INPUT_FILES}}
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. */}
108
109 SECTIONS
110 {
111 /* Read-only sections, merged into text segment: */
112 ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}
113 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
114 ${CREATE_SHLIB-${INTERP}}
115 ${INITIAL_READONLY_SECTIONS}
116 ${TEXT_DYNAMIC+${DYNAMIC}}
117 .hash ${RELOCATING-0} : { *(.hash) }
118 .dynsym ${RELOCATING-0} : { *(.dynsym) }
119 .dynstr ${RELOCATING-0} : { *(.dynstr) }
120 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
121 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
122 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
123
124 .rel.init ${RELOCATING-0} : { *(.rel.init) }
125 .rela.init ${RELOCATING-0} : { *(.rela.init) }
126 .rel.text ${RELOCATING-0} :
127 {
128 *(.rel.text)
129 ${RELOCATING+*(.rel.text.*)}
130 ${RELOCATING+*(.rel.gnu.linkonce.t*)}
131 }
132 .rela.text ${RELOCATING-0} :
133 {
134 *(.rela.text)
135 ${RELOCATING+*(.rela.text.*)}
136 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
137 }
138 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
139 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
140 .rel.rodata ${RELOCATING-0} :
141 {
142 *(.rel.rodata)
143 ${RELOCATING+*(.rel.rodata.*)}
144 ${RELOCATING+*(.rel.gnu.linkonce.r*)}
145 }
146 .rela.rodata ${RELOCATING-0} :
147 {
148 *(.rela.rodata)
149 ${RELOCATING+*(.rela.rodata.*)}
150 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
151 }
152 ${OTHER_READONLY_RELOC_SECTIONS}
153 .rel.data ${RELOCATING-0} :
154 {
155 *(.rel.data)
156 ${RELOCATING+*(.rel.data.*)}
157 ${RELOCATING+*(.rel.gnu.linkonce.d*)}
158 }
159 .rela.data ${RELOCATING-0} :
160 {
161 *(.rela.data)
162 ${RELOCATING+*(.rela.data.*)}
163 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
164 }
165 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
166 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
167 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
168 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
169 .rel.got ${RELOCATING-0} : { *(.rel.got) }
170 .rela.got ${RELOCATING-0} : { *(.rela.got) }
171 ${OTHER_GOT_RELOC_SECTIONS}
172 .rel.sdata ${RELOCATING-0} :
173 {
174 *(.rel.sdata)
175 ${RELOCATING+*(.rel.sdata.*)}
176 ${RELOCATING+*(.rel.gnu.linkonce.s*)}
177 }
178 .rela.sdata ${RELOCATING-0} :
179 {
180 *(.rela.sdata)
181 ${RELOCATING+*(.rela.sdata.*)}
182 ${RELOCATING+*(.rela.gnu.linkonce.s*)}
183 }
184 .rel.sbss ${RELOCATING-0} : { *(.rel.sbss) }
185 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) }
186 .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
187 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
188 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
189 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
190
191 .init ${RELOCATING-0} :
192 {
193 ${INIT_START}
194 KEEP (*(.init))
195 ${INIT_END}
196 } =${NOP-0}
197
198 ${DATA_PLT-${PLT}}
199 .text ${RELOCATING-0} :
200 {
201 ${RELOCATING+${TEXT_START_SYMBOLS}}
202 *(.text)
203 ${RELOCATING+*(.text.*)}
204 *(.stub)
205 /* .gnu.warning sections are handled specially by elf32.em. */
206 *(.gnu.warning)
207 ${RELOCATING+*(.gnu.linkonce.t*)}
208 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
209 } =${NOP-0}
210 ${RELOCATING+_etext = .;}
211 ${RELOCATING+PROVIDE (etext = .);}
212 .fini ${RELOCATING-0} :
213 {
214 ${FINI_START}
215 KEEP (*(.fini))
216 ${FINI_END}
217 } =${NOP-0}
218 ${WRITABLE_RODATA-${RODATA}}
219 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
220 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
221
222 /* Adjust the address for the data segment. We want to adjust up to
223 the same address within the page on the next page up. */
224 ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
225 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
226
227 .data ${RELOCATING-0} :
228 {
229 ${RELOCATING+${DATA_START_SYMBOLS}}
230 *(.data)
231 ${RELOCATING+*(.data.*)}
232 ${RELOCATING+*(.gnu.linkonce.d*)}
233 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
234 }
235 .data1 ${RELOCATING-0} : { *(.data1) }
236 .eh_frame : { *(.eh_frame) }
237 .gcc_except_table : { *(.gcc_except_table) }
238 ${WRITABLE_RODATA+${RODATA}}
239 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
240 ${RELOCATING+${CTOR}}
241 ${RELOCATING+${DTOR}}
242 ${DATA_PLT+${PLT}}
243 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
244 .got ${RELOCATING-0} : { *(.got.plt) *(.got) }
245 ${TEXT_DYNAMIC-${DYNAMIC}}
246 /* We want the small data sections together, so single-instruction offsets
247 can access them all, and initialized data all before uninitialized, so
248 we can shorten the on-disk segment size. */
249 .sdata ${RELOCATING-0} :
250 {
251 ${RELOCATING+${SDATA_START_SYMBOLS}}
252 *(.sdata)
253 ${RELOCATING+*(.sdata.*)}
254 ${RELOCATING+*(.gnu.linkonce.s.*)}
255 }
256 ${RELOCATING+${OTHER_GOT_SECTIONS}}
257 ${RELOCATING+_edata = .;}
258 ${RELOCATING+PROVIDE (edata = .);}
259 ${RELOCATING+__bss_start = .;}
260 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
261 .sbss ${RELOCATING-0} :
262 {
263 *(.dynsbss)
264 *(.sbss)
265 ${RELOCATING+*(.sbss.*)}
266 *(.scommon)
267 }
268 .bss ${RELOCATING-0} :
269 {
270 *(.dynbss)
271 *(.bss)
272 ${RELOCATING+*(.bss.*)}
273 *(COMMON)
274 /* Align here to ensure that the .bss section occupies space up to
275 _end. Align after .bss to ensure correct alignment even if the
276 .bss section disappears because there are no input sections. */
277 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
278 }
279 ${RELOCATING+${OTHER_BSS_SECTIONS}}
280 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
281 ${RELOCATING+_end = .;}
282 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
283 ${RELOCATING+PROVIDE (end = .);}
284
285 /* Stabs debugging sections. */
286 .stab 0 : { *(.stab) }
287 .stabstr 0 : { *(.stabstr) }
288 .stab.excl 0 : { *(.stab.excl) }
289 .stab.exclstr 0 : { *(.stab.exclstr) }
290 .stab.index 0 : { *(.stab.index) }
291 .stab.indexstr 0 : { *(.stab.indexstr) }
292
293 .comment 0 : { *(.comment) }
294
295 /* DWARF debug sections.
296 Symbols in the DWARF debugging sections are relative to the beginning
297 of the section so we begin them at 0. */
298
299 /* DWARF 1 */
300 .debug 0 : { *(.debug) }
301 .line 0 : { *(.line) }
302
303 /* GNU DWARF 1 extensions */
304 .debug_srcinfo 0 : { *(.debug_srcinfo) }
305 .debug_sfnames 0 : { *(.debug_sfnames) }
306
307 /* DWARF 1.1 and DWARF 2 */
308 .debug_aranges 0 : { *(.debug_aranges) }
309 .debug_pubnames 0 : { *(.debug_pubnames) }
310
311 /* DWARF 2 */
312 .debug_info 0 : { *(.debug_info) }
313 .debug_abbrev 0 : { *(.debug_abbrev) }
314 .debug_line 0 : { *(.debug_line) }
315 .debug_frame 0 : { *(.debug_frame) }
316 .debug_str 0 : { *(.debug_str) }
317 .debug_loc 0 : { *(.debug_loc) }
318 .debug_macinfo 0 : { *(.debug_macinfo) }
319
320 /* SGI/MIPS DWARF 2 extensions */
321 .debug_weaknames 0 : { *(.debug_weaknames) }
322 .debug_funcnames 0 : { *(.debug_funcnames) }
323 .debug_typenames 0 : { *(.debug_typenames) }
324 .debug_varnames 0 : { *(.debug_varnames) }
325
326 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
327
328 /* These must appear regardless of ${RELOCATING}. */
329 ${OTHER_SECTIONS}
330 }
331 EOF
This page took 0.059524 seconds and 5 git commands to generate.