1999-01-31 17:57:31 1998 Michael Meissner <meissner@cygnus.com>
[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_SECTIONS - at the end
12 # EXECUTABLE_SYMBOLS - symbols that must be defined for an
13 # executable (e.g., _DYNAMIC_LINK)
14 # TEXT_START_SYMBOLS - symbols that appear at the start of the
15 # .text section.
16 # DATA_START_SYMBOLS - symbols that appear at the start of the
17 # .data section.
18 # OTHER_GOT_SYMBOLS - symbols defined just before .got.
19 # OTHER_GOT_SECTIONS - sections just after .got and .sdata.
20 # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
21 # .bss section besides __bss_start.
22 # DATA_PLT - .plt should be in data segment, not text segment.
23 # TEXT_DYNAMIC - .dynamic in text segment, not data segment.
24 # EMBEDDED - whether this is for an embedded system.
25 # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
26 # start address of shared library.
27 # INPUT_FILES - INPUT command of files to always include
28 #
29 # When adding sections, do note that the names of some sections are used
30 # when specifying the start address of the next.
31 #
32
33 test -z "$ENTRY" && ENTRY=_start
34 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
35 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
36 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
37 test -z "${ELFSIZE}" && ELFSIZE=32
38 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
39 test "$LD_FLAG" = "N" && DATA_ADDR=.
40 INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
41 PLT=".plt ${RELOCATING-0} : { *(.plt) }"
42 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
43
44 # if this is for an embedded system, don't add SIZEOF_HEADERS.
45 if [ -z "$EMBEDDED" ]; then
46 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
47 else
48 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
49 fi
50
51 cat <<EOF
52 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
53 "${LITTLE_OUTPUT_FORMAT}")
54 OUTPUT_ARCH(${OUTPUT_ARCH})
55 ENTRY(${ENTRY})
56
57 ${RELOCATING+${LIB_SEARCH_DIRS}}
58 ${RELOCATING+/* Do we need any of these for elf?
59 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
60 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
61 ${RELOCATING+${INPUT_FILES}}
62 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
63 if gld -r is used and the intermediate file has sections starting
64 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
65 bug. But for now assigning the zero vmas works. */}
66
67 SECTIONS
68 {
69 /* Read-only sections, merged into text segment: */
70 ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}
71 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
72 ${CREATE_SHLIB-${INTERP}}
73 ${INITIAL_READONLY_SECTIONS}
74 ${TEXT_DYNAMIC+${DYNAMIC}}
75 .hash ${RELOCATING-0} : { *(.hash) }
76 .dynsym ${RELOCATING-0} : { *(.dynsym) }
77 .dynstr ${RELOCATING-0} : { *(.dynstr) }
78 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
79 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
80 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
81 .rel.text ${RELOCATING-0} :
82 {
83 *(.rel.text)
84 ${RELOCATING+*(.rel.text.*)}
85 ${RELOCATING+*(.rel.gnu.linkonce.t*)}
86 }
87 .rela.text ${RELOCATING-0} :
88 {
89 *(.rela.text)
90 ${RELOCATING+*(.rela.text.*)}
91 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
92 }
93 .rel.data ${RELOCATING-0} :
94 {
95 *(.rel.data)
96 ${RELOCATING+*(.rel.data.*)}
97 ${RELOCATING+*(.rel.gnu.linkonce.d*)}
98 }
99 .rela.data ${RELOCATING-0} :
100 {
101 *(.rela.data)
102 ${RELOCATING+*(.rela.data.*)}
103 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
104 }
105 .rel.rodata ${RELOCATING-0} :
106 {
107 *(.rel.rodata)
108 ${RELOCATING+*(.rel.rodata.*)}
109 ${RELOCATING+*(.rel.gnu.linkonce.r*)}
110 }
111 .rela.rodata ${RELOCATING-0} :
112 {
113 *(.rela.rodata)
114 ${RELOCATING+*(.rela.rodata.*)}
115 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
116 }
117 .rel.got ${RELOCATING-0} : { *(.rel.got) }
118 .rela.got ${RELOCATING-0} : { *(.rela.got) }
119 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
120 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
121 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
122 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
123 .rel.init ${RELOCATING-0} : { *(.rel.init) }
124 .rela.init ${RELOCATING-0} : { *(.rela.init) }
125 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
126 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
127 .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
128 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
129 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
130 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
131 .init ${RELOCATING-0} : { KEEP (*(.init)) } =${NOP-0}
132 ${DATA_PLT-${PLT}}
133 .text ${RELOCATING-0} :
134 {
135 ${RELOCATING+${TEXT_START_SYMBOLS}}
136 *(.text)
137 ${RELOCATING+*(.text.*)}
138 *(.stub)
139 /* .gnu.warning sections are handled specially by elf32.em. */
140 *(.gnu.warning)
141 ${RELOCATING+*(.gnu.linkonce.t*)}
142 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
143 } =${NOP-0}
144 ${RELOCATING+_etext = .;}
145 ${RELOCATING+PROVIDE (etext = .);}
146 .fini ${RELOCATING-0} : { KEEP (*(.fini)) } =${NOP-0}
147 .rodata ${RELOCATING-0} :
148 {
149 *(.rodata)
150 ${RELOCATING+*(.rodata.*)}
151 ${RELOCATING+*(.gnu.linkonce.r*)}
152 }
153 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
154 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
155
156 /* Adjust the address for the data segment. We want to adjust up to
157 the same address within the page on the next page up. */
158 ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
159 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
160
161 .data ${RELOCATING-0} :
162 {
163 ${RELOCATING+${DATA_START_SYMBOLS}}
164 *(.data)
165 ${RELOCATING+*(.data.*)}
166 ${RELOCATING+*(.gnu.linkonce.d*)}
167 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
168 }
169 .data1 ${RELOCATING-0} : { *(.data1) }
170 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
171 .ctors ${RELOCATING-0} :
172 {
173 ${CONSTRUCTING+${CTOR_START}}
174 /* gcc uses crtbegin.o to find the start of the constructors, so
175 we make sure it is first. Because this is a wildcard, it
176 doesn't matter if the user does not actually link against
177 crtbegin.o; the linker won't look for a file to match a
178 wildcard. The wildcard also means that it doesn't matter which
179 directory crtbegin.o is in. */
180 KEEP (*crtbegin.o(.ctors))
181 KEEP (*(SORT(.ctors.*)))
182 KEEP (*(.ctors))
183 ${CONSTRUCTING+${CTOR_END}}
184 }
185 .dtors ${RELOCATING-0} :
186 {
187 ${CONSTRUCTING+${DTOR_START}}
188 KEEP (*crtbegin.o(.dtors))
189 KEEP (*(SORT(.dtors.*)))
190 KEEP (*(.dtors))
191 ${CONSTRUCTING+${DTOR_END}}
192 }
193 ${DATA_PLT+${PLT}}
194 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
195 .got ${RELOCATING-0} : { *(.got.plt) *(.got) }
196 ${TEXT_DYNAMIC-${DYNAMIC}}
197 /* We want the small data sections together, so single-instruction offsets
198 can access them all, and initialized data all before uninitialized, so
199 we can shorten the on-disk segment size. */
200 .sdata ${RELOCATING-0} : { *(.sdata) }
201 ${RELOCATING+${OTHER_GOT_SECTIONS}}
202 ${RELOCATING+_edata = .;}
203 ${RELOCATING+PROVIDE (edata = .);}
204 ${RELOCATING+__bss_start = .;}
205 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
206 .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) }
207 .bss ${RELOCATING-0} :
208 {
209 *(.dynbss)
210 *(.bss)
211 *(COMMON)
212 }
213 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
214 ${RELOCATING+_end = . ;}
215 ${RELOCATING+PROVIDE (end = .);}
216
217 /* Stabs debugging sections. */
218 .stab 0 : { *(.stab) }
219 .stabstr 0 : { *(.stabstr) }
220 .stab.excl 0 : { *(.stab.excl) }
221 .stab.exclstr 0 : { *(.stab.exclstr) }
222 .stab.index 0 : { *(.stab.index) }
223 .stab.indexstr 0 : { *(.stab.indexstr) }
224
225 .comment 0 : { *(.comment) }
226
227 /* DWARF debug sections.
228 Symbols in the DWARF debugging sections are relative to the beginning
229 of the section so we begin them at 0. */
230
231 /* DWARF 1 */
232 .debug 0 : { *(.debug) }
233 .line 0 : { *(.line) }
234
235 /* GNU DWARF 1 extensions */
236 .debug_srcinfo 0 : { *(.debug_srcinfo) }
237 .debug_sfnames 0 : { *(.debug_sfnames) }
238
239 /* DWARF 1.1 and DWARF 2 */
240 .debug_aranges 0 : { *(.debug_aranges) }
241 .debug_pubnames 0 : { *(.debug_pubnames) }
242
243 /* DWARF 2 */
244 .debug_info 0 : { *(.debug_info) }
245 .debug_abbrev 0 : { *(.debug_abbrev) }
246 .debug_line 0 : { *(.debug_line) }
247 .debug_frame 0 : { *(.debug_frame) }
248 .debug_str 0 : { *(.debug_str) }
249 .debug_loc 0 : { *(.debug_loc) }
250 .debug_macinfo 0 : { *(.debug_macinfo) }
251
252 /* SGI/MIPS DWARF 2 extensions */
253 .debug_weaknames 0 : { *(.debug_weaknames) }
254 .debug_funcnames 0 : { *(.debug_funcnames) }
255 .debug_typenames 0 : { *(.debug_typenames) }
256 .debug_varnames 0 : { *(.debug_varnames) }
257
258 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
259
260 /* These must appear regardless of ${RELOCATING}. */
261 ${OTHER_SECTIONS}
262 }
263 EOF
This page took 0.0354 seconds and 4 git commands to generate.