* emultempl/armelf.em (gld_armelf_before_allocation):
[deliverable/binutils-gdb.git] / ld / scripttempl / elfarm.sc
CommitLineData
020c70e9
CM
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
33test -z "$ENTRY" && ENTRY=_start
34test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
35test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
36if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
37test -z "${ELFSIZE}" && ELFSIZE=32
38test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
39test "$LD_FLAG" = "N" && DATA_ADDR=.
40INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
41PLT=".plt ${RELOCATING-0} : { *(.plt) }"
42DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
43
44# if this is for an embedded system, don't add SIZEOF_HEADERS.
45if [ -z "$EMBEDDED" ]; then
46 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
47else
48 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
49fi
50
51cat <<EOF
52OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
53 "${LITTLE_OUTPUT_FORMAT}")
54OUTPUT_ARCH(${OUTPUT_ARCH})
55ENTRY(${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
67SECTIONS
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}}
b3bd5b15 133 .text ${RELOCATING-0} :
020c70e9
CM
134 {
135 ${RELOCATING+${TEXT_START_SYMBOLS}}
136 *(.text)
527c54a6
CM
137 *(.glue_7t)
138 *(.glue_7)
020c70e9
CM
139 ${RELOCATING+*(.text.*)}
140 *(.stub)
141 /* .gnu.warning sections are handled specially by elf32.em. */
142 *(.gnu.warning)
143 ${RELOCATING+*(.gnu.linkonce.t*)}
144 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
145 } =${NOP-0}
146 ${RELOCATING+_etext = .;}
147 ${RELOCATING+PROVIDE (etext = .);}
148 .fini ${RELOCATING-0} : { KEEP (*(.fini)) } =${NOP-0}
149 .rodata ${RELOCATING-0} :
150 {
151 *(.rodata)
152 ${RELOCATING+*(.rodata.*)}
153 ${RELOCATING+*(.gnu.linkonce.r*)}
154 }
155 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
156 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
157
158 /* Adjust the address for the data segment. We want to adjust up to
159 the same address within the page on the next page up. */
160 ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
161 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
162
163 .data ${RELOCATING-0} :
164 {
165 ${RELOCATING+${DATA_START_SYMBOLS}}
166 *(.data)
167 ${RELOCATING+*(.data.*)}
168 ${RELOCATING+*(.gnu.linkonce.d*)}
169 ${CONSTRUCTING+CONSTRUCTORS}
170 }
171 .data1 ${RELOCATING-0} : { *(.data1) }
172 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
173 .ctors ${RELOCATING-0} :
174 {
175 ${CONSTRUCTING+${CTOR_START}}
176 /* gcc uses crtbegin.o to find the start of the constructors, so
177 we make sure it is first. Because this is a wildcard, it
178 doesn't matter if the user does not actually link against
179 crtbegin.o; the linker won't look for a file to match a
180 wildcard. The wildcard also means that it doesn't matter which
181 directory crtbegin.o is in. */
182 KEEP (*crtbegin.o(.ctors))
183 KEEP (*(SORT(.ctors.*)))
184 KEEP (*(.ctors))
185 ${CONSTRUCTING+${CTOR_END}}
186 }
187 .dtors ${RELOCATING-0} :
188 {
189 ${CONSTRUCTING+${DTOR_START}}
190 KEEP (*crtbegin.o(.dtors))
191 KEEP (*(SORT(.dtors.*)))
192 KEEP (*(.dtors))
193 ${CONSTRUCTING+${DTOR_END}}
194 }
195 ${DATA_PLT+${PLT}}
196 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
197 .got ${RELOCATING-0} : { *(.got.plt) *(.got) }
198 ${TEXT_DYNAMIC-${DYNAMIC}}
199 /* We want the small data sections together, so single-instruction offsets
200 can access them all, and initialized data all before uninitialized, so
201 we can shorten the on-disk segment size. */
202 .sdata ${RELOCATING-0} : { *(.sdata) }
203 ${RELOCATING+${OTHER_GOT_SECTIONS}}
204 ${RELOCATING+_edata = .;}
205 ${RELOCATING+PROVIDE (edata = .);}
206 ${RELOCATING+__bss_start = .;}
207 ${RELOCATING+__bss_start__ = .;}
208 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
209 .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) }
210 .bss ${RELOCATING-0} :
211 {
212 *(.dynbss)
213 *(.bss)
214 *(COMMON)
215 }
216 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
217 ${RELOCATING+_end = . ;}
218 ${RELOCATING+_bss_end__ = . ;}
45834a73 219 ${RELOCATING+__bss_end__ = . ;}
020c70e9
CM
220 ${RELOCATING+PROVIDE (end = .);}
221
222 /* Stabs debugging sections. */
223 .stab 0 : { *(.stab) }
224 .stabstr 0 : { *(.stabstr) }
225 .stab.excl 0 : { *(.stab.excl) }
226 .stab.exclstr 0 : { *(.stab.exclstr) }
227 .stab.index 0 : { *(.stab.index) }
228 .stab.indexstr 0 : { *(.stab.indexstr) }
229
230 .comment 0 : { *(.comment) }
231
232 /* DWARF debug sections.
233 Symbols in the DWARF debugging sections are relative to the beginning
234 of the section so we begin them at 0. */
235
236 /* DWARF 1 */
237 .debug 0 : { *(.debug) }
238 .line 0 : { *(.line) }
239
240 /* GNU DWARF 1 extensions */
241 .debug_srcinfo 0 : { *(.debug_srcinfo) }
242 .debug_sfnames 0 : { *(.debug_sfnames) }
243
244 /* DWARF 1.1 and DWARF 2 */
245 .debug_aranges 0 : { *(.debug_aranges) }
246 .debug_pubnames 0 : { *(.debug_pubnames) }
247
248 /* DWARF 2 */
249 .debug_info 0 : { *(.debug_info) }
250 .debug_abbrev 0 : { *(.debug_abbrev) }
251 .debug_line 0 : { *(.debug_line) }
252 .debug_frame 0 : { *(.debug_frame) }
253 .debug_str 0 : { *(.debug_str) }
254 .debug_loc 0 : { *(.debug_loc) }
255 .debug_macinfo 0 : { *(.debug_macinfo) }
256
257 /* SGI/MIPS DWARF 2 extensions */
258 .debug_weaknames 0 : { *(.debug_weaknames) }
259 .debug_funcnames 0 : { *(.debug_funcnames) }
260 .debug_typenames 0 : { *(.debug_typenames) }
261 .debug_varnames 0 : { *(.debug_varnames) }
262
263 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
264
265 /* These must appear regardless of ${RELOCATING}. */
266 ${OTHER_SECTIONS}
267}
268EOF
This page took 0.035127 seconds and 4 git commands to generate.