* ldgram.y: Include "ldctor.h".
[deliverable/binutils-gdb.git] / ld / scripttempl / elfppc.sc
CommitLineData
5f16938d
MM
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
c2b6884b 5# OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
5f16938d 6# (e.g., .PARISC.milli)
c2b6884b 7# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
5f16938d
MM
8# (e.g., .PARISC.global)
9# OTHER_SECTIONS - at the end
10# EXECUTABLE_SYMBOLS - symbols that must be defined for an
11# executable (e.g., _DYNAMIC_LINK)
12# TEXT_START_SYMBOLS - symbols that appear at the start of the
13# .text section.
14# DATA_START_SYMBOLS - symbols that appear at the start of the
15# .data section.
16# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
17# .bss section besides __bss_start.
5f16938d
MM
18#
19# When adding sections, do note that the names of some sections are used
20# when specifying the start address of the next.
21#
22test -z "$ENTRY" && ENTRY=_start
23test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
24test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
25test "$LD_FLAG" = "N" && DATA_ADDR=.
c56c9218
C
26SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) }"
27SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) }"
28INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
29PLT=".plt ${RELOCATING-0} : { *(.plt) }"
5f16938d
MM
30cat <<EOF
31OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
32 "${LITTLE_OUTPUT_FORMAT}")
33OUTPUT_ARCH(${ARCH})
34ENTRY(${ENTRY})
35
36${RELOCATING+${LIB_SEARCH_DIRS}}
37${RELOCATING+/* Do we need any of these for elf?
38 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
39${RELOCATING+${EXECUTABLE_SYMBOLS}}
40${RELOCATING- /* For some reason, the Solaris linker makes bad executables
41 if gld -r is used and the intermediate file has sections starting
42 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
43 bug. But for now assigning the zero vmas works. */}
fb2a7661
MM
44
45${RELOCATING+PROVIDE (__stack = 0);}
5f16938d
MM
46SECTIONS
47{
48 /* Read-only sections, merged into text segment: */
49 ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}}
50 ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}}
51 ${CREATE_SHLIB-${INTERP}}
be03dc3e
MM
52 .hash ${RELOCATING-0} : { *(.hash) }
53 .dynsym ${RELOCATING-0} : { *(.dynsym) }
54 .dynstr ${RELOCATING-0} : { *(.dynstr) }
4602e5f4
ILT
55 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
56 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
57 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
f5f212fb 58 .rela.text ${RELOCATING-0} :
71b012a8
RH
59 {
60 *(.rela.text)
61 ${RELOCATING+*(.rela.text.*)}
62 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
63 }
f5f212fb 64 .rela.data ${RELOCATING-0} :
71b012a8
RH
65 {
66 *(.rela.data)
67 ${RELOCATING+*(.rela.data.*)}
68 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
69 }
f5f212fb 70 .rela.rodata ${RELOCATING-0} :
71b012a8
RH
71 {
72 *(.rela.rodata)
73 ${RELOCATING+*(.rela.rodata.*)}
74 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
75 }
be03dc3e 76 .rela.got ${RELOCATING-0} : { *(.rela.got) }
be03dc3e
MM
77 .rela.got1 ${RELOCATING-0} : { *(.rela.got1) }
78 .rela.got2 ${RELOCATING-0} : { *(.rela.got2) }
79 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
80 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
81 .rela.init ${RELOCATING-0} : { *(.rela.init) }
82 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
83 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
84 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
4602e5f4
ILT
85 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
86 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) }
c2b6884b
MM
87 .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2) }
88 .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2) }
5f16938d
MM
89 .text ${RELOCATING-0} :
90 {
91 ${RELOCATING+${TEXT_START_SYMBOLS}}
92 *(.text)
71b012a8 93 ${RELOCATING+*(.text.*)}
5f16938d
MM
94 /* .gnu.warning sections are handled specially by elf32.em. */
95 *(.gnu.warning)
71b012a8 96 ${RELOCATING+*(.gnu.linkonce.t*)}
5f16938d 97 } =${NOP-0}
71b012a8
RH
98 .init ${RELOCATING-0} : { KEEP (*(.init)) } =${NOP-0}
99 .fini ${RELOCATING-0} : { KEEP (*(.fini)) } =${NOP-0}
100 .rodata ${RELOCATING-0} :
101 {
102 *(.rodata)
103 ${RELOCATING+*(.rodata.*)}
104 ${RELOCATING+*(.gnu.linkonce.r*)}
105 }
c2b6884b 106 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
28ad0357
MM
107 ${RELOCATING+_etext = .;}
108 ${RELOCATING+PROVIDE (etext = .);}
c56c9218
C
109 ${CREATE_SHLIB-${SDATA2}}
110 ${CREATE_SHLIB-${SBSS2}}
5f16938d
MM
111 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
112
c2b6884b
MM
113 /* Adjust the address for the data segment. We want to adjust up to
114 the same address within the page on the next page up. It would
115 be more correct to do this:
116 ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (ALIGN(8) & (${MAXPAGESIZE} - 1))};}
117 The current expression does not correctly handle the case of a
118 text segment ending precisely at the end of a page; it causes the
119 data segment to skip a page. The above expression does not have
120 this problem, but it will currently (2/95) cause BFD to allocate
121 a single segment, combining both text and data, for this case.
122 This will prevent the text segment from being shared among
123 multiple executions of the program; I think that is more
124 important than losing a page of the virtual address space (note
125 that no actual memory is lost; the page which is skipped can not
126 be referenced). */
5f16938d 127 ${RELOCATING+. = ${DATA_ADDR- ALIGN(8) + ${MAXPAGESIZE}};}
c2b6884b 128
5f16938d
MM
129 .data ${RELOCATING-0} :
130 {
131 ${RELOCATING+${DATA_START_SYMBOLS}}
132 *(.data)
71b012a8
RH
133 ${RELOCATING+*(.data.*)}
134 ${RELOCATING+*(.gnu.linkonce.d*)}
5f16938d
MM
135 ${CONSTRUCTING+CONSTRUCTORS}
136 }
137 .data1 ${RELOCATING-0} : { *(.data1) }
138 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
5f16938d 139
4fe13b2b
MM
140 .got1 ${RELOCATING-0} : { *(.got1) }
141 .dynamic ${RELOCATING-0} : { *(.dynamic) }
dd0f9635 142
86d0248d 143 /* Put .ctors and .dtors next to the .got2 section, so that the pointers
4fe13b2b
MM
144 get relocated with -mrelocatable. Also put in the .fixup pointers.
145 The current compiler no longer needs this, but keep it around for 2.7.2 */
86d0248d 146
4d99a950 147 ${RELOCATING+PROVIDE (_GOT2_START_ = .);}
4fe13b2b
MM
148 .got2 ${RELOCATING-0} : { *(.got2) }
149
4d99a950 150 ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);}
b4c61dc9
ILT
151 .ctors ${RELOCATING-0} : {
152 /* gcc uses crtbegin.o to find the start of
153 the constructors, so we make sure it is
154 first. Because this is a wildcard, it
155 doesn't matter if the user does not
156 actually link against crtbegin.o; the
157 linker won't look for a file to match a
158 wildcard. The wildcard also means that it
159 doesn't matter which directory crtbegin.o
160 is in. */
71b012a8
RH
161 KEEP (*crtbegin.o(.ctors))
162 KEEP (*(SORT(.ctors.*)))
163 KEEP (*(.ctors)) }
4d99a950 164 ${RELOCATING+PROVIDE (__CTOR_END__ = .);}
4fe13b2b 165
4d99a950 166 ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);}
b4c61dc9 167 .dtors ${RELOCATING-0} : {
71b012a8
RH
168 KEEP (*crtbegin.o(.dtors))
169 KEEP (*(SORT(.dtors.*)))
170 KEEP (*(.dtors)) }
4d99a950 171 ${RELOCATING+PROVIDE (__DTOR_END__ = .);}
4fe13b2b 172
4d99a950 173 ${RELOCATING+PROVIDE (_FIXUP_START_ = .);}
4fe13b2b 174 .fixup ${RELOCATING-0} : { *(.fixup) }
4d99a950
MM
175 ${RELOCATING+PROVIDE (_FIXUP_END_ = .);}
176 ${RELOCATING+PROVIDE (_GOT2_END_ = .);}
4fe13b2b 177
4d99a950 178 ${RELOCATING+PROVIDE (_GOT_START_ = .);}
4fe13b2b
MM
179 .got ${RELOCATING-0} : { *(.got) }
180 .got.plt ${RELOCATING-0} : { *(.got.plt) }
c56c9218
C
181 ${CREATE_SHLIB+${SDATA2}}
182 ${CREATE_SHLIB+${SBSS2}}
4d99a950 183 ${RELOCATING+PROVIDE (_GOT_END_ = .);}
1e4b4b1c 184
5f16938d
MM
185 /* We want the small data sections together, so single-instruction offsets
186 can access them all, and initialized data all before uninitialized, so
187 we can shorten the on-disk segment size. */
4d99a950 188 .sdata ${RELOCATING-0} : { *(.sdata) }
5f16938d
MM
189 ${RELOCATING+_edata = .;}
190 ${RELOCATING+PROVIDE (edata = .);}
7453a753
MM
191 .sbss ${RELOCATING-0} :
192 {
4d99a950 193 ${RELOCATING+PROVIDE (__sbss_start = .);}
7453a753
MM
194 *(.sbss)
195 *(.scommon)
93ed82b0 196 *(.dynsbss)
4d99a950 197 ${RELOCATING+PROVIDE (__sbss_end = .);}
7453a753 198 }
4602e5f4 199 ${PLT}
5f16938d
MM
200 .bss ${RELOCATING-0} :
201 {
7453a753 202 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
4d99a950 203 ${RELOCATING+PROVIDE (__bss_start = .);}
5f16938d
MM
204 *(.dynbss)
205 *(.bss)
206 *(COMMON)
207 }
208 ${RELOCATING+_end = . ;}
209 ${RELOCATING+PROVIDE (end = .);}
210
211 /* These are needed for ELF backends which have not yet been
212 converted to the new style linker. */
213 .stab 0 : { *(.stab) }
214 .stabstr 0 : { *(.stabstr) }
215
c2b6884b 216 /* DWARF debug sections.
264677bb
JM
217 Symbols in the DWARF debugging sections are relative to the beginning
218 of the section so we begin them at 0. */
219
220 /* DWARF 1 */
c2b6884b 221 .debug 0 : { *(.debug) }
264677bb
JM
222 .line 0 : { *(.line) }
223
224 /* GNU DWARF 1 extensions */
225 .debug_srcinfo 0 : { *(.debug_srcinfo) }
226 .debug_sfnames 0 : { *(.debug_sfnames) }
227
228 /* DWARF 1.1 and DWARF 2 */
229 .debug_aranges 0 : { *(.debug_aranges) }
230 .debug_pubnames 0 : { *(.debug_pubnames) }
231
232 /* DWARF 2 */
9193c60b
JM
233 .debug_info 0 : { *(.debug_info) }
234 .debug_abbrev 0 : { *(.debug_abbrev) }
235 .debug_line 0 : { *(.debug_line) }
236 .debug_frame 0 : { *(.debug_frame) }
264677bb
JM
237 .debug_str 0 : { *(.debug_str) }
238 .debug_loc 0 : { *(.debug_loc) }
239 .debug_macinfo 0 : { *(.debug_macinfo) }
240
241 /* SGI/MIPS DWARF 2 extensions */
242 .debug_weaknames 0 : { *(.debug_weaknames) }
243 .debug_funcnames 0 : { *(.debug_funcnames) }
244 .debug_typenames 0 : { *(.debug_typenames) }
245 .debug_varnames 0 : { *(.debug_varnames) }
c2b6884b 246
5f16938d
MM
247 /* These must appear regardless of ${RELOCATING}. */
248 ${OTHER_SECTIONS}
249}
250EOF
This page took 0.14582 seconds and 4 git commands to generate.