]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* PowerPC-specific support for 32-bit ELF |
b491616a | 2 | Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 |
7898deda | 3 | Free Software Foundation, Inc. |
252b5132 RH |
4 | Written by Ian Lance Taylor, Cygnus Support. |
5 | ||
6 | This file is part of BFD, the Binary File Descriptor library. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | /* This file is based on a preliminary PowerPC ELF ABI. The | |
23 | information may not match the final PowerPC ELF ABI. It includes | |
24 | suggestions from the in-progress Embedded PowerPC ABI, and that | |
25 | information may also not match. */ | |
26 | ||
27 | #include "bfd.h" | |
28 | #include "sysdep.h" | |
29 | #include "bfdlink.h" | |
30 | #include "libbfd.h" | |
31 | #include "elf-bfd.h" | |
32 | #include "elf/ppc.h" | |
33 | ||
f0fe0e16 | 34 | /* RELA relocations are used here. */ |
252b5132 | 35 | |
252b5132 RH |
36 | static reloc_howto_type *ppc_elf_reloc_type_lookup |
37 | PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); | |
38 | static void ppc_elf_info_to_howto | |
947216bf | 39 | PARAMS ((bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)); |
252b5132 | 40 | static void ppc_elf_howto_init PARAMS ((void)); |
a7b97311 AM |
41 | static int ppc_elf_sort_rela PARAMS ((const PTR, const PTR)); |
42 | static boolean ppc_elf_relax_section | |
43 | PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *)); | |
252b5132 RH |
44 | static bfd_reloc_status_type ppc_elf_addr16_ha_reloc |
45 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
feee612b | 46 | static boolean ppc_elf_object_p PARAMS ((bfd *)); |
252b5132 | 47 | static boolean ppc_elf_set_private_flags PARAMS ((bfd *, flagword)); |
252b5132 RH |
48 | static boolean ppc_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); |
49 | ||
50 | static int ppc_elf_additional_program_headers PARAMS ((bfd *)); | |
51 | static boolean ppc_elf_modify_segment_map PARAMS ((bfd *)); | |
52 | ||
41fcb14e AM |
53 | static asection *ppc_elf_create_got |
54 | PARAMS ((bfd *, struct bfd_link_info *)); | |
252b5132 RH |
55 | static boolean ppc_elf_create_dynamic_sections |
56 | PARAMS ((bfd *, struct bfd_link_info *)); | |
57 | ||
58 | static boolean ppc_elf_section_from_shdr PARAMS ((bfd *, | |
947216bf | 59 | Elf_Internal_Shdr *, |
90937f86 | 60 | const char *)); |
252b5132 | 61 | static boolean ppc_elf_fake_sections |
947216bf | 62 | PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); |
252b5132 RH |
63 | |
64 | static elf_linker_section_t *ppc_elf_create_linker_section | |
65 | PARAMS ((bfd *abfd, | |
66 | struct bfd_link_info *info, | |
67 | enum elf_linker_section_enum)); | |
68 | ||
69 | static boolean ppc_elf_check_relocs PARAMS ((bfd *, | |
70 | struct bfd_link_info *, | |
71 | asection *, | |
72 | const Elf_Internal_Rela *)); | |
73 | ||
1e2f5b6e | 74 | static asection * ppc_elf_gc_mark_hook PARAMS ((asection *sec, |
252b5132 RH |
75 | struct bfd_link_info *info, |
76 | Elf_Internal_Rela *rel, | |
77 | struct elf_link_hash_entry *h, | |
78 | Elf_Internal_Sym *sym)); | |
79 | ||
80 | static boolean ppc_elf_gc_sweep_hook PARAMS ((bfd *abfd, | |
81 | struct bfd_link_info *info, | |
82 | asection *sec, | |
83 | const Elf_Internal_Rela *relocs)); | |
84 | ||
85 | static boolean ppc_elf_adjust_dynamic_symbol PARAMS ((struct bfd_link_info *, | |
86 | struct elf_link_hash_entry *)); | |
87 | ||
252b5132 RH |
88 | static boolean ppc_elf_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); |
89 | ||
90 | static boolean ppc_elf_relocate_section PARAMS ((bfd *, | |
91 | struct bfd_link_info *info, | |
92 | bfd *, | |
93 | asection *, | |
94 | bfd_byte *, | |
95 | Elf_Internal_Rela *relocs, | |
96 | Elf_Internal_Sym *local_syms, | |
97 | asection **)); | |
98 | ||
99 | static boolean ppc_elf_add_symbol_hook PARAMS ((bfd *, | |
100 | struct bfd_link_info *, | |
101 | const Elf_Internal_Sym *, | |
102 | const char **, | |
103 | flagword *, | |
104 | asection **, | |
105 | bfd_vma *)); | |
106 | ||
107 | static boolean ppc_elf_finish_dynamic_symbol PARAMS ((bfd *, | |
108 | struct bfd_link_info *, | |
109 | struct elf_link_hash_entry *, | |
110 | Elf_Internal_Sym *)); | |
111 | ||
112 | static boolean ppc_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); | |
f51e552e AM |
113 | static enum elf_reloc_type_class ppc_elf_reloc_type_class |
114 | PARAMS ((const Elf_Internal_Rela *)); | |
2e67030c DJ |
115 | static boolean ppc_elf_grok_prstatus |
116 | PARAMS ((bfd *abfd, Elf_Internal_Note *note)); | |
117 | static boolean ppc_elf_grok_psinfo | |
118 | PARAMS ((bfd *abfd, Elf_Internal_Note *note)); | |
252b5132 RH |
119 | |
120 | #define BRANCH_PREDICT_BIT 0x200000 /* branch prediction bit for branch taken relocs */ | |
121 | #define RA_REGISTER_MASK 0x001f0000 /* mask to set RA in memory instructions */ | |
122 | #define RA_REGISTER_SHIFT 16 /* value to shift register by to insert RA */ | |
123 | ||
124 | /* The name of the dynamic interpreter. This is put in the .interp | |
125 | section. */ | |
126 | ||
127 | #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" | |
128 | ||
129 | /* The size in bytes of an entry in the procedure linkage table. */ | |
130 | #define PLT_ENTRY_SIZE 12 | |
131 | /* The initial size of the plt reserved for the dynamic linker. */ | |
132 | #define PLT_INITIAL_ENTRY_SIZE 72 | |
133 | /* The size of the gap between entries in the PLT. */ | |
134 | #define PLT_SLOT_SIZE 8 | |
135 | /* The number of single-slot PLT entries (the rest use two slots). */ | |
136 | #define PLT_NUM_SINGLE_ENTRIES 8192 | |
137 | ||
e1e0340b GK |
138 | /* Will references to this symbol always reference the symbol |
139 | in this object? */ | |
140 | #define SYMBOL_REFERENCES_LOCAL(INFO, H) \ | |
141 | ((! INFO->shared \ | |
142 | || INFO->symbolic \ | |
143 | || H->dynindx == -1 \ | |
144 | || ELF_ST_VISIBILITY (H->other) == STV_INTERNAL \ | |
145 | || ELF_ST_VISIBILITY (H->other) == STV_HIDDEN) \ | |
146 | && (H->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0) | |
147 | ||
148 | /* Will _calls_ to this symbol always call the version in this object? */ | |
149 | #define SYMBOL_CALLS_LOCAL(INFO, H) \ | |
150 | ((! INFO->shared \ | |
151 | || INFO->symbolic \ | |
152 | || H->dynindx == -1 \ | |
153 | || ELF_ST_VISIBILITY (H->other) != STV_DEFAULT) \ | |
154 | && (H->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0) | |
252b5132 | 155 | \f |
8da6118f | 156 | static reloc_howto_type *ppc_elf_howto_table[(int) R_PPC_max]; |
252b5132 | 157 | |
8da6118f | 158 | static reloc_howto_type ppc_elf_howto_raw[] = { |
252b5132 RH |
159 | /* This reloc does nothing. */ |
160 | HOWTO (R_PPC_NONE, /* type */ | |
161 | 0, /* rightshift */ | |
162 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
163 | 32, /* bitsize */ | |
164 | false, /* pc_relative */ | |
165 | 0, /* bitpos */ | |
166 | complain_overflow_bitfield, /* complain_on_overflow */ | |
167 | bfd_elf_generic_reloc, /* special_function */ | |
168 | "R_PPC_NONE", /* name */ | |
169 | false, /* partial_inplace */ | |
170 | 0, /* src_mask */ | |
171 | 0, /* dst_mask */ | |
172 | false), /* pcrel_offset */ | |
173 | ||
174 | /* A standard 32 bit relocation. */ | |
175 | HOWTO (R_PPC_ADDR32, /* type */ | |
176 | 0, /* rightshift */ | |
177 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
178 | 32, /* bitsize */ | |
179 | false, /* pc_relative */ | |
180 | 0, /* bitpos */ | |
181 | complain_overflow_bitfield, /* complain_on_overflow */ | |
182 | bfd_elf_generic_reloc, /* special_function */ | |
183 | "R_PPC_ADDR32", /* name */ | |
184 | false, /* partial_inplace */ | |
185 | 0, /* src_mask */ | |
186 | 0xffffffff, /* dst_mask */ | |
187 | false), /* pcrel_offset */ | |
188 | ||
189 | /* An absolute 26 bit branch; the lower two bits must be zero. | |
190 | FIXME: we don't check that, we just clear them. */ | |
191 | HOWTO (R_PPC_ADDR24, /* type */ | |
192 | 0, /* rightshift */ | |
193 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
194 | 26, /* bitsize */ | |
195 | false, /* pc_relative */ | |
196 | 0, /* bitpos */ | |
197 | complain_overflow_bitfield, /* complain_on_overflow */ | |
198 | bfd_elf_generic_reloc, /* special_function */ | |
199 | "R_PPC_ADDR24", /* name */ | |
200 | false, /* partial_inplace */ | |
201 | 0, /* src_mask */ | |
202 | 0x3fffffc, /* dst_mask */ | |
203 | false), /* pcrel_offset */ | |
204 | ||
205 | /* A standard 16 bit relocation. */ | |
206 | HOWTO (R_PPC_ADDR16, /* type */ | |
207 | 0, /* rightshift */ | |
208 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
209 | 16, /* bitsize */ | |
210 | false, /* pc_relative */ | |
211 | 0, /* bitpos */ | |
212 | complain_overflow_bitfield, /* complain_on_overflow */ | |
213 | bfd_elf_generic_reloc, /* special_function */ | |
214 | "R_PPC_ADDR16", /* name */ | |
215 | false, /* partial_inplace */ | |
216 | 0, /* src_mask */ | |
217 | 0xffff, /* dst_mask */ | |
218 | false), /* pcrel_offset */ | |
219 | ||
220 | /* A 16 bit relocation without overflow. */ | |
221 | HOWTO (R_PPC_ADDR16_LO, /* type */ | |
222 | 0, /* rightshift */ | |
223 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
224 | 16, /* bitsize */ | |
225 | false, /* pc_relative */ | |
226 | 0, /* bitpos */ | |
227 | complain_overflow_dont,/* complain_on_overflow */ | |
228 | bfd_elf_generic_reloc, /* special_function */ | |
229 | "R_PPC_ADDR16_LO", /* name */ | |
230 | false, /* partial_inplace */ | |
231 | 0, /* src_mask */ | |
232 | 0xffff, /* dst_mask */ | |
233 | false), /* pcrel_offset */ | |
234 | ||
235 | /* The high order 16 bits of an address. */ | |
236 | HOWTO (R_PPC_ADDR16_HI, /* type */ | |
237 | 16, /* rightshift */ | |
238 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
239 | 16, /* bitsize */ | |
240 | false, /* pc_relative */ | |
241 | 0, /* bitpos */ | |
242 | complain_overflow_dont, /* complain_on_overflow */ | |
243 | bfd_elf_generic_reloc, /* special_function */ | |
244 | "R_PPC_ADDR16_HI", /* name */ | |
245 | false, /* partial_inplace */ | |
246 | 0, /* src_mask */ | |
247 | 0xffff, /* dst_mask */ | |
248 | false), /* pcrel_offset */ | |
249 | ||
250 | /* The high order 16 bits of an address, plus 1 if the contents of | |
8da6118f | 251 | the low 16 bits, treated as a signed number, is negative. */ |
252b5132 RH |
252 | HOWTO (R_PPC_ADDR16_HA, /* type */ |
253 | 16, /* rightshift */ | |
254 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
255 | 16, /* bitsize */ | |
256 | false, /* pc_relative */ | |
257 | 0, /* bitpos */ | |
258 | complain_overflow_dont, /* complain_on_overflow */ | |
259 | ppc_elf_addr16_ha_reloc, /* special_function */ | |
260 | "R_PPC_ADDR16_HA", /* name */ | |
261 | false, /* partial_inplace */ | |
262 | 0, /* src_mask */ | |
263 | 0xffff, /* dst_mask */ | |
264 | false), /* pcrel_offset */ | |
265 | ||
266 | /* An absolute 16 bit branch; the lower two bits must be zero. | |
267 | FIXME: we don't check that, we just clear them. */ | |
268 | HOWTO (R_PPC_ADDR14, /* type */ | |
269 | 0, /* rightshift */ | |
270 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
271 | 16, /* bitsize */ | |
272 | false, /* pc_relative */ | |
273 | 0, /* bitpos */ | |
274 | complain_overflow_bitfield, /* complain_on_overflow */ | |
275 | bfd_elf_generic_reloc, /* special_function */ | |
276 | "R_PPC_ADDR14", /* name */ | |
277 | false, /* partial_inplace */ | |
278 | 0, /* src_mask */ | |
279 | 0xfffc, /* dst_mask */ | |
280 | false), /* pcrel_offset */ | |
281 | ||
282 | /* An absolute 16 bit branch, for which bit 10 should be set to | |
283 | indicate that the branch is expected to be taken. The lower two | |
8da6118f | 284 | bits must be zero. */ |
252b5132 RH |
285 | HOWTO (R_PPC_ADDR14_BRTAKEN, /* type */ |
286 | 0, /* rightshift */ | |
287 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
288 | 16, /* bitsize */ | |
289 | false, /* pc_relative */ | |
290 | 0, /* bitpos */ | |
291 | complain_overflow_bitfield, /* complain_on_overflow */ | |
292 | bfd_elf_generic_reloc, /* special_function */ | |
293 | "R_PPC_ADDR14_BRTAKEN",/* name */ | |
294 | false, /* partial_inplace */ | |
295 | 0, /* src_mask */ | |
296 | 0xfffc, /* dst_mask */ | |
297 | false), /* pcrel_offset */ | |
298 | ||
299 | /* An absolute 16 bit branch, for which bit 10 should be set to | |
300 | indicate that the branch is not expected to be taken. The lower | |
301 | two bits must be zero. */ | |
302 | HOWTO (R_PPC_ADDR14_BRNTAKEN, /* type */ | |
303 | 0, /* rightshift */ | |
304 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
305 | 16, /* bitsize */ | |
306 | false, /* pc_relative */ | |
307 | 0, /* bitpos */ | |
308 | complain_overflow_bitfield, /* complain_on_overflow */ | |
309 | bfd_elf_generic_reloc, /* special_function */ | |
310 | "R_PPC_ADDR14_BRNTAKEN",/* name */ | |
311 | false, /* partial_inplace */ | |
312 | 0, /* src_mask */ | |
313 | 0xfffc, /* dst_mask */ | |
314 | false), /* pcrel_offset */ | |
315 | ||
8da6118f | 316 | /* A relative 26 bit branch; the lower two bits must be zero. */ |
252b5132 RH |
317 | HOWTO (R_PPC_REL24, /* type */ |
318 | 0, /* rightshift */ | |
319 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
320 | 26, /* bitsize */ | |
321 | true, /* pc_relative */ | |
322 | 0, /* bitpos */ | |
323 | complain_overflow_signed, /* complain_on_overflow */ | |
324 | bfd_elf_generic_reloc, /* special_function */ | |
325 | "R_PPC_REL24", /* name */ | |
326 | false, /* partial_inplace */ | |
327 | 0, /* src_mask */ | |
328 | 0x3fffffc, /* dst_mask */ | |
329 | true), /* pcrel_offset */ | |
330 | ||
8da6118f | 331 | /* A relative 16 bit branch; the lower two bits must be zero. */ |
252b5132 RH |
332 | HOWTO (R_PPC_REL14, /* type */ |
333 | 0, /* rightshift */ | |
334 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
335 | 16, /* bitsize */ | |
336 | true, /* pc_relative */ | |
337 | 0, /* bitpos */ | |
338 | complain_overflow_signed, /* complain_on_overflow */ | |
339 | bfd_elf_generic_reloc, /* special_function */ | |
340 | "R_PPC_REL14", /* name */ | |
341 | false, /* partial_inplace */ | |
342 | 0, /* src_mask */ | |
343 | 0xfffc, /* dst_mask */ | |
344 | true), /* pcrel_offset */ | |
345 | ||
8da6118f | 346 | /* A relative 16 bit branch. Bit 10 should be set to indicate that |
252b5132 RH |
347 | the branch is expected to be taken. The lower two bits must be |
348 | zero. */ | |
349 | HOWTO (R_PPC_REL14_BRTAKEN, /* type */ | |
350 | 0, /* rightshift */ | |
351 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
352 | 16, /* bitsize */ | |
353 | true, /* pc_relative */ | |
354 | 0, /* bitpos */ | |
355 | complain_overflow_signed, /* complain_on_overflow */ | |
356 | bfd_elf_generic_reloc, /* special_function */ | |
357 | "R_PPC_REL14_BRTAKEN", /* name */ | |
358 | false, /* partial_inplace */ | |
359 | 0, /* src_mask */ | |
360 | 0xfffc, /* dst_mask */ | |
361 | true), /* pcrel_offset */ | |
362 | ||
8da6118f | 363 | /* A relative 16 bit branch. Bit 10 should be set to indicate that |
252b5132 RH |
364 | the branch is not expected to be taken. The lower two bits must |
365 | be zero. */ | |
366 | HOWTO (R_PPC_REL14_BRNTAKEN, /* type */ | |
367 | 0, /* rightshift */ | |
368 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
369 | 16, /* bitsize */ | |
370 | true, /* pc_relative */ | |
371 | 0, /* bitpos */ | |
372 | complain_overflow_signed, /* complain_on_overflow */ | |
373 | bfd_elf_generic_reloc, /* special_function */ | |
374 | "R_PPC_REL14_BRNTAKEN",/* name */ | |
375 | false, /* partial_inplace */ | |
376 | 0, /* src_mask */ | |
377 | 0xfffc, /* dst_mask */ | |
378 | true), /* pcrel_offset */ | |
379 | ||
380 | /* Like R_PPC_ADDR16, but referring to the GOT table entry for the | |
381 | symbol. */ | |
382 | HOWTO (R_PPC_GOT16, /* type */ | |
383 | 0, /* rightshift */ | |
384 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
385 | 16, /* bitsize */ | |
386 | false, /* pc_relative */ | |
387 | 0, /* bitpos */ | |
388 | complain_overflow_signed, /* complain_on_overflow */ | |
389 | bfd_elf_generic_reloc, /* special_function */ | |
390 | "R_PPC_GOT16", /* name */ | |
391 | false, /* partial_inplace */ | |
392 | 0, /* src_mask */ | |
393 | 0xffff, /* dst_mask */ | |
394 | false), /* pcrel_offset */ | |
395 | ||
396 | /* Like R_PPC_ADDR16_LO, but referring to the GOT table entry for | |
397 | the symbol. */ | |
398 | HOWTO (R_PPC_GOT16_LO, /* type */ | |
399 | 0, /* rightshift */ | |
400 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
401 | 16, /* bitsize */ | |
402 | false, /* pc_relative */ | |
403 | 0, /* bitpos */ | |
404 | complain_overflow_dont, /* complain_on_overflow */ | |
405 | bfd_elf_generic_reloc, /* special_function */ | |
406 | "R_PPC_GOT16_LO", /* name */ | |
407 | false, /* partial_inplace */ | |
408 | 0, /* src_mask */ | |
409 | 0xffff, /* dst_mask */ | |
410 | false), /* pcrel_offset */ | |
411 | ||
412 | /* Like R_PPC_ADDR16_HI, but referring to the GOT table entry for | |
413 | the symbol. */ | |
414 | HOWTO (R_PPC_GOT16_HI, /* type */ | |
415 | 16, /* rightshift */ | |
416 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
417 | 16, /* bitsize */ | |
418 | false, /* pc_relative */ | |
419 | 0, /* bitpos */ | |
420 | complain_overflow_bitfield, /* complain_on_overflow */ | |
421 | bfd_elf_generic_reloc, /* special_function */ | |
422 | "R_PPC_GOT16_HI", /* name */ | |
423 | false, /* partial_inplace */ | |
424 | 0, /* src_mask */ | |
425 | 0xffff, /* dst_mask */ | |
426 | false), /* pcrel_offset */ | |
427 | ||
428 | /* Like R_PPC_ADDR16_HA, but referring to the GOT table entry for | |
429 | the symbol. */ | |
430 | HOWTO (R_PPC_GOT16_HA, /* type */ | |
431 | 16, /* rightshift */ | |
432 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
433 | 16, /* bitsize */ | |
434 | false, /* pc_relative */ | |
435 | 0, /* bitpos */ | |
436 | complain_overflow_bitfield, /* complain_on_overflow */ | |
437 | ppc_elf_addr16_ha_reloc, /* special_function */ | |
438 | "R_PPC_GOT16_HA", /* name */ | |
439 | false, /* partial_inplace */ | |
440 | 0, /* src_mask */ | |
441 | 0xffff, /* dst_mask */ | |
442 | false), /* pcrel_offset */ | |
443 | ||
444 | /* Like R_PPC_REL24, but referring to the procedure linkage table | |
445 | entry for the symbol. */ | |
446 | HOWTO (R_PPC_PLTREL24, /* type */ | |
447 | 0, /* rightshift */ | |
448 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
449 | 26, /* bitsize */ | |
450 | true, /* pc_relative */ | |
451 | 0, /* bitpos */ | |
452 | complain_overflow_signed, /* complain_on_overflow */ | |
453 | bfd_elf_generic_reloc, /* special_function */ | |
454 | "R_PPC_PLTREL24", /* name */ | |
455 | false, /* partial_inplace */ | |
456 | 0, /* src_mask */ | |
457 | 0x3fffffc, /* dst_mask */ | |
458 | true), /* pcrel_offset */ | |
459 | ||
460 | /* This is used only by the dynamic linker. The symbol should exist | |
461 | both in the object being run and in some shared library. The | |
462 | dynamic linker copies the data addressed by the symbol from the | |
463 | shared library into the object, because the object being | |
464 | run has to have the data at some particular address. */ | |
465 | HOWTO (R_PPC_COPY, /* type */ | |
466 | 0, /* rightshift */ | |
467 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
468 | 32, /* bitsize */ | |
469 | false, /* pc_relative */ | |
470 | 0, /* bitpos */ | |
471 | complain_overflow_bitfield, /* complain_on_overflow */ | |
472 | bfd_elf_generic_reloc, /* special_function */ | |
473 | "R_PPC_COPY", /* name */ | |
474 | false, /* partial_inplace */ | |
475 | 0, /* src_mask */ | |
476 | 0, /* dst_mask */ | |
477 | false), /* pcrel_offset */ | |
478 | ||
479 | /* Like R_PPC_ADDR32, but used when setting global offset table | |
480 | entries. */ | |
481 | HOWTO (R_PPC_GLOB_DAT, /* type */ | |
482 | 0, /* rightshift */ | |
483 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
484 | 32, /* bitsize */ | |
485 | false, /* pc_relative */ | |
486 | 0, /* bitpos */ | |
487 | complain_overflow_bitfield, /* complain_on_overflow */ | |
488 | bfd_elf_generic_reloc, /* special_function */ | |
489 | "R_PPC_GLOB_DAT", /* name */ | |
490 | false, /* partial_inplace */ | |
491 | 0, /* src_mask */ | |
492 | 0xffffffff, /* dst_mask */ | |
493 | false), /* pcrel_offset */ | |
494 | ||
495 | /* Marks a procedure linkage table entry for a symbol. */ | |
496 | HOWTO (R_PPC_JMP_SLOT, /* type */ | |
497 | 0, /* rightshift */ | |
498 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
499 | 32, /* bitsize */ | |
500 | false, /* pc_relative */ | |
501 | 0, /* bitpos */ | |
502 | complain_overflow_bitfield, /* complain_on_overflow */ | |
503 | bfd_elf_generic_reloc, /* special_function */ | |
504 | "R_PPC_JMP_SLOT", /* name */ | |
505 | false, /* partial_inplace */ | |
506 | 0, /* src_mask */ | |
507 | 0, /* dst_mask */ | |
508 | false), /* pcrel_offset */ | |
509 | ||
510 | /* Used only by the dynamic linker. When the object is run, this | |
511 | longword is set to the load address of the object, plus the | |
512 | addend. */ | |
513 | HOWTO (R_PPC_RELATIVE, /* type */ | |
514 | 0, /* rightshift */ | |
515 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
516 | 32, /* bitsize */ | |
517 | false, /* pc_relative */ | |
518 | 0, /* bitpos */ | |
519 | complain_overflow_bitfield, /* complain_on_overflow */ | |
520 | bfd_elf_generic_reloc, /* special_function */ | |
521 | "R_PPC_RELATIVE", /* name */ | |
522 | false, /* partial_inplace */ | |
523 | 0, /* src_mask */ | |
524 | 0xffffffff, /* dst_mask */ | |
525 | false), /* pcrel_offset */ | |
526 | ||
527 | /* Like R_PPC_REL24, but uses the value of the symbol within the | |
528 | object rather than the final value. Normally used for | |
529 | _GLOBAL_OFFSET_TABLE_. */ | |
530 | HOWTO (R_PPC_LOCAL24PC, /* type */ | |
531 | 0, /* rightshift */ | |
532 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
533 | 26, /* bitsize */ | |
534 | true, /* pc_relative */ | |
535 | 0, /* bitpos */ | |
536 | complain_overflow_signed, /* complain_on_overflow */ | |
537 | bfd_elf_generic_reloc, /* special_function */ | |
538 | "R_PPC_LOCAL24PC", /* name */ | |
539 | false, /* partial_inplace */ | |
540 | 0, /* src_mask */ | |
541 | 0x3fffffc, /* dst_mask */ | |
542 | true), /* pcrel_offset */ | |
543 | ||
544 | /* Like R_PPC_ADDR32, but may be unaligned. */ | |
545 | HOWTO (R_PPC_UADDR32, /* type */ | |
546 | 0, /* rightshift */ | |
547 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
548 | 32, /* bitsize */ | |
549 | false, /* pc_relative */ | |
550 | 0, /* bitpos */ | |
551 | complain_overflow_bitfield, /* complain_on_overflow */ | |
552 | bfd_elf_generic_reloc, /* special_function */ | |
553 | "R_PPC_UADDR32", /* name */ | |
554 | false, /* partial_inplace */ | |
555 | 0, /* src_mask */ | |
556 | 0xffffffff, /* dst_mask */ | |
557 | false), /* pcrel_offset */ | |
558 | ||
559 | /* Like R_PPC_ADDR16, but may be unaligned. */ | |
560 | HOWTO (R_PPC_UADDR16, /* type */ | |
561 | 0, /* rightshift */ | |
562 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
563 | 16, /* bitsize */ | |
564 | false, /* pc_relative */ | |
565 | 0, /* bitpos */ | |
566 | complain_overflow_bitfield, /* complain_on_overflow */ | |
567 | bfd_elf_generic_reloc, /* special_function */ | |
568 | "R_PPC_UADDR16", /* name */ | |
569 | false, /* partial_inplace */ | |
570 | 0, /* src_mask */ | |
571 | 0xffff, /* dst_mask */ | |
572 | false), /* pcrel_offset */ | |
573 | ||
574 | /* 32-bit PC relative */ | |
575 | HOWTO (R_PPC_REL32, /* type */ | |
576 | 0, /* rightshift */ | |
577 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
578 | 32, /* bitsize */ | |
579 | true, /* pc_relative */ | |
580 | 0, /* bitpos */ | |
581 | complain_overflow_bitfield, /* complain_on_overflow */ | |
582 | bfd_elf_generic_reloc, /* special_function */ | |
583 | "R_PPC_REL32", /* name */ | |
584 | false, /* partial_inplace */ | |
585 | 0, /* src_mask */ | |
586 | 0xffffffff, /* dst_mask */ | |
587 | true), /* pcrel_offset */ | |
588 | ||
589 | /* 32-bit relocation to the symbol's procedure linkage table. | |
c3668558 | 590 | FIXME: not supported. */ |
252b5132 RH |
591 | HOWTO (R_PPC_PLT32, /* type */ |
592 | 0, /* rightshift */ | |
593 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
594 | 32, /* bitsize */ | |
595 | false, /* pc_relative */ | |
596 | 0, /* bitpos */ | |
597 | complain_overflow_bitfield, /* complain_on_overflow */ | |
598 | bfd_elf_generic_reloc, /* special_function */ | |
599 | "R_PPC_PLT32", /* name */ | |
600 | false, /* partial_inplace */ | |
601 | 0, /* src_mask */ | |
602 | 0, /* dst_mask */ | |
603 | false), /* pcrel_offset */ | |
604 | ||
605 | /* 32-bit PC relative relocation to the symbol's procedure linkage table. | |
c3668558 | 606 | FIXME: not supported. */ |
252b5132 RH |
607 | HOWTO (R_PPC_PLTREL32, /* type */ |
608 | 0, /* rightshift */ | |
609 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
610 | 32, /* bitsize */ | |
611 | true, /* pc_relative */ | |
612 | 0, /* bitpos */ | |
613 | complain_overflow_bitfield, /* complain_on_overflow */ | |
614 | bfd_elf_generic_reloc, /* special_function */ | |
615 | "R_PPC_PLTREL32", /* name */ | |
616 | false, /* partial_inplace */ | |
617 | 0, /* src_mask */ | |
618 | 0, /* dst_mask */ | |
619 | true), /* pcrel_offset */ | |
620 | ||
621 | /* Like R_PPC_ADDR16_LO, but referring to the PLT table entry for | |
622 | the symbol. */ | |
623 | HOWTO (R_PPC_PLT16_LO, /* type */ | |
624 | 0, /* rightshift */ | |
625 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
626 | 16, /* bitsize */ | |
627 | false, /* pc_relative */ | |
628 | 0, /* bitpos */ | |
629 | complain_overflow_dont, /* complain_on_overflow */ | |
630 | bfd_elf_generic_reloc, /* special_function */ | |
631 | "R_PPC_PLT16_LO", /* name */ | |
632 | false, /* partial_inplace */ | |
633 | 0, /* src_mask */ | |
634 | 0xffff, /* dst_mask */ | |
635 | false), /* pcrel_offset */ | |
636 | ||
637 | /* Like R_PPC_ADDR16_HI, but referring to the PLT table entry for | |
638 | the symbol. */ | |
639 | HOWTO (R_PPC_PLT16_HI, /* type */ | |
640 | 16, /* rightshift */ | |
641 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
642 | 16, /* bitsize */ | |
643 | false, /* pc_relative */ | |
644 | 0, /* bitpos */ | |
645 | complain_overflow_bitfield, /* complain_on_overflow */ | |
646 | bfd_elf_generic_reloc, /* special_function */ | |
647 | "R_PPC_PLT16_HI", /* name */ | |
648 | false, /* partial_inplace */ | |
649 | 0, /* src_mask */ | |
650 | 0xffff, /* dst_mask */ | |
651 | false), /* pcrel_offset */ | |
652 | ||
653 | /* Like R_PPC_ADDR16_HA, but referring to the PLT table entry for | |
654 | the symbol. */ | |
655 | HOWTO (R_PPC_PLT16_HA, /* type */ | |
656 | 16, /* rightshift */ | |
657 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
658 | 16, /* bitsize */ | |
659 | false, /* pc_relative */ | |
660 | 0, /* bitpos */ | |
661 | complain_overflow_bitfield, /* complain_on_overflow */ | |
662 | ppc_elf_addr16_ha_reloc, /* special_function */ | |
663 | "R_PPC_PLT16_HA", /* name */ | |
664 | false, /* partial_inplace */ | |
665 | 0, /* src_mask */ | |
666 | 0xffff, /* dst_mask */ | |
667 | false), /* pcrel_offset */ | |
668 | ||
669 | /* A sign-extended 16 bit value relative to _SDA_BASE_, for use with | |
670 | small data items. */ | |
671 | HOWTO (R_PPC_SDAREL16, /* type */ | |
672 | 0, /* rightshift */ | |
673 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
674 | 16, /* bitsize */ | |
675 | false, /* pc_relative */ | |
676 | 0, /* bitpos */ | |
677 | complain_overflow_signed, /* complain_on_overflow */ | |
678 | bfd_elf_generic_reloc, /* special_function */ | |
679 | "R_PPC_SDAREL16", /* name */ | |
680 | false, /* partial_inplace */ | |
681 | 0, /* src_mask */ | |
682 | 0xffff, /* dst_mask */ | |
683 | false), /* pcrel_offset */ | |
684 | ||
c061c2d8 | 685 | /* 16-bit section relative relocation. */ |
252b5132 RH |
686 | HOWTO (R_PPC_SECTOFF, /* type */ |
687 | 0, /* rightshift */ | |
c061c2d8 AM |
688 | 1, /* size (0 = byte, 1 = short, 2 = long) */ |
689 | 16, /* bitsize */ | |
690 | false, /* pc_relative */ | |
252b5132 RH |
691 | 0, /* bitpos */ |
692 | complain_overflow_bitfield, /* complain_on_overflow */ | |
693 | bfd_elf_generic_reloc, /* special_function */ | |
694 | "R_PPC_SECTOFF", /* name */ | |
695 | false, /* partial_inplace */ | |
696 | 0, /* src_mask */ | |
c061c2d8 AM |
697 | 0xffff, /* dst_mask */ |
698 | false), /* pcrel_offset */ | |
252b5132 | 699 | |
c3668558 | 700 | /* 16-bit lower half section relative relocation. */ |
252b5132 RH |
701 | HOWTO (R_PPC_SECTOFF_LO, /* type */ |
702 | 0, /* rightshift */ | |
703 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
704 | 16, /* bitsize */ | |
705 | false, /* pc_relative */ | |
706 | 0, /* bitpos */ | |
707 | complain_overflow_dont, /* complain_on_overflow */ | |
708 | bfd_elf_generic_reloc, /* special_function */ | |
709 | "R_PPC_SECTOFF_LO", /* name */ | |
710 | false, /* partial_inplace */ | |
711 | 0, /* src_mask */ | |
712 | 0xffff, /* dst_mask */ | |
713 | false), /* pcrel_offset */ | |
714 | ||
c3668558 | 715 | /* 16-bit upper half section relative relocation. */ |
252b5132 RH |
716 | HOWTO (R_PPC_SECTOFF_HI, /* type */ |
717 | 16, /* rightshift */ | |
718 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
719 | 16, /* bitsize */ | |
720 | false, /* pc_relative */ | |
721 | 0, /* bitpos */ | |
722 | complain_overflow_bitfield, /* complain_on_overflow */ | |
723 | bfd_elf_generic_reloc, /* special_function */ | |
724 | "R_PPC_SECTOFF_HI", /* name */ | |
725 | false, /* partial_inplace */ | |
726 | 0, /* src_mask */ | |
727 | 0xffff, /* dst_mask */ | |
728 | false), /* pcrel_offset */ | |
729 | ||
c3668558 | 730 | /* 16-bit upper half adjusted section relative relocation. */ |
252b5132 RH |
731 | HOWTO (R_PPC_SECTOFF_HA, /* type */ |
732 | 16, /* rightshift */ | |
733 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
734 | 16, /* bitsize */ | |
735 | false, /* pc_relative */ | |
736 | 0, /* bitpos */ | |
737 | complain_overflow_bitfield, /* complain_on_overflow */ | |
738 | ppc_elf_addr16_ha_reloc, /* special_function */ | |
739 | "R_PPC_SECTOFF_HA", /* name */ | |
740 | false, /* partial_inplace */ | |
741 | 0, /* src_mask */ | |
742 | 0xffff, /* dst_mask */ | |
743 | false), /* pcrel_offset */ | |
744 | ||
745 | /* The remaining relocs are from the Embedded ELF ABI, and are not | |
746 | in the SVR4 ELF ABI. */ | |
747 | ||
748 | /* 32 bit value resulting from the addend minus the symbol */ | |
749 | HOWTO (R_PPC_EMB_NADDR32, /* type */ | |
750 | 0, /* rightshift */ | |
751 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
752 | 32, /* bitsize */ | |
753 | false, /* pc_relative */ | |
754 | 0, /* bitpos */ | |
755 | complain_overflow_bitfield, /* complain_on_overflow */ | |
756 | bfd_elf_generic_reloc, /* special_function */ | |
757 | "R_PPC_EMB_NADDR32", /* name */ | |
758 | false, /* partial_inplace */ | |
759 | 0, /* src_mask */ | |
760 | 0xffffffff, /* dst_mask */ | |
761 | false), /* pcrel_offset */ | |
762 | ||
763 | /* 16 bit value resulting from the addend minus the symbol */ | |
764 | HOWTO (R_PPC_EMB_NADDR16, /* type */ | |
765 | 0, /* rightshift */ | |
766 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
767 | 16, /* bitsize */ | |
768 | false, /* pc_relative */ | |
769 | 0, /* bitpos */ | |
770 | complain_overflow_bitfield, /* complain_on_overflow */ | |
771 | bfd_elf_generic_reloc, /* special_function */ | |
772 | "R_PPC_EMB_NADDR16", /* name */ | |
773 | false, /* partial_inplace */ | |
774 | 0, /* src_mask */ | |
775 | 0xffff, /* dst_mask */ | |
776 | false), /* pcrel_offset */ | |
777 | ||
778 | /* 16 bit value resulting from the addend minus the symbol */ | |
779 | HOWTO (R_PPC_EMB_NADDR16_LO, /* type */ | |
780 | 0, /* rightshift */ | |
781 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
782 | 16, /* bitsize */ | |
783 | false, /* pc_relative */ | |
784 | 0, /* bitpos */ | |
785 | complain_overflow_dont,/* complain_on_overflow */ | |
786 | bfd_elf_generic_reloc, /* special_function */ | |
787 | "R_PPC_EMB_ADDR16_LO", /* name */ | |
788 | false, /* partial_inplace */ | |
789 | 0, /* src_mask */ | |
790 | 0xffff, /* dst_mask */ | |
791 | false), /* pcrel_offset */ | |
792 | ||
793 | /* The high order 16 bits of the addend minus the symbol */ | |
794 | HOWTO (R_PPC_EMB_NADDR16_HI, /* type */ | |
795 | 16, /* rightshift */ | |
796 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
797 | 16, /* bitsize */ | |
798 | false, /* pc_relative */ | |
799 | 0, /* bitpos */ | |
800 | complain_overflow_dont, /* complain_on_overflow */ | |
801 | bfd_elf_generic_reloc, /* special_function */ | |
802 | "R_PPC_EMB_NADDR16_HI", /* name */ | |
803 | false, /* partial_inplace */ | |
804 | 0, /* src_mask */ | |
805 | 0xffff, /* dst_mask */ | |
806 | false), /* pcrel_offset */ | |
807 | ||
808 | /* The high order 16 bits of the result of the addend minus the address, | |
809 | plus 1 if the contents of the low 16 bits, treated as a signed number, | |
810 | is negative. */ | |
811 | HOWTO (R_PPC_EMB_NADDR16_HA, /* type */ | |
812 | 16, /* rightshift */ | |
813 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
814 | 16, /* bitsize */ | |
815 | false, /* pc_relative */ | |
816 | 0, /* bitpos */ | |
817 | complain_overflow_dont, /* complain_on_overflow */ | |
818 | ppc_elf_addr16_ha_reloc, /* special_function */ | |
819 | "R_PPC_EMB_NADDR16_HA", /* name */ | |
820 | false, /* partial_inplace */ | |
821 | 0, /* src_mask */ | |
822 | 0xffff, /* dst_mask */ | |
823 | false), /* pcrel_offset */ | |
824 | ||
825 | /* 16 bit value resulting from allocating a 4 byte word to hold an | |
826 | address in the .sdata section, and returning the offset from | |
827 | _SDA_BASE_ for that relocation */ | |
828 | HOWTO (R_PPC_EMB_SDAI16, /* type */ | |
829 | 0, /* rightshift */ | |
830 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
831 | 16, /* bitsize */ | |
832 | false, /* pc_relative */ | |
833 | 0, /* bitpos */ | |
834 | complain_overflow_bitfield, /* complain_on_overflow */ | |
835 | bfd_elf_generic_reloc, /* special_function */ | |
836 | "R_PPC_EMB_SDAI16", /* name */ | |
837 | false, /* partial_inplace */ | |
838 | 0, /* src_mask */ | |
839 | 0xffff, /* dst_mask */ | |
840 | false), /* pcrel_offset */ | |
841 | ||
842 | /* 16 bit value resulting from allocating a 4 byte word to hold an | |
843 | address in the .sdata2 section, and returning the offset from | |
844 | _SDA2_BASE_ for that relocation */ | |
845 | HOWTO (R_PPC_EMB_SDA2I16, /* type */ | |
846 | 0, /* rightshift */ | |
847 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
848 | 16, /* bitsize */ | |
849 | false, /* pc_relative */ | |
850 | 0, /* bitpos */ | |
851 | complain_overflow_bitfield, /* complain_on_overflow */ | |
852 | bfd_elf_generic_reloc, /* special_function */ | |
853 | "R_PPC_EMB_SDA2I16", /* name */ | |
854 | false, /* partial_inplace */ | |
855 | 0, /* src_mask */ | |
856 | 0xffff, /* dst_mask */ | |
857 | false), /* pcrel_offset */ | |
858 | ||
859 | /* A sign-extended 16 bit value relative to _SDA2_BASE_, for use with | |
860 | small data items. */ | |
861 | HOWTO (R_PPC_EMB_SDA2REL, /* type */ | |
862 | 0, /* rightshift */ | |
863 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
864 | 16, /* bitsize */ | |
865 | false, /* pc_relative */ | |
866 | 0, /* bitpos */ | |
867 | complain_overflow_signed, /* complain_on_overflow */ | |
868 | bfd_elf_generic_reloc, /* special_function */ | |
869 | "R_PPC_EMB_SDA2REL", /* name */ | |
870 | false, /* partial_inplace */ | |
871 | 0, /* src_mask */ | |
872 | 0xffff, /* dst_mask */ | |
873 | false), /* pcrel_offset */ | |
874 | ||
875 | /* Relocate against either _SDA_BASE_ or _SDA2_BASE_, filling in the 16 bit | |
876 | signed offset from the appropriate base, and filling in the register | |
877 | field with the appropriate register (0, 2, or 13). */ | |
878 | HOWTO (R_PPC_EMB_SDA21, /* type */ | |
879 | 0, /* rightshift */ | |
880 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
881 | 16, /* bitsize */ | |
882 | false, /* pc_relative */ | |
883 | 0, /* bitpos */ | |
884 | complain_overflow_signed, /* complain_on_overflow */ | |
885 | bfd_elf_generic_reloc, /* special_function */ | |
886 | "R_PPC_EMB_SDA21", /* name */ | |
887 | false, /* partial_inplace */ | |
888 | 0, /* src_mask */ | |
889 | 0xffff, /* dst_mask */ | |
890 | false), /* pcrel_offset */ | |
891 | ||
892 | /* Relocation not handled: R_PPC_EMB_MRKREF */ | |
893 | /* Relocation not handled: R_PPC_EMB_RELSEC16 */ | |
894 | /* Relocation not handled: R_PPC_EMB_RELST_LO */ | |
895 | /* Relocation not handled: R_PPC_EMB_RELST_HI */ | |
896 | /* Relocation not handled: R_PPC_EMB_RELST_HA */ | |
897 | /* Relocation not handled: R_PPC_EMB_BIT_FLD */ | |
898 | ||
899 | /* PC relative relocation against either _SDA_BASE_ or _SDA2_BASE_, filling | |
900 | in the 16 bit signed offset from the appropriate base, and filling in the | |
901 | register field with the appropriate register (0, 2, or 13). */ | |
902 | HOWTO (R_PPC_EMB_RELSDA, /* type */ | |
903 | 0, /* rightshift */ | |
904 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
905 | 16, /* bitsize */ | |
906 | true, /* pc_relative */ | |
907 | 0, /* bitpos */ | |
908 | complain_overflow_signed, /* complain_on_overflow */ | |
909 | bfd_elf_generic_reloc, /* special_function */ | |
910 | "R_PPC_EMB_RELSDA", /* name */ | |
911 | false, /* partial_inplace */ | |
912 | 0, /* src_mask */ | |
913 | 0xffff, /* dst_mask */ | |
914 | false), /* pcrel_offset */ | |
915 | ||
916 | /* GNU extension to record C++ vtable hierarchy */ | |
917 | HOWTO (R_PPC_GNU_VTINHERIT, /* type */ | |
918 | 0, /* rightshift */ | |
919 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
920 | 0, /* bitsize */ | |
921 | false, /* pc_relative */ | |
922 | 0, /* bitpos */ | |
923 | complain_overflow_dont, /* complain_on_overflow */ | |
924 | NULL, /* special_function */ | |
925 | "R_PPC_GNU_VTINHERIT", /* name */ | |
926 | false, /* partial_inplace */ | |
927 | 0, /* src_mask */ | |
928 | 0, /* dst_mask */ | |
929 | false), /* pcrel_offset */ | |
930 | ||
931 | /* GNU extension to record C++ vtable member usage */ | |
932 | HOWTO (R_PPC_GNU_VTENTRY, /* type */ | |
933 | 0, /* rightshift */ | |
934 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
935 | 0, /* bitsize */ | |
936 | false, /* pc_relative */ | |
937 | 0, /* bitpos */ | |
938 | complain_overflow_dont, /* complain_on_overflow */ | |
939 | NULL, /* special_function */ | |
940 | "R_PPC_GNU_VTENTRY", /* name */ | |
941 | false, /* partial_inplace */ | |
942 | 0, /* src_mask */ | |
943 | 0, /* dst_mask */ | |
944 | false), /* pcrel_offset */ | |
945 | ||
946 | /* Phony reloc to handle AIX style TOC entries */ | |
947 | HOWTO (R_PPC_TOC16, /* type */ | |
948 | 0, /* rightshift */ | |
949 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
950 | 16, /* bitsize */ | |
951 | false, /* pc_relative */ | |
952 | 0, /* bitpos */ | |
953 | complain_overflow_signed, /* complain_on_overflow */ | |
954 | bfd_elf_generic_reloc, /* special_function */ | |
955 | "R_PPC_TOC16", /* name */ | |
956 | false, /* partial_inplace */ | |
957 | 0, /* src_mask */ | |
958 | 0xffff, /* dst_mask */ | |
959 | false), /* pcrel_offset */ | |
960 | }; | |
252b5132 RH |
961 | \f |
962 | /* Initialize the ppc_elf_howto_table, so that linear accesses can be done. */ | |
963 | ||
964 | static void | |
965 | ppc_elf_howto_init () | |
966 | { | |
967 | unsigned int i, type; | |
968 | ||
969 | for (i = 0; i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); i++) | |
970 | { | |
971 | type = ppc_elf_howto_raw[i].type; | |
c3668558 | 972 | BFD_ASSERT (type < sizeof (ppc_elf_howto_table) / sizeof (ppc_elf_howto_table[0])); |
252b5132 RH |
973 | ppc_elf_howto_table[type] = &ppc_elf_howto_raw[i]; |
974 | } | |
975 | } | |
252b5132 RH |
976 | \f |
977 | /* This function handles relaxing for the PPC with option --mpc860c0[=<n>]. | |
978 | ||
979 | The MPC860, revision C0 or earlier contains a bug in the die. | |
980 | If all of the following conditions are true, the next instruction | |
981 | to be executed *may* be treated as a no-op. | |
982 | 1/ A forward branch is executed. | |
983 | 2/ The branch is predicted as not taken. | |
984 | 3/ The branch is taken. | |
985 | 4/ The branch is located in the last 5 words of a page. | |
986 | (The EOP limit is 5 by default but may be specified as any value from 1-10.) | |
c3668558 | 987 | |
252b5132 RH |
988 | Our software solution is to detect these problematic branches in a |
989 | linker pass and modify them as follows: | |
990 | 1/ Unconditional branches - Since these are always predicted taken, | |
991 | there is no problem and no action is required. | |
992 | 2/ Conditional backward branches - No problem, no action required. | |
993 | 3/ Conditional forward branches - Ensure that the "inverse prediction | |
994 | bit" is set (ensure it is predicted taken). | |
995 | 4/ Conditional register branches - Ensure that the "y bit" is set | |
996 | (ensure it is predicted taken). | |
997 | */ | |
998 | ||
999 | /* Sort sections by address. */ | |
1000 | ||
1001 | static int | |
1002 | ppc_elf_sort_rela (arg1, arg2) | |
a7b97311 AM |
1003 | const PTR arg1; |
1004 | const PTR arg2; | |
252b5132 RH |
1005 | { |
1006 | const Elf_Internal_Rela **rela1 = (const Elf_Internal_Rela**) arg1; | |
1007 | const Elf_Internal_Rela **rela2 = (const Elf_Internal_Rela**) arg2; | |
1008 | ||
c3668558 | 1009 | /* Sort by offset. */ |
252b5132 RH |
1010 | return ((*rela1)->r_offset - (*rela2)->r_offset); |
1011 | } | |
1012 | ||
1013 | static boolean | |
1014 | ppc_elf_relax_section (abfd, isec, link_info, again) | |
8da6118f KH |
1015 | bfd *abfd; |
1016 | asection *isec; | |
1017 | struct bfd_link_info *link_info; | |
1018 | boolean *again; | |
252b5132 RH |
1019 | { |
1020 | #define PAGESIZE 0x1000 | |
1021 | ||
1022 | bfd_byte *contents = NULL; | |
1023 | bfd_byte *free_contents = NULL; | |
1024 | Elf_Internal_Rela *internal_relocs = NULL; | |
1025 | Elf_Internal_Rela *free_relocs = NULL; | |
1026 | Elf_Internal_Rela **rela_comb = NULL; | |
1027 | int comb_curr, comb_count; | |
1028 | ||
c3668558 | 1029 | /* We never have to do this more than once per input section. */ |
252b5132 RH |
1030 | *again = false; |
1031 | ||
1032 | /* If needed, initialize this section's cooked size. */ | |
1033 | if (isec->_cooked_size == 0) | |
1034 | isec->_cooked_size = isec->_raw_size; | |
1035 | ||
1036 | /* We're only interested in text sections which overlap the | |
8da6118f | 1037 | troublesome area at the end of a page. */ |
252b5132 RH |
1038 | if (link_info->mpc860c0 && (isec->flags & SEC_CODE) && isec->_cooked_size) |
1039 | { | |
1040 | bfd_vma dot, end_page, end_section; | |
1041 | boolean section_modified; | |
1042 | ||
c3668558 | 1043 | /* Get the section contents. */ |
252b5132 RH |
1044 | /* Get cached copy if it exists. */ |
1045 | if (elf_section_data (isec)->this_hdr.contents != NULL) | |
1046 | contents = elf_section_data (isec)->this_hdr.contents; | |
1047 | else | |
1048 | { | |
1049 | /* Go get them off disk. */ | |
1050 | contents = (bfd_byte *) bfd_malloc (isec->_raw_size); | |
1051 | if (contents == NULL) | |
8da6118f | 1052 | goto error_return; |
252b5132 RH |
1053 | free_contents = contents; |
1054 | ||
1055 | if (! bfd_get_section_contents (abfd, isec, contents, | |
1056 | (file_ptr) 0, isec->_raw_size)) | |
8da6118f | 1057 | goto error_return; |
252b5132 RH |
1058 | } |
1059 | ||
1060 | comb_curr = 0; | |
1061 | comb_count = 0; | |
1062 | if (isec->reloc_count) | |
8da6118f | 1063 | { |
252b5132 | 1064 | unsigned n; |
dc810e39 | 1065 | bfd_size_type amt; |
252b5132 RH |
1066 | |
1067 | /* Get a copy of the native relocations. */ | |
1068 | internal_relocs = _bfd_elf32_link_read_relocs ( | |
c3668558 | 1069 | abfd, isec, (PTR) NULL, (Elf_Internal_Rela *) NULL, |
252b5132 RH |
1070 | link_info->keep_memory); |
1071 | if (internal_relocs == NULL) | |
1072 | goto error_return; | |
1073 | if (! link_info->keep_memory) | |
1074 | free_relocs = internal_relocs; | |
c3668558 KH |
1075 | |
1076 | /* Setup a faster access method for the reloc info we need. */ | |
dc810e39 AM |
1077 | amt = isec->reloc_count; |
1078 | amt *= sizeof (Elf_Internal_Rela*); | |
1079 | rela_comb = (Elf_Internal_Rela**) bfd_malloc (amt); | |
252b5132 RH |
1080 | if (rela_comb == NULL) |
1081 | goto error_return; | |
8da6118f | 1082 | for (n = 0; n < isec->reloc_count; ++n) |
252b5132 RH |
1083 | { |
1084 | long r_type; | |
c3668558 | 1085 | |
252b5132 | 1086 | r_type = ELF32_R_TYPE (internal_relocs[n].r_info); |
8da6118f | 1087 | if (r_type < 0 || r_type >= (int) R_PPC_max) |
252b5132 | 1088 | goto error_return; |
c3668558 | 1089 | |
252b5132 RH |
1090 | /* Prologue constants are sometimes present in the ".text" |
1091 | sections and they can be identified by their associated relocation. | |
1092 | We don't want to process those words and some others which | |
1093 | can also be identified by their relocations. However, not all | |
1094 | conditional branches will have a relocation so we will | |
1095 | only ignore words that 1) have a reloc, and 2) the reloc | |
1096 | is not applicable to a conditional branch. | |
c3668558 | 1097 | The array rela_comb is built here for use in the EOP scan loop. */ |
252b5132 RH |
1098 | switch (r_type) |
1099 | { | |
1100 | case R_PPC_ADDR14_BRNTAKEN: /* absolute, predicted not taken */ | |
c3668558 | 1101 | case R_PPC_REL14: /* relative cond. br. */ |
252b5132 | 1102 | case R_PPC_REL14_BRNTAKEN: /* rel. cond. br., predicted not taken */ |
c3668558 | 1103 | /* We should check the instruction. */ |
252b5132 RH |
1104 | break; |
1105 | default: | |
c3668558 | 1106 | /* The word is not a conditional branch - ignore it. */ |
252b5132 RH |
1107 | rela_comb[comb_count++] = &internal_relocs[n]; |
1108 | break; | |
1109 | } | |
1110 | } | |
1111 | if (comb_count > 1) | |
8da6118f KH |
1112 | qsort (rela_comb, (size_t) comb_count, sizeof (int), ppc_elf_sort_rela); |
1113 | } | |
252b5132 | 1114 | |
c3668558 | 1115 | /* Enumerate each EOP region that overlaps this section. */ |
252b5132 RH |
1116 | end_section = isec->vma + isec->_cooked_size; |
1117 | dot = end_page = (isec->vma | (PAGESIZE - 1)) + 1; | |
1118 | dot -= link_info->mpc860c0; | |
1119 | section_modified = false; | |
1120 | if (dot < isec->vma) /* Increment the start position if this section */ | |
c3668558 | 1121 | dot = isec->vma; /* begins in the middle of its first EOP region. */ |
252b5132 RH |
1122 | for (; |
1123 | dot < end_section; | |
1124 | dot += PAGESIZE, end_page += PAGESIZE) | |
1125 | { | |
1126 | ||
c3668558 | 1127 | /* Check each word in this EOP region. */ |
252b5132 RH |
1128 | for (; dot < end_page; dot += 4) |
1129 | { | |
1130 | bfd_vma isec_offset; | |
1131 | unsigned long insn; | |
1132 | boolean skip, modified; | |
1133 | ||
1134 | /* Don't process this word if there is a relocation for it and | |
c3668558 | 1135 | the relocation indicates the word is not a conditional branch. */ |
252b5132 RH |
1136 | skip = false; |
1137 | isec_offset = dot - isec->vma; | |
1138 | for (; comb_curr<comb_count; ++comb_curr) | |
1139 | { | |
1140 | bfd_vma r_offset; | |
1141 | ||
1142 | r_offset = rela_comb[comb_curr]->r_offset; | |
1143 | if (r_offset >= isec_offset) | |
1144 | { | |
1145 | if (r_offset == isec_offset) skip = true; | |
1146 | break; | |
1147 | } | |
1148 | } | |
1149 | if (skip) continue; | |
1150 | ||
c3668558 | 1151 | /* Check the current word for a problematic conditional branch. */ |
252b5132 RH |
1152 | #define BO0(insn) ((insn) & 0x02000000) |
1153 | #define BO2(insn) ((insn) & 0x00800000) | |
1154 | #define BO4(insn) ((insn) & 0x00200000) | |
1155 | insn = (unsigned long) bfd_get_32 (abfd, contents + isec_offset); | |
1156 | modified = false; | |
1157 | if ((insn & 0xFc000000) == 0x40000000) | |
1158 | { | |
1159 | /* Instruction is BCx */ | |
1160 | if ((!BO0(insn) || !BO2(insn)) && !BO4(insn)) | |
1161 | { | |
1162 | bfd_vma target; | |
1163 | /* This branch is predicted as "normal". | |
c3668558 | 1164 | If this is a forward branch, it is problematic. */ |
252b5132 RH |
1165 | |
1166 | target = insn & 0x0000Fffc; /*extract*/ | |
1167 | target = (target ^ 0x8000) - 0x8000; /*sign extend*/ | |
1168 | if ((insn & 0x00000002) == 0) | |
1169 | target += dot; /*convert to abs*/ | |
1170 | if (target > dot) | |
1171 | { | |
1172 | insn |= 0x00200000; /* set the prediction bit */ | |
1173 | modified = true; | |
1174 | } | |
1175 | } | |
1176 | } | |
1177 | else if ((insn & 0xFc00Fffe) == 0x4c000420) | |
1178 | { | |
1179 | /* Instruction is BCCTRx */ | |
1180 | if ((!BO0(insn) || !BO2(insn)) && !BO4(insn)) | |
1181 | { | |
1182 | /* This branch is predicted as not-taken. | |
1183 | If this is a forward branch, it is problematic. | |
1184 | Since we can't tell statically if it will branch forward, | |
c3668558 | 1185 | always set the prediction bit. */ |
252b5132 RH |
1186 | insn |= 0x00200000; /* set the prediction bit */ |
1187 | modified = true; | |
1188 | } | |
1189 | } | |
1190 | else if ((insn & 0xFc00Fffe) == 0x4c000020) | |
1191 | { | |
1192 | /* Instruction is BCLRx */ | |
1193 | if ((!BO0(insn) || !BO2(insn)) && !BO4(insn)) | |
1194 | { | |
1195 | /* This branch is predicted as not-taken. | |
1196 | If this is a forward branch, it is problematic. | |
1197 | Since we can't tell statically if it will branch forward, | |
c3668558 | 1198 | always set the prediction bit. */ |
252b5132 RH |
1199 | insn |= 0x00200000; /* set the prediction bit */ |
1200 | modified = true; | |
1201 | } | |
1202 | } | |
1203 | #undef BO0 | |
1204 | #undef BO2 | |
1205 | #undef BO4 | |
1206 | if (modified) | |
1207 | { | |
dc810e39 | 1208 | bfd_put_32 (abfd, (bfd_vma) insn, contents + isec_offset); |
252b5132 RH |
1209 | section_modified = true; |
1210 | } | |
1211 | } | |
1212 | } | |
1213 | if (section_modified) | |
1214 | { | |
1215 | elf_section_data (isec)->this_hdr.contents = contents; | |
1216 | free_contents = NULL; | |
1217 | } | |
1218 | } | |
1219 | ||
1220 | if (rela_comb != NULL) | |
1221 | { | |
1222 | free (rela_comb); | |
1223 | rela_comb = NULL; | |
1224 | } | |
1225 | ||
1226 | if (free_relocs != NULL) | |
1227 | { | |
1228 | free (free_relocs); | |
1229 | free_relocs = NULL; | |
1230 | } | |
1231 | ||
1232 | if (free_contents != NULL) | |
1233 | { | |
1234 | if (! link_info->keep_memory) | |
1235 | free (free_contents); | |
1236 | else | |
1237 | { | |
1238 | /* Cache the section contents for elf_link_input_bfd. */ | |
1239 | elf_section_data (isec)->this_hdr.contents = contents; | |
1240 | } | |
1241 | free_contents = NULL; | |
1242 | } | |
1243 | ||
1244 | return true; | |
1245 | ||
1246 | error_return: | |
1247 | if (rela_comb != NULL) | |
1248 | free (rela_comb); | |
1249 | if (free_relocs != NULL) | |
1250 | free (free_relocs); | |
1251 | if (free_contents != NULL) | |
1252 | free (free_contents); | |
1253 | return false; | |
1254 | } | |
252b5132 RH |
1255 | \f |
1256 | static reloc_howto_type * | |
1257 | ppc_elf_reloc_type_lookup (abfd, code) | |
5f771d47 | 1258 | bfd *abfd ATTRIBUTE_UNUSED; |
252b5132 RH |
1259 | bfd_reloc_code_real_type code; |
1260 | { | |
1261 | enum elf_ppc_reloc_type ppc_reloc = R_PPC_NONE; | |
1262 | ||
1263 | if (!ppc_elf_howto_table[R_PPC_ADDR32]) | |
8da6118f | 1264 | /* Initialize howto table if needed. */ |
252b5132 RH |
1265 | ppc_elf_howto_init (); |
1266 | ||
8da6118f | 1267 | switch ((int) code) |
252b5132 RH |
1268 | { |
1269 | default: | |
8da6118f | 1270 | return (reloc_howto_type *) NULL; |
252b5132 RH |
1271 | |
1272 | case BFD_RELOC_NONE: ppc_reloc = R_PPC_NONE; break; | |
1273 | case BFD_RELOC_32: ppc_reloc = R_PPC_ADDR32; break; | |
1274 | case BFD_RELOC_PPC_BA26: ppc_reloc = R_PPC_ADDR24; break; | |
1275 | case BFD_RELOC_16: ppc_reloc = R_PPC_ADDR16; break; | |
1276 | case BFD_RELOC_LO16: ppc_reloc = R_PPC_ADDR16_LO; break; | |
1277 | case BFD_RELOC_HI16: ppc_reloc = R_PPC_ADDR16_HI; break; | |
1278 | case BFD_RELOC_HI16_S: ppc_reloc = R_PPC_ADDR16_HA; break; | |
1279 | case BFD_RELOC_PPC_BA16: ppc_reloc = R_PPC_ADDR14; break; | |
1280 | case BFD_RELOC_PPC_BA16_BRTAKEN: ppc_reloc = R_PPC_ADDR14_BRTAKEN; break; | |
1281 | case BFD_RELOC_PPC_BA16_BRNTAKEN: ppc_reloc = R_PPC_ADDR14_BRNTAKEN; break; | |
1282 | case BFD_RELOC_PPC_B26: ppc_reloc = R_PPC_REL24; break; | |
1283 | case BFD_RELOC_PPC_B16: ppc_reloc = R_PPC_REL14; break; | |
1284 | case BFD_RELOC_PPC_B16_BRTAKEN: ppc_reloc = R_PPC_REL14_BRTAKEN; break; | |
1285 | case BFD_RELOC_PPC_B16_BRNTAKEN: ppc_reloc = R_PPC_REL14_BRNTAKEN; break; | |
1286 | case BFD_RELOC_16_GOTOFF: ppc_reloc = R_PPC_GOT16; break; | |
1287 | case BFD_RELOC_LO16_GOTOFF: ppc_reloc = R_PPC_GOT16_LO; break; | |
1288 | case BFD_RELOC_HI16_GOTOFF: ppc_reloc = R_PPC_GOT16_HI; break; | |
1289 | case BFD_RELOC_HI16_S_GOTOFF: ppc_reloc = R_PPC_GOT16_HA; break; | |
1290 | case BFD_RELOC_24_PLT_PCREL: ppc_reloc = R_PPC_PLTREL24; break; | |
1291 | case BFD_RELOC_PPC_COPY: ppc_reloc = R_PPC_COPY; break; | |
1292 | case BFD_RELOC_PPC_GLOB_DAT: ppc_reloc = R_PPC_GLOB_DAT; break; | |
1293 | case BFD_RELOC_PPC_LOCAL24PC: ppc_reloc = R_PPC_LOCAL24PC; break; | |
1294 | case BFD_RELOC_32_PCREL: ppc_reloc = R_PPC_REL32; break; | |
1295 | case BFD_RELOC_32_PLTOFF: ppc_reloc = R_PPC_PLT32; break; | |
1296 | case BFD_RELOC_32_PLT_PCREL: ppc_reloc = R_PPC_PLTREL32; break; | |
1297 | case BFD_RELOC_LO16_PLTOFF: ppc_reloc = R_PPC_PLT16_LO; break; | |
1298 | case BFD_RELOC_HI16_PLTOFF: ppc_reloc = R_PPC_PLT16_HI; break; | |
1299 | case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC_PLT16_HA; break; | |
1300 | case BFD_RELOC_GPREL16: ppc_reloc = R_PPC_SDAREL16; break; | |
c061c2d8 | 1301 | case BFD_RELOC_16_BASEREL: ppc_reloc = R_PPC_SECTOFF; break; |
252b5132 RH |
1302 | case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC_SECTOFF_LO; break; |
1303 | case BFD_RELOC_HI16_BASEREL: ppc_reloc = R_PPC_SECTOFF_HI; break; | |
1304 | case BFD_RELOC_HI16_S_BASEREL: ppc_reloc = R_PPC_SECTOFF_HA; break; | |
1305 | case BFD_RELOC_CTOR: ppc_reloc = R_PPC_ADDR32; break; | |
1306 | case BFD_RELOC_PPC_TOC16: ppc_reloc = R_PPC_TOC16; break; | |
1307 | case BFD_RELOC_PPC_EMB_NADDR32: ppc_reloc = R_PPC_EMB_NADDR32; break; | |
1308 | case BFD_RELOC_PPC_EMB_NADDR16: ppc_reloc = R_PPC_EMB_NADDR16; break; | |
1309 | case BFD_RELOC_PPC_EMB_NADDR16_LO: ppc_reloc = R_PPC_EMB_NADDR16_LO; break; | |
1310 | case BFD_RELOC_PPC_EMB_NADDR16_HI: ppc_reloc = R_PPC_EMB_NADDR16_HI; break; | |
1311 | case BFD_RELOC_PPC_EMB_NADDR16_HA: ppc_reloc = R_PPC_EMB_NADDR16_HA; break; | |
1312 | case BFD_RELOC_PPC_EMB_SDAI16: ppc_reloc = R_PPC_EMB_SDAI16; break; | |
1313 | case BFD_RELOC_PPC_EMB_SDA2I16: ppc_reloc = R_PPC_EMB_SDA2I16; break; | |
1314 | case BFD_RELOC_PPC_EMB_SDA2REL: ppc_reloc = R_PPC_EMB_SDA2REL; break; | |
1315 | case BFD_RELOC_PPC_EMB_SDA21: ppc_reloc = R_PPC_EMB_SDA21; break; | |
1316 | case BFD_RELOC_PPC_EMB_MRKREF: ppc_reloc = R_PPC_EMB_MRKREF; break; | |
1317 | case BFD_RELOC_PPC_EMB_RELSEC16: ppc_reloc = R_PPC_EMB_RELSEC16; break; | |
1318 | case BFD_RELOC_PPC_EMB_RELST_LO: ppc_reloc = R_PPC_EMB_RELST_LO; break; | |
1319 | case BFD_RELOC_PPC_EMB_RELST_HI: ppc_reloc = R_PPC_EMB_RELST_HI; break; | |
1320 | case BFD_RELOC_PPC_EMB_RELST_HA: ppc_reloc = R_PPC_EMB_RELST_HA; break; | |
1321 | case BFD_RELOC_PPC_EMB_BIT_FLD: ppc_reloc = R_PPC_EMB_BIT_FLD; break; | |
1322 | case BFD_RELOC_PPC_EMB_RELSDA: ppc_reloc = R_PPC_EMB_RELSDA; break; | |
1323 | case BFD_RELOC_VTABLE_INHERIT: ppc_reloc = R_PPC_GNU_VTINHERIT; break; | |
1324 | case BFD_RELOC_VTABLE_ENTRY: ppc_reloc = R_PPC_GNU_VTENTRY; break; | |
1325 | } | |
1326 | ||
8da6118f | 1327 | return ppc_elf_howto_table[(int) ppc_reloc]; |
252b5132 RH |
1328 | }; |
1329 | ||
1330 | /* Set the howto pointer for a PowerPC ELF reloc. */ | |
1331 | ||
1332 | static void | |
1333 | ppc_elf_info_to_howto (abfd, cache_ptr, dst) | |
5f771d47 | 1334 | bfd *abfd ATTRIBUTE_UNUSED; |
252b5132 | 1335 | arelent *cache_ptr; |
947216bf | 1336 | Elf_Internal_Rela *dst; |
252b5132 | 1337 | { |
8da6118f KH |
1338 | if (!ppc_elf_howto_table[R_PPC_ADDR32]) |
1339 | /* Initialize howto table if needed. */ | |
252b5132 RH |
1340 | ppc_elf_howto_init (); |
1341 | ||
1342 | BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_PPC_max); | |
1343 | cache_ptr->howto = ppc_elf_howto_table[ELF32_R_TYPE (dst->r_info)]; | |
1344 | } | |
1345 | ||
1346 | /* Handle the R_PPC_ADDR16_HA reloc. */ | |
1347 | ||
1348 | static bfd_reloc_status_type | |
1349 | ppc_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section, | |
1350 | output_bfd, error_message) | |
5f771d47 | 1351 | bfd *abfd ATTRIBUTE_UNUSED; |
252b5132 RH |
1352 | arelent *reloc_entry; |
1353 | asymbol *symbol; | |
5f771d47 | 1354 | PTR data ATTRIBUTE_UNUSED; |
252b5132 RH |
1355 | asection *input_section; |
1356 | bfd *output_bfd; | |
5f771d47 | 1357 | char **error_message ATTRIBUTE_UNUSED; |
252b5132 RH |
1358 | { |
1359 | bfd_vma relocation; | |
1360 | ||
1361 | if (output_bfd != NULL) | |
1362 | { | |
1363 | reloc_entry->address += input_section->output_offset; | |
1364 | return bfd_reloc_ok; | |
1365 | } | |
1366 | ||
1367 | if (reloc_entry->address > input_section->_cooked_size) | |
1368 | return bfd_reloc_outofrange; | |
1369 | ||
1370 | if (bfd_is_com_section (symbol->section)) | |
1371 | relocation = 0; | |
1372 | else | |
1373 | relocation = symbol->value; | |
1374 | ||
1375 | relocation += symbol->section->output_section->vma; | |
1376 | relocation += symbol->section->output_offset; | |
1377 | relocation += reloc_entry->addend; | |
1378 | ||
1379 | reloc_entry->addend += (relocation & 0x8000) << 1; | |
1380 | ||
1381 | return bfd_reloc_continue; | |
1382 | } | |
1383 | ||
feee612b AM |
1384 | /* Fix bad default arch selected for a 32 bit input bfd when the |
1385 | default is 64 bit. */ | |
1386 | ||
1387 | static boolean | |
1388 | ppc_elf_object_p (abfd) | |
1389 | bfd *abfd; | |
1390 | { | |
1391 | if (abfd->arch_info->the_default && abfd->arch_info->bits_per_word == 64) | |
1392 | { | |
1393 | Elf_Internal_Ehdr *i_ehdr = elf_elfheader (abfd); | |
1394 | ||
1395 | if (i_ehdr->e_ident[EI_CLASS] == ELFCLASS32) | |
1396 | { | |
1397 | /* Relies on arch after 64 bit default being 32 bit default. */ | |
1398 | abfd->arch_info = abfd->arch_info->next; | |
1399 | BFD_ASSERT (abfd->arch_info->bits_per_word == 32); | |
1400 | } | |
1401 | } | |
1402 | return true; | |
1403 | } | |
1404 | ||
c3668558 | 1405 | /* Function to set whether a module needs the -mrelocatable bit set. */ |
252b5132 RH |
1406 | |
1407 | static boolean | |
1408 | ppc_elf_set_private_flags (abfd, flags) | |
1409 | bfd *abfd; | |
1410 | flagword flags; | |
1411 | { | |
1412 | BFD_ASSERT (!elf_flags_init (abfd) | |
1413 | || elf_elfheader (abfd)->e_flags == flags); | |
1414 | ||
1415 | elf_elfheader (abfd)->e_flags = flags; | |
1416 | elf_flags_init (abfd) = true; | |
1417 | return true; | |
1418 | } | |
1419 | ||
252b5132 RH |
1420 | /* Merge backend specific data from an object file to the output |
1421 | object file when linking */ | |
1422 | static boolean | |
1423 | ppc_elf_merge_private_bfd_data (ibfd, obfd) | |
1424 | bfd *ibfd; | |
1425 | bfd *obfd; | |
1426 | { | |
1427 | flagword old_flags; | |
1428 | flagword new_flags; | |
1429 | boolean error; | |
1430 | ||
1431 | /* Check if we have the same endianess */ | |
82e51918 | 1432 | if (! _bfd_generic_verify_endian_match (ibfd, obfd)) |
1fe494a5 | 1433 | return false; |
252b5132 RH |
1434 | |
1435 | if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour | |
1436 | || bfd_get_flavour (obfd) != bfd_target_elf_flavour) | |
1437 | return true; | |
1438 | ||
1439 | new_flags = elf_elfheader (ibfd)->e_flags; | |
1440 | old_flags = elf_elfheader (obfd)->e_flags; | |
1441 | if (!elf_flags_init (obfd)) /* First call, no flags set */ | |
1442 | { | |
1443 | elf_flags_init (obfd) = true; | |
1444 | elf_elfheader (obfd)->e_flags = new_flags; | |
1445 | } | |
1446 | ||
1447 | else if (new_flags == old_flags) /* Compatible flags are ok */ | |
1448 | ; | |
1449 | ||
1450 | else /* Incompatible flags */ | |
1451 | { | |
1452 | /* Warn about -mrelocatable mismatch. Allow -mrelocatable-lib to be linked | |
1453 | with either. */ | |
1454 | error = false; | |
1455 | if ((new_flags & EF_PPC_RELOCATABLE) != 0 | |
1456 | && (old_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0) | |
1457 | { | |
1458 | error = true; | |
1459 | (*_bfd_error_handler) | |
1460 | (_("%s: compiled with -mrelocatable and linked with modules compiled normally"), | |
8f615d07 | 1461 | bfd_archive_filename (ibfd)); |
252b5132 RH |
1462 | } |
1463 | else if ((new_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0 | |
1464 | && (old_flags & EF_PPC_RELOCATABLE) != 0) | |
1465 | { | |
1466 | error = true; | |
1467 | (*_bfd_error_handler) | |
1468 | (_("%s: compiled normally and linked with modules compiled with -mrelocatable"), | |
8f615d07 | 1469 | bfd_archive_filename (ibfd)); |
252b5132 RH |
1470 | } |
1471 | ||
1472 | /* The output is -mrelocatable-lib iff both the input files are. */ | |
1473 | if (! (new_flags & EF_PPC_RELOCATABLE_LIB)) | |
1474 | elf_elfheader (obfd)->e_flags &= ~EF_PPC_RELOCATABLE_LIB; | |
1475 | ||
1476 | /* The output is -mrelocatable iff it can't be -mrelocatable-lib, | |
1477 | but each input file is either -mrelocatable or -mrelocatable-lib. */ | |
1478 | if (! (elf_elfheader (obfd)->e_flags & EF_PPC_RELOCATABLE_LIB) | |
1479 | && (new_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE)) | |
1480 | && (old_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE))) | |
1481 | elf_elfheader (obfd)->e_flags |= EF_PPC_RELOCATABLE; | |
1482 | ||
1483 | /* Do not warn about eabi vs. V.4 mismatch, just or in the bit if any module uses it */ | |
1484 | elf_elfheader (obfd)->e_flags |= (new_flags & EF_PPC_EMB); | |
1485 | ||
1486 | new_flags &= ~ (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB); | |
1487 | old_flags &= ~ (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB); | |
1488 | ||
1489 | /* Warn about any other mismatches */ | |
1490 | if (new_flags != old_flags) | |
1491 | { | |
1492 | error = true; | |
1493 | (*_bfd_error_handler) | |
1494 | (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"), | |
8f615d07 | 1495 | bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags); |
252b5132 RH |
1496 | } |
1497 | ||
1498 | if (error) | |
1499 | { | |
1500 | bfd_set_error (bfd_error_bad_value); | |
1501 | return false; | |
1502 | } | |
1503 | } | |
1504 | ||
1505 | return true; | |
1506 | } | |
252b5132 RH |
1507 | \f |
1508 | /* Handle a PowerPC specific section when reading an object file. This | |
1509 | is called when elfcode.h finds a section with an unknown type. */ | |
1510 | ||
1511 | static boolean | |
1512 | ppc_elf_section_from_shdr (abfd, hdr, name) | |
1513 | bfd *abfd; | |
947216bf | 1514 | Elf_Internal_Shdr *hdr; |
90937f86 | 1515 | const char *name; |
252b5132 RH |
1516 | { |
1517 | asection *newsect; | |
1518 | flagword flags; | |
1519 | ||
1520 | if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) | |
1521 | return false; | |
1522 | ||
1523 | newsect = hdr->bfd_section; | |
1524 | flags = bfd_get_section_flags (abfd, newsect); | |
1525 | if (hdr->sh_flags & SHF_EXCLUDE) | |
1526 | flags |= SEC_EXCLUDE; | |
1527 | ||
1528 | if (hdr->sh_type == SHT_ORDERED) | |
1529 | flags |= SEC_SORT_ENTRIES; | |
1530 | ||
1531 | bfd_set_section_flags (abfd, newsect, flags); | |
1532 | return true; | |
1533 | } | |
252b5132 RH |
1534 | \f |
1535 | /* Set up any other section flags and such that may be necessary. */ | |
1536 | ||
1537 | static boolean | |
1538 | ppc_elf_fake_sections (abfd, shdr, asect) | |
5f771d47 | 1539 | bfd *abfd ATTRIBUTE_UNUSED; |
947216bf | 1540 | Elf_Internal_Shdr *shdr; |
252b5132 RH |
1541 | asection *asect; |
1542 | { | |
1543 | if ((asect->flags & SEC_EXCLUDE) != 0) | |
1544 | shdr->sh_flags |= SHF_EXCLUDE; | |
1545 | ||
1546 | if ((asect->flags & SEC_SORT_ENTRIES) != 0) | |
1547 | shdr->sh_type = SHT_ORDERED; | |
1548 | ||
1549 | return true; | |
1550 | } | |
252b5132 RH |
1551 | \f |
1552 | /* Create a special linker section */ | |
1553 | static elf_linker_section_t * | |
1554 | ppc_elf_create_linker_section (abfd, info, which) | |
1555 | bfd *abfd; | |
1556 | struct bfd_link_info *info; | |
1557 | enum elf_linker_section_enum which; | |
1558 | { | |
1559 | bfd *dynobj = elf_hash_table (info)->dynobj; | |
1560 | elf_linker_section_t *lsect; | |
1561 | ||
1562 | /* Record the first bfd section that needs the special section */ | |
1563 | if (!dynobj) | |
1564 | dynobj = elf_hash_table (info)->dynobj = abfd; | |
1565 | ||
1566 | /* If this is the first time, create the section */ | |
1567 | lsect = elf_linker_section (dynobj, which); | |
1568 | if (!lsect) | |
1569 | { | |
1570 | elf_linker_section_t defaults; | |
1571 | static elf_linker_section_t zero_section; | |
1572 | ||
1573 | defaults = zero_section; | |
1574 | defaults.which = which; | |
1575 | defaults.hole_written_p = false; | |
1576 | defaults.alignment = 2; | |
1577 | ||
1578 | /* Both of these sections are (technically) created by the user | |
1579 | putting data in them, so they shouldn't be marked | |
1580 | SEC_LINKER_CREATED. | |
1581 | ||
1582 | The linker creates them so it has somewhere to attach their | |
1583 | respective symbols. In fact, if they were empty it would | |
1584 | be OK to leave the symbol set to 0 (or any random number), because | |
1585 | the appropriate register should never be used. */ | |
1586 | defaults.flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | |
1587 | | SEC_IN_MEMORY); | |
1588 | ||
1589 | switch (which) | |
1590 | { | |
1591 | default: | |
1592 | (*_bfd_error_handler) (_("%s: Unknown special linker type %d"), | |
1593 | bfd_get_filename (abfd), | |
8da6118f | 1594 | (int) which); |
252b5132 RH |
1595 | |
1596 | bfd_set_error (bfd_error_bad_value); | |
8da6118f | 1597 | return (elf_linker_section_t *) 0; |
252b5132 RH |
1598 | |
1599 | case LINKER_SECTION_SDATA: /* .sdata/.sbss section */ | |
1600 | defaults.name = ".sdata"; | |
1601 | defaults.rel_name = ".rela.sdata"; | |
1602 | defaults.bss_name = ".sbss"; | |
1603 | defaults.sym_name = "_SDA_BASE_"; | |
1604 | defaults.sym_offset = 32768; | |
1605 | break; | |
1606 | ||
1607 | case LINKER_SECTION_SDATA2: /* .sdata2/.sbss2 section */ | |
1608 | defaults.name = ".sdata2"; | |
1609 | defaults.rel_name = ".rela.sdata2"; | |
1610 | defaults.bss_name = ".sbss2"; | |
1611 | defaults.sym_name = "_SDA2_BASE_"; | |
1612 | defaults.sym_offset = 32768; | |
1613 | defaults.flags |= SEC_READONLY; | |
1614 | break; | |
1615 | } | |
1616 | ||
1617 | lsect = _bfd_elf_create_linker_section (abfd, info, which, &defaults); | |
1618 | } | |
1619 | ||
1620 | return lsect; | |
1621 | } | |
252b5132 | 1622 | \f |
8da6118f KH |
1623 | /* If we have a non-zero sized .sbss2 or .PPC.EMB.sbss0 sections, we |
1624 | need to bump up the number of section headers. */ | |
252b5132 RH |
1625 | |
1626 | static int | |
1627 | ppc_elf_additional_program_headers (abfd) | |
1628 | bfd *abfd; | |
1629 | { | |
1630 | asection *s; | |
1631 | int ret; | |
1632 | ||
1633 | ret = 0; | |
1634 | ||
1635 | s = bfd_get_section_by_name (abfd, ".interp"); | |
1636 | if (s != NULL) | |
1637 | ++ret; | |
1638 | ||
1639 | s = bfd_get_section_by_name (abfd, ".sbss2"); | |
1640 | if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0) | |
1641 | ++ret; | |
1642 | ||
1643 | s = bfd_get_section_by_name (abfd, ".PPC.EMB.sbss0"); | |
1644 | if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0) | |
1645 | ++ret; | |
1646 | ||
1647 | return ret; | |
1648 | } | |
1649 | ||
8da6118f | 1650 | /* Modify the segment map if needed. */ |
252b5132 RH |
1651 | |
1652 | static boolean | |
1653 | ppc_elf_modify_segment_map (abfd) | |
5f771d47 | 1654 | bfd *abfd ATTRIBUTE_UNUSED; |
252b5132 RH |
1655 | { |
1656 | return true; | |
1657 | } | |
1658 | \f | |
41fcb14e AM |
1659 | /* The powerpc .got has a blrl instruction in it. Mark it executable. */ |
1660 | ||
1661 | static asection * | |
1662 | ppc_elf_create_got (abfd, info) | |
1663 | bfd *abfd; | |
1664 | struct bfd_link_info *info; | |
1665 | { | |
1666 | register asection *s; | |
1667 | flagword flags; | |
1668 | ||
1669 | if (!_bfd_elf_create_got_section (abfd, info)) | |
1670 | return NULL; | |
1671 | ||
1672 | s = bfd_get_section_by_name (abfd, ".got"); | |
1673 | if (s == NULL) | |
1674 | abort (); | |
1675 | ||
1676 | flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY | |
1677 | | SEC_LINKER_CREATED); | |
1678 | if (!bfd_set_section_flags (abfd, s, flags)) | |
1679 | return NULL; | |
1680 | return s; | |
1681 | } | |
1682 | ||
252b5132 RH |
1683 | /* We have to create .dynsbss and .rela.sbss here so that they get mapped |
1684 | to output sections (just like _bfd_elf_create_dynamic_sections has | |
1685 | to create .dynbss and .rela.bss). */ | |
1686 | ||
1687 | static boolean | |
1688 | ppc_elf_create_dynamic_sections (abfd, info) | |
1689 | bfd *abfd; | |
1690 | struct bfd_link_info *info; | |
1691 | { | |
1692 | register asection *s; | |
1693 | flagword flags; | |
1694 | ||
41fcb14e AM |
1695 | if (!ppc_elf_create_got (abfd, info)) |
1696 | return false; | |
1697 | ||
8da6118f | 1698 | if (!_bfd_elf_create_dynamic_sections (abfd, info)) |
252b5132 RH |
1699 | return false; |
1700 | ||
1701 | flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | |
1702 | | SEC_LINKER_CREATED); | |
1703 | ||
1704 | s = bfd_make_section (abfd, ".dynsbss"); | |
1705 | if (s == NULL | |
1706 | || ! bfd_set_section_flags (abfd, s, SEC_ALLOC)) | |
1707 | return false; | |
1708 | ||
1709 | if (! info->shared) | |
1710 | { | |
1711 | s = bfd_make_section (abfd, ".rela.sbss"); | |
1712 | if (s == NULL | |
1713 | || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) | |
1714 | || ! bfd_set_section_alignment (abfd, s, 2)) | |
1715 | return false; | |
1716 | } | |
41fcb14e AM |
1717 | |
1718 | s = bfd_get_section_by_name (abfd, ".plt"); | |
1719 | if (s == NULL) | |
1720 | abort (); | |
1721 | ||
1722 | flags = SEC_ALLOC | SEC_CODE | SEC_IN_MEMORY | SEC_LINKER_CREATED; | |
1723 | return bfd_set_section_flags (abfd, s, flags); | |
252b5132 RH |
1724 | } |
1725 | ||
1726 | /* Adjust a symbol defined by a dynamic object and referenced by a | |
1727 | regular object. The current definition is in some section of the | |
1728 | dynamic object, but we're not including those sections. We have to | |
1729 | change the definition to something the rest of the link can | |
1730 | understand. */ | |
1731 | ||
1732 | static boolean | |
1733 | ppc_elf_adjust_dynamic_symbol (info, h) | |
1734 | struct bfd_link_info *info; | |
1735 | struct elf_link_hash_entry *h; | |
1736 | { | |
1737 | bfd *dynobj = elf_hash_table (info)->dynobj; | |
1738 | asection *s; | |
1739 | unsigned int power_of_two; | |
1740 | bfd_vma plt_offset; | |
1741 | ||
1742 | #ifdef DEBUG | |
1743 | fprintf (stderr, "ppc_elf_adjust_dynamic_symbol called for %s\n", h->root.root.string); | |
1744 | #endif | |
1745 | ||
1746 | /* Make sure we know what is going on here. */ | |
1747 | BFD_ASSERT (dynobj != NULL | |
1748 | && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) | |
1749 | || h->weakdef != NULL | |
1750 | || ((h->elf_link_hash_flags | |
1751 | & ELF_LINK_HASH_DEF_DYNAMIC) != 0 | |
1752 | && (h->elf_link_hash_flags | |
1753 | & ELF_LINK_HASH_REF_REGULAR) != 0 | |
1754 | && (h->elf_link_hash_flags | |
1755 | & ELF_LINK_HASH_DEF_REGULAR) == 0))); | |
1756 | ||
252b5132 RH |
1757 | /* If this is a function, put it in the procedure linkage table. We |
1758 | will fill in the contents of the procedure linkage table later, | |
1759 | when we know the address of the .got section. */ | |
1760 | if (h->type == STT_FUNC | |
1761 | || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) | |
1762 | { | |
1763 | if (! elf_hash_table (info)->dynamic_sections_created | |
e1e0340b | 1764 | || SYMBOL_CALLS_LOCAL (info, h) |
252b5132 RH |
1765 | || (info->shared && h->plt.refcount <= 0)) |
1766 | { | |
1767 | /* A PLT entry is not required/allowed when: | |
1768 | ||
1769 | 1. We are not using ld.so; because then the PLT entry | |
1770 | can't be set up, so we can't use one. | |
1771 | ||
e1e0340b GK |
1772 | 2. We know for certain that a call to this symbol |
1773 | will go to this object. | |
252b5132 RH |
1774 | |
1775 | 3. GC has rendered the entry unused. | |
1776 | Note, however, that in an executable all references to the | |
1777 | symbol go to the PLT, so we can't turn it off in that case. | |
1778 | ??? The correct thing to do here is to reference count | |
1779 | all uses of the symbol, not just those to the GOT or PLT. */ | |
1780 | h->plt.offset = (bfd_vma) -1; | |
1781 | h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; | |
1782 | return true; | |
1783 | } | |
1784 | ||
1785 | /* Make sure this symbol is output as a dynamic symbol. */ | |
1786 | if (h->dynindx == -1) | |
1787 | { | |
1788 | if (! bfd_elf32_link_record_dynamic_symbol (info, h)) | |
1789 | return false; | |
1790 | } | |
1791 | BFD_ASSERT (h->dynindx != -1); | |
1792 | ||
1793 | s = bfd_get_section_by_name (dynobj, ".plt"); | |
1794 | BFD_ASSERT (s != NULL); | |
1795 | ||
1796 | /* If this is the first .plt entry, make room for the special | |
1797 | first entry. */ | |
1798 | if (s->_raw_size == 0) | |
1799 | s->_raw_size += PLT_INITIAL_ENTRY_SIZE; | |
1800 | ||
1801 | /* The PowerPC PLT is actually composed of two parts, the first part | |
1802 | is 2 words (for a load and a jump), and then there is a remaining | |
1803 | word available at the end. */ | |
1804 | plt_offset = (PLT_INITIAL_ENTRY_SIZE | |
1805 | + (PLT_SLOT_SIZE | |
1806 | * ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) | |
1807 | / PLT_ENTRY_SIZE))); | |
1808 | ||
1809 | /* If this symbol is not defined in a regular file, and we are | |
1810 | not generating a shared library, then set the symbol to this | |
1811 | location in the .plt. This is required to make function | |
1812 | pointers compare as equal between the normal executable and | |
1813 | the shared library. */ | |
1814 | if (! info->shared | |
1815 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) | |
1816 | { | |
1817 | h->root.u.def.section = s; | |
1818 | h->root.u.def.value = plt_offset; | |
1819 | } | |
1820 | ||
1821 | h->plt.offset = plt_offset; | |
1822 | ||
1823 | /* Make room for this entry. After the 8192nd entry, room | |
1824 | for two entries is allocated. */ | |
1825 | if ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE | |
1826 | >= PLT_NUM_SINGLE_ENTRIES) | |
1827 | s->_raw_size += 2 * PLT_ENTRY_SIZE; | |
1828 | else | |
1829 | s->_raw_size += PLT_ENTRY_SIZE; | |
1830 | ||
1831 | /* We also need to make an entry in the .rela.plt section. */ | |
1832 | s = bfd_get_section_by_name (dynobj, ".rela.plt"); | |
1833 | BFD_ASSERT (s != NULL); | |
1834 | s->_raw_size += sizeof (Elf32_External_Rela); | |
1835 | ||
1836 | return true; | |
1837 | } | |
bbd7ec4a AM |
1838 | else |
1839 | h->plt.offset = (bfd_vma) -1; | |
252b5132 RH |
1840 | |
1841 | /* If this is a weak symbol, and there is a real definition, the | |
1842 | processor independent code will have arranged for us to see the | |
1843 | real definition first, and we can just use the same value. */ | |
1844 | if (h->weakdef != NULL) | |
1845 | { | |
1846 | BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined | |
1847 | || h->weakdef->root.type == bfd_link_hash_defweak); | |
1848 | h->root.u.def.section = h->weakdef->root.u.def.section; | |
1849 | h->root.u.def.value = h->weakdef->root.u.def.value; | |
1850 | return true; | |
1851 | } | |
1852 | ||
1853 | /* This is a reference to a symbol defined by a dynamic object which | |
1854 | is not a function. */ | |
1855 | ||
1856 | /* If we are creating a shared library, we must presume that the | |
1857 | only references to the symbol are via the global offset table. | |
1858 | For such cases we need not do anything here; the relocations will | |
1859 | be handled correctly by relocate_section. */ | |
1860 | if (info->shared) | |
1861 | return true; | |
1862 | ||
1863 | /* We must allocate the symbol in our .dynbss section, which will | |
1864 | become part of the .bss section of the executable. There will be | |
1865 | an entry for this symbol in the .dynsym section. The dynamic | |
1866 | object will contain position independent code, so all references | |
1867 | from the dynamic object to this symbol will go through the global | |
1868 | offset table. The dynamic linker will use the .dynsym entry to | |
1869 | determine the address it must put in the global offset table, so | |
1870 | both the dynamic object and the regular object will refer to the | |
1871 | same memory location for the variable. | |
1872 | ||
1873 | Of course, if the symbol is sufficiently small, we must instead | |
1874 | allocate it in .sbss. FIXME: It would be better to do this if and | |
1875 | only if there were actually SDAREL relocs for that symbol. */ | |
1876 | ||
1877 | if (h->size <= elf_gp_size (dynobj)) | |
1878 | s = bfd_get_section_by_name (dynobj, ".dynsbss"); | |
1879 | else | |
1880 | s = bfd_get_section_by_name (dynobj, ".dynbss"); | |
1881 | BFD_ASSERT (s != NULL); | |
1882 | ||
1883 | /* We must generate a R_PPC_COPY reloc to tell the dynamic linker to | |
1884 | copy the initial value out of the dynamic object and into the | |
1885 | runtime process image. We need to remember the offset into the | |
1886 | .rela.bss section we are going to use. */ | |
1887 | if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) | |
1888 | { | |
1889 | asection *srel; | |
1890 | ||
1891 | if (h->size <= elf_gp_size (dynobj)) | |
1892 | srel = bfd_get_section_by_name (dynobj, ".rela.sbss"); | |
1893 | else | |
1894 | srel = bfd_get_section_by_name (dynobj, ".rela.bss"); | |
1895 | BFD_ASSERT (srel != NULL); | |
1896 | srel->_raw_size += sizeof (Elf32_External_Rela); | |
1897 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; | |
1898 | } | |
1899 | ||
1900 | /* We need to figure out the alignment required for this symbol. I | |
1901 | have no idea how ELF linkers handle this. */ | |
1902 | power_of_two = bfd_log2 (h->size); | |
1903 | if (power_of_two > 4) | |
1904 | power_of_two = 4; | |
1905 | ||
1906 | /* Apply the required alignment. */ | |
1907 | s->_raw_size = BFD_ALIGN (s->_raw_size, | |
1908 | (bfd_size_type) (1 << power_of_two)); | |
1909 | if (power_of_two > bfd_get_section_alignment (dynobj, s)) | |
1910 | { | |
1911 | if (! bfd_set_section_alignment (dynobj, s, power_of_two)) | |
1912 | return false; | |
1913 | } | |
1914 | ||
1915 | /* Define the symbol as being at this point in the section. */ | |
1916 | h->root.u.def.section = s; | |
1917 | h->root.u.def.value = s->_raw_size; | |
1918 | ||
1919 | /* Increment the section size to make room for the symbol. */ | |
1920 | s->_raw_size += h->size; | |
1921 | ||
1922 | return true; | |
1923 | } | |
252b5132 RH |
1924 | \f |
1925 | /* Set the sizes of the dynamic sections. */ | |
1926 | ||
1927 | static boolean | |
1928 | ppc_elf_size_dynamic_sections (output_bfd, info) | |
29c2fb7c | 1929 | bfd *output_bfd ATTRIBUTE_UNUSED; |
252b5132 RH |
1930 | struct bfd_link_info *info; |
1931 | { | |
1932 | bfd *dynobj; | |
1933 | asection *s; | |
1934 | boolean plt; | |
1935 | boolean relocs; | |
252b5132 RH |
1936 | |
1937 | #ifdef DEBUG | |
1938 | fprintf (stderr, "ppc_elf_size_dynamic_sections called\n"); | |
1939 | #endif | |
1940 | ||
1941 | dynobj = elf_hash_table (info)->dynobj; | |
1942 | BFD_ASSERT (dynobj != NULL); | |
1943 | ||
1944 | if (elf_hash_table (info)->dynamic_sections_created) | |
1945 | { | |
1946 | /* Set the contents of the .interp section to the interpreter. */ | |
1947 | if (! info->shared) | |
1948 | { | |
1949 | s = bfd_get_section_by_name (dynobj, ".interp"); | |
1950 | BFD_ASSERT (s != NULL); | |
1951 | s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; | |
1952 | s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; | |
1953 | } | |
1954 | } | |
1955 | else | |
1956 | { | |
1957 | /* We may have created entries in the .rela.got, .rela.sdata, and | |
1958 | .rela.sdata2 sections. However, if we are not creating the | |
1959 | dynamic sections, we will not actually use these entries. Reset | |
1960 | the size of .rela.got, et al, which will cause it to get | |
1961 | stripped from the output file below. */ | |
1962 | static char *rela_sections[] = { ".rela.got", ".rela.sdata", | |
1963 | ".rela.sdata2", ".rela.sbss", | |
8da6118f | 1964 | (char *) 0 }; |
252b5132 RH |
1965 | char **p; |
1966 | ||
8da6118f | 1967 | for (p = rela_sections; *p != (char *) 0; p++) |
252b5132 RH |
1968 | { |
1969 | s = bfd_get_section_by_name (dynobj, *p); | |
1970 | if (s != NULL) | |
1971 | s->_raw_size = 0; | |
1972 | } | |
1973 | } | |
1974 | ||
1975 | /* The check_relocs and adjust_dynamic_symbol entry points have | |
1976 | determined the sizes of the various dynamic sections. Allocate | |
1977 | memory for them. */ | |
1978 | plt = false; | |
1979 | relocs = false; | |
252b5132 RH |
1980 | for (s = dynobj->sections; s != NULL; s = s->next) |
1981 | { | |
1982 | const char *name; | |
1983 | boolean strip; | |
1984 | ||
1985 | if ((s->flags & SEC_LINKER_CREATED) == 0) | |
1986 | continue; | |
1987 | ||
1988 | /* It's OK to base decisions on the section name, because none | |
1989 | of the dynobj section names depend upon the input files. */ | |
1990 | name = bfd_get_section_name (dynobj, s); | |
1991 | ||
1992 | strip = false; | |
1993 | ||
1994 | if (strcmp (name, ".plt") == 0) | |
1995 | { | |
1996 | if (s->_raw_size == 0) | |
1997 | { | |
1998 | /* Strip this section if we don't need it; see the | |
1999 | comment below. */ | |
2000 | strip = true; | |
2001 | } | |
2002 | else | |
2003 | { | |
2004 | /* Remember whether there is a PLT. */ | |
2005 | plt = true; | |
2006 | } | |
2007 | } | |
2008 | else if (strncmp (name, ".rela", 5) == 0) | |
2009 | { | |
2010 | if (s->_raw_size == 0) | |
2011 | { | |
2012 | /* If we don't need this section, strip it from the | |
2013 | output file. This is mostly to handle .rela.bss and | |
2014 | .rela.plt. We must create both sections in | |
2015 | create_dynamic_sections, because they must be created | |
2016 | before the linker maps input sections to output | |
2017 | sections. The linker does that before | |
2018 | adjust_dynamic_symbol is called, and it is that | |
2019 | function which decides whether anything needs to go | |
2020 | into these sections. */ | |
2021 | strip = true; | |
2022 | } | |
2023 | else | |
2024 | { | |
c3668558 | 2025 | /* Remember whether there are any relocation sections. */ |
252b5132 RH |
2026 | relocs = true; |
2027 | ||
252b5132 RH |
2028 | /* We use the reloc_count field as a counter if we need |
2029 | to copy relocs into the output file. */ | |
2030 | s->reloc_count = 0; | |
2031 | } | |
2032 | } | |
2033 | else if (strcmp (name, ".got") != 0 | |
2034 | && strcmp (name, ".sdata") != 0 | |
2035 | && strcmp (name, ".sdata2") != 0) | |
2036 | { | |
2037 | /* It's not one of our sections, so don't allocate space. */ | |
2038 | continue; | |
2039 | } | |
2040 | ||
2041 | if (strip) | |
2042 | { | |
7f8d5fc9 | 2043 | _bfd_strip_section_from_output (info, s); |
252b5132 RH |
2044 | continue; |
2045 | } | |
2046 | ||
2047 | /* Allocate memory for the section contents. */ | |
2048 | s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); | |
2049 | if (s->contents == NULL && s->_raw_size != 0) | |
2050 | return false; | |
2051 | } | |
2052 | ||
2053 | if (elf_hash_table (info)->dynamic_sections_created) | |
2054 | { | |
2055 | /* Add some entries to the .dynamic section. We fill in the | |
2056 | values later, in ppc_elf_finish_dynamic_sections, but we | |
2057 | must add the entries now so that we get the correct size for | |
2058 | the .dynamic section. The DT_DEBUG entry is filled in by the | |
2059 | dynamic linker and used by the debugger. */ | |
dc810e39 AM |
2060 | #define add_dynamic_entry(TAG, VAL) \ |
2061 | bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) | |
2062 | ||
2063 | if (!info->shared) | |
252b5132 | 2064 | { |
dc810e39 | 2065 | if (!add_dynamic_entry (DT_DEBUG, 0)) |
252b5132 RH |
2066 | return false; |
2067 | } | |
2068 | ||
2069 | if (plt) | |
2070 | { | |
dc810e39 AM |
2071 | if (!add_dynamic_entry (DT_PLTGOT, 0) |
2072 | || !add_dynamic_entry (DT_PLTRELSZ, 0) | |
2073 | || !add_dynamic_entry (DT_PLTREL, DT_RELA) | |
2074 | || !add_dynamic_entry (DT_JMPREL, 0)) | |
252b5132 RH |
2075 | return false; |
2076 | } | |
2077 | ||
2078 | if (relocs) | |
2079 | { | |
dc810e39 AM |
2080 | if (!add_dynamic_entry (DT_RELA, 0) |
2081 | || !add_dynamic_entry (DT_RELASZ, 0) | |
2082 | || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))) | |
252b5132 RH |
2083 | return false; |
2084 | } | |
2085 | ||
29c2fb7c | 2086 | if ((info->flags & DF_TEXTREL) != 0) |
252b5132 | 2087 | { |
dc810e39 | 2088 | if (!add_dynamic_entry (DT_TEXTREL, 0)) |
252b5132 | 2089 | return false; |
d6cf2879 | 2090 | info->flags |= DF_TEXTREL; |
252b5132 RH |
2091 | } |
2092 | } | |
dc810e39 | 2093 | #undef add_dynamic_entry |
252b5132 | 2094 | |
252b5132 RH |
2095 | return true; |
2096 | } | |
252b5132 RH |
2097 | \f |
2098 | /* Look through the relocs for a section during the first phase, and | |
2099 | allocate space in the global offset table or procedure linkage | |
2100 | table. */ | |
2101 | ||
2102 | static boolean | |
2103 | ppc_elf_check_relocs (abfd, info, sec, relocs) | |
2104 | bfd *abfd; | |
2105 | struct bfd_link_info *info; | |
2106 | asection *sec; | |
2107 | const Elf_Internal_Rela *relocs; | |
2108 | { | |
2109 | bfd *dynobj; | |
2110 | Elf_Internal_Shdr *symtab_hdr; | |
2111 | struct elf_link_hash_entry **sym_hashes, **sym_hashes_end; | |
2112 | const Elf_Internal_Rela *rel; | |
2113 | const Elf_Internal_Rela *rel_end; | |
2114 | bfd_signed_vma *local_got_refcounts; | |
2115 | elf_linker_section_t *sdata; | |
2116 | elf_linker_section_t *sdata2; | |
2117 | asection *sreloc; | |
2118 | asection *sgot = NULL; | |
2119 | asection *srelgot = NULL; | |
2120 | ||
2121 | if (info->relocateable) | |
2122 | return true; | |
2123 | ||
2124 | #ifdef DEBUG | |
2125 | fprintf (stderr, "ppc_elf_check_relocs called for section %s in %s\n", | |
2126 | bfd_get_section_name (abfd, sec), | |
8f615d07 | 2127 | bfd_archive_filename (abfd)); |
252b5132 RH |
2128 | #endif |
2129 | ||
2130 | /* Create the linker generated sections all the time so that the | |
2131 | special symbols are created. */ | |
2132 | ||
2133 | if ((sdata = elf_linker_section (abfd, LINKER_SECTION_SDATA)) == NULL) | |
2134 | { | |
2135 | sdata = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA); | |
2136 | if (!sdata) | |
2137 | return false; | |
2138 | } | |
2139 | ||
252b5132 RH |
2140 | if ((sdata2 = elf_linker_section (abfd, LINKER_SECTION_SDATA2)) == NULL) |
2141 | { | |
2142 | sdata2 = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA2); | |
2143 | if (!sdata2) | |
2144 | return false; | |
2145 | } | |
2146 | ||
2147 | dynobj = elf_hash_table (info)->dynobj; | |
2148 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; | |
2149 | local_got_refcounts = elf_local_got_refcounts (abfd); | |
2150 | ||
2151 | sym_hashes = elf_sym_hashes (abfd); | |
c3668558 | 2152 | sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof (Elf32_External_Sym); |
252b5132 RH |
2153 | if (!elf_bad_symtab (abfd)) |
2154 | sym_hashes_end -= symtab_hdr->sh_info; | |
2155 | ||
2156 | sreloc = NULL; | |
2157 | ||
2158 | rel_end = relocs + sec->reloc_count; | |
2159 | for (rel = relocs; rel < rel_end; rel++) | |
2160 | { | |
2161 | unsigned long r_symndx; | |
2162 | struct elf_link_hash_entry *h; | |
2163 | ||
2164 | r_symndx = ELF32_R_SYM (rel->r_info); | |
2165 | if (r_symndx < symtab_hdr->sh_info) | |
2166 | h = NULL; | |
2167 | else | |
2168 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
2169 | ||
2170 | /* If a relocation refers to _GLOBAL_OFFSET_TABLE_, create the .got. | |
2171 | This shows up in particular in an R_PPC_ADDR32 in the eabi | |
2172 | startup code. */ | |
2173 | if (h && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) | |
2174 | { | |
2175 | if (sgot == NULL) | |
2176 | { | |
2177 | if (dynobj == NULL) | |
2178 | elf_hash_table (info)->dynobj = dynobj = abfd; | |
41fcb14e AM |
2179 | sgot = ppc_elf_create_got (dynobj, info); |
2180 | if (sgot == NULL) | |
252b5132 | 2181 | return false; |
252b5132 RH |
2182 | } |
2183 | } | |
2184 | ||
2185 | switch (ELF32_R_TYPE (rel->r_info)) | |
2186 | { | |
2187 | /* GOT16 relocations */ | |
2188 | case R_PPC_GOT16: | |
2189 | case R_PPC_GOT16_LO: | |
2190 | case R_PPC_GOT16_HI: | |
2191 | case R_PPC_GOT16_HA: | |
2192 | /* This symbol requires a global offset table entry. */ | |
2193 | ||
2194 | if (sgot == NULL) | |
2195 | { | |
2196 | if (dynobj == NULL) | |
2197 | elf_hash_table (info)->dynobj = dynobj = abfd; | |
41fcb14e AM |
2198 | sgot = ppc_elf_create_got (dynobj, info); |
2199 | if (sgot == NULL) | |
252b5132 | 2200 | return false; |
252b5132 RH |
2201 | } |
2202 | ||
2203 | if (srelgot == NULL | |
2204 | && (h != NULL || info->shared)) | |
2205 | { | |
2206 | srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); | |
2207 | if (srelgot == NULL) | |
2208 | { | |
2209 | srelgot = bfd_make_section (dynobj, ".rela.got"); | |
2210 | if (srelgot == NULL | |
2211 | || ! bfd_set_section_flags (dynobj, srelgot, | |
2212 | (SEC_ALLOC | |
2213 | | SEC_LOAD | |
2214 | | SEC_HAS_CONTENTS | |
2215 | | SEC_IN_MEMORY | |
2216 | | SEC_LINKER_CREATED | |
2217 | | SEC_READONLY)) | |
2218 | || ! bfd_set_section_alignment (dynobj, srelgot, 2)) | |
2219 | return false; | |
2220 | } | |
2221 | } | |
2222 | ||
2223 | if (h != NULL) | |
2224 | { | |
51b64d56 | 2225 | if (h->got.refcount == 0) |
252b5132 RH |
2226 | { |
2227 | /* Make sure this symbol is output as a dynamic symbol. */ | |
2228 | if (h->dynindx == -1) | |
2229 | if (!bfd_elf32_link_record_dynamic_symbol (info, h)) | |
2230 | return false; | |
2231 | ||
2232 | /* Allocate space in the .got. */ | |
2233 | sgot->_raw_size += 4; | |
2234 | /* Allocate relocation space. */ | |
2235 | srelgot->_raw_size += sizeof (Elf32_External_Rela); | |
252b5132 | 2236 | } |
51b64d56 | 2237 | h->got.refcount++; |
252b5132 RH |
2238 | } |
2239 | else | |
2240 | { | |
2241 | /* This is a global offset table entry for a local symbol. */ | |
2242 | if (local_got_refcounts == NULL) | |
2243 | { | |
dc810e39 | 2244 | bfd_size_type size; |
252b5132 | 2245 | |
dc810e39 AM |
2246 | size = symtab_hdr->sh_info; |
2247 | size *= sizeof (bfd_signed_vma); | |
2248 | local_got_refcounts | |
51b64d56 | 2249 | = (bfd_signed_vma *) bfd_zalloc (abfd, size); |
252b5132 RH |
2250 | if (local_got_refcounts == NULL) |
2251 | return false; | |
2252 | elf_local_got_refcounts (abfd) = local_got_refcounts; | |
252b5132 | 2253 | } |
51b64d56 | 2254 | if (local_got_refcounts[r_symndx] == 0) |
252b5132 RH |
2255 | { |
2256 | sgot->_raw_size += 4; | |
2257 | ||
2258 | /* If we are generating a shared object, we need to | |
2259 | output a R_PPC_RELATIVE reloc so that the | |
2260 | dynamic linker can adjust this GOT entry. */ | |
2261 | if (info->shared) | |
2262 | srelgot->_raw_size += sizeof (Elf32_External_Rela); | |
252b5132 | 2263 | } |
51b64d56 | 2264 | local_got_refcounts[r_symndx]++; |
252b5132 RH |
2265 | } |
2266 | break; | |
2267 | ||
2268 | /* Indirect .sdata relocation */ | |
2269 | case R_PPC_EMB_SDAI16: | |
2270 | if (info->shared) | |
2271 | { | |
2272 | ((*_bfd_error_handler) | |
2273 | (_("%s: relocation %s cannot be used when making a shared object"), | |
8f615d07 | 2274 | bfd_archive_filename (abfd), "R_PPC_EMB_SDAI16")); |
8da6118f | 2275 | return false; |
252b5132 RH |
2276 | } |
2277 | ||
2278 | if (srelgot == NULL && (h != NULL || info->shared)) | |
2279 | { | |
2280 | srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); | |
2281 | if (srelgot == NULL) | |
2282 | { | |
2283 | srelgot = bfd_make_section (dynobj, ".rela.got"); | |
2284 | if (srelgot == NULL | |
2285 | || ! bfd_set_section_flags (dynobj, srelgot, | |
2286 | (SEC_ALLOC | |
2287 | | SEC_LOAD | |
2288 | | SEC_HAS_CONTENTS | |
2289 | | SEC_IN_MEMORY | |
2290 | | SEC_LINKER_CREATED | |
2291 | | SEC_READONLY)) | |
2292 | || ! bfd_set_section_alignment (dynobj, srelgot, 2)) | |
2293 | return false; | |
2294 | } | |
2295 | } | |
2296 | ||
2297 | if (!bfd_elf32_create_pointer_linker_section (abfd, info, sdata, h, rel)) | |
2298 | return false; | |
2299 | ||
2300 | break; | |
2301 | ||
2302 | /* Indirect .sdata2 relocation */ | |
2303 | case R_PPC_EMB_SDA2I16: | |
2304 | if (info->shared) | |
2305 | { | |
2306 | ((*_bfd_error_handler) | |
2307 | (_("%s: relocation %s cannot be used when making a shared object"), | |
8f615d07 | 2308 | bfd_archive_filename (abfd), "R_PPC_EMB_SDA2I16")); |
252b5132 RH |
2309 | return false; |
2310 | } | |
2311 | ||
2312 | if (srelgot == NULL && (h != NULL || info->shared)) | |
2313 | { | |
2314 | srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); | |
2315 | if (srelgot == NULL) | |
2316 | { | |
2317 | srelgot = bfd_make_section (dynobj, ".rela.got"); | |
2318 | if (srelgot == NULL | |
2319 | || ! bfd_set_section_flags (dynobj, srelgot, | |
2320 | (SEC_ALLOC | |
2321 | | SEC_LOAD | |
2322 | | SEC_HAS_CONTENTS | |
2323 | | SEC_IN_MEMORY | |
2324 | | SEC_LINKER_CREATED | |
2325 | | SEC_READONLY)) | |
2326 | || ! bfd_set_section_alignment (dynobj, srelgot, 2)) | |
2327 | return false; | |
2328 | } | |
2329 | } | |
2330 | ||
2331 | if (!bfd_elf32_create_pointer_linker_section (abfd, info, sdata2, h, rel)) | |
2332 | return false; | |
2333 | ||
2334 | break; | |
2335 | ||
2336 | case R_PPC_SDAREL16: | |
2337 | case R_PPC_EMB_SDA2REL: | |
2338 | case R_PPC_EMB_SDA21: | |
2339 | if (info->shared) | |
2340 | { | |
2341 | ((*_bfd_error_handler) | |
2342 | (_("%s: relocation %s cannot be used when making a shared object"), | |
8f615d07 | 2343 | bfd_archive_filename (abfd), |
8da6118f | 2344 | ppc_elf_howto_table[(int) ELF32_R_TYPE (rel->r_info)]->name)); |
252b5132 RH |
2345 | return false; |
2346 | } | |
2347 | break; | |
2348 | ||
2349 | case R_PPC_PLT32: | |
2350 | case R_PPC_PLTREL24: | |
2351 | case R_PPC_PLT16_LO: | |
2352 | case R_PPC_PLT16_HI: | |
2353 | case R_PPC_PLT16_HA: | |
2354 | #ifdef DEBUG | |
2355 | fprintf (stderr, "Reloc requires a PLT entry\n"); | |
2356 | #endif | |
2357 | /* This symbol requires a procedure linkage table entry. We | |
2358 | actually build the entry in adjust_dynamic_symbol, | |
2359 | because this might be a case of linking PIC code without | |
2360 | linking in any dynamic objects, in which case we don't | |
2361 | need to generate a procedure linkage table after all. */ | |
2362 | ||
2363 | if (h == NULL) | |
2364 | { | |
2365 | /* It does not make sense to have a procedure linkage | |
2366 | table entry for a local symbol. */ | |
2367 | bfd_set_error (bfd_error_bad_value); | |
2368 | return false; | |
2369 | } | |
2370 | ||
2371 | /* Make sure this symbol is output as a dynamic symbol. */ | |
2372 | if (h->dynindx == -1) | |
2373 | { | |
2374 | if (! bfd_elf32_link_record_dynamic_symbol (info, h)) | |
2375 | return false; | |
2376 | } | |
51b64d56 AM |
2377 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; |
2378 | h->plt.refcount++; | |
252b5132 RH |
2379 | break; |
2380 | ||
2381 | /* The following relocations don't need to propagate the | |
2382 | relocation if linking a shared object since they are | |
2383 | section relative. */ | |
2384 | case R_PPC_SECTOFF: | |
2385 | case R_PPC_SECTOFF_LO: | |
2386 | case R_PPC_SECTOFF_HI: | |
2387 | case R_PPC_SECTOFF_HA: | |
2388 | break; | |
2389 | ||
2390 | /* This refers only to functions defined in the shared library */ | |
2391 | case R_PPC_LOCAL24PC: | |
2392 | break; | |
2393 | ||
2394 | /* This relocation describes the C++ object vtable hierarchy. | |
2395 | Reconstruct it for later use during GC. */ | |
2396 | case R_PPC_GNU_VTINHERIT: | |
2397 | if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) | |
2398 | return false; | |
2399 | break; | |
2400 | ||
2401 | /* This relocation describes which C++ vtable entries are actually | |
2402 | used. Record for later use during GC. */ | |
2403 | case R_PPC_GNU_VTENTRY: | |
2404 | if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)) | |
2405 | return false; | |
2406 | break; | |
2407 | ||
2408 | /* When creating a shared object, we must copy these | |
2409 | relocs into the output file. We create a reloc | |
2410 | section in dynobj and make room for the reloc. */ | |
2411 | case R_PPC_REL24: | |
2412 | case R_PPC_REL14: | |
2413 | case R_PPC_REL14_BRTAKEN: | |
2414 | case R_PPC_REL14_BRNTAKEN: | |
2415 | case R_PPC_REL32: | |
2416 | if (h == NULL | |
e1e0340b GK |
2417 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0 |
2418 | || SYMBOL_REFERENCES_LOCAL (info, h)) | |
252b5132 RH |
2419 | break; |
2420 | /* fall through */ | |
2421 | ||
2422 | default: | |
2423 | if (info->shared) | |
2424 | { | |
2425 | #ifdef DEBUG | |
2426 | fprintf (stderr, "ppc_elf_check_relocs need to create relocation for %s\n", | |
2427 | (h && h->root.root.string) ? h->root.root.string : "<unknown>"); | |
2428 | #endif | |
2429 | if (sreloc == NULL) | |
2430 | { | |
2431 | const char *name; | |
2432 | ||
2433 | name = (bfd_elf_string_from_elf_section | |
2434 | (abfd, | |
2435 | elf_elfheader (abfd)->e_shstrndx, | |
2436 | elf_section_data (sec)->rel_hdr.sh_name)); | |
2437 | if (name == NULL) | |
2438 | return false; | |
2439 | ||
2440 | BFD_ASSERT (strncmp (name, ".rela", 5) == 0 | |
2441 | && strcmp (bfd_get_section_name (abfd, sec), | |
2442 | name + 5) == 0); | |
2443 | ||
2444 | sreloc = bfd_get_section_by_name (dynobj, name); | |
2445 | if (sreloc == NULL) | |
2446 | { | |
2447 | flagword flags; | |
2448 | ||
2449 | sreloc = bfd_make_section (dynobj, name); | |
2450 | flags = (SEC_HAS_CONTENTS | SEC_READONLY | |
2451 | | SEC_IN_MEMORY | SEC_LINKER_CREATED); | |
2452 | if ((sec->flags & SEC_ALLOC) != 0) | |
2453 | flags |= SEC_ALLOC | SEC_LOAD; | |
2454 | if (sreloc == NULL | |
2455 | || ! bfd_set_section_flags (dynobj, sreloc, flags) | |
2456 | || ! bfd_set_section_alignment (dynobj, sreloc, 2)) | |
2457 | return false; | |
2458 | } | |
29c2fb7c AJ |
2459 | if (sec->flags & SEC_READONLY) |
2460 | info->flags |= DF_TEXTREL; | |
252b5132 RH |
2461 | } |
2462 | ||
2463 | sreloc->_raw_size += sizeof (Elf32_External_Rela); | |
2464 | ||
2465 | /* FIXME: We should here do what the m68k and i386 | |
2466 | backends do: if the reloc is pc-relative, record it | |
2467 | in case it turns out that the reloc is unnecessary | |
2468 | because the symbol is forced local by versioning or | |
2469 | we are linking with -Bdynamic. Fortunately this | |
2470 | case is not frequent. */ | |
2471 | } | |
2472 | ||
2473 | break; | |
2474 | } | |
2475 | } | |
2476 | ||
2477 | return true; | |
2478 | } | |
2479 | ||
2480 | /* Return the section that should be marked against GC for a given | |
2481 | relocation. */ | |
2482 | ||
2483 | static asection * | |
1e2f5b6e AM |
2484 | ppc_elf_gc_mark_hook (sec, info, rel, h, sym) |
2485 | asection *sec; | |
5f771d47 | 2486 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
252b5132 RH |
2487 | Elf_Internal_Rela *rel; |
2488 | struct elf_link_hash_entry *h; | |
2489 | Elf_Internal_Sym *sym; | |
2490 | { | |
2491 | if (h != NULL) | |
2492 | { | |
2493 | switch (ELF32_R_TYPE (rel->r_info)) | |
2494 | { | |
2495 | case R_PPC_GNU_VTINHERIT: | |
2496 | case R_PPC_GNU_VTENTRY: | |
2497 | break; | |
2498 | ||
2499 | default: | |
2500 | switch (h->root.type) | |
2501 | { | |
2502 | case bfd_link_hash_defined: | |
2503 | case bfd_link_hash_defweak: | |
2504 | return h->root.u.def.section; | |
2505 | ||
2506 | case bfd_link_hash_common: | |
2507 | return h->root.u.c.p->section; | |
2508 | ||
2509 | default: | |
2510 | break; | |
2511 | } | |
2512 | } | |
2513 | } | |
2514 | else | |
1e2f5b6e | 2515 | return bfd_section_from_elf_index (sec->owner, sym->st_shndx); |
252b5132 RH |
2516 | |
2517 | return NULL; | |
2518 | } | |
2519 | ||
2520 | /* Update the got entry reference counts for the section being removed. */ | |
2521 | ||
2522 | static boolean | |
2523 | ppc_elf_gc_sweep_hook (abfd, info, sec, relocs) | |
2524 | bfd *abfd; | |
5f771d47 | 2525 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
252b5132 RH |
2526 | asection *sec; |
2527 | const Elf_Internal_Rela *relocs; | |
2528 | { | |
2529 | Elf_Internal_Shdr *symtab_hdr; | |
2530 | struct elf_link_hash_entry **sym_hashes; | |
2531 | bfd_signed_vma *local_got_refcounts; | |
2532 | const Elf_Internal_Rela *rel, *relend; | |
2533 | unsigned long r_symndx; | |
2534 | struct elf_link_hash_entry *h; | |
2535 | ||
2536 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; | |
2537 | sym_hashes = elf_sym_hashes (abfd); | |
2538 | local_got_refcounts = elf_local_got_refcounts (abfd); | |
2539 | ||
2540 | relend = relocs + sec->reloc_count; | |
2541 | for (rel = relocs; rel < relend; rel++) | |
2542 | switch (ELF32_R_TYPE (rel->r_info)) | |
2543 | { | |
2544 | case R_PPC_GOT16: | |
2545 | case R_PPC_GOT16_LO: | |
2546 | case R_PPC_GOT16_HI: | |
2547 | case R_PPC_GOT16_HA: | |
2548 | r_symndx = ELF32_R_SYM (rel->r_info); | |
2549 | if (r_symndx >= symtab_hdr->sh_info) | |
2550 | { | |
2551 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
2552 | if (h->got.refcount > 0) | |
2553 | h->got.refcount--; | |
2554 | } | |
dd5724d5 | 2555 | else if (local_got_refcounts != NULL) |
252b5132 RH |
2556 | { |
2557 | if (local_got_refcounts[r_symndx] > 0) | |
2558 | local_got_refcounts[r_symndx]--; | |
2559 | } | |
2560 | break; | |
2561 | ||
2562 | case R_PPC_PLT32: | |
2563 | case R_PPC_PLTREL24: | |
2564 | case R_PPC_PLT16_LO: | |
2565 | case R_PPC_PLT16_HI: | |
2566 | case R_PPC_PLT16_HA: | |
2567 | r_symndx = ELF32_R_SYM (rel->r_info); | |
2568 | if (r_symndx >= symtab_hdr->sh_info) | |
2569 | { | |
2570 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
2571 | if (h->plt.refcount > 0) | |
2572 | h->plt.refcount--; | |
2573 | } | |
2574 | break; | |
2575 | ||
2576 | default: | |
2577 | break; | |
2578 | } | |
2579 | ||
2580 | return true; | |
2581 | } | |
2582 | \f | |
2583 | /* Hook called by the linker routine which adds symbols from an object | |
2584 | file. We use it to put .comm items in .sbss, and not .bss. */ | |
2585 | ||
252b5132 RH |
2586 | static boolean |
2587 | ppc_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) | |
2588 | bfd *abfd; | |
2589 | struct bfd_link_info *info; | |
2590 | const Elf_Internal_Sym *sym; | |
5f771d47 ILT |
2591 | const char **namep ATTRIBUTE_UNUSED; |
2592 | flagword *flagsp ATTRIBUTE_UNUSED; | |
252b5132 RH |
2593 | asection **secp; |
2594 | bfd_vma *valp; | |
2595 | { | |
2596 | if (sym->st_shndx == SHN_COMMON | |
2597 | && !info->relocateable | |
27242387 AM |
2598 | && sym->st_size <= elf_gp_size (abfd) |
2599 | && info->hash->creator->flavour == bfd_target_elf_flavour) | |
252b5132 RH |
2600 | { |
2601 | /* Common symbols less than or equal to -G nn bytes are automatically | |
2602 | put into .sdata. */ | |
2603 | elf_linker_section_t *sdata | |
2604 | = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA); | |
2605 | ||
2606 | if (!sdata->bss_section) | |
2607 | { | |
dc810e39 AM |
2608 | bfd_size_type amt; |
2609 | ||
252b5132 RH |
2610 | /* We don't go through bfd_make_section, because we don't |
2611 | want to attach this common section to DYNOBJ. The linker | |
2612 | will move the symbols to the appropriate output section | |
2613 | when it defines common symbols. */ | |
dc810e39 AM |
2614 | amt = sizeof (asection); |
2615 | sdata->bss_section = (asection *) bfd_zalloc (abfd, amt); | |
252b5132 RH |
2616 | if (sdata->bss_section == NULL) |
2617 | return false; | |
2618 | sdata->bss_section->name = sdata->bss_name; | |
2619 | sdata->bss_section->flags = SEC_IS_COMMON; | |
2620 | sdata->bss_section->output_section = sdata->bss_section; | |
dc810e39 AM |
2621 | amt = sizeof (asymbol); |
2622 | sdata->bss_section->symbol = (asymbol *) bfd_zalloc (abfd, amt); | |
2623 | amt = sizeof (asymbol *); | |
252b5132 | 2624 | sdata->bss_section->symbol_ptr_ptr = |
dc810e39 | 2625 | (asymbol **) bfd_zalloc (abfd, amt); |
252b5132 RH |
2626 | if (sdata->bss_section->symbol == NULL |
2627 | || sdata->bss_section->symbol_ptr_ptr == NULL) | |
2628 | return false; | |
2629 | sdata->bss_section->symbol->name = sdata->bss_name; | |
2630 | sdata->bss_section->symbol->flags = BSF_SECTION_SYM; | |
2631 | sdata->bss_section->symbol->section = sdata->bss_section; | |
2632 | *sdata->bss_section->symbol_ptr_ptr = sdata->bss_section->symbol; | |
2633 | } | |
2634 | ||
2635 | *secp = sdata->bss_section; | |
2636 | *valp = sym->st_size; | |
2637 | } | |
2638 | ||
2639 | return true; | |
2640 | } | |
252b5132 RH |
2641 | \f |
2642 | /* Finish up dynamic symbol handling. We set the contents of various | |
2643 | dynamic sections here. */ | |
2644 | ||
2645 | static boolean | |
2646 | ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym) | |
2647 | bfd *output_bfd; | |
2648 | struct bfd_link_info *info; | |
2649 | struct elf_link_hash_entry *h; | |
2650 | Elf_Internal_Sym *sym; | |
2651 | { | |
2652 | bfd *dynobj; | |
2653 | ||
2654 | #ifdef DEBUG | |
2655 | fprintf (stderr, "ppc_elf_finish_dynamic_symbol called for %s", | |
2656 | h->root.root.string); | |
2657 | #endif | |
2658 | ||
2659 | dynobj = elf_hash_table (info)->dynobj; | |
2660 | BFD_ASSERT (dynobj != NULL); | |
2661 | ||
2662 | if (h->plt.offset != (bfd_vma) -1) | |
2663 | { | |
2664 | asection *splt; | |
2665 | asection *srela; | |
2666 | Elf_Internal_Rela rela; | |
947216bf | 2667 | bfd_byte *loc; |
252b5132 RH |
2668 | bfd_vma reloc_index; |
2669 | ||
2670 | #ifdef DEBUG | |
2671 | fprintf (stderr, ", plt_offset = %d", h->plt.offset); | |
2672 | #endif | |
2673 | ||
2674 | /* This symbol has an entry in the procedure linkage table. Set | |
2675 | it up. */ | |
2676 | ||
2677 | BFD_ASSERT (h->dynindx != -1); | |
2678 | ||
2679 | splt = bfd_get_section_by_name (dynobj, ".plt"); | |
2680 | srela = bfd_get_section_by_name (dynobj, ".rela.plt"); | |
2681 | BFD_ASSERT (splt != NULL && srela != NULL); | |
2682 | ||
2683 | /* We don't need to fill in the .plt. The ppc dynamic linker | |
2684 | will fill it in. */ | |
2685 | ||
2686 | /* Fill in the entry in the .rela.plt section. */ | |
2687 | rela.r_offset = (splt->output_section->vma | |
2688 | + splt->output_offset | |
2689 | + h->plt.offset); | |
2690 | rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_JMP_SLOT); | |
2691 | rela.r_addend = 0; | |
2692 | ||
2693 | reloc_index = (h->plt.offset - PLT_INITIAL_ENTRY_SIZE) / PLT_SLOT_SIZE; | |
2694 | if (reloc_index > PLT_NUM_SINGLE_ENTRIES) | |
2695 | reloc_index -= (reloc_index - PLT_NUM_SINGLE_ENTRIES) / 2; | |
947216bf AM |
2696 | loc = srela->contents + reloc_index * sizeof (Elf32_External_Rela); |
2697 | bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); | |
252b5132 RH |
2698 | |
2699 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) | |
2700 | { | |
2701 | /* Mark the symbol as undefined, rather than as defined in | |
2702 | the .plt section. Leave the value alone. */ | |
2703 | sym->st_shndx = SHN_UNDEF; | |
a4b120e1 GK |
2704 | /* If the symbol is weak, we do need to clear the value. |
2705 | Otherwise, the PLT entry would provide a definition for | |
2706 | the symbol even if the symbol wasn't defined anywhere, | |
2707 | and so the symbol would never be NULL. */ | |
c3668558 | 2708 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR_NONWEAK) |
a4b120e1 GK |
2709 | == 0) |
2710 | sym->st_value = 0; | |
252b5132 RH |
2711 | } |
2712 | } | |
2713 | ||
2714 | if (h->got.offset != (bfd_vma) -1) | |
2715 | { | |
2716 | asection *sgot; | |
2717 | asection *srela; | |
2718 | Elf_Internal_Rela rela; | |
947216bf | 2719 | bfd_byte *loc; |
252b5132 RH |
2720 | |
2721 | /* This symbol has an entry in the global offset table. Set it | |
2722 | up. */ | |
2723 | ||
2724 | sgot = bfd_get_section_by_name (dynobj, ".got"); | |
2725 | srela = bfd_get_section_by_name (dynobj, ".rela.got"); | |
2726 | BFD_ASSERT (sgot != NULL && srela != NULL); | |
2727 | ||
2728 | rela.r_offset = (sgot->output_section->vma | |
2729 | + sgot->output_offset | |
dc810e39 | 2730 | + (h->got.offset &~ (bfd_vma) 1)); |
252b5132 RH |
2731 | |
2732 | /* If this is a -Bsymbolic link, and the symbol is defined | |
2733 | locally, we just want to emit a RELATIVE reloc. The entry in | |
2734 | the global offset table will already have been initialized in | |
2735 | the relocate_section function. */ | |
2736 | if (info->shared | |
e1e0340b | 2737 | && SYMBOL_REFERENCES_LOCAL (info, h)) |
252b5132 RH |
2738 | { |
2739 | rela.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE); | |
2740 | rela.r_addend = (h->root.u.def.value | |
2741 | + h->root.u.def.section->output_section->vma | |
2742 | + h->root.u.def.section->output_offset); | |
2743 | } | |
2744 | else | |
2745 | { | |
8da6118f | 2746 | BFD_ASSERT ((h->got.offset & 1) == 0); |
252b5132 RH |
2747 | rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_GLOB_DAT); |
2748 | rela.r_addend = 0; | |
2749 | } | |
2750 | ||
2243deae | 2751 | bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset); |
947216bf AM |
2752 | loc = srela->contents; |
2753 | loc += srela->reloc_count++ * sizeof (Elf32_External_Rela); | |
2754 | bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); | |
252b5132 RH |
2755 | } |
2756 | ||
2757 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0) | |
2758 | { | |
2759 | asection *s; | |
2760 | Elf_Internal_Rela rela; | |
947216bf | 2761 | bfd_byte *loc; |
252b5132 RH |
2762 | |
2763 | /* This symbols needs a copy reloc. Set it up. */ | |
2764 | ||
2765 | #ifdef DEBUG | |
2766 | fprintf (stderr, ", copy"); | |
2767 | #endif | |
2768 | ||
2769 | BFD_ASSERT (h->dynindx != -1); | |
2770 | ||
2771 | if (h->size <= elf_gp_size (dynobj)) | |
2772 | s = bfd_get_section_by_name (h->root.u.def.section->owner, | |
2773 | ".rela.sbss"); | |
2774 | else | |
2775 | s = bfd_get_section_by_name (h->root.u.def.section->owner, | |
2776 | ".rela.bss"); | |
2777 | BFD_ASSERT (s != NULL); | |
2778 | ||
2779 | rela.r_offset = (h->root.u.def.value | |
2780 | + h->root.u.def.section->output_section->vma | |
2781 | + h->root.u.def.section->output_offset); | |
2782 | rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_COPY); | |
2783 | rela.r_addend = 0; | |
947216bf AM |
2784 | loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela); |
2785 | bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); | |
252b5132 RH |
2786 | } |
2787 | ||
2788 | #ifdef DEBUG | |
2789 | fprintf (stderr, "\n"); | |
2790 | #endif | |
2791 | ||
2792 | /* Mark some specially defined symbols as absolute. */ | |
2793 | if (strcmp (h->root.root.string, "_DYNAMIC") == 0 | |
2794 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0 | |
2795 | || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0) | |
2796 | sym->st_shndx = SHN_ABS; | |
2797 | ||
2798 | return true; | |
2799 | } | |
252b5132 RH |
2800 | \f |
2801 | /* Finish up the dynamic sections. */ | |
2802 | ||
2803 | static boolean | |
2804 | ppc_elf_finish_dynamic_sections (output_bfd, info) | |
2805 | bfd *output_bfd; | |
2806 | struct bfd_link_info *info; | |
2807 | { | |
2808 | asection *sdyn; | |
2809 | bfd *dynobj = elf_hash_table (info)->dynobj; | |
2810 | asection *sgot = bfd_get_section_by_name (dynobj, ".got"); | |
2811 | ||
2812 | #ifdef DEBUG | |
2813 | fprintf (stderr, "ppc_elf_finish_dynamic_sections called\n"); | |
2814 | #endif | |
2815 | ||
2816 | sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); | |
2817 | ||
2818 | if (elf_hash_table (info)->dynamic_sections_created) | |
2819 | { | |
2820 | asection *splt; | |
2821 | Elf32_External_Dyn *dyncon, *dynconend; | |
2822 | ||
2823 | splt = bfd_get_section_by_name (dynobj, ".plt"); | |
2824 | BFD_ASSERT (splt != NULL && sdyn != NULL); | |
2825 | ||
2826 | dyncon = (Elf32_External_Dyn *) sdyn->contents; | |
2827 | dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); | |
2828 | for (; dyncon < dynconend; dyncon++) | |
2829 | { | |
2830 | Elf_Internal_Dyn dyn; | |
2831 | const char *name; | |
2832 | boolean size; | |
2833 | ||
2834 | bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); | |
2835 | ||
2836 | switch (dyn.d_tag) | |
2837 | { | |
2838 | case DT_PLTGOT: name = ".plt"; size = false; break; | |
2839 | case DT_PLTRELSZ: name = ".rela.plt"; size = true; break; | |
2840 | case DT_JMPREL: name = ".rela.plt"; size = false; break; | |
2841 | default: name = NULL; size = false; break; | |
2842 | } | |
2843 | ||
2844 | if (name != NULL) | |
2845 | { | |
2846 | asection *s; | |
2847 | ||
2848 | s = bfd_get_section_by_name (output_bfd, name); | |
2849 | if (s == NULL) | |
2850 | dyn.d_un.d_val = 0; | |
2851 | else | |
2852 | { | |
2853 | if (! size) | |
2854 | dyn.d_un.d_ptr = s->vma; | |
2855 | else | |
2856 | { | |
2857 | if (s->_cooked_size != 0) | |
2858 | dyn.d_un.d_val = s->_cooked_size; | |
2859 | else | |
2860 | dyn.d_un.d_val = s->_raw_size; | |
2861 | } | |
2862 | } | |
2863 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); | |
2864 | } | |
2865 | } | |
2866 | } | |
2867 | ||
2868 | /* Add a blrl instruction at _GLOBAL_OFFSET_TABLE_-4 so that a function can | |
2869 | easily find the address of the _GLOBAL_OFFSET_TABLE_. */ | |
2870 | if (sgot) | |
2871 | { | |
2872 | unsigned char *contents = sgot->contents; | |
dc810e39 | 2873 | bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents); |
252b5132 RH |
2874 | |
2875 | if (sdyn == NULL) | |
2876 | bfd_put_32 (output_bfd, (bfd_vma) 0, contents+4); | |
2877 | else | |
2878 | bfd_put_32 (output_bfd, | |
2879 | sdyn->output_section->vma + sdyn->output_offset, | |
2880 | contents+4); | |
2881 | ||
2882 | elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; | |
2883 | } | |
2884 | ||
252b5132 RH |
2885 | return true; |
2886 | } | |
252b5132 RH |
2887 | \f |
2888 | /* The RELOCATE_SECTION function is called by the ELF backend linker | |
2889 | to handle the relocations for a section. | |
2890 | ||
2891 | The relocs are always passed as Rela structures; if the section | |
2892 | actually uses Rel structures, the r_addend field will always be | |
2893 | zero. | |
2894 | ||
2895 | This function is responsible for adjust the section contents as | |
2896 | necessary, and (if using Rela relocs and generating a | |
2897 | relocateable output file) adjusting the reloc addend as | |
2898 | necessary. | |
2899 | ||
2900 | This function does not have to worry about setting the reloc | |
2901 | address or the reloc symbol index. | |
2902 | ||
2903 | LOCAL_SYMS is a pointer to the swapped in local symbols. | |
2904 | ||
2905 | LOCAL_SECTIONS is an array giving the section in the input file | |
2906 | corresponding to the st_shndx field of each local symbol. | |
2907 | ||
2908 | The global hash table entry for the global symbols can be found | |
2909 | via elf_sym_hashes (input_bfd). | |
2910 | ||
2911 | When generating relocateable output, this function must handle | |
2912 | STB_LOCAL/STT_SECTION symbols specially. The output symbol is | |
2913 | going to be the section symbol corresponding to the output | |
2914 | section, which means that the addend must be adjusted | |
2915 | accordingly. */ | |
2916 | ||
2917 | static boolean | |
2918 | ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, | |
2919 | contents, relocs, local_syms, local_sections) | |
2920 | bfd *output_bfd; | |
2921 | struct bfd_link_info *info; | |
2922 | bfd *input_bfd; | |
2923 | asection *input_section; | |
2924 | bfd_byte *contents; | |
2925 | Elf_Internal_Rela *relocs; | |
2926 | Elf_Internal_Sym *local_syms; | |
2927 | asection **local_sections; | |
2928 | { | |
2929 | Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; | |
2930 | struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd); | |
2931 | bfd *dynobj = elf_hash_table (info)->dynobj; | |
2932 | elf_linker_section_t *sdata = (dynobj) ? elf_linker_section (dynobj, LINKER_SECTION_SDATA) : NULL; | |
2933 | elf_linker_section_t *sdata2 = (dynobj) ? elf_linker_section (dynobj, LINKER_SECTION_SDATA2) : NULL; | |
2934 | Elf_Internal_Rela *rel = relocs; | |
2935 | Elf_Internal_Rela *relend = relocs + input_section->reloc_count; | |
2936 | asection *sreloc = NULL; | |
2937 | asection *splt; | |
2938 | asection *sgot; | |
2939 | bfd_vma *local_got_offsets; | |
2940 | boolean ret = true; | |
2941 | long insn; | |
2942 | ||
2943 | #ifdef DEBUG | |
2944 | fprintf (stderr, "ppc_elf_relocate_section called for %s section %s, %ld relocations%s\n", | |
8f615d07 | 2945 | bfd_archive_filename (input_bfd), |
252b5132 | 2946 | bfd_section_name(input_bfd, input_section), |
8da6118f | 2947 | (long) input_section->reloc_count, |
252b5132 RH |
2948 | (info->relocateable) ? " (relocatable)" : ""); |
2949 | #endif | |
2950 | ||
b491616a AM |
2951 | if (info->relocateable) |
2952 | return true; | |
2953 | ||
8da6118f KH |
2954 | if (!ppc_elf_howto_table[R_PPC_ADDR32]) |
2955 | /* Initialize howto table if needed. */ | |
252b5132 RH |
2956 | ppc_elf_howto_init (); |
2957 | ||
2958 | local_got_offsets = elf_local_got_offsets (input_bfd); | |
2959 | ||
2960 | splt = sgot = NULL; | |
2961 | if (dynobj != NULL) | |
2962 | { | |
2963 | splt = bfd_get_section_by_name (dynobj, ".plt"); | |
2964 | sgot = bfd_get_section_by_name (dynobj, ".got"); | |
2965 | } | |
2966 | ||
2967 | for (; rel < relend; rel++) | |
2968 | { | |
2969 | enum elf_ppc_reloc_type r_type = (enum elf_ppc_reloc_type)ELF32_R_TYPE (rel->r_info); | |
2970 | bfd_vma offset = rel->r_offset; | |
2971 | bfd_vma addend = rel->r_addend; | |
2972 | bfd_reloc_status_type r = bfd_reloc_other; | |
8da6118f KH |
2973 | Elf_Internal_Sym *sym = (Elf_Internal_Sym *) 0; |
2974 | asection *sec = (asection *) 0; | |
2975 | struct elf_link_hash_entry *h = (struct elf_link_hash_entry *) 0; | |
2976 | const char *sym_name = (const char *) 0; | |
252b5132 RH |
2977 | reloc_howto_type *howto; |
2978 | unsigned long r_symndx; | |
2979 | bfd_vma relocation; | |
e1e0340b | 2980 | int will_become_local; |
252b5132 RH |
2981 | |
2982 | /* Unknown relocation handling */ | |
8da6118f KH |
2983 | if ((unsigned) r_type >= (unsigned) R_PPC_max |
2984 | || !ppc_elf_howto_table[(int) r_type]) | |
252b5132 RH |
2985 | { |
2986 | (*_bfd_error_handler) (_("%s: unknown relocation type %d"), | |
8f615d07 | 2987 | bfd_archive_filename (input_bfd), |
8da6118f | 2988 | (int) r_type); |
252b5132 RH |
2989 | |
2990 | bfd_set_error (bfd_error_bad_value); | |
2991 | ret = false; | |
2992 | continue; | |
2993 | } | |
2994 | ||
8da6118f | 2995 | howto = ppc_elf_howto_table[(int) r_type]; |
252b5132 RH |
2996 | r_symndx = ELF32_R_SYM (rel->r_info); |
2997 | ||
252b5132 RH |
2998 | if (r_symndx < symtab_hdr->sh_info) |
2999 | { | |
3000 | sym = local_syms + r_symndx; | |
3001 | sec = local_sections[r_symndx]; | |
3002 | sym_name = "<local symbol>"; | |
3003 | ||
f8df10f4 JJ |
3004 | relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); |
3005 | addend = rel->r_addend; | |
e1e0340b GK |
3006 | /* Relocs to local symbols are always resolved. */ |
3007 | will_become_local = 1; | |
252b5132 RH |
3008 | } |
3009 | else | |
3010 | { | |
3011 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
3012 | while (h->root.type == bfd_link_hash_indirect | |
3013 | || h->root.type == bfd_link_hash_warning) | |
3014 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
3015 | sym_name = h->root.root.string; | |
e1e0340b GK |
3016 | |
3017 | /* Can this relocation be resolved immediately? */ | |
3018 | will_become_local = SYMBOL_REFERENCES_LOCAL (info, h); | |
3019 | ||
252b5132 RH |
3020 | if (h->root.type == bfd_link_hash_defined |
3021 | || h->root.type == bfd_link_hash_defweak) | |
3022 | { | |
3023 | sec = h->root.u.def.section; | |
e1e0340b GK |
3024 | if (((r_type == R_PPC_PLT32 |
3025 | || r_type == R_PPC_PLTREL24) | |
dd5724d5 | 3026 | && splt != NULL |
252b5132 RH |
3027 | && h->plt.offset != (bfd_vma) -1) |
3028 | || (r_type == R_PPC_LOCAL24PC | |
3029 | && sec->output_section == NULL) | |
3030 | || ((r_type == R_PPC_GOT16 | |
3031 | || r_type == R_PPC_GOT16_LO | |
3032 | || r_type == R_PPC_GOT16_HI | |
3033 | || r_type == R_PPC_GOT16_HA) | |
3034 | && elf_hash_table (info)->dynamic_sections_created | |
e1e0340b | 3035 | && (! info->shared || ! will_become_local)) |
252b5132 | 3036 | || (info->shared |
e1e0340b | 3037 | && ! will_become_local |
2d146250 ILT |
3038 | && ((input_section->flags & SEC_ALLOC) != 0 |
3039 | /* Testing SEC_DEBUGGING here may be wrong. | |
3040 | It's here to avoid a crash when | |
3041 | generating a shared library with DWARF | |
3042 | debugging information. */ | |
1319985e AM |
3043 | || ((input_section->flags & SEC_DEBUGGING) != 0 |
3044 | && (h->elf_link_hash_flags | |
3045 | & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) | |
252b5132 RH |
3046 | && (r_type == R_PPC_ADDR32 |
3047 | || r_type == R_PPC_ADDR24 | |
3048 | || r_type == R_PPC_ADDR16 | |
3049 | || r_type == R_PPC_ADDR16_LO | |
3050 | || r_type == R_PPC_ADDR16_HI | |
3051 | || r_type == R_PPC_ADDR16_HA | |
3052 | || r_type == R_PPC_ADDR14 | |
3053 | || r_type == R_PPC_ADDR14_BRTAKEN | |
3054 | || r_type == R_PPC_ADDR14_BRNTAKEN | |
252b5132 RH |
3055 | || r_type == R_PPC_COPY |
3056 | || r_type == R_PPC_GLOB_DAT | |
3057 | || r_type == R_PPC_JMP_SLOT | |
3058 | || r_type == R_PPC_UADDR32 | |
3059 | || r_type == R_PPC_UADDR16 | |
3060 | || r_type == R_PPC_SDAREL16 | |
3061 | || r_type == R_PPC_EMB_NADDR32 | |
3062 | || r_type == R_PPC_EMB_NADDR16 | |
3063 | || r_type == R_PPC_EMB_NADDR16_LO | |
3064 | || r_type == R_PPC_EMB_NADDR16_HI | |
3065 | || r_type == R_PPC_EMB_NADDR16_HA | |
3066 | || r_type == R_PPC_EMB_SDAI16 | |
3067 | || r_type == R_PPC_EMB_SDA2I16 | |
3068 | || r_type == R_PPC_EMB_SDA2REL | |
3069 | || r_type == R_PPC_EMB_SDA21 | |
3070 | || r_type == R_PPC_EMB_MRKREF | |
3071 | || r_type == R_PPC_EMB_BIT_FLD | |
3072 | || r_type == R_PPC_EMB_RELSDA | |
3073 | || ((r_type == R_PPC_REL24 | |
3074 | || r_type == R_PPC_REL32 | |
3075 | || r_type == R_PPC_REL14 | |
3076 | || r_type == R_PPC_REL14_BRTAKEN | |
3077 | || r_type == R_PPC_REL14_BRNTAKEN | |
3078 | || r_type == R_PPC_RELATIVE) | |
3079 | && strcmp (h->root.root.string, | |
3080 | "_GLOBAL_OFFSET_TABLE_") != 0)))) | |
3081 | { | |
3082 | /* In these cases, we don't need the relocation | |
3083 | value. We check specially because in some | |
3084 | obscure cases sec->output_section will be NULL. */ | |
3085 | relocation = 0; | |
3086 | } | |
2d146250 | 3087 | else if (sec->output_section == NULL) |
8da6118f | 3088 | { |
2d146250 ILT |
3089 | (*_bfd_error_handler) |
3090 | (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"), | |
8f615d07 | 3091 | bfd_archive_filename (input_bfd), h->root.root.string, |
2d146250 ILT |
3092 | bfd_get_section_name (input_bfd, input_section)); |
3093 | relocation = 0; | |
8da6118f | 3094 | } |
252b5132 RH |
3095 | else |
3096 | relocation = (h->root.u.def.value | |
3097 | + sec->output_section->vma | |
3098 | + sec->output_offset); | |
3099 | } | |
3100 | else if (h->root.type == bfd_link_hash_undefweak) | |
3101 | relocation = 0; | |
671bae9c NC |
3102 | else if (info->shared |
3103 | && (!info->symbolic || info->allow_shlib_undefined) | |
3104 | && !info->no_undefined | |
3a27a730 | 3105 | && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) |
252b5132 RH |
3106 | relocation = 0; |
3107 | else | |
3108 | { | |
c3668558 | 3109 | if (! (*info->callbacks->undefined_symbol) (info, |
464e1740 ILT |
3110 | h->root.root.string, |
3111 | input_bfd, | |
3112 | input_section, | |
5cc7c785 L |
3113 | rel->r_offset, |
3114 | (!info->shared | |
3a27a730 | 3115 | || info->no_undefined |
ba09750c | 3116 | || ELF_ST_VISIBILITY (h->other)))) |
464e1740 ILT |
3117 | return false; |
3118 | relocation = 0; | |
252b5132 RH |
3119 | } |
3120 | } | |
3121 | ||
8da6118f | 3122 | switch ((int) r_type) |
252b5132 RH |
3123 | { |
3124 | default: | |
3125 | (*_bfd_error_handler) (_("%s: unknown relocation type %d for symbol %s"), | |
8f615d07 | 3126 | bfd_archive_filename (input_bfd), |
8da6118f | 3127 | (int) r_type, sym_name); |
252b5132 RH |
3128 | |
3129 | bfd_set_error (bfd_error_bad_value); | |
3130 | ret = false; | |
3131 | continue; | |
3132 | ||
7595d193 L |
3133 | case (int) R_PPC_NONE: |
3134 | continue; | |
3135 | ||
252b5132 | 3136 | /* Relocations that need no special processing. */ |
8da6118f | 3137 | case (int) R_PPC_LOCAL24PC: |
252b5132 RH |
3138 | /* It makes no sense to point a local relocation |
3139 | at a symbol not in this object. */ | |
3140 | if (h != NULL | |
3141 | && (h->root.type == bfd_link_hash_defined | |
3142 | || h->root.type == bfd_link_hash_defweak) | |
3143 | && sec->output_section == NULL) | |
3144 | { | |
464e1740 ILT |
3145 | if (! (*info->callbacks->undefined_symbol) (info, |
3146 | h->root.root.string, | |
3147 | input_bfd, | |
3148 | input_section, | |
5cc7c785 L |
3149 | rel->r_offset, |
3150 | true)) | |
464e1740 | 3151 | return false; |
252b5132 RH |
3152 | continue; |
3153 | } | |
3154 | break; | |
3155 | ||
3156 | /* Relocations that may need to be propagated if this is a shared | |
3157 | object. */ | |
8da6118f KH |
3158 | case (int) R_PPC_REL24: |
3159 | case (int) R_PPC_REL32: | |
3160 | case (int) R_PPC_REL14: | |
252b5132 RH |
3161 | /* If these relocations are not to a named symbol, they can be |
3162 | handled right here, no need to bother the dynamic linker. */ | |
3163 | if (h == NULL | |
e1e0340b GK |
3164 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0 |
3165 | || SYMBOL_REFERENCES_LOCAL (info, h)) | |
252b5132 RH |
3166 | break; |
3167 | /* fall through */ | |
3168 | ||
3169 | /* Relocations that always need to be propagated if this is a shared | |
3170 | object. */ | |
8da6118f KH |
3171 | case (int) R_PPC_ADDR32: |
3172 | case (int) R_PPC_ADDR24: | |
3173 | case (int) R_PPC_ADDR16: | |
3174 | case (int) R_PPC_ADDR16_LO: | |
3175 | case (int) R_PPC_ADDR16_HI: | |
3176 | case (int) R_PPC_ADDR16_HA: | |
3177 | case (int) R_PPC_ADDR14: | |
3178 | case (int) R_PPC_UADDR32: | |
3179 | case (int) R_PPC_UADDR16: | |
ec338859 | 3180 | if (info->shared && r_symndx != 0) |
252b5132 RH |
3181 | { |
3182 | Elf_Internal_Rela outrel; | |
947216bf | 3183 | bfd_byte *loc; |
0bb2d96a | 3184 | int skip; |
252b5132 RH |
3185 | |
3186 | #ifdef DEBUG | |
3187 | fprintf (stderr, "ppc_elf_relocate_section need to create relocation for %s\n", | |
3188 | (h && h->root.root.string) ? h->root.root.string : "<unknown>"); | |
3189 | #endif | |
3190 | ||
3191 | /* When generating a shared object, these relocations | |
3192 | are copied into the output file to be resolved at run | |
3193 | time. */ | |
3194 | ||
3195 | if (sreloc == NULL) | |
3196 | { | |
3197 | const char *name; | |
3198 | ||
3199 | name = (bfd_elf_string_from_elf_section | |
3200 | (input_bfd, | |
3201 | elf_elfheader (input_bfd)->e_shstrndx, | |
3202 | elf_section_data (input_section)->rel_hdr.sh_name)); | |
3203 | if (name == NULL) | |
3204 | return false; | |
3205 | ||
3206 | BFD_ASSERT (strncmp (name, ".rela", 5) == 0 | |
3207 | && strcmp (bfd_get_section_name (input_bfd, | |
3208 | input_section), | |
3209 | name + 5) == 0); | |
3210 | ||
3211 | sreloc = bfd_get_section_by_name (dynobj, name); | |
3212 | BFD_ASSERT (sreloc != NULL); | |
3213 | } | |
3214 | ||
0bb2d96a | 3215 | skip = 0; |
252b5132 | 3216 | |
c629eae0 JJ |
3217 | outrel.r_offset = |
3218 | _bfd_elf_section_offset (output_bfd, info, input_section, | |
3219 | rel->r_offset); | |
0bb2d96a JJ |
3220 | if (outrel.r_offset == (bfd_vma) -1 |
3221 | || outrel.r_offset == (bfd_vma) -2) | |
3222 | skip = (int) outrel.r_offset; | |
252b5132 RH |
3223 | outrel.r_offset += (input_section->output_section->vma |
3224 | + input_section->output_offset); | |
3225 | ||
3226 | if (skip) | |
3227 | memset (&outrel, 0, sizeof outrel); | |
3228 | /* h->dynindx may be -1 if this symbol was marked to | |
3229 | become local. */ | |
e1e0340b | 3230 | else if (! will_become_local) |
252b5132 | 3231 | { |
252b5132 RH |
3232 | outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); |
3233 | outrel.r_addend = rel->r_addend; | |
3234 | } | |
3235 | else | |
3236 | { | |
3237 | if (r_type == R_PPC_ADDR32) | |
3238 | { | |
3239 | outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE); | |
3240 | outrel.r_addend = relocation + rel->r_addend; | |
3241 | } | |
3242 | else | |
3243 | { | |
3244 | long indx; | |
3245 | ||
3246 | if (h == NULL) | |
3247 | sec = local_sections[r_symndx]; | |
3248 | else | |
3249 | { | |
3250 | BFD_ASSERT (h->root.type == bfd_link_hash_defined | |
3251 | || (h->root.type | |
3252 | == bfd_link_hash_defweak)); | |
3253 | sec = h->root.u.def.section; | |
3254 | } | |
3255 | if (sec != NULL && bfd_is_abs_section (sec)) | |
3256 | indx = 0; | |
3257 | else if (sec == NULL || sec->owner == NULL) | |
3258 | { | |
3259 | bfd_set_error (bfd_error_bad_value); | |
3260 | return false; | |
3261 | } | |
3262 | else | |
3263 | { | |
3264 | asection *osec; | |
3265 | ||
3266 | osec = sec->output_section; | |
3267 | indx = elf_section_data (osec)->dynindx; | |
8da6118f | 3268 | BFD_ASSERT (indx > 0); |
252b5132 RH |
3269 | #ifdef DEBUG |
3270 | if (indx <= 0) | |
3271 | { | |
c3668558 | 3272 | printf ("indx=%d section=%s flags=%08x name=%s\n", |
252b5132 RH |
3273 | indx, osec->name, osec->flags, |
3274 | h->root.root.string); | |
3275 | } | |
3276 | #endif | |
3277 | } | |
3278 | ||
3279 | outrel.r_info = ELF32_R_INFO (indx, r_type); | |
3280 | outrel.r_addend = relocation + rel->r_addend; | |
3281 | } | |
3282 | } | |
3283 | ||
947216bf AM |
3284 | loc = sreloc->contents; |
3285 | loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela); | |
3286 | bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); | |
252b5132 | 3287 | |
2243deae | 3288 | if (skip == -1) |
252b5132 | 3289 | continue; |
2243deae L |
3290 | |
3291 | /* This reloc will be computed at runtime. We clear the memory | |
3292 | so that it contains predictable value. */ | |
3293 | if (! skip | |
3294 | && ((input_section->flags & SEC_ALLOC) != 0 | |
3295 | || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE)) | |
3296 | { | |
3297 | relocation = howto->pc_relative ? outrel.r_offset : 0; | |
3298 | addend = 0; | |
3299 | break; | |
3300 | } | |
252b5132 RH |
3301 | } |
3302 | ||
3303 | /* Arithmetic adjust relocations that aren't going into a | |
3304 | shared object. */ | |
3305 | if (r_type == R_PPC_ADDR16_HA | |
3306 | /* It's just possible that this symbol is a weak symbol | |
3307 | that's not actually defined anywhere. In that case, | |
3308 | 'sec' would be NULL, and we should leave the symbol | |
3309 | alone (it will be set to zero elsewhere in the link). */ | |
3310 | && sec != NULL) | |
3311 | { | |
3312 | addend += ((relocation + addend) & 0x8000) << 1; | |
3313 | } | |
3314 | break; | |
3315 | ||
3316 | /* branch taken prediction relocations */ | |
8da6118f KH |
3317 | case (int) R_PPC_ADDR14_BRTAKEN: |
3318 | case (int) R_PPC_REL14_BRTAKEN: | |
252b5132 RH |
3319 | insn = bfd_get_32 (output_bfd, contents + offset); |
3320 | if ((relocation - offset) & 0x8000) | |
3321 | insn &= ~BRANCH_PREDICT_BIT; | |
3322 | else | |
3323 | insn |= BRANCH_PREDICT_BIT; | |
dc810e39 | 3324 | bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset); |
252b5132 RH |
3325 | break; |
3326 | ||
3327 | /* branch not taken predicition relocations */ | |
8da6118f KH |
3328 | case (int) R_PPC_ADDR14_BRNTAKEN: |
3329 | case (int) R_PPC_REL14_BRNTAKEN: | |
252b5132 RH |
3330 | insn = bfd_get_32 (output_bfd, contents + offset); |
3331 | if ((relocation - offset) & 0x8000) | |
3332 | insn |= BRANCH_PREDICT_BIT; | |
3333 | else | |
3334 | insn &= ~BRANCH_PREDICT_BIT; | |
dc810e39 | 3335 | bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset); |
252b5132 RH |
3336 | break; |
3337 | ||
3338 | /* GOT16 relocations */ | |
8da6118f KH |
3339 | case (int) R_PPC_GOT16: |
3340 | case (int) R_PPC_GOT16_LO: | |
3341 | case (int) R_PPC_GOT16_HI: | |
3342 | case (int) R_PPC_GOT16_HA: | |
252b5132 RH |
3343 | /* Relocation is to the entry for this symbol in the global |
3344 | offset table. */ | |
3345 | BFD_ASSERT (sgot != NULL); | |
3346 | ||
3347 | if (h != NULL) | |
3348 | { | |
3349 | bfd_vma off; | |
3350 | ||
3351 | off = h->got.offset; | |
3352 | BFD_ASSERT (off != (bfd_vma) -1); | |
3353 | ||
3354 | if (! elf_hash_table (info)->dynamic_sections_created | |
3355 | || (info->shared | |
e1e0340b | 3356 | && SYMBOL_REFERENCES_LOCAL (info, h))) |
252b5132 RH |
3357 | { |
3358 | /* This is actually a static link, or it is a | |
3359 | -Bsymbolic link and the symbol is defined | |
3360 | locally. We must initialize this entry in the | |
3361 | global offset table. Since the offset must | |
3362 | always be a multiple of 4, we use the least | |
3363 | significant bit to record whether we have | |
3364 | initialized it already. | |
3365 | ||
3366 | When doing a dynamic link, we create a .rela.got | |
3367 | relocation entry to initialize the value. This | |
3368 | is done in the finish_dynamic_symbol routine. */ | |
3369 | if ((off & 1) != 0) | |
3370 | off &= ~1; | |
3371 | else | |
3372 | { | |
3373 | bfd_put_32 (output_bfd, relocation, | |
3374 | sgot->contents + off); | |
3375 | h->got.offset |= 1; | |
3376 | } | |
3377 | } | |
3378 | ||
3379 | relocation = sgot->output_offset + off - 4; | |
3380 | } | |
3381 | else | |
3382 | { | |
3383 | bfd_vma off; | |
3384 | ||
3385 | BFD_ASSERT (local_got_offsets != NULL | |
3386 | && local_got_offsets[r_symndx] != (bfd_vma) -1); | |
3387 | ||
3388 | off = local_got_offsets[r_symndx]; | |
3389 | ||
3390 | /* The offset must always be a multiple of 4. We use | |
3391 | the least significant bit to record whether we have | |
3392 | already processed this entry. */ | |
3393 | if ((off & 1) != 0) | |
3394 | off &= ~1; | |
3395 | else | |
3396 | { | |
252b5132 RH |
3397 | |
3398 | if (info->shared) | |
3399 | { | |
3400 | asection *srelgot; | |
3401 | Elf_Internal_Rela outrel; | |
947216bf | 3402 | bfd_byte *loc; |
252b5132 RH |
3403 | |
3404 | /* We need to generate a R_PPC_RELATIVE reloc | |
3405 | for the dynamic linker. */ | |
3406 | srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); | |
3407 | BFD_ASSERT (srelgot != NULL); | |
3408 | ||
3409 | outrel.r_offset = (sgot->output_section->vma | |
3410 | + sgot->output_offset | |
3411 | + off); | |
3412 | outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE); | |
3413 | outrel.r_addend = relocation; | |
947216bf AM |
3414 | loc = srelgot->contents; |
3415 | loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela); | |
3416 | bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); | |
2243deae | 3417 | relocation = 0; |
252b5132 RH |
3418 | } |
3419 | ||
2243deae | 3420 | bfd_put_32 (output_bfd, relocation, sgot->contents + off); |
252b5132 RH |
3421 | local_got_offsets[r_symndx] |= 1; |
3422 | } | |
3423 | ||
3424 | relocation = sgot->output_offset + off - 4; | |
3425 | } | |
3426 | break; | |
3427 | ||
3428 | /* Indirect .sdata relocation */ | |
8da6118f | 3429 | case (int) R_PPC_EMB_SDAI16: |
252b5132 RH |
3430 | BFD_ASSERT (sdata != NULL); |
3431 | relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info, | |
3432 | sdata, h, relocation, rel, | |
3433 | R_PPC_RELATIVE); | |
3434 | break; | |
3435 | ||
3436 | /* Indirect .sdata2 relocation */ | |
8da6118f | 3437 | case (int) R_PPC_EMB_SDA2I16: |
252b5132 RH |
3438 | BFD_ASSERT (sdata2 != NULL); |
3439 | relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info, | |
3440 | sdata2, h, relocation, rel, | |
3441 | R_PPC_RELATIVE); | |
3442 | break; | |
3443 | ||
3444 | /* Handle the TOC16 reloc. We want to use the offset within the .got | |
3445 | section, not the actual VMA. This is appropriate when generating | |
3446 | an embedded ELF object, for which the .got section acts like the | |
3447 | AIX .toc section. */ | |
8da6118f KH |
3448 | case (int) R_PPC_TOC16: /* phony GOT16 relocations */ |
3449 | BFD_ASSERT (sec != (asection *) 0); | |
252b5132 RH |
3450 | BFD_ASSERT (bfd_is_und_section (sec) |
3451 | || strcmp (bfd_get_section_name (abfd, sec), ".got") == 0 | |
3452 | || strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0) | |
3453 | ||
3454 | addend -= sec->output_section->vma + sec->output_offset + 0x8000; | |
3455 | break; | |
3456 | ||
8da6118f | 3457 | case (int) R_PPC_PLTREL24: |
252b5132 RH |
3458 | /* Relocation is to the entry for this symbol in the |
3459 | procedure linkage table. */ | |
3460 | BFD_ASSERT (h != NULL); | |
3461 | ||
3462 | if (h->plt.offset == (bfd_vma) -1 | |
3463 | || splt == NULL) | |
3464 | { | |
3465 | /* We didn't make a PLT entry for this symbol. This | |
3466 | happens when statically linking PIC code, or when | |
3467 | using -Bsymbolic. */ | |
3468 | break; | |
3469 | } | |
3470 | ||
3471 | relocation = (splt->output_section->vma | |
3472 | + splt->output_offset | |
3473 | + h->plt.offset); | |
8da6118f | 3474 | break; |
252b5132 RH |
3475 | |
3476 | /* relocate against _SDA_BASE_ */ | |
8da6118f | 3477 | case (int) R_PPC_SDAREL16: |
252b5132 RH |
3478 | { |
3479 | const char *name; | |
3480 | ||
8da6118f | 3481 | BFD_ASSERT (sec != (asection *) 0); |
252b5132 | 3482 | name = bfd_get_section_name (abfd, sec->output_section); |
5f819128 AM |
3483 | if (! ((strncmp (name, ".sdata", 6) == 0 |
3484 | && (name[6] == 0 || name[6] == '.')) | |
3485 | || (strncmp (name, ".sbss", 5) == 0 | |
3486 | && (name[5] == 0 || name[5] == '.')))) | |
252b5132 RH |
3487 | { |
3488 | (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"), | |
8f615d07 | 3489 | bfd_archive_filename (input_bfd), |
252b5132 | 3490 | sym_name, |
8da6118f | 3491 | ppc_elf_howto_table[(int) r_type]->name, |
252b5132 RH |
3492 | name); |
3493 | } | |
3494 | addend -= (sdata->sym_hash->root.u.def.value | |
3495 | + sdata->sym_hash->root.u.def.section->output_section->vma | |
3496 | + sdata->sym_hash->root.u.def.section->output_offset); | |
3497 | } | |
3498 | break; | |
3499 | ||
252b5132 | 3500 | /* relocate against _SDA2_BASE_ */ |
8da6118f | 3501 | case (int) R_PPC_EMB_SDA2REL: |
252b5132 RH |
3502 | { |
3503 | const char *name; | |
3504 | ||
8da6118f | 3505 | BFD_ASSERT (sec != (asection *) 0); |
252b5132 | 3506 | name = bfd_get_section_name (abfd, sec->output_section); |
5f819128 AM |
3507 | if (! (strncmp (name, ".sdata2", 7) == 0 |
3508 | || strncmp (name, ".sbss2", 6) == 0)) | |
252b5132 RH |
3509 | { |
3510 | (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"), | |
8f615d07 | 3511 | bfd_archive_filename (input_bfd), |
252b5132 | 3512 | sym_name, |
8da6118f | 3513 | ppc_elf_howto_table[(int) r_type]->name, |
252b5132 | 3514 | name); |
c3668558 | 3515 | |
252b5132 RH |
3516 | bfd_set_error (bfd_error_bad_value); |
3517 | ret = false; | |
3518 | continue; | |
3519 | } | |
3520 | addend -= (sdata2->sym_hash->root.u.def.value | |
3521 | + sdata2->sym_hash->root.u.def.section->output_section->vma | |
3522 | + sdata2->sym_hash->root.u.def.section->output_offset); | |
3523 | } | |
3524 | break; | |
3525 | ||
252b5132 | 3526 | /* relocate against either _SDA_BASE_, _SDA2_BASE_, or 0 */ |
8da6118f KH |
3527 | case (int) R_PPC_EMB_SDA21: |
3528 | case (int) R_PPC_EMB_RELSDA: | |
252b5132 RH |
3529 | { |
3530 | const char *name; | |
3531 | int reg; | |
3532 | ||
8da6118f | 3533 | BFD_ASSERT (sec != (asection *) 0); |
252b5132 | 3534 | name = bfd_get_section_name (abfd, sec->output_section); |
5f819128 AM |
3535 | if (((strncmp (name, ".sdata", 6) == 0 |
3536 | && (name[6] == 0 || name[6] == '.')) | |
3537 | || (strncmp (name, ".sbss", 5) == 0 | |
3538 | && (name[5] == 0 || name[5] == '.')))) | |
252b5132 RH |
3539 | { |
3540 | reg = 13; | |
3541 | addend -= (sdata->sym_hash->root.u.def.value | |
3542 | + sdata->sym_hash->root.u.def.section->output_section->vma | |
3543 | + sdata->sym_hash->root.u.def.section->output_offset); | |
3544 | } | |
3545 | ||
5f819128 AM |
3546 | else if (strncmp (name, ".sdata2", 7) == 0 |
3547 | || strncmp (name, ".sbss2", 6) == 0) | |
252b5132 RH |
3548 | { |
3549 | reg = 2; | |
3550 | addend -= (sdata2->sym_hash->root.u.def.value | |
3551 | + sdata2->sym_hash->root.u.def.section->output_section->vma | |
3552 | + sdata2->sym_hash->root.u.def.section->output_offset); | |
3553 | } | |
3554 | ||
8da6118f KH |
3555 | else if (strcmp (name, ".PPC.EMB.sdata0") == 0 |
3556 | || strcmp (name, ".PPC.EMB.sbss0") == 0) | |
252b5132 RH |
3557 | { |
3558 | reg = 0; | |
3559 | } | |
3560 | ||
3561 | else | |
3562 | { | |
3563 | (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"), | |
8f615d07 | 3564 | bfd_archive_filename (input_bfd), |
252b5132 | 3565 | sym_name, |
8da6118f | 3566 | ppc_elf_howto_table[(int) r_type]->name, |
252b5132 RH |
3567 | name); |
3568 | ||
3569 | bfd_set_error (bfd_error_bad_value); | |
3570 | ret = false; | |
3571 | continue; | |
3572 | } | |
3573 | ||
3574 | if (r_type == R_PPC_EMB_SDA21) | |
3575 | { /* fill in register field */ | |
3576 | insn = bfd_get_32 (output_bfd, contents + offset); | |
3577 | insn = (insn & ~RA_REGISTER_MASK) | (reg << RA_REGISTER_SHIFT); | |
dc810e39 | 3578 | bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset); |
252b5132 RH |
3579 | } |
3580 | } | |
3581 | break; | |
3582 | ||
3583 | /* Relocate against the beginning of the section */ | |
8da6118f KH |
3584 | case (int) R_PPC_SECTOFF: |
3585 | case (int) R_PPC_SECTOFF_LO: | |
3586 | case (int) R_PPC_SECTOFF_HI: | |
3587 | BFD_ASSERT (sec != (asection *) 0); | |
252b5132 RH |
3588 | addend -= sec->output_section->vma; |
3589 | break; | |
3590 | ||
8da6118f KH |
3591 | case (int) R_PPC_SECTOFF_HA: |
3592 | BFD_ASSERT (sec != (asection *) 0); | |
252b5132 RH |
3593 | addend -= sec->output_section->vma; |
3594 | addend += ((relocation + addend) & 0x8000) << 1; | |
3595 | break; | |
3596 | ||
3597 | /* Negative relocations */ | |
8da6118f KH |
3598 | case (int) R_PPC_EMB_NADDR32: |
3599 | case (int) R_PPC_EMB_NADDR16: | |
3600 | case (int) R_PPC_EMB_NADDR16_LO: | |
3601 | case (int) R_PPC_EMB_NADDR16_HI: | |
3602 | addend -= 2 * relocation; | |
252b5132 RH |
3603 | break; |
3604 | ||
8da6118f KH |
3605 | case (int) R_PPC_EMB_NADDR16_HA: |
3606 | addend -= 2 * relocation; | |
252b5132 RH |
3607 | addend += ((relocation + addend) & 0x8000) << 1; |
3608 | break; | |
3609 | ||
3610 | /* NOP relocation that prevents garbage collecting linkers from omitting a | |
3611 | reference. */ | |
8da6118f | 3612 | case (int) R_PPC_EMB_MRKREF: |
252b5132 RH |
3613 | continue; |
3614 | ||
8da6118f KH |
3615 | case (int) R_PPC_COPY: |
3616 | case (int) R_PPC_GLOB_DAT: | |
3617 | case (int) R_PPC_JMP_SLOT: | |
3618 | case (int) R_PPC_RELATIVE: | |
3619 | case (int) R_PPC_PLT32: | |
3620 | case (int) R_PPC_PLTREL32: | |
3621 | case (int) R_PPC_PLT16_LO: | |
3622 | case (int) R_PPC_PLT16_HI: | |
3623 | case (int) R_PPC_PLT16_HA: | |
3624 | case (int) R_PPC_EMB_RELSEC16: | |
3625 | case (int) R_PPC_EMB_RELST_LO: | |
3626 | case (int) R_PPC_EMB_RELST_HI: | |
3627 | case (int) R_PPC_EMB_RELST_HA: | |
3628 | case (int) R_PPC_EMB_BIT_FLD: | |
252b5132 | 3629 | (*_bfd_error_handler) (_("%s: Relocation %s is not yet supported for symbol %s."), |
8f615d07 | 3630 | bfd_archive_filename (input_bfd), |
8da6118f | 3631 | ppc_elf_howto_table[(int) r_type]->name, |
252b5132 RH |
3632 | sym_name); |
3633 | ||
3634 | bfd_set_error (bfd_error_invalid_operation); | |
3635 | ret = false; | |
3636 | continue; | |
3637 | ||
8da6118f KH |
3638 | case (int) R_PPC_GNU_VTINHERIT: |
3639 | case (int) R_PPC_GNU_VTENTRY: | |
252b5132 RH |
3640 | /* These are no-ops in the end. */ |
3641 | continue; | |
3642 | } | |
3643 | ||
252b5132 RH |
3644 | #ifdef DEBUG |
3645 | fprintf (stderr, "\ttype = %s (%d), name = %s, symbol index = %ld, offset = %ld, addend = %ld\n", | |
3646 | howto->name, | |
8da6118f | 3647 | (int) r_type, |
252b5132 RH |
3648 | sym_name, |
3649 | r_symndx, | |
8da6118f KH |
3650 | (long) offset, |
3651 | (long) addend); | |
252b5132 RH |
3652 | #endif |
3653 | ||
3654 | r = _bfd_final_link_relocate (howto, | |
3655 | input_bfd, | |
3656 | input_section, | |
3657 | contents, | |
3658 | offset, | |
3659 | relocation, | |
3660 | addend); | |
3661 | ||
dc1bc0c9 RH |
3662 | if (r == bfd_reloc_ok) |
3663 | ; | |
3664 | else if (r == bfd_reloc_overflow) | |
252b5132 | 3665 | { |
dc1bc0c9 RH |
3666 | const char *name; |
3667 | ||
3668 | if (h != NULL) | |
252b5132 | 3669 | { |
dc1bc0c9 RH |
3670 | if (h->root.type == bfd_link_hash_undefweak |
3671 | && howto->pc_relative) | |
3672 | { | |
3673 | /* Assume this is a call protected by other code that | |
3674 | detect the symbol is undefined. If this is the case, | |
3675 | we can safely ignore the overflow. If not, the | |
3676 | program is hosed anyway, and a little warning isn't | |
3677 | going to help. */ | |
252b5132 | 3678 | |
dc1bc0c9 RH |
3679 | continue; |
3680 | } | |
252b5132 | 3681 | |
dc1bc0c9 RH |
3682 | name = h->root.root.string; |
3683 | } | |
3684 | else | |
3685 | { | |
3686 | name = bfd_elf_string_from_elf_section (input_bfd, | |
3687 | symtab_hdr->sh_link, | |
3688 | sym->st_name); | |
3689 | if (name == NULL) | |
3690 | continue; | |
3691 | if (*name == '\0') | |
3692 | name = bfd_section_name (input_bfd, sec); | |
252b5132 | 3693 | } |
dc1bc0c9 | 3694 | |
c3668558 | 3695 | if (! (*info->callbacks->reloc_overflow) (info, |
464e1740 ILT |
3696 | name, |
3697 | howto->name, | |
3698 | (bfd_vma) 0, | |
3699 | input_bfd, | |
3700 | input_section, | |
3701 | offset)) | |
3702 | return false; | |
252b5132 | 3703 | } |
dc1bc0c9 RH |
3704 | else |
3705 | ret = false; | |
252b5132 RH |
3706 | } |
3707 | ||
252b5132 RH |
3708 | #ifdef DEBUG |
3709 | fprintf (stderr, "\n"); | |
3710 | #endif | |
3711 | ||
3712 | return ret; | |
3713 | } | |
29c2fb7c AJ |
3714 | |
3715 | static enum elf_reloc_type_class | |
f51e552e AM |
3716 | ppc_elf_reloc_type_class (rela) |
3717 | const Elf_Internal_Rela *rela; | |
29c2fb7c | 3718 | { |
f51e552e | 3719 | switch ((int) ELF32_R_TYPE (rela->r_info)) |
29c2fb7c AJ |
3720 | { |
3721 | case R_PPC_RELATIVE: | |
3722 | return reloc_class_relative; | |
3723 | case R_PPC_REL24: | |
3724 | case R_PPC_ADDR24: | |
3725 | case R_PPC_JMP_SLOT: | |
3726 | return reloc_class_plt; | |
3727 | case R_PPC_COPY: | |
3728 | return reloc_class_copy; | |
3729 | default: | |
3730 | return reloc_class_normal; | |
3731 | } | |
3732 | } | |
252b5132 | 3733 | \f |
c5fccbec DJ |
3734 | /* Support for core dump NOTE sections */ |
3735 | static boolean | |
3736 | ppc_elf_grok_prstatus (abfd, note) | |
3737 | bfd *abfd; | |
3738 | Elf_Internal_Note *note; | |
3739 | { | |
3740 | int offset; | |
dc810e39 | 3741 | unsigned int raw_size; |
c5fccbec DJ |
3742 | |
3743 | switch (note->descsz) | |
3744 | { | |
3745 | default: | |
3746 | return false; | |
3747 | ||
3748 | case 268: /* Linux/PPC */ | |
3749 | /* pr_cursig */ | |
3750 | elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); | |
3751 | ||
3752 | /* pr_pid */ | |
3753 | elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24); | |
3754 | ||
3755 | /* pr_reg */ | |
3756 | offset = 72; | |
3757 | raw_size = 192; | |
3758 | ||
3759 | break; | |
3760 | } | |
3761 | ||
3762 | /* Make a ".reg/999" section. */ | |
3763 | return _bfd_elfcore_make_pseudosection (abfd, ".reg", | |
3764 | raw_size, note->descpos + offset); | |
3765 | } | |
3766 | ||
3767 | static boolean | |
3768 | ppc_elf_grok_psinfo (abfd, note) | |
3769 | bfd *abfd; | |
3770 | Elf_Internal_Note *note; | |
3771 | { | |
3772 | switch (note->descsz) | |
3773 | { | |
3774 | default: | |
3775 | return false; | |
3776 | ||
3777 | case 128: /* Linux/PPC elf_prpsinfo */ | |
3778 | elf_tdata (abfd)->core_program | |
3779 | = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16); | |
3780 | elf_tdata (abfd)->core_command | |
3781 | = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80); | |
3782 | } | |
3783 | ||
3784 | /* Note that for some reason, a spurious space is tacked | |
3785 | onto the end of the args in some (at least one anyway) | |
3786 | implementations, so strip it off if it exists. */ | |
3787 | ||
3788 | { | |
3789 | char *command = elf_tdata (abfd)->core_command; | |
3790 | int n = strlen (command); | |
3791 | ||
3792 | if (0 < n && command[n - 1] == ' ') | |
3793 | command[n - 1] = '\0'; | |
3794 | } | |
3795 | ||
3796 | return true; | |
3797 | } | |
3798 | \f | |
252b5132 RH |
3799 | #define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec |
3800 | #define TARGET_LITTLE_NAME "elf32-powerpcle" | |
3801 | #define TARGET_BIG_SYM bfd_elf32_powerpc_vec | |
3802 | #define TARGET_BIG_NAME "elf32-powerpc" | |
3803 | #define ELF_ARCH bfd_arch_powerpc | |
3804 | #define ELF_MACHINE_CODE EM_PPC | |
3805 | #define ELF_MAXPAGESIZE 0x10000 | |
3806 | #define elf_info_to_howto ppc_elf_info_to_howto | |
3807 | ||
3808 | #ifdef EM_CYGNUS_POWERPC | |
3809 | #define ELF_MACHINE_ALT1 EM_CYGNUS_POWERPC | |
3810 | #endif | |
3811 | ||
3812 | #ifdef EM_PPC_OLD | |
3813 | #define ELF_MACHINE_ALT2 EM_PPC_OLD | |
3814 | #endif | |
3815 | ||
3816 | #define elf_backend_plt_not_loaded 1 | |
3817 | #define elf_backend_got_symbol_offset 4 | |
3818 | #define elf_backend_can_gc_sections 1 | |
51b64d56 | 3819 | #define elf_backend_can_refcount 1 |
252b5132 RH |
3820 | #define elf_backend_got_header_size 12 |
3821 | #define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE | |
b491616a | 3822 | #define elf_backend_rela_normal 1 |
252b5132 | 3823 | |
252b5132 RH |
3824 | #define bfd_elf32_bfd_merge_private_bfd_data ppc_elf_merge_private_bfd_data |
3825 | #define bfd_elf32_bfd_relax_section ppc_elf_relax_section | |
3826 | #define bfd_elf32_bfd_reloc_type_lookup ppc_elf_reloc_type_lookup | |
3827 | #define bfd_elf32_bfd_set_private_flags ppc_elf_set_private_flags | |
3828 | #define bfd_elf32_bfd_final_link _bfd_elf32_gc_common_final_link | |
3829 | ||
feee612b | 3830 | #define elf_backend_object_p ppc_elf_object_p |
252b5132 RH |
3831 | #define elf_backend_gc_mark_hook ppc_elf_gc_mark_hook |
3832 | #define elf_backend_gc_sweep_hook ppc_elf_gc_sweep_hook | |
3833 | #define elf_backend_section_from_shdr ppc_elf_section_from_shdr | |
3834 | #define elf_backend_relocate_section ppc_elf_relocate_section | |
3835 | #define elf_backend_create_dynamic_sections ppc_elf_create_dynamic_sections | |
3836 | #define elf_backend_check_relocs ppc_elf_check_relocs | |
3837 | #define elf_backend_adjust_dynamic_symbol ppc_elf_adjust_dynamic_symbol | |
3838 | #define elf_backend_add_symbol_hook ppc_elf_add_symbol_hook | |
3839 | #define elf_backend_size_dynamic_sections ppc_elf_size_dynamic_sections | |
3840 | #define elf_backend_finish_dynamic_symbol ppc_elf_finish_dynamic_symbol | |
3841 | #define elf_backend_finish_dynamic_sections ppc_elf_finish_dynamic_sections | |
3842 | #define elf_backend_fake_sections ppc_elf_fake_sections | |
3843 | #define elf_backend_additional_program_headers ppc_elf_additional_program_headers | |
3844 | #define elf_backend_modify_segment_map ppc_elf_modify_segment_map | |
c5fccbec DJ |
3845 | #define elf_backend_grok_prstatus ppc_elf_grok_prstatus |
3846 | #define elf_backend_grok_psinfo ppc_elf_grok_psinfo | |
29c2fb7c | 3847 | #define elf_backend_reloc_type_class ppc_elf_reloc_type_class |
252b5132 RH |
3848 | |
3849 | #include "elf32-target.h" |