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
17 # DATA_START_SYMBOLS - symbols that appear at the start of the
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.
35 # When adding sections, do note that the names of some sections are used
36 # when specifying the start address of the next.
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} :
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
63 KEEP (*crtbegin.o(.ctors))
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 */
70 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
71 KEEP (*(SORT(.ctors.*)))
73 ${CONSTRUCTING+${CTOR_END}}
76 DTOR=" .dtors ${CONSTRUCTING-0} :
78 ${CONSTRUCTING+${DTOR_START}}
79 KEEP (*crtbegin.o(.dtors))
80 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
81 KEEP (*(SORT(.dtors.*)))
83 ${CONSTRUCTING+${DTOR_END}}
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"
90 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
94 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
95 "${LITTLE_OUTPUT_FORMAT}")
96 OUTPUT_ARCH(${OUTPUT_ARCH})
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. */}
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) }
124 .rel.init ${RELOCATING-0} : { *(.rel.init) }
125 .rela.init ${RELOCATING-0} : { *(.rela.init) }
126 .rel.text ${RELOCATING-0} :
129 ${RELOCATING+*(.rel.text.*)}
130 ${RELOCATING+*(.rel.gnu.linkonce.t*)}
132 .rela.text ${RELOCATING-0} :
135 ${RELOCATING+*(.rela.text.*)}
136 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
138 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
139 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
140 .rel.rodata ${RELOCATING-0} :
143 ${RELOCATING+*(.rel.rodata.*)}
144 ${RELOCATING+*(.rel.gnu.linkonce.r*)}
146 .rela.rodata ${RELOCATING-0} :
149 ${RELOCATING+*(.rela.rodata.*)}
150 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
152 ${OTHER_READONLY_RELOC_SECTIONS}
153 .rel.data ${RELOCATING-0} :
156 ${RELOCATING+*(.rel.data.*)}
157 ${RELOCATING+*(.rel.gnu.linkonce.d*)}
159 .rela.data ${RELOCATING-0} :
162 ${RELOCATING+*(.rela.data.*)}
163 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
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} :
175 ${RELOCATING+*(.rel.sdata.*)}
176 ${RELOCATING+*(.rel.gnu.linkonce.s*)}
178 .rela.sdata ${RELOCATING-0} :
181 ${RELOCATING+*(.rela.sdata.*)}
182 ${RELOCATING+*(.rela.gnu.linkonce.s*)}
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) }
191 .init ${RELOCATING-0} :
199 .text ${RELOCATING-0} :
201 ${RELOCATING+${TEXT_START_SYMBOLS}}
203 ${RELOCATING+*(.text.*)}
205 /* .gnu.warning sections are handled specially by elf32.em. */
207 ${RELOCATING+*(.gnu.linkonce.t*)}
208 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
210 ${RELOCATING+_etext = .;}
211 ${RELOCATING+PROVIDE (etext = .);}
212 .fini ${RELOCATING-0} :
218 ${WRITABLE_RODATA-${RODATA}}
219 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
220 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
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))};}}
227 .data ${RELOCATING-0} :
229 ${RELOCATING+${DATA_START_SYMBOLS}}
231 ${RELOCATING+*(.data.*)}
232 ${RELOCATING+*(.gnu.linkonce.d*)}
233 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
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}}
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} :
251 ${RELOCATING+${SDATA_START_SYMBOLS}}
253 ${RELOCATING+*(.sdata.*)}
254 ${RELOCATING+*(.gnu.linkonce.s.*)}
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} :
265 ${RELOCATING+*(.sbss.*)}
268 .bss ${RELOCATING-0} :
272 ${RELOCATING+*(.bss.*)}
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});}
279 ${RELOCATING+${OTHER_BSS_SECTIONS}}
280 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
281 ${RELOCATING+_end = .;}
282 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
283 ${RELOCATING+PROVIDE (end = .);}
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) }
293 .comment 0 : { *(.comment) }
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. */
300 .debug 0 : { *(.debug) }
301 .line 0 : { *(.line) }
303 /* GNU DWARF 1 extensions */
304 .debug_srcinfo 0 : { *(.debug_srcinfo) }
305 .debug_sfnames 0 : { *(.debug_sfnames) }
307 /* DWARF 1.1 and DWARF 2 */
308 .debug_aranges 0 : { *(.debug_aranges) }
309 .debug_pubnames 0 : { *(.debug_pubnames) }
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) }
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) }
326 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
328 /* These must appear regardless of ${RELOCATING}. */