* scripttempl/elf.sc (.sdata): Include .gnu.linkonce.s.* sections
[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.bss ${RELOCATING-0} : { *(.rel.bss) }
173 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
174 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
175 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
176
177 .init ${RELOCATING-0} :
178 {
179 ${INIT_START}
180 KEEP (*(.init))
181 ${INIT_END}
182 } =${NOP-0}
183
184 ${DATA_PLT-${PLT}}
185 .text ${RELOCATING-0} :
186 {
187 ${RELOCATING+${TEXT_START_SYMBOLS}}
188 *(.text)
189 ${RELOCATING+*(.text.*)}
190 *(.stub)
191 /* .gnu.warning sections are handled specially by elf32.em. */
192 *(.gnu.warning)
193 ${RELOCATING+*(.gnu.linkonce.t*)}
194 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
195 } =${NOP-0}
196 ${RELOCATING+_etext = .;}
197 ${RELOCATING+PROVIDE (etext = .);}
198 .fini ${RELOCATING-0} :
199 {
200 ${FINI_START}
201 KEEP (*(.fini))
202 ${FINI_END}
203 } =${NOP-0}
204 ${WRITABLE_RODATA-${RODATA}}
205 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
206 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
207
208 /* Adjust the address for the data segment. We want to adjust up to
209 the same address within the page on the next page up. */
210 ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
211 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
212
213 .data ${RELOCATING-0} :
214 {
215 ${RELOCATING+${DATA_START_SYMBOLS}}
216 *(.data)
217 ${RELOCATING+*(.data.*)}
218 ${RELOCATING+*(.gnu.linkonce.d*)}
219 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
220 }
221 .data1 ${RELOCATING-0} : { *(.data1) }
222 .eh_frame : { *(.eh_frame) }
223 .gcc_except_table : { *(.gcc_except_table) }
224 ${WRITABLE_RODATA+${RODATA}}
225 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
226 ${RELOCATING+${CTOR}}
227 ${RELOCATING+${DTOR}}
228 ${DATA_PLT+${PLT}}
229 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
230 .got ${RELOCATING-0} : { *(.got.plt) *(.got) }
231 ${TEXT_DYNAMIC-${DYNAMIC}}
232 /* We want the small data sections together, so single-instruction offsets
233 can access them all, and initialized data all before uninitialized, so
234 we can shorten the on-disk segment size. */
235 .sdata ${RELOCATING-0} : { *(.sdata) *(.sdata.*) *(.gnu.linkonce.s.*) }
236 ${RELOCATING+${OTHER_GOT_SECTIONS}}
237 ${RELOCATING+_edata = .;}
238 ${RELOCATING+PROVIDE (edata = .);}
239 ${RELOCATING+__bss_start = .;}
240 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
241 .sbss ${RELOCATING-0} :
242 {
243 *(.sbss) *(.scommon)
244 ${RELOCATING+*(.sbss.*)}
245 }
246 .bss ${RELOCATING-0} :
247 {
248 *(.dynbss)
249 *(.bss)
250 ${RELOCATING+*(.bss.*)}
251 *(COMMON)
252 /* Align here to ensure that the .bss section occupies space up to
253 _end. Align after .bss to ensure correct alignment even if the
254 .bss section disappears because there are no input sections. */
255 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
256 }
257 ${RELOCATING+${OTHER_BSS_SECTIONS}}
258 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
259 ${RELOCATING+_end = .;}
260 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
261 ${RELOCATING+PROVIDE (end = .);}
262
263 /* Stabs debugging sections. */
264 .stab 0 : { *(.stab) }
265 .stabstr 0 : { *(.stabstr) }
266 .stab.excl 0 : { *(.stab.excl) }
267 .stab.exclstr 0 : { *(.stab.exclstr) }
268 .stab.index 0 : { *(.stab.index) }
269 .stab.indexstr 0 : { *(.stab.indexstr) }
270
271 .comment 0 : { *(.comment) }
272
273 /* DWARF debug sections.
274 Symbols in the DWARF debugging sections are relative to the beginning
275 of the section so we begin them at 0. */
276
277 /* DWARF 1 */
278 .debug 0 : { *(.debug) }
279 .line 0 : { *(.line) }
280
281 /* GNU DWARF 1 extensions */
282 .debug_srcinfo 0 : { *(.debug_srcinfo) }
283 .debug_sfnames 0 : { *(.debug_sfnames) }
284
285 /* DWARF 1.1 and DWARF 2 */
286 .debug_aranges 0 : { *(.debug_aranges) }
287 .debug_pubnames 0 : { *(.debug_pubnames) }
288
289 /* DWARF 2 */
290 .debug_info 0 : { *(.debug_info) }
291 .debug_abbrev 0 : { *(.debug_abbrev) }
292 .debug_line 0 : { *(.debug_line) }
293 .debug_frame 0 : { *(.debug_frame) }
294 .debug_str 0 : { *(.debug_str) }
295 .debug_loc 0 : { *(.debug_loc) }
296 .debug_macinfo 0 : { *(.debug_macinfo) }
297
298 /* SGI/MIPS DWARF 2 extensions */
299 .debug_weaknames 0 : { *(.debug_weaknames) }
300 .debug_funcnames 0 : { *(.debug_funcnames) }
301 .debug_typenames 0 : { *(.debug_typenames) }
302 .debug_varnames 0 : { *(.debug_varnames) }
303
304 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
305
306 /* These must appear regardless of ${RELOCATING}. */
307 ${OTHER_SECTIONS}
308 }
309 EOF
This page took 0.038585 seconds and 5 git commands to generate.