]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/elf.sc
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / ld / scripttempl / elf.sc
CommitLineData
267a3ab3
ILT
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
26c7ca95 5# INITIAL_READONLY_SECTIONS - at start of text segment
fa247c00 6# OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
267a3ab3 7# (e.g., .PARISC.milli)
26c7ca95 8# OTHER_TEXT_SECTIONS - these get put in .text when relocating
fa247c00 9# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
267a3ab3 10# (e.g., .PARISC.global)
31ddb156 11# OTHER_SECTIONS - at the end
267a3ab3
ILT
12# EXECUTABLE_SYMBOLS - symbols that must be defined for an
13# executable (e.g., _DYNAMIC_LINK)
2a9fa50c
ILT
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.
26c7ca95
ILT
18# OTHER_GOT_SYMBOLS - symbols defined just before .got.
19# OTHER_GOT_SECTIONS - sections just after .got and .sdata.
bff600cf
ILT
20# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
21# .bss section besides __bss_start.
2a9fa50c 22# DATA_PLT - .plt should be in data segment, not text segment.
26c7ca95 23# TEXT_DYNAMIC - .dynamic in text segment, not data segment.
3d046499 24# EMBEDDED - whether this is for an embedded system.
26c7ca95
ILT
25# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
26# start address of shared library.
63bb5e9a 27# INPUT_FILES - INPUT command of files to always include
267a3ab3
ILT
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#
26c7ca95 32
fa247c00 33test -z "$ENTRY" && ENTRY=_start
cd1d4f83
ILT
34test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
35test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
18f0961e 36if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
26c7ca95 37test -z "${ELFSIZE}" && ELFSIZE=32
63bb5e9a 38test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
cd1d4f83 39test "$LD_FLAG" = "N" && DATA_ADDR=.
31ddb156 40INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
2a9fa50c 41PLT=".plt ${RELOCATING-0} : { *(.plt) }"
26c7ca95 42DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
3d046499
ILT
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
f90bb826 51cat <<EOF
cd1d4f83
ILT
52OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
53 "${LITTLE_OUTPUT_FORMAT}")
18f0961e 54OUTPUT_ARCH(${OUTPUT_ARCH})
fa247c00 55ENTRY(${ENTRY})
f90bb826
KR
56
57${RELOCATING+${LIB_SEARCH_DIRS}}
267a3ab3
ILT
58${RELOCATING+/* Do we need any of these for elf?
59 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
60${RELOCATING+${EXECUTABLE_SYMBOLS}}
63bb5e9a 61${RELOCATING+${INPUT_FILES}}
267a3ab3
ILT
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. */}
63bb5e9a 66
f90bb826
KR
67SECTIONS
68{
267a3ab3 69 /* Read-only sections, merged into text segment: */
3d046499 70 ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}
26c7ca95 71 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
31ddb156 72 ${CREATE_SHLIB-${INTERP}}
26c7ca95
ILT
73 ${INITIAL_READONLY_SECTIONS}
74 ${TEXT_DYNAMIC+${DYNAMIC}}
cd1d4f83
ILT
75 .hash ${RELOCATING-0} : { *(.hash) }
76 .dynsym ${RELOCATING-0} : { *(.dynsym) }
77 .dynstr ${RELOCATING-0} : { *(.dynstr) }
3d046499
ILT
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} :
63bb5e9a
ILT
82 {
83 *(.rel.text)
84 ${RELOCATING+*(.rel.text.*)}
85 ${RELOCATING+*(.rel.gnu.linkonce.t*)}
86 }
3d046499 87 .rela.text ${RELOCATING-0} :
63bb5e9a
ILT
88 {
89 *(.rela.text)
90 ${RELOCATING+*(.rela.text.*)}
91 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
92 }
3d046499 93 .rel.data ${RELOCATING-0} :
63bb5e9a
ILT
94 {
95 *(.rel.data)
96 ${RELOCATING+*(.rel.data.*)}
97 ${RELOCATING+*(.rel.gnu.linkonce.d*)}
98 }
3d046499 99 .rela.data ${RELOCATING-0} :
63bb5e9a
ILT
100 {
101 *(.rela.data)
102 ${RELOCATING+*(.rela.data.*)}
103 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
104 }
3d046499 105 .rel.rodata ${RELOCATING-0} :
63bb5e9a
ILT
106 {
107 *(.rel.rodata)
108 ${RELOCATING+*(.rel.rodata.*)}
109 ${RELOCATING+*(.rel.gnu.linkonce.r*)}
110 }
3d046499 111 .rela.rodata ${RELOCATING-0} :
63bb5e9a
ILT
112 {
113 *(.rela.rodata)
114 ${RELOCATING+*(.rela.rodata.*)}
115 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
116 }
cd1d4f83
ILT
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) }
63bb5e9a 131 .init ${RELOCATING-0} : { KEEP (*(.init)) } =${NOP-0}
2a9fa50c
ILT
132 ${DATA_PLT-${PLT}}
133 .text ${RELOCATING-0} :
f90bb826 134 {
2a9fa50c 135 ${RELOCATING+${TEXT_START_SYMBOLS}}
f90bb826 136 *(.text)
63bb5e9a 137 ${RELOCATING+*(.text.*)}
26c7ca95 138 *(.stub)
fa247c00
ILT
139 /* .gnu.warning sections are handled specially by elf32.em. */
140 *(.gnu.warning)
26c7ca95
ILT
141 ${RELOCATING+*(.gnu.linkonce.t*)}
142 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
fa247c00 143 } =${NOP-0}
2a9fa50c 144 ${RELOCATING+_etext = .;}
31ddb156 145 ${RELOCATING+PROVIDE (etext = .);}
63bb5e9a
ILT
146 .fini ${RELOCATING-0} : { KEEP (*(.fini)) } =${NOP-0}
147 .rodata ${RELOCATING-0} :
148 {
149 *(.rodata)
150 ${RELOCATING+*(.rodata.*)}
151 ${RELOCATING+*(.gnu.linkonce.r*)}
152 }
2a9fa50c 153 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
267a3ab3 154 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
267a3ab3 155
18f0961e
ILT
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. */
26c7ca95
ILT
158 ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
159 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
18f0961e 160
2a9fa50c 161 .data ${RELOCATING-0} :
f90bb826 162 {
2a9fa50c 163 ${RELOCATING+${DATA_START_SYMBOLS}}
f90bb826 164 *(.data)
63bb5e9a 165 ${RELOCATING+*(.data.*)}
26c7ca95 166 ${RELOCATING+*(.gnu.linkonce.d*)}
63bb5e9a 167 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
f90bb826 168 }
2a9fa50c 169 .data1 ${RELOCATING-0} : { *(.data1) }
267a3ab3 170 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
3d046499
ILT
171 .ctors ${RELOCATING-0} :
172 {
173 ${CONSTRUCTING+${CTOR_START}}
63bb5e9a
ILT
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))
3d046499
ILT
183 ${CONSTRUCTING+${CTOR_END}}
184 }
185 .dtors ${RELOCATING-0} :
186 {
187 ${CONSTRUCTING+${DTOR_START}}
63bb5e9a
ILT
188 KEEP (*crtbegin.o(.dtors))
189 KEEP (*(SORT(.dtors.*)))
190 KEEP (*(.dtors))
3d046499
ILT
191 ${CONSTRUCTING+${DTOR_END}}
192 }
193 ${DATA_PLT+${PLT}}
26c7ca95 194 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
cd1d4f83 195 .got ${RELOCATING-0} : { *(.got.plt) *(.got) }
26c7ca95 196 ${TEXT_DYNAMIC-${DYNAMIC}}
267a3ab3
ILT
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. */
2a9fa50c 200 .sdata ${RELOCATING-0} : { *(.sdata) }
26c7ca95 201 ${RELOCATING+${OTHER_GOT_SECTIONS}}
bff600cf 202 ${RELOCATING+_edata = .;}
31ddb156 203 ${RELOCATING+PROVIDE (edata = .);}
2a9fa50c 204 ${RELOCATING+__bss_start = .;}
bff600cf 205 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
2a9fa50c
ILT
206 .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) }
207 .bss ${RELOCATING-0} :
f90bb826 208 {
2a9fa50c 209 *(.dynbss)
f90bb826
KR
210 *(.bss)
211 *(COMMON)
f90bb826 212 }
63bb5e9a 213 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
2a9fa50c 214 ${RELOCATING+_end = . ;}
31ddb156
ILT
215 ${RELOCATING+PROVIDE (end = .);}
216
18f0961e 217 /* Stabs debugging sections. */
31ddb156
ILT
218 .stab 0 : { *(.stab) }
219 .stabstr 0 : { *(.stabstr) }
18f0961e
ILT
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.
3d046499
ILT
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 */
18f0961e 232 .debug 0 : { *(.debug) }
3d046499
ILT
233 .line 0 : { *(.line) }
234
235 /* GNU DWARF 1 extensions */
18f0961e 236 .debug_srcinfo 0 : { *(.debug_srcinfo) }
3d046499
ILT
237 .debug_sfnames 0 : { *(.debug_sfnames) }
238
239 /* DWARF 1.1 and DWARF 2 */
18f0961e
ILT
240 .debug_aranges 0 : { *(.debug_aranges) }
241 .debug_pubnames 0 : { *(.debug_pubnames) }
3d046499
ILT
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}}
31ddb156
ILT
259
260 /* These must appear regardless of ${RELOCATING}. */
261 ${OTHER_SECTIONS}
f90bb826
KR
262}
263EOF