61ef1331f5d7d635b78504261f77aa626098e504
[binutils-gdb.git] / ld / scripttempl / elfppc.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 # OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
6 # (e.g., .PARISC.milli)
7 # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
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.
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 #
22 test -z "$ENTRY" && ENTRY=_start
23 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
24 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
25 test "$LD_FLAG" = "N" && DATA_ADDR=.
26 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) }"
27 SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) }"
28 INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
29 PLT=".plt ${RELOCATING-0} : { *(.plt) }"
30 cat <<EOF
31 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
32 "${LITTLE_OUTPUT_FORMAT}")
33 OUTPUT_ARCH(${ARCH})
34 ENTRY(${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. */}
44
45 ${RELOCATING+PROVIDE (__stack = 0);}
46 SECTIONS
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}}
52 .hash ${RELOCATING-0} : { *(.hash) }
53 .dynsym ${RELOCATING-0} : { *(.dynsym) }
54 .dynstr ${RELOCATING-0} : { *(.dynstr) }
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) }
58 .rela.text ${RELOCATING-0} :
59 { *(.rela.text) *(.rela.gnu.linkonce.t*) }
60 .rela.data ${RELOCATING-0} :
61 { *(.rela.data) *(.rela.gnu.linkonce.d*) }
62 .rela.rodata ${RELOCATING-0} :
63 { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
64 .rela.got ${RELOCATING-0} : { *(.rela.got) }
65 .rela.got1 ${RELOCATING-0} : { *(.rela.got1) }
66 .rela.got2 ${RELOCATING-0} : { *(.rela.got2) }
67 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
68 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
69 .rela.init ${RELOCATING-0} : { *(.rela.init) }
70 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
71 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
72 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
73 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
74 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) }
75 .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2) }
76 .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2) }
77 .text ${RELOCATING-0} :
78 {
79 ${RELOCATING+${TEXT_START_SYMBOLS}}
80 *(.text)
81 /* .gnu.warning sections are handled specially by elf32.em. */
82 *(.gnu.warning)
83 *(.gnu.linkonce.t*)
84 } =${NOP-0}
85 .init ${RELOCATING-0} : { *(.init) } =${NOP-0}
86 .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0}
87 .rodata ${RELOCATING-0} : { *(.rodata) *(.gnu.linkonce.r*) }
88 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
89 ${RELOCATING+_etext = .;}
90 ${RELOCATING+PROVIDE (etext = .);}
91 ${CREATE_SHLIB-${SDATA2}}
92 ${CREATE_SHLIB-${SBSS2}}
93 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
94
95 /* Adjust the address for the data segment. We want to adjust up to
96 the same address within the page on the next page up. It would
97 be more correct to do this:
98 ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (ALIGN(8) & (${MAXPAGESIZE} - 1))};}
99 The current expression does not correctly handle the case of a
100 text segment ending precisely at the end of a page; it causes the
101 data segment to skip a page. The above expression does not have
102 this problem, but it will currently (2/95) cause BFD to allocate
103 a single segment, combining both text and data, for this case.
104 This will prevent the text segment from being shared among
105 multiple executions of the program; I think that is more
106 important than losing a page of the virtual address space (note
107 that no actual memory is lost; the page which is skipped can not
108 be referenced). */
109 ${RELOCATING+. = ${DATA_ADDR- ALIGN(8) + ${MAXPAGESIZE}};}
110
111 .data ${RELOCATING-0} :
112 {
113 ${RELOCATING+${DATA_START_SYMBOLS}}
114 *(.data)
115 *(.gnu.linkonce.d*)
116 ${CONSTRUCTING+CONSTRUCTORS}
117 }
118 .data1 ${RELOCATING-0} : { *(.data1) }
119 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
120
121 .got1 ${RELOCATING-0} : { *(.got1) }
122 .dynamic ${RELOCATING-0} : { *(.dynamic) }
123
124 /* Put .ctors and .dtors next to the .got2 section, so that the pointers
125 get relocated with -mrelocatable. Also put in the .fixup pointers.
126 The current compiler no longer needs this, but keep it around for 2.7.2 */
127
128 ${RELOCATING+PROVIDE (_GOT2_START_ = .);}
129 .got2 ${RELOCATING-0} : { *(.got2) }
130
131 ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);}
132 .ctors ${RELOCATING-0} : {
133 /* gcc uses crtbegin.o to find the start of
134 the constructors, so we make sure it is
135 first. Because this is a wildcard, it
136 doesn't matter if the user does not
137 actually link against crtbegin.o; the
138 linker won't look for a file to match a
139 wildcard. The wildcard also means that it
140 doesn't matter which directory crtbegin.o
141 is in. */
142 *crtbegin.o(.ctors)
143 *(SORT(.ctors.*))
144 *(.ctors) }
145 ${RELOCATING+PROVIDE (__CTOR_END__ = .);}
146
147 ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);}
148 .dtors ${RELOCATING-0} : {
149 *crtbegin.o(.dtors)
150 *(SORT(.dtors.*))
151 *(.dtors) }
152 ${RELOCATING+PROVIDE (__DTOR_END__ = .);}
153
154 ${RELOCATING+PROVIDE (_FIXUP_START_ = .);}
155 .fixup ${RELOCATING-0} : { *(.fixup) }
156 ${RELOCATING+PROVIDE (_FIXUP_END_ = .);}
157 ${RELOCATING+PROVIDE (_GOT2_END_ = .);}
158
159 ${RELOCATING+PROVIDE (_GOT_START_ = .);}
160 .got ${RELOCATING-0} : { *(.got) }
161 .got.plt ${RELOCATING-0} : { *(.got.plt) }
162 ${CREATE_SHLIB+${SDATA2}}
163 ${CREATE_SHLIB+${SBSS2}}
164 ${RELOCATING+PROVIDE (_GOT_END_ = .);}
165
166 /* We want the small data sections together, so single-instruction offsets
167 can access them all, and initialized data all before uninitialized, so
168 we can shorten the on-disk segment size. */
169 .sdata ${RELOCATING-0} : { *(.sdata) }
170 ${RELOCATING+_edata = .;}
171 ${RELOCATING+PROVIDE (edata = .);}
172 .sbss ${RELOCATING-0} :
173 {
174 ${RELOCATING+PROVIDE (__sbss_start = .);}
175 *(.sbss)
176 *(.scommon)
177 *(.dynsbss)
178 ${RELOCATING+PROVIDE (__sbss_end = .);}
179 }
180 ${PLT}
181 .bss ${RELOCATING-0} :
182 {
183 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
184 ${RELOCATING+PROVIDE (__bss_start = .);}
185 *(.dynbss)
186 *(.bss)
187 *(COMMON)
188 }
189 ${RELOCATING+_end = . ;}
190 ${RELOCATING+PROVIDE (end = .);}
191
192 /* These are needed for ELF backends which have not yet been
193 converted to the new style linker. */
194 .stab 0 : { *(.stab) }
195 .stabstr 0 : { *(.stabstr) }
196
197 /* DWARF debug sections.
198 Symbols in the DWARF debugging sections are relative to the beginning
199 of the section so we begin them at 0. */
200
201 /* DWARF 1 */
202 .debug 0 : { *(.debug) }
203 .line 0 : { *(.line) }
204
205 /* GNU DWARF 1 extensions */
206 .debug_srcinfo 0 : { *(.debug_srcinfo) }
207 .debug_sfnames 0 : { *(.debug_sfnames) }
208
209 /* DWARF 1.1 and DWARF 2 */
210 .debug_aranges 0 : { *(.debug_aranges) }
211 .debug_pubnames 0 : { *(.debug_pubnames) }
212
213 /* DWARF 2 */
214 .debug_info 0 : { *(.debug_info) }
215 .debug_abbrev 0 : { *(.debug_abbrev) }
216 .debug_line 0 : { *(.debug_line) }
217 .debug_frame 0 : { *(.debug_frame) }
218 .debug_str 0 : { *(.debug_str) }
219 .debug_loc 0 : { *(.debug_loc) }
220 .debug_macinfo 0 : { *(.debug_macinfo) }
221
222 /* SGI/MIPS DWARF 2 extensions */
223 .debug_weaknames 0 : { *(.debug_weaknames) }
224 .debug_funcnames 0 : { *(.debug_funcnames) }
225 .debug_typenames 0 : { *(.debug_typenames) }
226 .debug_varnames 0 : { *(.debug_varnames) }
227
228 /* These must appear regardless of ${RELOCATING}. */
229 ${OTHER_SECTIONS}
230 }
231 EOF