* pdp11-dis.c (print_insn_pdp11): Handle illegal instructions.
[deliverable/binutils-gdb.git] / bfd / elf64-ppc.c
CommitLineData
5bd4f169
AM
1/* PowerPC64-specific support for 64-bit ELF.
2 Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
3 Written by Linus Nordberg, Swox AB <info@swox.com>,
4 based on elf32-ppc.c by Ian Lance Taylor.
5
6This file is part of BFD, the Binary File Descriptor library.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
22/* This file is based on the 64-bit PowerPC ELF ABI. It is also based
23 on the file elf32-ppc.c. */
24
25#include "bfd.h"
26#include "sysdep.h"
27#include "bfdlink.h"
28#include "libbfd.h"
29#include "elf-bfd.h"
30#include "elf/ppc.h"
31
32#define USE_RELA /* we want RELA relocations, not REL. */
33
34
35static void ppc_howto_init
36 PARAMS ((void));
37static reloc_howto_type *ppc64_elf_reloc_type_lookup
38 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
39static void ppc64_elf_info_to_howto
40 PARAMS ((bfd *abfd, arelent *cache_ptr, Elf64_Internal_Rela *dst));
41static bfd_reloc_status_type ppc64_elf_addr16_ha_reloc
42 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
43static boolean ppc64_elf_set_private_flags
44 PARAMS ((bfd *, flagword));
45static boolean ppc64_elf_copy_private_bfd_data
46 PARAMS ((bfd *, bfd *));
47static boolean ppc64_elf_merge_private_bfd_data
48 PARAMS ((bfd *, bfd *));
49static boolean ppc64_elf_section_from_shdr
50 PARAMS ((bfd *, Elf64_Internal_Shdr *, char *));
65f38f15
AM
51static struct bfd_hash_entry *link_hash_newfunc
52 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
53static struct bfd_link_hash_table *ppc64_elf_link_hash_table_create
54 PARAMS ((bfd *));
55static boolean create_got_section
56 PARAMS ((bfd *, struct bfd_link_info *));
5bd4f169
AM
57static boolean ppc64_elf_create_dynamic_sections
58 PARAMS ((bfd *, struct bfd_link_info *));
65f38f15
AM
59static void ppc64_elf_copy_indirect_symbol
60 PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
5bd4f169
AM
61static boolean ppc64_elf_check_relocs
62 PARAMS ((bfd *, struct bfd_link_info *, asection *,
63 const Elf_Internal_Rela *));
64static asection * ppc64_elf_gc_mark_hook
65 PARAMS ((bfd *abfd, struct bfd_link_info *info, Elf_Internal_Rela *rel,
66 struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
67static boolean ppc64_elf_gc_sweep_hook
68 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec,
69 const Elf_Internal_Rela *relocs));
70static boolean ppc64_elf_adjust_dynamic_symbol
71 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
65f38f15
AM
72static boolean allocate_dynrelocs
73 PARAMS ((struct elf_link_hash_entry *, PTR));
74static boolean readonly_dynrelocs
5bd4f169 75 PARAMS ((struct elf_link_hash_entry *, PTR));
65f38f15
AM
76static enum elf_reloc_type_class ppc64_elf_reloc_type_class
77 PARAMS ((const Elf_Internal_Rela *));
5bd4f169
AM
78static boolean ppc64_elf_size_dynamic_sections
79 PARAMS ((bfd *, struct bfd_link_info *));
80static boolean ppc64_elf_final_link
81 PARAMS ((bfd *, struct bfd_link_info *));
82static boolean ppc64_elf_fake_sections
83 PARAMS ((bfd *, Elf64_Internal_Shdr *, asection *));
84static boolean ppc64_elf_relocate_section
85 PARAMS ((bfd *, struct bfd_link_info *info, bfd *, asection *, bfd_byte *,
86 Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
87 asection **));
88static boolean ppc64_elf_finish_dynamic_symbol
89 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
90 Elf_Internal_Sym *));
91static boolean ppc64_elf_finish_dynamic_sections
92 PARAMS ((bfd *, struct bfd_link_info *));
93
94
5bd4f169
AM
95/* Mask to set RA in memory instructions. */
96#define RA_REGISTER_MASK 0x001f0000
97
98/* Value to shift register by to insert RA. */
99#define RA_REGISTER_SHIFT 16
100
101/* The name of the dynamic interpreter. This is put in the .interp
102 section. */
103#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
104
105/* The size in bytes of an entry in the procedure linkage table. */
106#define PLT_ENTRY_SIZE 24
107
108/* The initial size of the plt reserved for the dynamic linker. */
109#define PLT_INITIAL_ENTRY_SIZE 96
110
111/* TOC base pointers offset from start of TOC. */
112#define TOC_BASE_OFF (0x8000)
113
114/* Global linkage stub. The first instruction has its offset patched. */
115/* FIXME: Need traceback table? */
116static const unsigned int ppc64_elf_glink_code[] = {
117 0xe9820000, /* ld %r12,0(%r2) */
118 0xf8410028, /* std %r2,40(%r1) */
119 0xe80c0000, /* ld %r0,0(%r12) */
120 0xe84c0008, /* ld %r2,8(%r12) */
121 0x7c0903a6, /* mtctr %r0 */
122 0x4e800420 /* bctr */
123};
124
125#define PPC64_ELF_GLINK_SIZE \
126 ((sizeof ppc64_elf_glink_code / sizeof ppc64_elf_glink_code[0]) * 4)
127\f
128/* Relocation HOWTO's. */
129static reloc_howto_type *ppc64_elf_howto_table[(int) R_PPC_max];
130
131static reloc_howto_type ppc64_elf_howto_raw[] = {
132 /* This reloc does nothing. */
133 HOWTO (R_PPC64_NONE, /* type */
134 0, /* rightshift */
135 2, /* size (0 = byte, 1 = short, 2 = long) */
136 32, /* bitsize */
137 false, /* pc_relative */
138 0, /* bitpos */
139 complain_overflow_bitfield, /* complain_on_overflow */
140 bfd_elf_generic_reloc, /* special_function */
141 "R_PPC64_NONE", /* name */
142 false, /* partial_inplace */
143 0, /* src_mask */
144 0, /* dst_mask */
145 false), /* pcrel_offset */
146
147 /* A standard 32 bit relocation. */
148 HOWTO (R_PPC64_ADDR32, /* type */
149 0, /* rightshift */
150 2, /* size (0 = byte, 1 = short, 2 = long) */
151 32, /* bitsize */
152 false, /* pc_relative */
153 0, /* bitpos */
154 complain_overflow_bitfield, /* complain_on_overflow */
155 bfd_elf_generic_reloc, /* special_function */
156 "R_PPC64_ADDR32", /* name */
157 false, /* partial_inplace */
158 0, /* src_mask */
159 0xffffffff, /* dst_mask */
160 false), /* pcrel_offset */
161
162 /* An absolute 26 bit branch; the lower two bits must be zero.
163 FIXME: we don't check that, we just clear them. */
164 HOWTO (R_PPC64_ADDR24, /* type */
165 0, /* rightshift */
166 2, /* size (0 = byte, 1 = short, 2 = long) */
167 26, /* bitsize */
168 false, /* pc_relative */
169 0, /* bitpos */
170 complain_overflow_bitfield, /* complain_on_overflow */
171 bfd_elf_generic_reloc, /* special_function */
172 "R_PPC64_ADDR24", /* name */
173 false, /* partial_inplace */
174 0, /* src_mask */
175 0x3fffffc, /* dst_mask */
176 false), /* pcrel_offset */
177
178 /* A standard 16 bit relocation. */
179 HOWTO (R_PPC64_ADDR16, /* type */
180 0, /* rightshift */
181 1, /* size (0 = byte, 1 = short, 2 = long) */
182 16, /* bitsize */
183 false, /* pc_relative */
184 0, /* bitpos */
185 complain_overflow_bitfield, /* complain_on_overflow */
186 bfd_elf_generic_reloc, /* special_function */
187 "R_PPC64_ADDR16", /* name */
188 false, /* partial_inplace */
189 0, /* src_mask */
190 0xffff, /* dst_mask */
191 false), /* pcrel_offset */
192
193 /* A 16 bit relocation without overflow. */
194 HOWTO (R_PPC64_ADDR16_LO, /* type */
195 0, /* rightshift */
196 1, /* size (0 = byte, 1 = short, 2 = long) */
197 16, /* bitsize */
198 false, /* pc_relative */
199 0, /* bitpos */
200 complain_overflow_dont,/* complain_on_overflow */
201 bfd_elf_generic_reloc, /* special_function */
202 "R_PPC64_ADDR16_LO", /* name */
203 false, /* partial_inplace */
204 0, /* src_mask */
205 0xffff, /* dst_mask */
206 false), /* pcrel_offset */
207
208 /* Bits 16-31 of an address. */
209 HOWTO (R_PPC64_ADDR16_HI, /* type */
210 16, /* rightshift */
211 1, /* size (0 = byte, 1 = short, 2 = long) */
212 16, /* bitsize */
213 false, /* pc_relative */
214 0, /* bitpos */
215 complain_overflow_dont, /* complain_on_overflow */
216 bfd_elf_generic_reloc, /* special_function */
217 "R_PPC64_ADDR16_HI", /* name */
218 false, /* partial_inplace */
219 0, /* src_mask */
220 0xffff, /* dst_mask */
221 false), /* pcrel_offset */
222
223 /* Bits 16-31 of an address, plus 1 if the contents of the low 16
224 bits, treated as a signed number, is negative. */
225 HOWTO (R_PPC64_ADDR16_HA, /* type */
226 16, /* rightshift */
227 1, /* size (0 = byte, 1 = short, 2 = long) */
228 16, /* bitsize */
229 false, /* pc_relative */
230 0, /* bitpos */
231 complain_overflow_dont, /* complain_on_overflow */
232 ppc64_elf_addr16_ha_reloc, /* special_function */
233 "R_PPC64_ADDR16_HA", /* name */
234 false, /* partial_inplace */
235 0, /* src_mask */
236 0xffff, /* dst_mask */
237 false), /* pcrel_offset */
238
239 /* An absolute 16 bit branch; the lower two bits must be zero.
240 FIXME: we don't check that, we just clear them. */
241 HOWTO (R_PPC64_ADDR14, /* type */
242 0, /* rightshift */
243 2, /* size (0 = byte, 1 = short, 2 = long) */
244 16, /* bitsize */
245 false, /* pc_relative */
246 0, /* bitpos */
247 complain_overflow_bitfield, /* complain_on_overflow */
248 bfd_elf_generic_reloc, /* special_function */
249 "R_PPC64_ADDR14", /* name */
250 false, /* partial_inplace */
251 0, /* src_mask */
252 0xfffc, /* dst_mask */
253 false), /* pcrel_offset */
254
255 /* An absolute 16 bit branch, for which bit 10 should be set to
256 indicate that the branch is expected to be taken. The lower two
257 bits must be zero. */
258 HOWTO (R_PPC64_ADDR14_BRTAKEN, /* type */
259 0, /* rightshift */
260 2, /* size (0 = byte, 1 = short, 2 = long) */
261 16, /* bitsize */
262 false, /* pc_relative */
263 0, /* bitpos */
264 complain_overflow_bitfield, /* complain_on_overflow */
265 bfd_elf_generic_reloc, /* special_function */
266 "R_PPC64_ADDR14_BRTAKEN",/* name */
267 false, /* partial_inplace */
268 0, /* src_mask */
269 0xfffc, /* dst_mask */
270 false), /* pcrel_offset */
271
272 /* An absolute 16 bit branch, for which bit 10 should be set to
273 indicate that the branch is not expected to be taken. The lower
274 two bits must be zero. */
275 HOWTO (R_PPC64_ADDR14_BRNTAKEN, /* type */
276 0, /* rightshift */
277 2, /* size (0 = byte, 1 = short, 2 = long) */
278 16, /* bitsize */
279 false, /* pc_relative */
280 0, /* bitpos */
281 complain_overflow_bitfield, /* complain_on_overflow */
282 bfd_elf_generic_reloc, /* special_function */
283 "R_PPC64_ADDR14_BRNTAKEN",/* name */
284 false, /* partial_inplace */
285 0, /* src_mask */
286 0xfffc, /* dst_mask */
287 false), /* pcrel_offset */
288
289 /* A relative 26 bit branch; the lower two bits must be zero. */
290 HOWTO (R_PPC64_REL24, /* type */
291 0, /* rightshift */
292 2, /* size (0 = byte, 1 = short, 2 = long) */
293 26, /* bitsize */
294 true, /* pc_relative */
295 0, /* bitpos */
296 complain_overflow_signed, /* complain_on_overflow */
297 bfd_elf_generic_reloc, /* special_function */
298 "R_PPC64_REL24", /* name */
299 false, /* partial_inplace */
300 0, /* src_mask */
301 0x3fffffc, /* dst_mask */
302 true), /* pcrel_offset */
303
304 /* A relative 16 bit branch; the lower two bits must be zero. */
305 HOWTO (R_PPC64_REL14, /* type */
306 0, /* rightshift */
307 2, /* size (0 = byte, 1 = short, 2 = long) */
308 16, /* bitsize */
309 true, /* pc_relative */
310 0, /* bitpos */
311 complain_overflow_signed, /* complain_on_overflow */
312 bfd_elf_generic_reloc, /* special_function */
313 "R_PPC64_REL14", /* name */
314 false, /* partial_inplace */
315 0, /* src_mask */
316 0xfffc, /* dst_mask */
317 true), /* pcrel_offset */
318
319 /* A relative 16 bit branch. Bit 10 should be set to indicate that
320 the branch is expected to be taken. The lower two bits must be
321 zero. */
322 HOWTO (R_PPC64_REL14_BRTAKEN, /* type */
323 0, /* rightshift */
324 2, /* size (0 = byte, 1 = short, 2 = long) */
325 16, /* bitsize */
326 true, /* pc_relative */
327 0, /* bitpos */
328 complain_overflow_signed, /* complain_on_overflow */
329 bfd_elf_generic_reloc, /* special_function */
330 "R_PPC64_REL14_BRTAKEN", /* name */
331 false, /* partial_inplace */
332 0, /* src_mask */
333 0xfffc, /* dst_mask */
334 true), /* pcrel_offset */
335
336 /* A relative 16 bit branch. Bit 10 should be set to indicate that
337 the branch is not expected to be taken. The lower two bits must
338 be zero. */
339 HOWTO (R_PPC64_REL14_BRNTAKEN, /* type */
340 0, /* rightshift */
341 2, /* size (0 = byte, 1 = short, 2 = long) */
342 16, /* bitsize */
343 true, /* pc_relative */
344 0, /* bitpos */
345 complain_overflow_signed, /* complain_on_overflow */
346 bfd_elf_generic_reloc, /* special_function */
347 "R_PPC64_REL14_BRNTAKEN",/* name */
348 false, /* partial_inplace */
349 0, /* src_mask */
350 0xfffc, /* dst_mask */
351 true), /* pcrel_offset */
352
353 /* Like R_PPC64_ADDR16, but referring to the GOT table entry for the
354 symbol. */
355 HOWTO (R_PPC64_GOT16, /* type */
356 0, /* rightshift */
357 1, /* size (0 = byte, 1 = short, 2 = long) */
358 16, /* bitsize */
359 false, /* pc_relative */
360 0, /* bitpos */
361 complain_overflow_signed, /* complain_on_overflow */
362 bfd_elf_generic_reloc, /* special_function */
363 "R_PPC64_GOT16", /* name */
364 false, /* partial_inplace */
365 0, /* src_mask */
366 0xffff, /* dst_mask */
367 false), /* pcrel_offset */
368
369 /* Like R_PPC64_ADDR16_LO, but referring to the GOT table entry for
370 the symbol. */
371 HOWTO (R_PPC64_GOT16_LO, /* type */
372 0, /* rightshift */
373 1, /* size (0 = byte, 1 = short, 2 = long) */
374 16, /* bitsize */
375 false, /* pc_relative */
376 0, /* bitpos */
377 complain_overflow_dont, /* complain_on_overflow */
378 bfd_elf_generic_reloc, /* special_function */
379 "R_PPC64_GOT16_LO", /* name */
380 false, /* partial_inplace */
381 0, /* src_mask */
382 0xffff, /* dst_mask */
383 false), /* pcrel_offset */
384
385 /* Like R_PPC64_ADDR16_HI, but referring to the GOT table entry for
386 the symbol. */
387 HOWTO (R_PPC64_GOT16_HI, /* type */
388 16, /* rightshift */
389 1, /* size (0 = byte, 1 = short, 2 = long) */
390 16, /* bitsize */
391 false, /* pc_relative */
392 0, /* bitpos */
393 complain_overflow_dont,/* complain_on_overflow */
394 bfd_elf_generic_reloc, /* special_function */
395 "R_PPC64_GOT16_HI", /* name */
396 false, /* partial_inplace */
397 0, /* src_mask */
398 0xffff, /* dst_mask */
399 false), /* pcrel_offset */
400
401 /* Like R_PPC64_ADDR16_HA, but referring to the GOT table entry for
402 the symbol. */
403 HOWTO (R_PPC64_GOT16_HA, /* type */
404 16, /* rightshift */
405 1, /* size (0 = byte, 1 = short, 2 = long) */
406 16, /* bitsize */
407 false, /* pc_relative */
408 0, /* bitpos */
409 complain_overflow_dont,/* complain_on_overflow */
410 ppc64_elf_addr16_ha_reloc, /* special_function */
411 "R_PPC64_GOT16_HA", /* name */
412 false, /* partial_inplace */
413 0, /* src_mask */
414 0xffff, /* dst_mask */
415 false), /* pcrel_offset */
416
417 /* This is used only by the dynamic linker. The symbol should exist
418 both in the object being run and in some shared library. The
419 dynamic linker copies the data addressed by the symbol from the
420 shared library into the object, because the object being
421 run has to have the data at some particular address. */
422 HOWTO (R_PPC64_COPY, /* type */
423 0, /* rightshift */
424 2, /* size (0 = byte, 1 = short, 2 = long) */
425 32, /* bitsize */
426 false, /* pc_relative */
427 0, /* bitpos */
428 complain_overflow_bitfield, /* complain_on_overflow */
429 bfd_elf_generic_reloc, /* special_function */
430 "R_PPC64_COPY", /* name */
431 false, /* partial_inplace */
432 0, /* src_mask */
433 0, /* dst_mask */
434 false), /* pcrel_offset */
435
436 /* Like R_PPC64_ADDR64, but used when setting global offset table
437 entries. */
438 HOWTO (R_PPC64_GLOB_DAT, /* type */
439 0, /* rightshift */
440 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */
441 64, /* bitsize */
442 false, /* pc_relative */
443 0, /* bitpos */
444 complain_overflow_dont, /* complain_on_overflow */
445 bfd_elf_generic_reloc, /* special_function */
446 "R_PPC64_GLOB_DAT", /* name */
447 false, /* partial_inplace */
448 0, /* src_mask */
449 0xffffffffffffffff, /* dst_mask */
450 false), /* pcrel_offset */
451
452 /* Created by the link editor. Marks a procedure linkage table
453 entry for a symbol. */
454 HOWTO (R_PPC64_JMP_SLOT, /* type */
455 0, /* rightshift */
456 0, /* size (0 = byte, 1 = short, 2 = long) */
457 0, /* bitsize */
458 false, /* pc_relative */
459 0, /* bitpos */
460 complain_overflow_dont, /* complain_on_overflow */
461 bfd_elf_generic_reloc, /* special_function */
462 "R_PPC64_JMP_SLOT", /* name */
463 false, /* partial_inplace */
464 0, /* src_mask */
465 0, /* dst_mask */
466 false), /* pcrel_offset */
467
468 /* Used only by the dynamic linker. When the object is run, this
469 doubleword64 is set to the load address of the object, plus the
470 addend. */
471 HOWTO (R_PPC64_RELATIVE, /* type */
472 0, /* rightshift */
473 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */
474 64, /* bitsize */
475 false, /* pc_relative */
476 0, /* bitpos */
477 complain_overflow_dont, /* complain_on_overflow */
478 bfd_elf_generic_reloc, /* special_function */
479 "R_PPC64_RELATIVE", /* name */
480 false, /* partial_inplace */
481 0, /* src_mask */
482 0xffffffffffffffff, /* dst_mask */
483 false), /* pcrel_offset */
484
485 /* Like R_PPC64_ADDR32, but may be unaligned. */
486 HOWTO (R_PPC64_UADDR32, /* type */
487 0, /* rightshift */
488 2, /* size (0 = byte, 1 = short, 2 = long) */
489 32, /* bitsize */
490 false, /* pc_relative */
491 0, /* bitpos */
492 complain_overflow_bitfield, /* complain_on_overflow */
493 bfd_elf_generic_reloc, /* special_function */
494 "R_PPC64_UADDR32", /* name */
495 false, /* partial_inplace */
496 0, /* src_mask */
497 0xffffffff, /* dst_mask */
498 false), /* pcrel_offset */
499
500 /* Like R_PPC64_ADDR16, but may be unaligned. */
501 HOWTO (R_PPC64_UADDR16, /* type */
502 0, /* rightshift */
503 1, /* size (0 = byte, 1 = short, 2 = long) */
504 16, /* bitsize */
505 false, /* pc_relative */
506 0, /* bitpos */
507 complain_overflow_bitfield, /* complain_on_overflow */
508 bfd_elf_generic_reloc, /* special_function */
509 "R_PPC64_UADDR16", /* name */
510 false, /* partial_inplace */
511 0, /* src_mask */
512 0xffff, /* dst_mask */
513 false), /* pcrel_offset */
514
515 /* 32-bit PC relative. */
516 HOWTO (R_PPC64_REL32, /* type */
517 0, /* rightshift */
518 2, /* size (0 = byte, 1 = short, 2 = long) */
519 32, /* bitsize */
520 true, /* pc_relative */
521 0, /* bitpos */
522 /* FIXME: Verify. Was complain_overflow_bitfield. */
523 complain_overflow_signed, /* complain_on_overflow */
524 bfd_elf_generic_reloc, /* special_function */
525 "R_PPC64_REL32", /* name */
526 false, /* partial_inplace */
527 0, /* src_mask */
528 0xffffffff, /* dst_mask */
529 true), /* pcrel_offset */
530
531 /* 32-bit relocation to the symbol's procedure linkage table.
532 FIXME: R_PPC64_PLT32 not supported. */
533 HOWTO (R_PPC64_PLT32, /* type */
534 0, /* rightshift */
535 2, /* size (0 = byte, 1 = short, 2 = long) */
536 32, /* bitsize */
537 false, /* pc_relative */
538 0, /* bitpos */
539 complain_overflow_bitfield, /* complain_on_overflow */
540 bfd_elf_generic_reloc, /* special_function */
541 "R_PPC64_PLT32", /* name */
542 false, /* partial_inplace */
543 0, /* src_mask */
544 0, /* dst_mask */
545 false), /* pcrel_offset */
546
547 /* 32-bit PC relative relocation to the symbol's procedure linkage table.
548 FIXME: R_PPC64_PLTREL32 not supported. */
549 HOWTO (R_PPC64_PLTREL32, /* type */
550 0, /* rightshift */
551 2, /* size (0 = byte, 1 = short, 2 = long) */
552 32, /* bitsize */
553 true, /* pc_relative */
554 0, /* bitpos */
555 complain_overflow_signed, /* complain_on_overflow */
556 bfd_elf_generic_reloc, /* special_function */
557 "R_PPC64_PLTREL32", /* name */
558 false, /* partial_inplace */
559 0, /* src_mask */
560 0, /* dst_mask */
561 true), /* pcrel_offset */
562
563 /* Like R_PPC64_ADDR16_LO, but referring to the PLT table entry for
564 the symbol. */
565 HOWTO (R_PPC64_PLT16_LO, /* type */
566 0, /* rightshift */
567 1, /* size (0 = byte, 1 = short, 2 = long) */
568 16, /* bitsize */
569 false, /* pc_relative */
570 0, /* bitpos */
571 complain_overflow_dont, /* complain_on_overflow */
572 bfd_elf_generic_reloc, /* special_function */
573 "R_PPC64_PLT16_LO", /* name */
574 false, /* partial_inplace */
575 0, /* src_mask */
576 0xffff, /* dst_mask */
577 false), /* pcrel_offset */
578
579 /* Like R_PPC64_ADDR16_HI, but referring to the PLT table entry for
580 the symbol. */
581 HOWTO (R_PPC64_PLT16_HI, /* type */
582 16, /* rightshift */
583 1, /* size (0 = byte, 1 = short, 2 = long) */
584 16, /* bitsize */
585 false, /* pc_relative */
586 0, /* bitpos */
587 complain_overflow_dont, /* complain_on_overflow */
588 bfd_elf_generic_reloc, /* special_function */
589 "R_PPC64_PLT16_HI", /* name */
590 false, /* partial_inplace */
591 0, /* src_mask */
592 0xffff, /* dst_mask */
593 false), /* pcrel_offset */
594
595 /* Like R_PPC64_ADDR16_HA, but referring to the PLT table entry for
596 the symbol. */
597 HOWTO (R_PPC64_PLT16_HA, /* type */
598 16, /* rightshift */
599 1, /* size (0 = byte, 1 = short, 2 = long) */
600 16, /* bitsize */
601 false, /* pc_relative */
602 0, /* bitpos */
603 complain_overflow_dont, /* complain_on_overflow */
604 ppc64_elf_addr16_ha_reloc, /* special_function */
605 "R_PPC64_PLT16_HA", /* name */
606 false, /* partial_inplace */
607 0, /* src_mask */
608 0xffff, /* dst_mask */
609 false), /* pcrel_offset */
610
611 /* 32-bit section relative relocation. */
612 /* FIXME: Verify R_PPC64_SECTOFF. Seems strange with size=2 and
613 dst_mask=0. */
614 HOWTO (R_PPC64_SECTOFF, /* type */
615 0, /* rightshift */
616 2, /* size (0 = byte, 1 = short, 2 = long) */
617 32, /* bitsize */
618 true, /* pc_relative */
619 0, /* bitpos */
620 complain_overflow_bitfield, /* complain_on_overflow */
621 bfd_elf_generic_reloc, /* special_function */
622 "R_PPC64_SECTOFF", /* name */
623 false, /* partial_inplace */
624 0, /* src_mask */
625 0, /* dst_mask */
626 true), /* pcrel_offset */
627
628 /* 16-bit lower half section relative relocation. */
629 HOWTO (R_PPC64_SECTOFF_LO, /* type */
630 0, /* rightshift */
631 1, /* size (0 = byte, 1 = short, 2 = long) */
632 16, /* bitsize */
633 false, /* pc_relative */
634 0, /* bitpos */
635 complain_overflow_dont, /* complain_on_overflow */
636 bfd_elf_generic_reloc, /* special_function */
637 "R_PPC64_SECTOFF_LO", /* name */
638 false, /* partial_inplace */
639 0, /* src_mask */
640 0xffff, /* dst_mask */
641 false), /* pcrel_offset */
642
643 /* 16-bit upper half section relative relocation. */
644 HOWTO (R_PPC64_SECTOFF_HI, /* type */
645 16, /* rightshift */
646 1, /* size (0 = byte, 1 = short, 2 = long) */
647 16, /* bitsize */
648 false, /* pc_relative */
649 0, /* bitpos */
650 complain_overflow_dont, /* complain_on_overflow */
651 bfd_elf_generic_reloc, /* special_function */
652 "R_PPC64_SECTOFF_HI", /* name */
653 false, /* partial_inplace */
654 0, /* src_mask */
655 0xffff, /* dst_mask */
656 false), /* pcrel_offset */
657
658 /* 16-bit upper half adjusted section relative relocation. */
659 HOWTO (R_PPC64_SECTOFF_HA, /* type */
660 16, /* rightshift */
661 1, /* size (0 = byte, 1 = short, 2 = long) */
662 16, /* bitsize */
663 false, /* pc_relative */
664 0, /* bitpos */
665 complain_overflow_dont, /* complain_on_overflow */
666 ppc64_elf_addr16_ha_reloc, /* special_function */
667 "R_PPC64_SECTOFF_HA", /* name */
668 false, /* partial_inplace */
669 0, /* src_mask */
670 0xffff, /* dst_mask */
671 false), /* pcrel_offset */
672
673 /* Like R_PPC64_REL24 without touching the two least significant
674 bits. */
675 /* FIXME: Verify R_PPC64_ADDR30. */
676 HOWTO (R_PPC64_ADDR30, /* type */
677 2, /* rightshift */
678 2, /* size (0 = byte, 1 = short, 2 = long) */
679 30, /* bitsize */
680 true, /* pc_relative */
681 0, /* bitpos */
682 complain_overflow_dont, /* complain_on_overflow */
683 bfd_elf_generic_reloc, /* special_function */
684 "R_PPC64_ADDR30", /* name */
685 false, /* partial_inplace */
686 0, /* src_mask */
687 0xfffffffc, /* dst_mask */
688 true), /* pcrel_offset */
689
690 /* Relocs in the 64-bit PowerPC ELF ABI, not in the 32-bit ABI. */
691
692 /* A standard 64-bit relocation. */
693 HOWTO (R_PPC64_ADDR64, /* type */
694 0, /* rightshift */
695 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */
696 64, /* bitsize */
697 false, /* pc_relative */
698 0, /* bitpos */
699 complain_overflow_dont, /* complain_on_overflow */
700 bfd_elf_generic_reloc, /* special_function */
701 "R_PPC64_ADDR64", /* name */
702 false, /* partial_inplace */
703 0, /* src_mask */
704 0xffffffffffffffff, /* dst_mask */
705 false), /* pcrel_offset */
706
707 /* The bits 32-47 of an address. */
708 HOWTO (R_PPC64_ADDR16_HIGHER, /* type */
709 32, /* rightshift */
710 1, /* size (0 = byte, 1 = short, 2 = long) */
711 16, /* bitsize */
712 false, /* pc_relative */
713 0, /* bitpos */
714 complain_overflow_dont, /* complain_on_overflow */
715 bfd_elf_generic_reloc, /* special_function */
716 "R_PPC64_ADDR16_HIGHER", /* name */
717 false, /* partial_inplace */
718 0, /* src_mask */
719 0xffff, /* dst_mask */
720 false), /* pcrel_offset */
721
722 /* The bits 32-47 of an address, plus 1 if the contents of the low
723 16 bits, treated as a signed number, is negative. */
724 HOWTO (R_PPC64_ADDR16_HIGHERA, /* type */
725 32, /* rightshift */
726 1, /* size (0 = byte, 1 = short, 2 = long) */
727 16, /* bitsize */
728 false, /* pc_relative */
729 0, /* bitpos */
730 complain_overflow_dont, /* complain_on_overflow */
731 ppc64_elf_addr16_ha_reloc, /* special_function */
732 "R_PPC64_ADDR16_HIGHERA", /* name */
733 false, /* partial_inplace */
734 0, /* src_mask */
735 0xffff, /* dst_mask */
736 false), /* pcrel_offset */
737
738 /* The bits 48-63 of an address. */
739 HOWTO (R_PPC64_ADDR16_HIGHEST,/* type */
740 48, /* rightshift */
741 1, /* size (0 = byte, 1 = short, 2 = long) */
742 16, /* bitsize */
743 false, /* pc_relative */
744 0, /* bitpos */
745 complain_overflow_dont, /* complain_on_overflow */
746 bfd_elf_generic_reloc, /* special_function */
747 "R_PPC64_ADDR16_HIGHEST", /* name */
748 false, /* partial_inplace */
749 0, /* src_mask */
750 0xffff, /* dst_mask */
751 false), /* pcrel_offset */
752
753 /* The bits 48-63 of an address, plus 1 if the contents of the low
754 16 bits, treated as a signed number, is negative. */
755 HOWTO (R_PPC64_ADDR16_HIGHESTA,/* type */
756 48, /* rightshift */
757 1, /* size (0 = byte, 1 = short, 2 = long) */
758 16, /* bitsize */
759 false, /* pc_relative */
760 0, /* bitpos */
761 complain_overflow_dont, /* complain_on_overflow */
762 ppc64_elf_addr16_ha_reloc, /* special_function */
763 "R_PPC64_ADDR16_HIGHESTA", /* name */
764 false, /* partial_inplace */
765 0, /* src_mask */
766 0xffff, /* dst_mask */
767 false), /* pcrel_offset */
768
769 /* Like ADDR64, but may be unaligned. */
770 HOWTO (R_PPC64_UADDR64, /* type */
771 0, /* rightshift */
772 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */
773 64, /* bitsize */
774 false, /* pc_relative */
775 0, /* bitpos */
776 complain_overflow_dont, /* complain_on_overflow */
777 bfd_elf_generic_reloc, /* special_function */
778 "R_PPC64_UADDR64", /* name */
779 false, /* partial_inplace */
780 0, /* src_mask */
781 0xffffffffffffffff, /* dst_mask */
782 false), /* pcrel_offset */
783
784 /* 64-bit relative relocation. */
785 HOWTO (R_PPC64_REL64, /* type */
786 0, /* rightshift */
787 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */
788 64, /* bitsize */
789 true, /* pc_relative */
790 0, /* bitpos */
791 complain_overflow_dont, /* complain_on_overflow */
792 bfd_elf_generic_reloc, /* special_function */
793 "R_PPC64_REL64", /* name */
794 false, /* partial_inplace */
795 0, /* src_mask */
796 0xffffffffffffffff, /* dst_mask */
797 true), /* pcrel_offset */
798
799 /* 64-bit relocation to the symbol's procedure linkage table. */
800 /* FIXME: R_PPC64_PLT64 not supported. */
801 HOWTO (R_PPC64_PLT64, /* type */
802 0, /* rightshift */
803 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */
804 64, /* bitsize */
805 false, /* pc_relative */
806 0, /* bitpos */
807 complain_overflow_dont, /* complain_on_overflow */
808 bfd_elf_generic_reloc, /* special_function */
809 "R_PPC64_PLT64", /* name */
810 false, /* partial_inplace */
811 0, /* src_mask */
812 0, /* dst_mask */
813 false), /* pcrel_offset */
814
815 /* 64-bit PC relative relocation to the symbol's procedure linkage
816 table. */
817 /* FIXME: R_PPC64_PLTREL64 not supported. */
818 HOWTO (R_PPC64_PLTREL64, /* type */
819 0, /* rightshift */
820 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */
821 64, /* bitsize */
822 true, /* pc_relative */
823 0, /* bitpos */
824 complain_overflow_dont, /* complain_on_overflow */
825 bfd_elf_generic_reloc, /* special_function */
826 "R_PPC64_PLTREL64", /* name */
827 false, /* partial_inplace */
828 0, /* src_mask */
829 0, /* dst_mask */
830 true), /* pcrel_offset */
831
832 /* 16 bit TOC-relative relocation. */
833
834 /* R_PPC64_TOC16 47 half16* S + A - .TOC. */
835 HOWTO (R_PPC64_TOC16, /* type */
836 0, /* rightshift */
837 1, /* size (0 = byte, 1 = short, 2 = long) */
838 16, /* bitsize */
839 false, /* pc_relative */
840 0, /* bitpos */
841 complain_overflow_signed, /* complain_on_overflow */
842 bfd_elf_generic_reloc, /* special_function */
843 "R_PPC64_TOC16", /* name */
844 false, /* partial_inplace */
845 0, /* src_mask */
846 0xffff, /* dst_mask */
847 false), /* pcrel_offset */
848
849 /* 16 bit TOC-relative relocation without overflow. */
850
851 /* R_PPC64_TOC16_LO 48 half16 #lo (S + A - .TOC.) */
852 HOWTO (R_PPC64_TOC16_LO, /* type */
853 0, /* rightshift */
854 1, /* size (0 = byte, 1 = short, 2 = long) */
855 16, /* bitsize */
856 false, /* pc_relative */
857 0, /* bitpos */
858 complain_overflow_dont, /* complain_on_overflow */
859 bfd_elf_generic_reloc, /* special_function */
860 "R_PPC64_TOC16_LO", /* name */
861 false, /* partial_inplace */
862 0, /* src_mask */
863 0xffff, /* dst_mask */
864 false), /* pcrel_offset */
865
866 /* 16 bit TOC-relative relocation, high 16 bits. */
867
868 /* R_PPC64_TOC16_HI 49 half16 #hi (S + A - .TOC.) */
869 HOWTO (R_PPC64_TOC16_HI, /* type */
870 16, /* rightshift */
871 1, /* size (0 = byte, 1 = short, 2 = long) */
872 16, /* bitsize */
873 false, /* pc_relative */
874 0, /* bitpos */
875 complain_overflow_dont, /* complain_on_overflow */
876 bfd_elf_generic_reloc, /* special_function */
877 "R_PPC64_TOC16_HI", /* name */
878 false, /* partial_inplace */
879 0, /* src_mask */
880 0xffff, /* dst_mask */
881 false), /* pcrel_offset */
882
883 /* 16 bit TOC-relative relocation, high 16 bits, plus 1 if the
884 contents of the low 16 bits, treated as a signed number, is
885 negative. */
886
887 /* R_PPC64_TOC16_HA 50 half16 #ha (S + A - .TOC.) */
888 HOWTO (R_PPC64_TOC16_HA, /* type */
889 16, /* rightshift */
890 1, /* size (0 = byte, 1 = short, 2 = long) */
891 16, /* bitsize */
892 false, /* pc_relative */
893 0, /* bitpos */
894 complain_overflow_dont, /* complain_on_overflow */
895 ppc64_elf_addr16_ha_reloc, /* special_function */
896 "R_PPC64_TOC16_HA", /* name */
897 false, /* partial_inplace */
898 0, /* src_mask */
899 0xffff, /* dst_mask */
900 false), /* pcrel_offset */
901
902 /* 64-bit relocation; insert value of TOC base (.TOC.). */
903
904 /* R_PPC64_TOC 51 doubleword64 .TOC. */
905 HOWTO (R_PPC64_TOC, /* type */
906 0, /* rightshift */
907 4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */
908 64, /* bitsize */
909 false, /* pc_relative */
910 0, /* bitpos */
911 complain_overflow_bitfield, /* complain_on_overflow */
912 bfd_elf_generic_reloc, /* special_function */
913 "R_PPC64_TOC", /* name */
914 false, /* partial_inplace */
915 0, /* src_mask */
916 0xffffffffffffffff, /* dst_mask */
917 false), /* pcrel_offset */
918
919 /* Like R_PPC64_GOT16, but also informs the link editor that the
920 value to relocate may (!) refer to a PLT entry which the link
921 editor (a) may replace with the symbol value. If the link editor
922 is unable to fully resolve the symbol, it may (b) create a PLT
923 entry and store the address to the new PLT entry in the GOT.
924 This permits lazy resolution of function symbols at run time.
925 The link editor may also skip all of this and just (c) emit a
926 R_PPC64_GLOB_DAT to tie the symbol to the GOT entry. */
927 /* FIXME: R_PPC64_PLTGOT16 not implemented. */
928 HOWTO (R_PPC64_PLTGOT16, /* type */
929 0, /* rightshift */
930 1, /* size (0 = byte, 1 = short, 2 = long) */
931 16, /* bitsize */
932 false, /* pc_relative */
933 0, /* bitpos */
934 complain_overflow_signed, /* complain_on_overflow */
935 bfd_elf_generic_reloc, /* special_function */
936 "R_PPC64_PLTGOT16", /* name */
937 false, /* partial_inplace */
938 0, /* src_mask */
939 0xffff, /* dst_mask */
940 false), /* pcrel_offset */
941
942 /* Like R_PPC64_PLTGOT16, but without overflow. */
943 /* FIXME: R_PPC64_PLTGOT16_LO not implemented. */
944 HOWTO (R_PPC64_PLTGOT16_LO, /* type */
945 0, /* rightshift */
946 1, /* size (0 = byte, 1 = short, 2 = long) */
947 16, /* bitsize */
948 false, /* pc_relative */
949 0, /* bitpos */
950 complain_overflow_dont, /* complain_on_overflow */
951 bfd_elf_generic_reloc, /* special_function */
952 "R_PPC64_PLTGOT16_LO", /* name */
953 false, /* partial_inplace */
954 0, /* src_mask */
955 0xffff, /* dst_mask */
956 false), /* pcrel_offset */
957
958 /* Like R_PPC64_PLT_GOT16, but using bits 16-31 of the address. */
959 /* FIXME: R_PPC64_PLTGOT16_HI not implemented. */
960 HOWTO (R_PPC64_PLTGOT16_HI, /* type */
961 16, /* rightshift */
962 1, /* size (0 = byte, 1 = short, 2 = long) */
963 16, /* bitsize */
964 false, /* pc_relative */
965 0, /* bitpos */
966 complain_overflow_dont, /* complain_on_overflow */
967 bfd_elf_generic_reloc, /* special_function */
968 "R_PPC64_PLTGOT16_HI", /* name */
969 false, /* partial_inplace */
970 0, /* src_mask */
971 0xffff, /* dst_mask */
972 false), /* pcrel_offset */
973
974 /* Like R_PPC64_PLT_GOT16, but using bits 16-31 of the address, plus
975 1 if the contents of the low 16 bits, treated as a signed number,
976 is negative. */
977 /* FIXME: R_PPC64_PLTGOT16_HA not implemented. */
978 HOWTO (R_PPC64_PLTGOT16_HA, /* type */
979 16, /* rightshift */
980 1, /* size (0 = byte, 1 = short, 2 = long) */
981 16, /* bitsize */
982 false, /* pc_relative */
983 0, /* bitpos */
984 complain_overflow_dont,/* complain_on_overflow */
985 ppc64_elf_addr16_ha_reloc, /* special_function */
986 "R_PPC64_PLTGOT16_HA", /* name */
987 false, /* partial_inplace */
988 0, /* src_mask */
989 0xffff, /* dst_mask */
990 false), /* pcrel_offset */
991
992 /* Like R_PPC64_ADDR16, but for instructions with a DS field. */
993 HOWTO (R_PPC64_ADDR16_DS, /* type */
994 0, /* rightshift */
995 1, /* size (0 = byte, 1 = short, 2 = long) */
996 16, /* bitsize */
997 false, /* pc_relative */
998 0, /* bitpos */
999 complain_overflow_bitfield, /* complain_on_overflow */
1000 bfd_elf_generic_reloc, /* special_function */
1001 "R_PPC64_ADDR16_DS", /* name */
1002 false, /* partial_inplace */
1003 0, /* src_mask */
1004 0xfffc, /* dst_mask */
1005 false), /* pcrel_offset */
1006
1007 /* Like R_PPC64_ADDR16_LO, but for instructions with a DS field. */
1008 HOWTO (R_PPC64_ADDR16_LO_DS, /* type */
1009 0, /* rightshift */
1010 1, /* size (0 = byte, 1 = short, 2 = long) */
1011 16, /* bitsize */
1012 false, /* pc_relative */
1013 0, /* bitpos */
1014 complain_overflow_dont,/* complain_on_overflow */
1015 bfd_elf_generic_reloc, /* special_function */
1016 "R_PPC64_ADDR16_LO_DS",/* name */
1017 false, /* partial_inplace */
1018 0, /* src_mask */
1019 0xfffc, /* dst_mask */
1020 false), /* pcrel_offset */
1021
1022 /* Like R_PPC64_GOT16, but for instructions with a DS field. */
1023 HOWTO (R_PPC64_GOT16_DS, /* type */
1024 0, /* rightshift */
1025 1, /* size (0 = byte, 1 = short, 2 = long) */
1026 16, /* bitsize */
1027 false, /* pc_relative */
1028 0, /* bitpos */
1029 complain_overflow_signed, /* complain_on_overflow */
1030 bfd_elf_generic_reloc, /* special_function */
1031 "R_PPC64_GOT16_DS", /* name */
1032 false, /* partial_inplace */
1033 0, /* src_mask */
1034 0xfffc, /* dst_mask */
1035 false), /* pcrel_offset */
1036
1037 /* Like R_PPC64_GOT16_LO, but for instructions with a DS field. */
1038 HOWTO (R_PPC64_GOT16_LO_DS, /* type */
1039 0, /* rightshift */
1040 1, /* size (0 = byte, 1 = short, 2 = long) */
1041 16, /* bitsize */
1042 false, /* pc_relative */
1043 0, /* bitpos */
1044 complain_overflow_dont, /* complain_on_overflow */
1045 bfd_elf_generic_reloc, /* special_function */
1046 "R_PPC64_GOT16_LO_DS", /* name */
1047 false, /* partial_inplace */
1048 0, /* src_mask */
1049 0xfffc, /* dst_mask */
1050 false), /* pcrel_offset */
1051
1052 /* Like R_PPC64_PLT16_LO, but for instructions with a DS field. */
1053 HOWTO (R_PPC64_PLT16_LO_DS, /* type */
1054 0, /* rightshift */
1055 1, /* size (0 = byte, 1 = short, 2 = long) */
1056 16, /* bitsize */
1057 false, /* pc_relative */
1058 0, /* bitpos */
1059 complain_overflow_dont, /* complain_on_overflow */
1060 bfd_elf_generic_reloc, /* special_function */
1061 "R_PPC64_PLT16_LO_DS", /* name */
1062 false, /* partial_inplace */
1063 0, /* src_mask */
1064 0xfffc, /* dst_mask */
1065 false), /* pcrel_offset */
1066
1067 /* Like R_PPC64_SECTOFF, but for instructions with a DS field. */
1068 /* FIXME: Verify R_PPC64_SECTOFF. Seems strange with size=2 and
1069 dst_mask=0. */
1070 HOWTO (R_PPC64_SECTOFF_DS, /* type */
1071 0, /* rightshift */
1072 2, /* size (0 = byte, 1 = short, 2 = long) */
1073 32, /* bitsize */
1074 true, /* pc_relative */
1075 0, /* bitpos */
1076 complain_overflow_bitfield, /* complain_on_overflow */
1077 bfd_elf_generic_reloc, /* special_function */
1078 "R_PPC64_SECTOFF_DS", /* name */
1079 false, /* partial_inplace */
1080 0, /* src_mask */
1081 0, /* dst_mask */
1082 true), /* pcrel_offset */
1083
1084 /* Like R_PPC64_SECTOFF_LO, but for instructions with a DS field. */
1085 HOWTO (R_PPC64_SECTOFF_LO_DS, /* type */
1086 0, /* rightshift */
1087 1, /* size (0 = byte, 1 = short, 2 = long) */
1088 16, /* bitsize */
1089 false, /* pc_relative */
1090 0, /* bitpos */
1091 complain_overflow_dont, /* complain_on_overflow */
1092 bfd_elf_generic_reloc, /* special_function */
1093 "R_PPC64_SECTOFF_LO_DS",/* name */
1094 false, /* partial_inplace */
1095 0, /* src_mask */
1096 0xfffc, /* dst_mask */
1097 false), /* pcrel_offset */
1098
1099 /* Like R_PPC64_TOC16, but for instructions with a DS field. */
1100 HOWTO (R_PPC64_TOC16_DS, /* type */
1101 0, /* rightshift */
1102 1, /* size (0 = byte, 1 = short, 2 = long) */
1103 16, /* bitsize */
1104 false, /* pc_relative */
1105 0, /* bitpos */
1106 complain_overflow_signed, /* complain_on_overflow */
1107 bfd_elf_generic_reloc, /* special_function */
1108 "R_PPC64_TOC16_DS", /* name */
1109 false, /* partial_inplace */
1110 0, /* src_mask */
1111 0xfffc, /* dst_mask */
1112 false), /* pcrel_offset */
1113
1114 /* Like R_PPC64_TOC16_LO, but for instructions with a DS field. */
1115 HOWTO (R_PPC64_TOC16_LO_DS, /* type */
1116 0, /* rightshift */
1117 1, /* size (0 = byte, 1 = short, 2 = long) */
1118 16, /* bitsize */
1119 false, /* pc_relative */
1120 0, /* bitpos */
1121 complain_overflow_dont, /* complain_on_overflow */
1122 bfd_elf_generic_reloc, /* special_function */
1123 "R_PPC64_TOC16_LO_DS", /* name */
1124 false, /* partial_inplace */
1125 0, /* src_mask */
1126 0xfffc, /* dst_mask */
1127 false), /* pcrel_offset */
1128
1129 /* Like R_PPC64_PLTGOT16, but for instructions with a DS field. */
1130 /* FIXME: R_PPC64_PLTGOT16_DS not implemented. */
1131 HOWTO (R_PPC64_PLTGOT16_DS, /* type */
1132 0, /* rightshift */
1133 1, /* size (0 = byte, 1 = short, 2 = long) */
1134 16, /* bitsize */
1135 false, /* pc_relative */
1136 0, /* bitpos */
1137 complain_overflow_signed, /* complain_on_overflow */
1138 bfd_elf_generic_reloc, /* special_function */
1139 "R_PPC64_PLTGOT16_DS", /* name */
1140 false, /* partial_inplace */
1141 0, /* src_mask */
1142 0xfffc, /* dst_mask */
1143 false), /* pcrel_offset */
1144
1145 /* Like R_PPC64_PLTGOT16_LO, but for instructions with a DS field. */
1146 /* FIXME: R_PPC64_PLTGOT16_LO not implemented. */
1147 HOWTO (R_PPC64_PLTGOT16_LO_DS,/* type */
1148 0, /* rightshift */
1149 1, /* size (0 = byte, 1 = short, 2 = long) */
1150 16, /* bitsize */
1151 false, /* pc_relative */
1152 0, /* bitpos */
1153 complain_overflow_dont, /* complain_on_overflow */
1154 bfd_elf_generic_reloc, /* special_function */
1155 "R_PPC64_PLTGOT16_LO_DS",/* name */
1156 false, /* partial_inplace */
1157 0, /* src_mask */
1158 0xfffc, /* dst_mask */
1159 false), /* pcrel_offset */
1160
1161 /* GNU extension to record C++ vtable hierarchy. */
1162 HOWTO (R_PPC64_GNU_VTINHERIT, /* type */
1163 0, /* rightshift */
1164 0, /* size (0 = byte, 1 = short, 2 = long) */
1165 0, /* bitsize */
1166 false, /* pc_relative */
1167 0, /* bitpos */
1168 complain_overflow_dont, /* complain_on_overflow */
1169 NULL, /* special_function */
1170 "R_PPC64_GNU_VTINHERIT", /* name */
1171 false, /* partial_inplace */
1172 0, /* src_mask */
1173 0, /* dst_mask */
1174 false), /* pcrel_offset */
1175
1176 /* GNU extension to record C++ vtable member usage. */
1177 HOWTO (R_PPC64_GNU_VTENTRY, /* type */
1178 0, /* rightshift */
1179 0, /* size (0 = byte, 1 = short, 2 = long) */
1180 0, /* bitsize */
1181 false, /* pc_relative */
1182 0, /* bitpos */
1183 complain_overflow_dont, /* complain_on_overflow */
1184 NULL, /* special_function */
1185 "R_PPC64_GNU_VTENTRY", /* name */
1186 false, /* partial_inplace */
1187 0, /* src_mask */
1188 0, /* dst_mask */
1189 false), /* pcrel_offset */
1190};
1191
1192\f
1193/* Initialize the ppc64_elf_howto_table, so that linear accesses can
1194 be done. */
1195
1196static void
1197ppc_howto_init ()
1198{
1199 unsigned int i, type;
1200
1201 for (i = 0;
1202 i < sizeof (ppc64_elf_howto_raw) / sizeof (ppc64_elf_howto_raw[0]);
1203 i++)
1204 {
1205 type = ppc64_elf_howto_raw[i].type;
1206 BFD_ASSERT (type < (sizeof (ppc64_elf_howto_table)
1207 / sizeof (ppc64_elf_howto_table[0])));
1208 ppc64_elf_howto_table[type] = &ppc64_elf_howto_raw[i];
1209 }
1210}
1211
1212static reloc_howto_type *
1213ppc64_elf_reloc_type_lookup (abfd, code)
1214 bfd *abfd ATTRIBUTE_UNUSED;
1215 bfd_reloc_code_real_type code;
1216{
1217 enum elf_ppc_reloc_type ppc_reloc = R_PPC_NONE;
1218
1219 if (!ppc64_elf_howto_table[R_PPC64_ADDR32])
1220 /* Initialize howto table if needed. */
1221 ppc_howto_init ();
1222
1223 switch ((int) code)
1224 {
1225 default:
1226 return (reloc_howto_type *) NULL;
1227
1228 case BFD_RELOC_NONE: ppc_reloc = R_PPC64_NONE;
1229 break;
1230 case BFD_RELOC_32: ppc_reloc = R_PPC64_ADDR32;
1231 break;
1232 case BFD_RELOC_PPC_BA26: ppc_reloc = R_PPC64_ADDR24;
1233 break;
1234 case BFD_RELOC_16: ppc_reloc = R_PPC64_ADDR16;
1235 break;
1236 case BFD_RELOC_LO16: ppc_reloc = R_PPC64_ADDR16_LO;
1237 break;
1238 case BFD_RELOC_HI16: ppc_reloc = R_PPC64_ADDR16_HI;
1239 break;
1240 case BFD_RELOC_HI16_S: ppc_reloc = R_PPC64_ADDR16_HA;
1241 break;
1242 case BFD_RELOC_PPC_BA16: ppc_reloc = R_PPC64_ADDR14;
1243 break;
1244 case BFD_RELOC_PPC_BA16_BRTAKEN: ppc_reloc = R_PPC64_ADDR14_BRTAKEN;
1245 break;
1246 case BFD_RELOC_PPC_BA16_BRNTAKEN: ppc_reloc = R_PPC64_ADDR14_BRNTAKEN;
1247 break;
1248 case BFD_RELOC_PPC_B26: ppc_reloc = R_PPC64_REL24;
1249 break;
1250 case BFD_RELOC_PPC_B16: ppc_reloc = R_PPC64_REL14;
1251 break;
1252 case BFD_RELOC_PPC_B16_BRTAKEN: ppc_reloc = R_PPC64_REL14_BRTAKEN;
1253 break;
1254 case BFD_RELOC_PPC_B16_BRNTAKEN: ppc_reloc = R_PPC64_REL14_BRNTAKEN;
1255 break;
1256 case BFD_RELOC_16_GOTOFF: ppc_reloc = R_PPC64_GOT16;
1257 break;
1258 case BFD_RELOC_LO16_GOTOFF: ppc_reloc = R_PPC64_GOT16_LO;
1259 break;
1260 case BFD_RELOC_HI16_GOTOFF: ppc_reloc = R_PPC64_GOT16_HI;
1261 break;
1262 case BFD_RELOC_HI16_S_GOTOFF: ppc_reloc = R_PPC64_GOT16_HA;
1263 break;
1264 case BFD_RELOC_PPC_COPY: ppc_reloc = R_PPC64_COPY;
1265 break;
1266 case BFD_RELOC_PPC_GLOB_DAT: ppc_reloc = R_PPC64_GLOB_DAT;
1267 break;
1268 case BFD_RELOC_32_PCREL: ppc_reloc = R_PPC64_REL32;
1269 break;
1270 case BFD_RELOC_32_PLTOFF: ppc_reloc = R_PPC64_PLT32;
1271 break;
1272 case BFD_RELOC_32_PLT_PCREL: ppc_reloc = R_PPC64_PLTREL32;
1273 break;
1274 case BFD_RELOC_LO16_PLTOFF: ppc_reloc = R_PPC64_PLT16_LO;
1275 break;
1276 case BFD_RELOC_HI16_PLTOFF: ppc_reloc = R_PPC64_PLT16_HI;
1277 break;
1278 case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC64_PLT16_HA;
1279 break;
1280 case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC64_SECTOFF;
1281 break;
1282 case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC64_SECTOFF_LO;
1283 break;
1284 case BFD_RELOC_HI16_BASEREL: ppc_reloc = R_PPC64_SECTOFF_HI;
1285 break;
1286 case BFD_RELOC_HI16_S_BASEREL: ppc_reloc = R_PPC64_SECTOFF_HA;
1287 break;
1288 /* FIXME: Is CTOR 32 or 64 bits? Fix md_apply_fix3 in
1289 gas/config/tc-ppc.c too. */
1290 case BFD_RELOC_CTOR: ppc_reloc = R_PPC64_ADDR32;
1291 break;
1292 case BFD_RELOC_64: ppc_reloc = R_PPC64_ADDR64;
1293 break;
1294 case BFD_RELOC_PPC64_HIGHER: ppc_reloc = R_PPC64_ADDR16_HIGHER;
1295 break;
1296 case BFD_RELOC_PPC64_HIGHER_S: ppc_reloc = R_PPC64_ADDR16_HIGHERA;
1297 break;
1298 case BFD_RELOC_PPC64_HIGHEST: ppc_reloc = R_PPC64_ADDR16_HIGHEST;
1299 break;
1300 case BFD_RELOC_PPC64_HIGHEST_S: ppc_reloc = R_PPC64_ADDR16_HIGHESTA;
1301 break;
1302 case BFD_RELOC_64_PCREL: ppc_reloc = R_PPC64_REL64;
1303 break;
1304 case BFD_RELOC_64_PLTOFF: ppc_reloc = R_PPC64_PLT64;
1305 break;
1306 case BFD_RELOC_64_PLT_PCREL: ppc_reloc = R_PPC64_PLTREL64;
1307 break;
1308 case BFD_RELOC_PPC_TOC16: ppc_reloc = R_PPC64_TOC16;
1309 break;
1310 case BFD_RELOC_PPC64_TOC16_LO: ppc_reloc = R_PPC64_TOC16_LO;
1311 break;
1312 case BFD_RELOC_PPC64_TOC16_HI: ppc_reloc = R_PPC64_TOC16_HI;
1313 break;
1314 case BFD_RELOC_PPC64_TOC16_HA: ppc_reloc = R_PPC64_TOC16_HA;
1315 break;
1316 case BFD_RELOC_PPC64_TOC: ppc_reloc = R_PPC64_TOC;
1317 break;
1318 case BFD_RELOC_PPC64_PLTGOT16: ppc_reloc = R_PPC64_PLTGOT16;
1319 break;
1320 case BFD_RELOC_PPC64_PLTGOT16_LO: ppc_reloc = R_PPC64_PLTGOT16_LO;
1321 break;
1322 case BFD_RELOC_PPC64_PLTGOT16_HI: ppc_reloc = R_PPC64_PLTGOT16_HI;
1323 break;
1324 case BFD_RELOC_PPC64_PLTGOT16_HA: ppc_reloc = R_PPC64_PLTGOT16_HA;
1325 break;
1326 case BFD_RELOC_PPC64_ADDR16_DS: ppc_reloc = R_PPC64_ADDR16_DS;
1327 break;
1328 case BFD_RELOC_PPC64_ADDR16_LO_DS: ppc_reloc = R_PPC64_ADDR16_LO_DS;
1329 break;
1330 case BFD_RELOC_PPC64_GOT16_DS: ppc_reloc = R_PPC64_GOT16_DS;
1331 break;
1332 case BFD_RELOC_PPC64_GOT16_LO_DS: ppc_reloc = R_PPC64_GOT16_LO_DS;
1333 break;
1334 case BFD_RELOC_PPC64_PLT16_LO_DS: ppc_reloc = R_PPC64_PLT16_LO_DS;
1335 break;
1336 case BFD_RELOC_PPC64_SECTOFF_DS: ppc_reloc = R_PPC64_SECTOFF_DS;
1337 break;
1338 case BFD_RELOC_PPC64_SECTOFF_LO_DS: ppc_reloc = R_PPC64_SECTOFF_LO_DS;
1339 break;
1340 case BFD_RELOC_PPC64_TOC16_DS: ppc_reloc = R_PPC64_TOC16_DS;
1341 break;
1342 case BFD_RELOC_PPC64_TOC16_LO_DS: ppc_reloc = R_PPC64_TOC16_LO_DS;
1343 break;
1344 case BFD_RELOC_PPC64_PLTGOT16_DS: ppc_reloc = R_PPC64_PLTGOT16_DS;
1345 break;
1346 case BFD_RELOC_PPC64_PLTGOT16_LO_DS: ppc_reloc = R_PPC64_PLTGOT16_LO_DS;
1347 break;
1348 case BFD_RELOC_VTABLE_INHERIT: ppc_reloc = R_PPC64_GNU_VTINHERIT;
1349 break;
1350 case BFD_RELOC_VTABLE_ENTRY: ppc_reloc = R_PPC64_GNU_VTENTRY;
1351 break;
1352 }
1353
1354 return ppc64_elf_howto_table[(int) ppc_reloc];
1355};
1356
1357/* Set the howto pointer for a PowerPC ELF reloc. */
1358
1359static void
1360ppc64_elf_info_to_howto (abfd, cache_ptr, dst)
1361 bfd *abfd ATTRIBUTE_UNUSED;
1362 arelent *cache_ptr;
1363 Elf64_Internal_Rela *dst;
1364{
65f38f15
AM
1365 unsigned int type;
1366
5bd4f169
AM
1367 if (!ppc64_elf_howto_table[R_PPC64_ADDR32])
1368 /* Initialize howto table if needed. */
1369 ppc_howto_init ();
1370
65f38f15
AM
1371 type = ELF64_R_TYPE (dst->r_info);
1372 BFD_ASSERT (type < (sizeof (ppc64_elf_howto_table)
1373 / sizeof (ppc64_elf_howto_table[0])));
1374 cache_ptr->howto = ppc64_elf_howto_table[type];
5bd4f169
AM
1375}
1376
65f38f15 1377/* Handle the R_PPC_ADDR16_HA and similar relocs. */
5bd4f169
AM
1378
1379static bfd_reloc_status_type
1380ppc64_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section,
1381 output_bfd, error_message)
1382 bfd *abfd ATTRIBUTE_UNUSED;
1383 arelent *reloc_entry;
1384 asymbol *symbol;
1385 PTR data ATTRIBUTE_UNUSED;
1386 asection *input_section;
1387 bfd *output_bfd;
1388 char **error_message ATTRIBUTE_UNUSED;
1389{
1390 bfd_vma relocation;
1391
1392 if (output_bfd != NULL)
1393 {
1394 reloc_entry->address += input_section->output_offset;
1395 return bfd_reloc_ok;
1396 }
1397
1398 if (reloc_entry->address > input_section->_cooked_size)
1399 return bfd_reloc_outofrange;
1400
1401 if (bfd_is_com_section (symbol->section))
1402 relocation = 0;
1403 else
1404 relocation = symbol->value;
1405
1406 relocation += symbol->section->output_section->vma;
1407 relocation += symbol->section->output_offset;
1408 relocation += reloc_entry->addend;
1409
1410 reloc_entry->addend += (relocation & 0x8000) << 1;
1411
1412 return bfd_reloc_continue;
1413}
1414
1415/* Function to set whether a module needs the -mrelocatable bit set. */
1416
1417static boolean
1418ppc64_elf_set_private_flags (abfd, flags)
1419 bfd *abfd;
1420 flagword flags;
1421{
1422 BFD_ASSERT (!elf_flags_init (abfd)
1423 || elf_elfheader (abfd)->e_flags == flags);
1424
1425 elf_elfheader (abfd)->e_flags = flags;
1426 elf_flags_init (abfd) = true;
1427 return true;
1428}
1429
1430/* Copy backend specific data from one object module to another. */
1431static boolean
1432ppc64_elf_copy_private_bfd_data (ibfd, obfd)
1433 bfd *ibfd;
1434 bfd *obfd;
1435{
1436 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
1437 || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
1438 return true;
1439
1440 BFD_ASSERT (!elf_flags_init (obfd)
1441 || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);
1442
1443 elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
1444 elf_flags_init (obfd) = true;
1445 return true;
1446}
1447
1448/* Merge backend specific data from an object file to the output
1449 object file when linking. */
1450static boolean
1451ppc64_elf_merge_private_bfd_data (ibfd, obfd)
1452 bfd *ibfd;
1453 bfd *obfd;
1454{
1455 flagword old_flags;
1456 flagword new_flags;
1457 boolean error;
1458
1459 /* Check if we have the same endianess. */
1460 if (ibfd->xvec->byteorder != obfd->xvec->byteorder
1461 && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
1462 {
1463 const char *msg;
1464
1465 if (bfd_big_endian (ibfd))
1466 msg = _("%s: compiled for a big endian system and target is little endian");
1467 else
1468 msg = _("%s: compiled for a little endian system and target is big endian");
1469
8f615d07 1470 (*_bfd_error_handler) (msg, bfd_archive_filename (ibfd));
5bd4f169
AM
1471
1472 bfd_set_error (bfd_error_wrong_format);
1473 return false;
1474 }
1475
1476 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
1477 || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
1478 return true;
1479
1480 new_flags = elf_elfheader (ibfd)->e_flags;
1481 old_flags = elf_elfheader (obfd)->e_flags;
1482 if (!elf_flags_init (obfd))
1483 {
1484 /* First call, no flags set. */
1485 elf_flags_init (obfd) = true;
1486 elf_elfheader (obfd)->e_flags = new_flags;
1487 }
1488
1489 else if (new_flags == old_flags)
1490 /* Compatible flags are ok. */
1491 ;
1492
1493 else
1494 {
1495 /* Incompatible flags. Warn about -mrelocatable mismatch.
1496 Allow -mrelocatable-lib to be linked with either. */
1497 error = false;
1498 if ((new_flags & EF_PPC_RELOCATABLE) != 0
1499 && (old_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0)
1500 {
1501 error = true;
1502 (*_bfd_error_handler)
1503 (_("%s: compiled with -mrelocatable and linked with modules compiled normally"),
8f615d07 1504 bfd_archive_filename (ibfd));
5bd4f169
AM
1505 }
1506 else if ((new_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0
1507 && (old_flags & EF_PPC_RELOCATABLE) != 0)
1508 {
1509 error = true;
1510 (*_bfd_error_handler)
1511 (_("%s: compiled normally and linked with modules compiled with -mrelocatable"),
8f615d07 1512 bfd_archive_filename (ibfd));
5bd4f169
AM
1513 }
1514
1515 /* The output is -mrelocatable-lib iff both the input files are. */
1516 if (! (new_flags & EF_PPC_RELOCATABLE_LIB))
1517 elf_elfheader (obfd)->e_flags &= ~EF_PPC_RELOCATABLE_LIB;
1518
1519 /* The output is -mrelocatable iff it can't be -mrelocatable-lib,
1520 but each input file is either -mrelocatable or -mrelocatable-lib. */
1521 if (! (elf_elfheader (obfd)->e_flags & EF_PPC_RELOCATABLE_LIB)
1522 && (new_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE))
1523 && (old_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE)))
1524 elf_elfheader (obfd)->e_flags |= EF_PPC_RELOCATABLE;
1525
1526 /* Do not warn about eabi vs. V.4 mismatch, just or in the bit
1527 if any module uses it. */
1528 elf_elfheader (obfd)->e_flags |= (new_flags & EF_PPC_EMB);
1529
1530 new_flags &= ~(EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB);
1531 old_flags &= ~(EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB);
1532
1533 /* Warn about any other mismatches. */
1534 if (new_flags != old_flags)
1535 {
1536 error = true;
1537 (*_bfd_error_handler)
1538 (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
8f615d07 1539 bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags);
5bd4f169
AM
1540 }
1541
1542 if (error)
1543 {
1544 bfd_set_error (bfd_error_bad_value);
1545 return false;
1546 }
1547 }
1548
1549 return true;
1550}
1551
1552/* Handle a PowerPC specific section when reading an object file. This
1553 is called when elfcode.h finds a section with an unknown type. */
1554
1555static boolean
1556ppc64_elf_section_from_shdr (abfd, hdr, name)
1557 bfd *abfd;
1558 Elf64_Internal_Shdr *hdr;
1559 char *name;
1560{
1561 asection *newsect;
1562 flagword flags;
1563
1564 if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
1565 return false;
1566
1567 newsect = hdr->bfd_section;
1568 flags = bfd_get_section_flags (abfd, newsect);
1569 if (hdr->sh_flags & SHF_EXCLUDE)
1570 flags |= SEC_EXCLUDE;
1571
1572 if (hdr->sh_type == SHT_ORDERED)
1573 flags |= SEC_SORT_ENTRIES;
1574
1575 bfd_set_section_flags (abfd, newsect, flags);
1576 return true;
1577}
1578\f
65f38f15
AM
1579/* The following functions are specific to the ELF linker, while
1580 functions above are used generally. Those named ppc64_elf_* are
1581 called by the main ELF linker code. They appear in this file more
1582 or less in the order in which they are called. eg.
1583 ppc64_elf_check_relocs is called early in the link process,
1584 ppc64_elf_finish_dynamic_sections is one of the last functions
1585 called. */
1586
1587/* The linker needs to keep track of the number of relocs that it
1588 decides to copy as dynamic relocs in check_relocs for each symbol.
1589 This is so that it can later discard them if they are found to be
1590 unnecessary. We store the information in a field extending the
1591 regular ELF linker hash table. */
1592
1593struct ppc_dyn_relocs
1594{
1595 struct ppc_dyn_relocs *next;
1596
1597 /* The input section of the reloc. */
1598 asection *sec;
1599
1600 /* Total number of relocs copied for the input section. */
1601 bfd_size_type count;
1602
1603 /* Number of pc-relative relocs copied for the input section. */
1604 bfd_size_type pc_count;
1605};
1606
1607/* Of those relocs that might be copied as dynamic relocs, this macro
1608 selects between relative and absolute types. */
1609
1610#define IS_ABSOLUTE_RELOC(RTYPE) \
1611 ((RTYPE) != R_PPC64_REL14 \
1612 && (RTYPE) != R_PPC64_REL14_BRNTAKEN \
1613 && (RTYPE) != R_PPC64_REL14_BRTAKEN \
1614 && (RTYPE) != R_PPC64_REL24 \
1615 && (RTYPE) != R_PPC64_REL32 \
1616 && (RTYPE) != R_PPC64_REL64)
1617
1618/* ppc64 ELF linker hash entry. */
1619
1620struct ppc_link_hash_entry
1621{
1622 struct elf_link_hash_entry elf;
1623
1624 /* Track dynamic relocs copied for this symbol. */
1625 struct ppc_dyn_relocs *dyn_relocs;
1626};
1627
1628/* ppc64 ELF linker hash table. */
1629
1630struct ppc_link_hash_table
1631{
1632 struct elf_link_hash_table elf;
1633
1634 /* Short-cuts to get to dynamic linker sections. */
1635 asection *sgot;
1636 asection *srelgot;
1637 asection *splt;
1638 asection *srelplt;
1639 asection *sdynbss;
1640 asection *srelbss;
1641 asection *sglink;
ec338859
AM
1642
1643 /* Small local sym to section mapping cache. */
1644 struct sym_sec_cache sym_sec;
65f38f15
AM
1645};
1646
1647/* Get the ppc64 ELF linker hash table from a link_info structure. */
1648
1649#define ppc_hash_table(p) \
1650 ((struct ppc_link_hash_table *) ((p)->hash))
1651
1652/* Create an entry in a ppc64 ELF linker hash table. */
1653
1654static struct bfd_hash_entry *
1655link_hash_newfunc (entry, table, string)
1656 struct bfd_hash_entry *entry;
1657 struct bfd_hash_table *table;
1658 const char *string;
1659{
1660 /* Allocate the structure if it has not already been allocated by a
1661 subclass. */
1662 if (entry == NULL)
1663 {
1664 entry = bfd_hash_allocate (table, sizeof (struct ppc_link_hash_entry));
1665 if (entry == NULL)
1666 return entry;
1667 }
1668
1669 /* Call the allocation method of the superclass. */
1670 entry = _bfd_elf_link_hash_newfunc (entry, table, string);
1671 if (entry != NULL)
1672 {
1673 struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) entry;
1674
1675 eh->dyn_relocs = NULL;
1676 }
1677
1678 return entry;
1679}
1680
1681/* Create a ppc64 ELF linker hash table. */
1682
1683static struct bfd_link_hash_table *
1684ppc64_elf_link_hash_table_create (abfd)
1685 bfd *abfd;
1686{
1687 struct ppc_link_hash_table *htab;
1688 bfd_size_type amt = sizeof (struct ppc_link_hash_table);
1689
1690 htab = (struct ppc_link_hash_table *) bfd_alloc (abfd, amt);
1691 if (htab == NULL)
1692 return NULL;
1693
1694 if (! _bfd_elf_link_hash_table_init (&htab->elf, abfd, link_hash_newfunc))
1695 {
1696 bfd_release (abfd, htab);
1697 return NULL;
1698 }
1699
1700 htab->sgot = NULL;
1701 htab->srelgot = NULL;
1702 htab->splt = NULL;
1703 htab->srelplt = NULL;
1704 htab->sdynbss = NULL;
1705 htab->srelbss = NULL;
1706 htab->sglink = NULL;
ec338859 1707 htab->sym_sec.abfd = NULL;
65f38f15
AM
1708
1709 return &htab->elf.root;
1710}
1711
1712/* Create .got and .rela.got sections in DYNOBJ, and set up
1713 shortcuts to them in our hash table. */
1714
1715static boolean
1716create_got_section (dynobj, info)
1717 bfd *dynobj;
1718 struct bfd_link_info *info;
1719{
1720 struct ppc_link_hash_table *htab;
1721
1722 if (! _bfd_elf_create_got_section (dynobj, info))
1723 return false;
1724
1725 htab = ppc_hash_table (info);
1726 htab->sgot = bfd_get_section_by_name (dynobj, ".got");
1727 if (!htab->sgot)
1728 abort ();
1729
1730 htab->srelgot = bfd_make_section (dynobj, ".rela.got");
1731 if (!htab->srelgot
1732 || ! bfd_set_section_flags (dynobj, htab->srelgot,
1733 (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
1734 | SEC_IN_MEMORY | SEC_LINKER_CREATED
1735 | SEC_READONLY))
1736 || ! bfd_set_section_alignment (dynobj, htab->srelgot, 3))
1737 return false;
1738 return true;
1739}
5bd4f169
AM
1740
1741/* Create the .glink section as well as the ordinary dynamic
1742 sections. */
1743
1744static boolean
65f38f15
AM
1745ppc64_elf_create_dynamic_sections (dynobj, info)
1746 bfd *dynobj;
5bd4f169
AM
1747 struct bfd_link_info *info;
1748{
65f38f15 1749 struct ppc_link_hash_table *htab;
5bd4f169
AM
1750 flagword flags;
1751
65f38f15
AM
1752 htab = ppc_hash_table (info);
1753 if (!htab->sgot && !create_got_section (dynobj, info))
5bd4f169
AM
1754 return false;
1755
65f38f15 1756 if (!_bfd_elf_create_dynamic_sections (dynobj, info))
5bd4f169 1757 return false;
65f38f15
AM
1758
1759 htab->splt = bfd_get_section_by_name (dynobj, ".plt");
1760 htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
1761 htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
1762 if (!info->shared)
1763 htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
1764
1765 if (!htab->splt || !htab->srelplt || !htab->sdynbss
1766 || (!info->shared && !htab->srelbss))
1767 abort ();
1768
1769 /* Our .plt just contains pointers, no code. */
1770 flags = bfd_get_section_flags (dynobj, htab->splt);
5bd4f169 1771 flags &= ~SEC_CODE;
65f38f15 1772 if (! bfd_set_section_flags (dynobj, htab->splt, flags))
5bd4f169
AM
1773 return false;
1774
1775 /* Create .glink for global linkage functions. */
1776 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
1777 | SEC_LINKER_CREATED);
65f38f15
AM
1778 htab->sglink = bfd_make_section (dynobj, ".glink");
1779 if (htab->sglink == NULL
1780 || ! bfd_set_section_flags (dynobj, htab->sglink, flags)
1781 || ! bfd_set_section_alignment (dynobj, htab->sglink, 3))
5bd4f169
AM
1782 return false;
1783
1784 return true;
1785}
1786
65f38f15
AM
1787/* Copy the extra info we tack onto an elf_link_hash_entry. */
1788
1789static void
1790ppc64_elf_copy_indirect_symbol (dir, ind)
1791 struct elf_link_hash_entry *dir, *ind;
1792{
1793 struct ppc_link_hash_entry *edir, *eind;
1794
1795 edir = (struct ppc_link_hash_entry *) dir;
1796 eind = (struct ppc_link_hash_entry *) ind;
1797
bbd7ec4a 1798 if (eind->dyn_relocs != NULL)
65f38f15 1799 {
bbd7ec4a
AM
1800 if (edir->dyn_relocs != NULL)
1801 {
1802 struct ppc_dyn_relocs **pp;
1803 struct ppc_dyn_relocs *p;
1804
1e370bd2 1805 if (ind->root.type == bfd_link_hash_indirect)
bbd7ec4a
AM
1806 abort ();
1807
1808 /* Add reloc counts against the weak sym to the strong sym
1809 list. Merge any entries against the same section. */
1810 for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
1811 {
1812 struct ppc_dyn_relocs *q;
1813
1814 for (q = edir->dyn_relocs; q != NULL; q = q->next)
1815 if (q->sec == p->sec)
1816 {
1817 q->pc_count += p->pc_count;
1818 q->count += p->count;
1819 *pp = p->next;
1820 break;
1821 }
1822 if (q == NULL)
1823 pp = &p->next;
1824 }
1825 *pp = edir->dyn_relocs;
1826 }
1827
65f38f15
AM
1828 edir->dyn_relocs = eind->dyn_relocs;
1829 eind->dyn_relocs = NULL;
1830 }
65f38f15
AM
1831
1832 _bfd_elf_link_hash_copy_indirect (dir, ind);
1833}
1834
5bd4f169 1835/* Look through the relocs for a section during the first phase, and
65f38f15
AM
1836 calculate needed space in the global offset table, procedure
1837 linkage table, and dynamic reloc sections. */
5bd4f169
AM
1838
1839static boolean
1840ppc64_elf_check_relocs (abfd, info, sec, relocs)
1841 bfd *abfd;
1842 struct bfd_link_info *info;
1843 asection *sec;
1844 const Elf_Internal_Rela *relocs;
1845{
65f38f15 1846 struct ppc_link_hash_table *htab;
5bd4f169
AM
1847 Elf_Internal_Shdr *symtab_hdr;
1848 struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
1849 const Elf_Internal_Rela *rel;
1850 const Elf_Internal_Rela *rel_end;
5bd4f169 1851 asection *sreloc;
5bd4f169
AM
1852
1853 if (info->relocateable)
1854 return true;
1855
65f38f15 1856 htab = ppc_hash_table (info);
5bd4f169 1857 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
5bd4f169
AM
1858
1859 sym_hashes = elf_sym_hashes (abfd);
1860 sym_hashes_end = (sym_hashes
1861 + symtab_hdr->sh_size / sizeof (Elf64_External_Sym));
1862 if (!elf_bad_symtab (abfd))
1863 sym_hashes_end -= symtab_hdr->sh_info;
1864
1865 sreloc = NULL;
1866
1867 rel_end = relocs + sec->reloc_count;
1868 for (rel = relocs; rel < rel_end; rel++)
1869 {
1870 unsigned long r_symndx;
1871 struct elf_link_hash_entry *h;
a33d1f77 1872 enum elf_ppc_reloc_type r_type;
5bd4f169
AM
1873
1874 r_symndx = ELF64_R_SYM (rel->r_info);
1875 if (r_symndx < symtab_hdr->sh_info)
1876 h = NULL;
1877 else
1878 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
1879
a33d1f77
AM
1880 r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
1881 switch (r_type)
5bd4f169
AM
1882 {
1883 /* GOT16 relocations */
1884 case R_PPC64_GOT16:
5bd4f169 1885 case R_PPC64_GOT16_DS:
65f38f15
AM
1886 case R_PPC64_GOT16_HA:
1887 case R_PPC64_GOT16_HI:
1888 case R_PPC64_GOT16_LO:
5bd4f169 1889 case R_PPC64_GOT16_LO_DS:
5bd4f169 1890
65f38f15
AM
1891 /* This symbol requires a global offset table entry. */
1892 if (htab->sgot == NULL)
5bd4f169 1893 {
65f38f15
AM
1894 if (htab->elf.dynobj == NULL)
1895 htab->elf.dynobj = abfd;
1896 if (!create_got_section (htab->elf.dynobj, info))
5bd4f169 1897 return false;
5bd4f169
AM
1898 }
1899
1900 if (h != NULL)
1901 {
65f38f15 1902 h->got.refcount += 1;
5bd4f169
AM
1903 }
1904 else
1905 {
65f38f15
AM
1906 bfd_signed_vma *local_got_refcounts;
1907
5bd4f169 1908 /* This is a global offset table entry for a local symbol. */
65f38f15 1909 local_got_refcounts = elf_local_got_refcounts (abfd);
5bd4f169
AM
1910 if (local_got_refcounts == NULL)
1911 {
dc810e39 1912 bfd_size_type size;
5bd4f169 1913
dc810e39
AM
1914 size = symtab_hdr->sh_info;
1915 size *= sizeof (bfd_signed_vma);
1916 local_got_refcounts = ((bfd_signed_vma *)
65f38f15 1917 bfd_zalloc (abfd, size));
5bd4f169
AM
1918 if (local_got_refcounts == NULL)
1919 return false;
1920 elf_local_got_refcounts (abfd) = local_got_refcounts;
5bd4f169 1921 }
65f38f15 1922 local_got_refcounts[r_symndx] += 1;
5bd4f169
AM
1923 }
1924 break;
1925
5bd4f169 1926 case R_PPC64_PLT16_HA:
65f38f15
AM
1927 case R_PPC64_PLT16_HI:
1928 case R_PPC64_PLT16_LO:
1929 case R_PPC64_PLT32:
1930 case R_PPC64_PLT64:
5bd4f169
AM
1931 /* This symbol requires a procedure linkage table entry. We
1932 actually build the entry in adjust_dynamic_symbol,
1933 because this might be a case of linking PIC code without
1934 linking in any dynamic objects, in which case we don't
1935 need to generate a procedure linkage table after all. */
5bd4f169
AM
1936 if (h == NULL)
1937 {
1938 /* It does not make sense to have a procedure linkage
1939 table entry for a local symbol. */
1940 bfd_set_error (bfd_error_bad_value);
1941 return false;
1942 }
1943
65f38f15
AM
1944 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
1945 h->plt.refcount += 1;
5bd4f169
AM
1946 break;
1947
1948 /* The following relocations don't need to propagate the
1949 relocation if linking a shared object since they are
1950 section relative. */
1951 case R_PPC64_SECTOFF:
1952 case R_PPC64_SECTOFF_LO:
1953 case R_PPC64_SECTOFF_HI:
1954 case R_PPC64_SECTOFF_HA:
1955 case R_PPC64_SECTOFF_DS:
1956 case R_PPC64_SECTOFF_LO_DS:
1957 case R_PPC64_TOC16:
1958 case R_PPC64_TOC16_LO:
1959 case R_PPC64_TOC16_HI:
1960 case R_PPC64_TOC16_HA:
1961 case R_PPC64_TOC16_DS:
1962 case R_PPC64_TOC16_LO_DS:
1963 break;
1964
1965 /* This relocation describes the C++ object vtable hierarchy.
1966 Reconstruct it for later use during GC. */
1967 case R_PPC64_GNU_VTINHERIT:
1968 if (!_bfd_elf64_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
1969 return false;
1970 break;
1971
1972 /* This relocation describes which C++ vtable entries are actually
1973 used. Record for later use during GC. */
1974 case R_PPC64_GNU_VTENTRY:
1975 if (!_bfd_elf64_gc_record_vtentry (abfd, sec, h, rel->r_addend))
1976 return false;
1977 break;
1978
5bd4f169
AM
1979 case R_PPC64_REL64:
1980 case R_PPC64_REL32:
1981 case R_PPC64_REL24:
1982 case R_PPC64_REL14:
1983 case R_PPC64_REL14_BRTAKEN:
1984 case R_PPC64_REL14_BRNTAKEN:
65f38f15
AM
1985 case R_PPC64_ADDR14:
1986 case R_PPC64_ADDR14_BRNTAKEN:
1987 case R_PPC64_ADDR14_BRTAKEN:
1988 case R_PPC64_ADDR16:
1989 case R_PPC64_ADDR16_DS:
1990 case R_PPC64_ADDR16_HA:
1991 case R_PPC64_ADDR16_HI:
1992 case R_PPC64_ADDR16_HIGHER:
1993 case R_PPC64_ADDR16_HIGHERA:
1994 case R_PPC64_ADDR16_HIGHEST:
1995 case R_PPC64_ADDR16_HIGHESTA:
1996 case R_PPC64_ADDR16_LO:
1997 case R_PPC64_ADDR16_LO_DS:
1998 case R_PPC64_ADDR24:
1999 case R_PPC64_ADDR30:
2000 case R_PPC64_ADDR32:
2001 case R_PPC64_ADDR64:
2002 case R_PPC64_UADDR16:
2003 case R_PPC64_UADDR32:
2004 case R_PPC64_UADDR64:
5bd4f169 2005 case R_PPC64_TOC:
65f38f15
AM
2006 /* If we are creating a shared library, and this is a reloc
2007 against a global symbol, or a non PC relative reloc
2008 against a local symbol, then we need to copy the reloc
2009 into the shared library. However, if we are linking with
2010 -Bsymbolic, we do not need to copy a reloc against a
2011 global symbol which is defined in an object we are
2012 including in the link (i.e., DEF_REGULAR is set). At
2013 this point we have not seen all the input files, so it is
2014 possible that DEF_REGULAR is not set now but will be set
2015 later (it is never cleared). In case of a weak definition,
2016 DEF_REGULAR may be cleared later by a strong definition in
2017 a shared library. We account for that possibility below by
2018 storing information in the relocs_copied field of the hash
2019 table entry. A similar situation occurs when creating
2020 shared libraries and symbol visibility changes render the
2021 symbol local.
2022
2023 If on the other hand, we are creating an executable, we
2024 may need to keep relocations for symbols satisfied by a
2025 dynamic library if we manage to avoid copy relocs for the
2026 symbol. */
2027 if ((info->shared
2028 && (sec->flags & SEC_ALLOC) != 0
a33d1f77 2029 && (IS_ABSOLUTE_RELOC (r_type)
65f38f15
AM
2030 || (h != NULL
2031 && (! info->symbolic
2032 || h->root.type == bfd_link_hash_defweak
2033 || (h->elf_link_hash_flags
2034 & ELF_LINK_HASH_DEF_REGULAR) == 0))))
2035 || (!info->shared
2036 && (sec->flags & SEC_ALLOC) != 0
2037 && h != NULL
2038 && (h->root.type == bfd_link_hash_defweak
2039 || (h->elf_link_hash_flags
2040 & ELF_LINK_HASH_DEF_REGULAR) == 0)))
5bd4f169 2041 {
ec338859
AM
2042 struct ppc_dyn_relocs *p;
2043 struct ppc_dyn_relocs **head;
2044
65f38f15
AM
2045 /* We must copy these reloc types into the output file.
2046 Create a reloc section in dynobj and make room for
2047 this reloc. */
5bd4f169
AM
2048 if (sreloc == NULL)
2049 {
2050 const char *name;
65f38f15 2051 bfd *dynobj;
5bd4f169
AM
2052
2053 name = (bfd_elf_string_from_elf_section
2054 (abfd,
2055 elf_elfheader (abfd)->e_shstrndx,
2056 elf_section_data (sec)->rel_hdr.sh_name));
2057 if (name == NULL)
2058 return false;
2059
65f38f15
AM
2060 if (strncmp (name, ".rela", 5) != 0
2061 || strcmp (bfd_get_section_name (abfd, sec),
2062 name + 5) != 0)
2063 {
2064 (*_bfd_error_handler)
2065 (_("%s: bad relocation section name `%s\'"),
2066 bfd_archive_filename (abfd), name);
2067 }
2068
2069 if (htab->elf.dynobj == NULL)
2070 htab->elf.dynobj = abfd;
5bd4f169 2071
65f38f15 2072 dynobj = htab->elf.dynobj;
5bd4f169
AM
2073 sreloc = bfd_get_section_by_name (dynobj, name);
2074 if (sreloc == NULL)
2075 {
2076 flagword flags;
2077
2078 sreloc = bfd_make_section (dynobj, name);
2079 flags = (SEC_HAS_CONTENTS | SEC_READONLY
2080 | SEC_IN_MEMORY | SEC_LINKER_CREATED);
2081 if ((sec->flags & SEC_ALLOC) != 0)
2082 flags |= SEC_ALLOC | SEC_LOAD;
2083 if (sreloc == NULL
2084 || ! bfd_set_section_flags (dynobj, sreloc, flags)
65f38f15 2085 || ! bfd_set_section_alignment (dynobj, sreloc, 3))
5bd4f169
AM
2086 return false;
2087 }
65f38f15 2088 elf_section_data (sec)->sreloc = sreloc;
5bd4f169
AM
2089 }
2090
65f38f15
AM
2091 /* If this is a global symbol, we count the number of
2092 relocations we need for this symbol. */
2093 if (h != NULL)
2094 {
ec338859 2095 head = &((struct ppc_link_hash_entry *) h)->dyn_relocs;
65f38f15
AM
2096 }
2097 else
2098 {
ec338859
AM
2099 /* Track dynamic relocs needed for local syms too.
2100 We really need local syms available to do this
2101 easily. Oh well. */
2102
2103 asection *s;
2104 s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
2105 sec, r_symndx);
2106 if (s == NULL)
2107 return false;
2108
2109 head = ((struct ppc_dyn_relocs **)
2110 &elf_section_data (s)->local_dynrel);
65f38f15 2111 }
ec338859
AM
2112
2113 p = *head;
2114 if (p == NULL || p->sec != sec)
2115 {
2116 p = ((struct ppc_dyn_relocs *)
2117 bfd_alloc (htab->elf.dynobj,
2118 (bfd_size_type) sizeof *p));
2119 if (p == NULL)
2120 return false;
2121 p->next = *head;
2122 *head = p;
2123 p->sec = sec;
2124 p->count = 0;
2125 p->pc_count = 0;
2126 }
2127
2128 p->count += 1;
2129 if (!IS_ABSOLUTE_RELOC (r_type))
2130 p->pc_count += 1;
65f38f15 2131 }
5bd4f169 2132 break;
65f38f15
AM
2133
2134 default:
5bd4f169
AM
2135 }
2136 }
2137
2138 return true;
2139}
2140
2141/* Return the section that should be marked against GC for a given
2142 relocation. */
2143
2144static asection *
2145ppc64_elf_gc_mark_hook (abfd, info, rel, h, sym)
2146 bfd *abfd;
2147 struct bfd_link_info *info ATTRIBUTE_UNUSED;
2148 Elf_Internal_Rela *rel;
2149 struct elf_link_hash_entry *h;
2150 Elf_Internal_Sym *sym;
2151{
2152 if (h != NULL)
2153 {
a33d1f77
AM
2154 enum elf_ppc_reloc_type r_type;
2155
2156 r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
2157 switch (r_type)
5bd4f169
AM
2158 {
2159 case R_PPC64_GNU_VTINHERIT:
2160 case R_PPC64_GNU_VTENTRY:
2161 break;
2162
2163 default:
2164 switch (h->root.type)
2165 {
2166 case bfd_link_hash_defined:
2167 case bfd_link_hash_defweak:
2168 return h->root.u.def.section;
2169
2170 case bfd_link_hash_common:
2171 return h->root.u.c.p->section;
2172
2173 default:
2174 break;
2175 }
2176 }
2177 }
2178 else
2179 {
2180 if (! (elf_bad_symtab (abfd)
2181 && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
2182 && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
2183 && sym->st_shndx != SHN_COMMON))
2184 {
2185 return bfd_section_from_elf_index (abfd, sym->st_shndx);
2186 }
2187 }
2188
2189 return NULL;
2190}
2191
65f38f15
AM
2192/* Update the .got, .plt. and dynamic reloc reference counts for the
2193 section being removed. */
5bd4f169
AM
2194
2195static boolean
2196ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs)
2197 bfd *abfd;
2198 struct bfd_link_info *info ATTRIBUTE_UNUSED;
2199 asection *sec;
2200 const Elf_Internal_Rela *relocs;
2201{
2202 Elf_Internal_Shdr *symtab_hdr;
2203 struct elf_link_hash_entry **sym_hashes;
2204 bfd_signed_vma *local_got_refcounts;
2205 const Elf_Internal_Rela *rel, *relend;
5bd4f169 2206
ec338859
AM
2207 elf_section_data (sec)->local_dynrel = NULL;
2208
5bd4f169
AM
2209 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
2210 sym_hashes = elf_sym_hashes (abfd);
2211 local_got_refcounts = elf_local_got_refcounts (abfd);
2212
2213 relend = relocs + sec->reloc_count;
2214 for (rel = relocs; rel < relend; rel++)
a33d1f77
AM
2215 {
2216 unsigned long r_symndx;
2217 enum elf_ppc_reloc_type r_type;
2218 struct elf_link_hash_entry *h;
5bd4f169 2219
a33d1f77
AM
2220 r_symndx = ELF64_R_SYM (rel->r_info);
2221 r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
2222 switch (r_type)
2223 {
2224 case R_PPC64_GOT16:
2225 case R_PPC64_GOT16_DS:
2226 case R_PPC64_GOT16_HA:
2227 case R_PPC64_GOT16_HI:
2228 case R_PPC64_GOT16_LO:
2229 case R_PPC64_GOT16_LO_DS:
2230 if (r_symndx >= symtab_hdr->sh_info)
2231 {
2232 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
2233 if (h->got.refcount > 0)
2234 h->got.refcount--;
2235 }
2236 else
2237 {
2238 if (local_got_refcounts[r_symndx] > 0)
2239 local_got_refcounts[r_symndx]--;
2240 }
2241 break;
65f38f15 2242
a33d1f77
AM
2243 case R_PPC64_PLT16_HA:
2244 case R_PPC64_PLT16_HI:
2245 case R_PPC64_PLT16_LO:
2246 case R_PPC64_PLT32:
2247 case R_PPC64_PLT64:
2248 if (r_symndx >= symtab_hdr->sh_info)
2249 {
2250 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
2251 if (h->plt.refcount > 0)
2252 h->plt.refcount--;
2253 }
2254 break;
65f38f15 2255
a33d1f77
AM
2256 case R_PPC64_REL14:
2257 case R_PPC64_REL14_BRNTAKEN:
2258 case R_PPC64_REL14_BRTAKEN:
2259 case R_PPC64_REL24:
2260 case R_PPC64_REL32:
2261 case R_PPC64_REL64:
2262 if (r_symndx >= symtab_hdr->sh_info)
2263 {
2264 struct ppc_link_hash_entry *eh;
2265 struct ppc_dyn_relocs **pp;
2266 struct ppc_dyn_relocs *p;
65f38f15 2267
a33d1f77
AM
2268 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
2269 eh = (struct ppc_link_hash_entry *) h;
65f38f15 2270
a33d1f77
AM
2271 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
2272 if (p->sec == sec)
2273 {
2274 p->pc_count -= 1;
2275 p->count -= 1;
2276 if (p->count == 0)
2277 *pp = p->next;
2278 break;
2279 }
2280 }
2281 break;
65f38f15 2282
a33d1f77
AM
2283 case R_PPC64_ADDR14:
2284 case R_PPC64_ADDR14_BRNTAKEN:
2285 case R_PPC64_ADDR14_BRTAKEN:
2286 case R_PPC64_ADDR16:
2287 case R_PPC64_ADDR16_DS:
2288 case R_PPC64_ADDR16_HA:
2289 case R_PPC64_ADDR16_HI:
2290 case R_PPC64_ADDR16_HIGHER:
2291 case R_PPC64_ADDR16_HIGHERA:
2292 case R_PPC64_ADDR16_HIGHEST:
2293 case R_PPC64_ADDR16_HIGHESTA:
2294 case R_PPC64_ADDR16_LO:
2295 case R_PPC64_ADDR16_LO_DS:
2296 case R_PPC64_ADDR24:
2297 case R_PPC64_ADDR30:
2298 case R_PPC64_ADDR32:
2299 case R_PPC64_ADDR64:
2300 case R_PPC64_UADDR16:
2301 case R_PPC64_UADDR32:
2302 case R_PPC64_UADDR64:
2303 case R_PPC64_TOC:
2304 if (r_symndx >= symtab_hdr->sh_info)
2305 {
2306 struct ppc_link_hash_entry *eh;
2307 struct ppc_dyn_relocs **pp;
2308 struct ppc_dyn_relocs *p;
65f38f15 2309
a33d1f77
AM
2310 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
2311 eh = (struct ppc_link_hash_entry *) h;
2312
2313 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
2314 if (p->sec == sec)
2315 {
2316 p->count -= 1;
2317 if (p->count == 0)
2318 *pp = p->next;
2319 break;
2320 }
2321 }
2322 break;
5bd4f169 2323
a33d1f77
AM
2324 default:
2325 break;
2326 }
2327 }
5bd4f169
AM
2328 return true;
2329}
2330
2331/* Adjust a symbol defined by a dynamic object and referenced by a
2332 regular object. The current definition is in some section of the
2333 dynamic object, but we're not including those sections. We have to
2334 change the definition to something the rest of the link can
2335 understand. */
2336
2337static boolean
2338ppc64_elf_adjust_dynamic_symbol (info, h)
2339 struct bfd_link_info *info;
2340 struct elf_link_hash_entry *h;
2341{
65f38f15
AM
2342 struct ppc_link_hash_table *htab;
2343 struct ppc_link_hash_entry * eh;
2344 struct ppc_dyn_relocs *p;
5bd4f169
AM
2345 asection *s;
2346 unsigned int power_of_two;
5bd4f169 2347
65f38f15 2348 htab = ppc_hash_table (info);
5bd4f169 2349
65f38f15
AM
2350 /* If this is a function, put it in the procedure linkage table. We
2351 will fill in the contents of the procedure linkage table later. */
5bd4f169
AM
2352 if (h->type == STT_FUNC
2353 || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
2354 {
65f38f15
AM
2355 struct elf_link_hash_entry *fdh;
2356
2357 /* If it's a function entry point, the name starts with a dot
2358 unless someone has written some poor assembly code. The ABI
2359 for .plt calls requires that there be a function descriptor
2360 sym which has the name of the function minus the dot. */
2361
2362 if (h->plt.refcount <= 0
2363 || h->root.root.string[0] != '.'
2364 || h->root.root.string[1] == '\0'
2365 || (! info->shared
2366 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
2367 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0))
5bd4f169 2368 {
65f38f15
AM
2369 /* This case can occur if we saw a PLT reloc in an input
2370 file, but the symbol was never referred to by a dynamic
2371 object, or if all references were garbage collected. In
2372 such a case, we don't actually need to build a procedure
2373 linkage table entry. */
5bd4f169
AM
2374 h->plt.offset = (bfd_vma) -1;
2375 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
2376 return true;
2377 }
2378
65f38f15
AM
2379 /* Find the corresponding function descriptor symbol. Create it
2380 as undefined if necessary. ppc_elf64_finish_dynamic_symbol
2381 will look it up again and create a JMP_SLOT reloc for it. */
5bd4f169 2382
65f38f15
AM
2383 fdh = elf_link_hash_lookup (elf_hash_table (info),
2384 h->root.root.string + 1,
2385 false, false, false);
5bd4f169 2386
65f38f15 2387 if (fdh == NULL)
5bd4f169 2388 {
65f38f15
AM
2389 asymbol *newsym;
2390
2391 /* Create it as undefined. */
2392 newsym = bfd_make_empty_symbol (htab->elf.dynobj);
2393 newsym->name = h->root.root.string + 1;
2394 newsym->section = bfd_und_section_ptr;
2395 newsym->value = 0;
2396 newsym->flags = BSF_DYNAMIC | BSF_OBJECT;
2397
2398 if ( !(_bfd_generic_link_add_one_symbol
2399 (info, htab->elf.dynobj, newsym->name, newsym->flags,
2400 newsym->section, newsym->value, NULL, false, false,
2401 (struct bfd_link_hash_entry **) &fdh)))
5bd4f169 2402 {
65f38f15 2403 return false;
5bd4f169 2404 }
5bd4f169 2405 }
5bd4f169
AM
2406 return true;
2407 }
bbd7ec4a
AM
2408 else
2409 h->plt.offset = (bfd_vma) -1;
5bd4f169
AM
2410
2411 /* If this is a weak symbol, and there is a real definition, the
2412 processor independent code will have arranged for us to see the
2413 real definition first, and we can just use the same value. */
2414 if (h->weakdef != NULL)
2415 {
2416 BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
2417 || h->weakdef->root.type == bfd_link_hash_defweak);
2418 h->root.u.def.section = h->weakdef->root.u.def.section;
2419 h->root.u.def.value = h->weakdef->root.u.def.value;
0a991dfe 2420 return true;
5bd4f169
AM
2421 }
2422
2423 /* This is a reference to a symbol defined by a dynamic object which
2424 is not a function. */
2425
2426 /* If we are creating a shared library, we must presume that the
2427 only references to the symbol are via the global offset table.
2428 For such cases we need not do anything here; the relocations will
2429 be handled correctly by relocate_section. */
2430 if (info->shared)
2431 return true;
2432
65f38f15
AM
2433 /* If there are no references to this symbol that do not use the
2434 GOT, we don't need to generate a copy reloc. */
2435 if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
2436 return true;
2437
2438 eh = (struct ppc_link_hash_entry *) h;
2439 for (p = eh->dyn_relocs; p != NULL; p = p->next)
2440 {
2441 s = p->sec->output_section;
2442 if (s != NULL && (s->flags & SEC_READONLY) != 0)
2443 break;
2444 }
2445
2446 /* If we didn't find any dynamic relocs in read-only sections, then
2447 we'll be keeping the dynamic relocs and avoiding the copy reloc. */
2448 if (p == NULL)
2449 {
2450 h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
2451 return true;
2452 }
2453
5bd4f169
AM
2454 /* We must allocate the symbol in our .dynbss section, which will
2455 become part of the .bss section of the executable. There will be
2456 an entry for this symbol in the .dynsym section. The dynamic
2457 object will contain position independent code, so all references
2458 from the dynamic object to this symbol will go through the global
2459 offset table. The dynamic linker will use the .dynsym entry to
2460 determine the address it must put in the global offset table, so
2461 both the dynamic object and the regular object will refer to the
2462 same memory location for the variable. */
5bd4f169
AM
2463
2464 /* We must generate a R_PPC_COPY reloc to tell the dynamic linker to
2465 copy the initial value out of the dynamic object and into the
2466 runtime process image. We need to remember the offset into the
2467 .rela.bss section we are going to use. */
2468 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
2469 {
65f38f15 2470 htab->srelbss->_raw_size += sizeof (Elf64_External_Rela);
5bd4f169
AM
2471 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
2472 }
2473
2474 /* We need to figure out the alignment required for this symbol. I
2475 have no idea how ELF linkers handle this. */
2476 power_of_two = bfd_log2 (h->size);
2477 if (power_of_two > 4)
2478 power_of_two = 4;
2479
2480 /* Apply the required alignment. */
65f38f15
AM
2481 s = htab->sdynbss;
2482 s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two));
2483 if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s))
5bd4f169 2484 {
65f38f15 2485 if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two))
5bd4f169
AM
2486 return false;
2487 }
2488
2489 /* Define the symbol as being at this point in the section. */
2490 h->root.u.def.section = s;
2491 h->root.u.def.value = s->_raw_size;
2492
2493 /* Increment the section size to make room for the symbol. */
2494 s->_raw_size += h->size;
2495
2496 return true;
2497}
2498
65f38f15
AM
2499/* This is the condition under which ppc64_elf_finish_dynamic_symbol
2500 will be called from elflink.h. If elflink.h doesn't call our
2501 finish_dynamic_symbol routine, we'll need to do something about
2502 initializing any .plt and .got entries in ppc64_elf_relocate_section. */
2503#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
2504 ((DYN) \
2505 && ((INFO)->shared \
2506 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
2507 && ((H)->dynindx != -1 \
2508 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
5bd4f169 2509
65f38f15
AM
2510/* Allocate space in .plt, .got and associated reloc sections for
2511 dynamic relocs. */
5bd4f169
AM
2512
2513static boolean
65f38f15
AM
2514allocate_dynrelocs (h, inf)
2515 struct elf_link_hash_entry *h;
2516 PTR inf;
5bd4f169 2517{
65f38f15
AM
2518 struct bfd_link_info *info;
2519 struct ppc_link_hash_table *htab;
5bd4f169 2520 asection *s;
65f38f15
AM
2521 struct ppc_link_hash_entry *eh;
2522 struct ppc_dyn_relocs *p;
5bd4f169 2523
65f38f15
AM
2524 if (h->root.type == bfd_link_hash_indirect
2525 || h->root.type == bfd_link_hash_warning)
2526 return true;
5bd4f169 2527
65f38f15
AM
2528 info = (struct bfd_link_info *) inf;
2529 htab = ppc_hash_table (info);
5bd4f169 2530
65f38f15
AM
2531 if (htab->elf.dynamic_sections_created
2532 && h->plt.refcount > 0)
5bd4f169 2533 {
65f38f15
AM
2534 /* Make sure this symbol is output as a dynamic symbol.
2535 Undefined weak syms won't yet be marked as dynamic. */
2536 if (h->dynindx == -1
2537 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
5bd4f169 2538 {
65f38f15
AM
2539 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
2540 return false;
5bd4f169 2541 }
5bd4f169 2542
65f38f15
AM
2543 BFD_ASSERT (h->root.root.string[0] == '.'
2544 && h->root.root.string[1] != '\0');
5bd4f169 2545
65f38f15
AM
2546 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
2547 {
2548 /* Make sure the corresponding function descriptor symbol is
2549 dynamic too. */
2550
2551 if (h->dynindx != -1)
2552 {
2553 struct elf_link_hash_entry *fdh;
5bd4f169 2554
65f38f15
AM
2555 fdh = elf_link_hash_lookup (elf_hash_table (info),
2556 h->root.root.string + 1,
2557 false, false, false);
5bd4f169 2558
65f38f15
AM
2559 if (fdh == NULL)
2560 abort ();
5bd4f169 2561
65f38f15
AM
2562 if (fdh->dynindx == -1
2563 && (fdh->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
2564 {
2565 if (! bfd_elf64_link_record_dynamic_symbol (info, fdh))
2566 return false;
2567 }
2568 }
2569
2570 /* If this is the first .plt entry, make room for the special
2571 first entry. */
2572 s = htab->splt;
5bd4f169 2573 if (s->_raw_size == 0)
65f38f15
AM
2574 s->_raw_size += PLT_INITIAL_ENTRY_SIZE;
2575
2576 h->plt.offset = s->_raw_size;
2577
2578 /* Make room for this entry. */
2579 s->_raw_size += PLT_ENTRY_SIZE;
2580
2581 /* Point the function at the linkage stub. This works because
2582 the only references to the function code sym are calls.
2583 Function pointer comparisons use the function descriptor. */
2584 s = htab->sglink;
2585 h->root.type = bfd_link_hash_defined;
2586 h->root.u.def.section = s;
2587 h->root.u.def.value = s->_raw_size;
2588 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
2589
2590 /* Make room for global linkage code in .glink. */
2591 s->_raw_size += PPC64_ELF_GLINK_SIZE;
2592
2593 /* We also need to make an entry in the .rela.plt section. */
2594 s = htab->srelplt;
2595 s->_raw_size += sizeof (Elf64_External_Rela);
2596 }
2597 else
2598 {
2599 h->plt.offset = (bfd_vma) -1;
2600 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
2601 }
2602 }
2603 else
2604 {
2605 h->plt.offset = (bfd_vma) -1;
2606 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
2607 }
2608
2609 if (h->got.refcount > 0)
2610 {
2611 boolean dyn;
2612
2613 /* Make sure this symbol is output as a dynamic symbol.
2614 Undefined weak syms won't yet be marked as dynamic. */
2615 if (h->dynindx == -1
2616 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
2617 {
2618 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
2619 return false;
2620 }
2621
2622 s = htab->sgot;
2623 h->got.offset = s->_raw_size;
2624 s->_raw_size += 8;
2625 dyn = htab->elf.dynamic_sections_created;
2626 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))
2627 htab->srelgot->_raw_size += sizeof (Elf64_External_Rela);
2628 }
2629 else
2630 h->got.offset = (bfd_vma) -1;
2631
2632 eh = (struct ppc_link_hash_entry *) h;
2633 if (eh->dyn_relocs == NULL)
2634 return true;
2635
2636 /* In the shared -Bsymbolic case, discard space allocated for
2637 dynamic pc-relative relocs against symbols which turn out to be
2638 defined in regular objects. For the normal shared case, discard
2639 space for relocs that have become local due to symbol visibility
2640 changes. */
2641
2642 if (info->shared)
2643 {
2644 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
2645 && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
2646 || info->symbolic))
2647 {
2648 struct ppc_dyn_relocs **pp;
2649
2650 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
5bd4f169 2651 {
65f38f15
AM
2652 p->count -= p->pc_count;
2653 p->pc_count = 0;
2654 if (p->count == 0)
2655 *pp = p->next;
2656 else
2657 pp = &p->next;
5bd4f169 2658 }
65f38f15
AM
2659 }
2660 }
2661 else
2662 {
2663 /* For the non-shared case, discard space for relocs against
2664 symbols which turn out to need copy relocs or are not
2665 dynamic. */
2666
2667 if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
2668 && (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
2669 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
2670 || (htab->elf.dynamic_sections_created
2671 && (h->root.type == bfd_link_hash_undefweak
2672 || h->root.type == bfd_link_hash_undefined))))
2673 {
2674 /* Make sure this symbol is output as a dynamic symbol.
2675 Undefined weak syms won't yet be marked as dynamic. */
2676 if (h->dynindx == -1
2677 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
2678 {
ec338859 2679 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
65f38f15
AM
2680 return false;
2681 }
2682
2683 /* If that succeeded, we know we'll be keeping all the
2684 relocs. */
2685 if (h->dynindx != -1)
2686 goto keep;
2687 }
2688
2689 eh->dyn_relocs = NULL;
2690
ec338859 2691 keep: ;
65f38f15
AM
2692 }
2693
2694 /* Finally, allocate space. */
2695 for (p = eh->dyn_relocs; p != NULL; p = p->next)
2696 {
2697 asection *sreloc = elf_section_data (p->sec)->sreloc;
2698 sreloc->_raw_size += p->count * sizeof (Elf64_External_Rela);
2699 }
2700
2701 return true;
2702}
2703
2704/* Find any dynamic relocs that apply to read-only sections. */
2705
2706static boolean
2707readonly_dynrelocs (h, inf)
2708 struct elf_link_hash_entry *h;
2709 PTR inf;
2710{
2711 struct ppc_link_hash_entry *eh;
2712 struct ppc_dyn_relocs *p;
2713
2714 eh = (struct ppc_link_hash_entry *) h;
2715 for (p = eh->dyn_relocs; p != NULL; p = p->next)
2716 {
2717 asection *s = p->sec->output_section;
2718
2719 if (s != NULL && (s->flags & SEC_READONLY) != 0)
2720 {
2721 struct bfd_link_info *info = (struct bfd_link_info *) inf;
2722
2723 info->flags |= DF_TEXTREL;
2724
2725 /* Not an error, just cut short the traversal. */
2726 return false;
2727 }
2728 }
2729 return true;
2730}
2731
2732/* Set the sizes of the dynamic sections. */
2733
2734static boolean
2735ppc64_elf_size_dynamic_sections (output_bfd, info)
2736 bfd *output_bfd ATTRIBUTE_UNUSED;
2737 struct bfd_link_info *info;
2738{
2739 struct ppc_link_hash_table *htab;
2740 bfd *dynobj;
2741 asection *s;
2742 boolean relocs;
2743 bfd *ibfd;
2744
2745 htab = ppc_hash_table (info);
2746 dynobj = htab->elf.dynobj;
2747 if (dynobj == NULL)
2748 abort ();
2749
2750 if (htab->elf.dynamic_sections_created)
2751 {
2752 /* Set the contents of the .interp section to the interpreter. */
2753 if (! info->shared)
2754 {
2755 s = bfd_get_section_by_name (dynobj, ".interp");
2756 if (s == NULL)
2757 abort ();
2758 s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
2759 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
2760 }
2761 }
2762
2763 /* Set up .got offsets for local syms, and space for local dynamic
2764 relocs. */
2765 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
2766 {
2767 bfd_signed_vma *local_got;
2768 bfd_signed_vma *end_local_got;
2769 bfd_size_type locsymcount;
2770 Elf_Internal_Shdr *symtab_hdr;
2771 asection *srel;
2772
2773 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
2774 continue;
2775
2776 for (s = ibfd->sections; s != NULL; s = s->next)
2777 {
ec338859 2778 struct ppc_dyn_relocs *p;
65f38f15 2779
ec338859
AM
2780 for (p = *((struct ppc_dyn_relocs **)
2781 &elf_section_data (s)->local_dynrel);
2782 p != NULL;
2783 p = p->next)
65f38f15 2784 {
ec338859
AM
2785 if (!bfd_is_abs_section (p->sec)
2786 && bfd_is_abs_section (p->sec->output_section))
2787 {
2788 /* Input section has been discarded, either because
2789 it is a copy of a linkonce section or due to
2790 linker script /DISCARD/, so we'll be discarding
2791 the relocs too. */
2792 }
2793 else
2794 {
2795 srel = elf_section_data (p->sec)->sreloc;
2796 srel->_raw_size += p->count * sizeof (Elf64_External_Rela);
2797 }
65f38f15
AM
2798 }
2799 }
2800
2801 local_got = elf_local_got_refcounts (ibfd);
2802 if (!local_got)
2803 continue;
2804
2805 symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
2806 locsymcount = symtab_hdr->sh_info;
2807 end_local_got = local_got + locsymcount;
2808 s = htab->sgot;
2809 srel = htab->srelgot;
2810 for (; local_got < end_local_got; ++local_got)
2811 {
2812 if (*local_got > 0)
5bd4f169 2813 {
65f38f15
AM
2814 *local_got = s->_raw_size;
2815 s->_raw_size += 8;
2816 if (info->shared)
2817 srel->_raw_size += sizeof (Elf64_External_Rela);
5bd4f169 2818 }
65f38f15
AM
2819 else
2820 *local_got = (bfd_vma) -1;
2821 }
2822 }
2823
2824 /* Allocate global sym .plt and .got entries, and space for global
2825 sym dynamic relocs. */
2826 elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
2827
2828 /* We now have determined the sizes of the various dynamic sections.
2829 Allocate memory for them. */
2830 relocs = false;
2831 for (s = dynobj->sections; s != NULL; s = s->next)
2832 {
2833 if ((s->flags & SEC_LINKER_CREATED) == 0)
2834 continue;
2835
2836 if (s == htab->splt
2837 || s == htab->sgot
2838 || s == htab->sglink)
2839 {
2840 /* Strip this section if we don't need it; see the
2841 comment below. */
5bd4f169 2842 }
65f38f15 2843 else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
5bd4f169
AM
2844 {
2845 if (s->_raw_size == 0)
2846 {
2847 /* If we don't need this section, strip it from the
2848 output file. This is mostly to handle .rela.bss and
2849 .rela.plt. We must create both sections in
2850 create_dynamic_sections, because they must be created
2851 before the linker maps input sections to output
2852 sections. The linker does that before
2853 adjust_dynamic_symbol is called, and it is that
2854 function which decides whether anything needs to go
2855 into these sections. */
5bd4f169
AM
2856 }
2857 else
2858 {
65f38f15
AM
2859 if (s != htab->srelplt)
2860 relocs = true;
5bd4f169
AM
2861
2862 /* We use the reloc_count field as a counter if we need
2863 to copy relocs into the output file. */
2864 s->reloc_count = 0;
2865 }
2866 }
65f38f15 2867 else
5bd4f169
AM
2868 {
2869 /* It's not one of our sections, so don't allocate space. */
2870 continue;
2871 }
2872
65f38f15 2873 if (s->_raw_size == 0)
5bd4f169
AM
2874 {
2875 _bfd_strip_section_from_output (info, s);
2876 continue;
2877 }
2878
65f38f15
AM
2879 /* Allocate memory for the section contents. We use bfd_zalloc
2880 here in case unused entries are not reclaimed before the
2881 section's contents are written out. This should not happen,
2882 but this way if it does, we get a R_PPC64_NONE reloc instead
2883 of garbage. */
5bd4f169 2884 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
65f38f15 2885 if (s->contents == NULL)
5bd4f169
AM
2886 return false;
2887 }
2888
2889 if (elf_hash_table (info)->dynamic_sections_created)
2890 {
2891 /* Add some entries to the .dynamic section. We fill in the
2892 values later, in ppc64_elf_finish_dynamic_sections, but we
2893 must add the entries now so that we get the correct size for
2894 the .dynamic section. The DT_DEBUG entry is filled in by the
2895 dynamic linker and used by the debugger. */
dc810e39
AM
2896#define add_dynamic_entry(TAG, VAL) \
2897 bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
2898
2899 if (!info->shared)
5bd4f169 2900 {
dc810e39 2901 if (!add_dynamic_entry (DT_DEBUG, 0))
5bd4f169
AM
2902 return false;
2903 }
2904
65f38f15 2905 if (htab->splt->_raw_size != 0)
5bd4f169 2906 {
dc810e39
AM
2907 if (!add_dynamic_entry (DT_PLTGOT, 0)
2908 || !add_dynamic_entry (DT_PLTRELSZ, 0)
2909 || !add_dynamic_entry (DT_PLTREL, DT_RELA)
2910 || !add_dynamic_entry (DT_JMPREL, 0))
5bd4f169
AM
2911 return false;
2912 }
2913
2914 if (relocs)
2915 {
dc810e39
AM
2916 if (!add_dynamic_entry (DT_RELA, 0)
2917 || !add_dynamic_entry (DT_RELASZ, 0)
2918 || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
5bd4f169 2919 return false;
5bd4f169 2920
65f38f15
AM
2921 /* If any dynamic relocs apply to a read-only section,
2922 then we need a DT_TEXTREL entry. */
2923 elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, (PTR) info);
5bd4f169 2924
65f38f15 2925 if ((info->flags & DF_TEXTREL) != 0)
5bd4f169 2926 {
65f38f15
AM
2927 if (!add_dynamic_entry (DT_TEXTREL, 0))
2928 return false;
5bd4f169 2929 }
5bd4f169 2930 }
5bd4f169 2931 }
65f38f15 2932#undef add_dynamic_entry
5bd4f169
AM
2933
2934 return true;
2935}
2936
2937/* Called after we have seen all the input files/sections, but before
2938 final symbol resolution and section placement has been determined.
2939
2940 We use this hook to provide a value for TOCstart, which we store in
2941 the output bfd elf_gp, then we call the generic ELF final link
2942 routine. */
2943
2944static boolean
2945ppc64_elf_final_link (abfd, info)
2946 bfd *abfd;
2947 struct bfd_link_info *info;
2948{
2949 if (! info->relocateable)
2950 {
2951 asection *s;
2952 bfd_vma TOCstart;
2953
2954 /* The TOC consists of sections .got, .toc, .tocbss, .plt in this
2955 order. The TOC starts where the first of these sections starts. */
2956 s = bfd_get_section_by_name (abfd, ".got");
2957 if (s == NULL)
2958 s = bfd_get_section_by_name (abfd, ".toc");
2959 if (s == NULL)
2960 s = bfd_get_section_by_name (abfd, ".tocbss");
2961 if (s == NULL)
2962 s = bfd_get_section_by_name (abfd, ".plt");
2963 if (s == NULL)
2964 {
2965 /* This may happen for
2966 o references to TOC base (SYM@toc / TOC[tc0]) without a
2967 .toc directive
2968 o bad linker script
2969 o --gc-sections and empty TOC sections
2970
2971 FIXME: Warn user? */
2972
2973 /* Look for a likely section. We probably won't even be
2974 using TOCstart. */
2975 for (s = abfd->sections; s != NULL; s = s->next)
2976 if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA | SEC_READONLY))
2977 == (SEC_ALLOC | SEC_SMALL_DATA))
2978 break;
2979 if (s == NULL)
2980 for (s = abfd->sections; s != NULL; s = s->next)
2981 if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA))
2982 == (SEC_ALLOC | SEC_SMALL_DATA))
2983 break;
2984 if (s == NULL)
2985 for (s = abfd->sections; s != NULL; s = s->next)
2986 if ((s->flags & (SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC)
2987 break;
2988 if (s == NULL)
2989 for (s = abfd->sections; s != NULL; s = s->next)
2990 if ((s->flags & SEC_ALLOC) == SEC_ALLOC)
2991 break;
2992 }
2993
2994 TOCstart = 0;
2995 if (s != NULL)
2996 TOCstart = s->output_section->vma + s->output_offset;
2997
2998 elf_gp (abfd) = TOCstart;
2999 }
3000
65f38f15
AM
3001 /* Invoke the regular ELF backend linker to do all the work. */
3002 return bfd_elf64_bfd_final_link (abfd, info);
5bd4f169
AM
3003}
3004
3005/* Set up any other section flags and such that may be necessary. */
3006
3007static boolean
3008ppc64_elf_fake_sections (abfd, shdr, asect)
3009 bfd *abfd ATTRIBUTE_UNUSED;
3010 Elf64_Internal_Shdr *shdr;
3011 asection *asect;
3012{
3013 if ((asect->flags & SEC_EXCLUDE) != 0)
3014 shdr->sh_flags |= SHF_EXCLUDE;
3015
3016 if ((asect->flags & SEC_SORT_ENTRIES) != 0)
3017 shdr->sh_type = SHT_ORDERED;
3018
3019 return true;
3020}
3021
3022/* The RELOCATE_SECTION function is called by the ELF backend linker
3023 to handle the relocations for a section.
3024
3025 The relocs are always passed as Rela structures; if the section
3026 actually uses Rel structures, the r_addend field will always be
3027 zero.
3028
3029 This function is responsible for adjust the section contents as
3030 necessary, and (if using Rela relocs and generating a
3031 relocateable output file) adjusting the reloc addend as
3032 necessary.
3033
3034 This function does not have to worry about setting the reloc
3035 address or the reloc symbol index.
3036
3037 LOCAL_SYMS is a pointer to the swapped in local symbols.
3038
3039 LOCAL_SECTIONS is an array giving the section in the input file
3040 corresponding to the st_shndx field of each local symbol.
3041
3042 The global hash table entry for the global symbols can be found
3043 via elf_sym_hashes (input_bfd).
3044
3045 When generating relocateable output, this function must handle
3046 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
3047 going to be the section symbol corresponding to the output
3048 section, which means that the addend must be adjusted
3049 accordingly. */
3050
3051static boolean
3052ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
3053 contents, relocs, local_syms, local_sections)
3054 bfd *output_bfd;
3055 struct bfd_link_info *info;
3056 bfd *input_bfd;
3057 asection *input_section;
3058 bfd_byte *contents;
3059 Elf_Internal_Rela *relocs;
3060 Elf_Internal_Sym *local_syms;
3061 asection **local_sections;
3062{
65f38f15 3063 struct ppc_link_hash_table *htab;
5bd4f169
AM
3064 Elf_Internal_Shdr *symtab_hdr;
3065 struct elf_link_hash_entry **sym_hashes;
5bd4f169
AM
3066 Elf_Internal_Rela *rel;
3067 Elf_Internal_Rela *relend;
5bd4f169
AM
3068 bfd_vma *local_got_offsets;
3069 bfd_vma TOCstart;
3070 boolean ret = true;
5bd4f169 3071
65f38f15 3072 /* Initialize howto table if needed. */
5bd4f169 3073 if (!ppc64_elf_howto_table[R_PPC64_ADDR32])
5bd4f169
AM
3074 ppc_howto_init ();
3075
65f38f15 3076 htab = ppc_hash_table (info);
5bd4f169 3077 local_got_offsets = elf_local_got_offsets (input_bfd);
5bd4f169 3078 TOCstart = elf_gp (output_bfd);
5bd4f169
AM
3079 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
3080 sym_hashes = elf_sym_hashes (input_bfd);
65f38f15 3081
5bd4f169
AM
3082 rel = relocs;
3083 relend = relocs + input_section->reloc_count;
3084 for (; rel < relend; rel++)
3085 {
3086 enum elf_ppc_reloc_type r_type;
3087 bfd_vma offset;
3088 bfd_vma addend;
3089 bfd_reloc_status_type r;
3090 Elf_Internal_Sym *sym;
3091 asection *sec;
3092 struct elf_link_hash_entry *h;
3093 const char *sym_name;
5bd4f169
AM
3094 unsigned long r_symndx;
3095 bfd_vma relocation;
65f38f15 3096 boolean unresolved_reloc;
dc810e39 3097 long insn;
5bd4f169
AM
3098
3099 r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
5bd4f169
AM
3100 r_symndx = ELF64_R_SYM (rel->r_info);
3101
3102 if (info->relocateable)
3103 {
3104 /* This is a relocatable link. We don't have to change
3105 anything, unless the reloc is against a section symbol,
3106 in which case we have to adjust according to where the
3107 section symbol winds up in the output section. */
3108 if (r_symndx < symtab_hdr->sh_info)
3109 {
3110 sym = local_syms + r_symndx;
3111 if ((unsigned) ELF_ST_TYPE (sym->st_info) == STT_SECTION)
3112 {
3113 sec = local_sections[r_symndx];
65f38f15 3114 rel->r_addend += sec->output_offset + sym->st_value;
5bd4f169
AM
3115 }
3116 }
5bd4f169
AM
3117 continue;
3118 }
3119
3120 /* This is a final link. */
3121
65f38f15
AM
3122 offset = rel->r_offset;
3123 addend = rel->r_addend;
3124 r = bfd_reloc_other;
3125 sym = (Elf_Internal_Sym *) 0;
3126 sec = (asection *) 0;
3127 h = (struct elf_link_hash_entry *) 0;
3128 sym_name = (const char *) 0;
3129 unresolved_reloc = false;
3130
5bd4f169
AM
3131 if (r_type == R_PPC64_TOC)
3132 {
3133 /* Relocation value is TOC base. Symbol is ignored. */
3134 relocation = TOCstart + TOC_BASE_OFF;
3135 }
3136 else if (r_symndx < symtab_hdr->sh_info)
3137 {
3138 /* It's a local symbol. */
3139 sym = local_syms + r_symndx;
3140 sec = local_sections[r_symndx];
3141 sym_name = "<local symbol>";
3142
3143 relocation = (sec->output_section->vma
3144 + sec->output_offset
3145 + sym->st_value);
3146 }
3147 else
3148 {
3149 /* It's a global symbol. */
3150 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
3151 while (h->root.type == bfd_link_hash_indirect
3152 || h->root.type == bfd_link_hash_warning)
3153 h = (struct elf_link_hash_entry *) h->root.u.i.link;
3154 sym_name = h->root.root.string;
65f38f15 3155 relocation = 0;
5bd4f169
AM
3156 if (h->root.type == bfd_link_hash_defined
3157 || h->root.type == bfd_link_hash_defweak)
3158 {
3159 sec = h->root.u.def.section;
65f38f15
AM
3160 if (sec->output_section == NULL)
3161 /* Set a flag that will be cleared later if we find a
3162 relocation value for this symbol. output_section
3163 is typically NULL for symbols satisfied by a shared
3164 library. */
3165 unresolved_reloc = true;
5bd4f169
AM
3166 else
3167 relocation = (h->root.u.def.value
3168 + sec->output_section->vma
3169 + sec->output_offset);
3170 }
3171 else if (h->root.type == bfd_link_hash_undefweak)
65f38f15 3172 ;
671bae9c 3173 else if (info->shared
65f38f15
AM
3174 && (!info->symbolic || info->allow_shlib_undefined)
3175 && !info->no_undefined
3176 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
3177 ;
5bd4f169
AM
3178 else
3179 {
3180 if (! ((*info->callbacks->undefined_symbol)
3181 (info, h->root.root.string, input_bfd, input_section,
65f38f15
AM
3182 offset, (!info->shared
3183 || info->no_undefined
3184 || ELF_ST_VISIBILITY (h->other)))))
5bd4f169
AM
3185 return false;
3186 relocation = 0;
3187 }
3188 }
3189
65f38f15 3190 /* First handle relocations that tweak non-addend part of insn. */
86c76c7b 3191 insn = 0;
65f38f15 3192 switch (r_type)
5bd4f169
AM
3193 {
3194 default:
65f38f15 3195 break;
5bd4f169 3196
65f38f15
AM
3197 /* Branch taken prediction relocations. */
3198 case R_PPC64_ADDR14_BRTAKEN:
3199 case R_PPC64_REL14_BRTAKEN:
86c76c7b
AM
3200 insn = 0x01 << 21; /* Set 't' bit, lowest bit of BO field. */
3201 /* Fall thru. */
65f38f15 3202
86c76c7b 3203 /* Branch not taken prediction relocations. */
65f38f15
AM
3204 case R_PPC64_ADDR14_BRNTAKEN:
3205 case R_PPC64_REL14_BRNTAKEN:
86c76c7b
AM
3206 insn |= bfd_get_32 (output_bfd, contents + offset) & ~(0x01 << 21);
3207 /* Set 'a' bit. This is 0b00010 in BO field for branch on CR(BI)
3208 insns (BO == 001at or 011at), and 0b01000 for branch on CTR
3209 insns (BO == 1a00t or 1a01t). */
3210 if ((insn & (0x14 << 21)) == (0x04 << 21))
3211 insn |= 0x02 << 21;
3212 else if ((insn & (0x14 << 21)) == (0x10 << 21))
3213 insn |= 0x08 << 21;
65f38f15 3214 else
86c76c7b
AM
3215 break;
3216
65f38f15
AM
3217 bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset);
3218 break;
5bd4f169 3219
65f38f15
AM
3220 case R_PPC64_REL24:
3221 case R_PPC64_ADDR24:
5bd4f169 3222 /* An ADDR24 or REL24 branching to a linkage function may be
65f38f15 3223 followed by a nop that we have to replace with a ld in
5bd4f169
AM
3224 order to restore the TOC base pointer. Only calls to
3225 shared objects need to alter the TOC base. These are
3226 recognized by their need for a PLT entry. */
3227 if (h != NULL
3228 && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0
3229 /* Make sure that there really is an instruction after
3230 the branch that we can decode. */
65f38f15 3231 && offset + 8 <= input_section->_cooked_size)
5bd4f169
AM
3232 {
3233 bfd_byte *pnext;
5bd4f169 3234
65f38f15 3235 pnext = contents + offset + 4;
5bd4f169
AM
3236 insn = bfd_get_32 (input_bfd, pnext);
3237
3238 if (insn == 0x60000000 /* nop (ori r0,r0,0) */
3239 || insn == 0x4def7b82 /* cror 15,15,15 */
dc810e39 3240 || insn == 0x4ffffb82) /* cror 31,31,31 */
5bd4f169 3241 {
dc810e39
AM
3242 bfd_put_32 (input_bfd,
3243 (bfd_vma) 0xe8410028, /* ld r2,40(r1) */
3244 pnext);
5bd4f169
AM
3245 }
3246 }
65f38f15
AM
3247 break;
3248 }
5bd4f169 3249
65f38f15
AM
3250 /* Set `addend'. */
3251 switch (r_type)
3252 {
3253 default:
3254 (*_bfd_error_handler)
3255 (_("%s: unknown relocation type %d for symbol %s"),
3256 bfd_archive_filename (input_bfd), (int) r_type, sym_name);
5bd4f169 3257
65f38f15
AM
3258 bfd_set_error (bfd_error_bad_value);
3259 ret = false;
3260 continue;
5bd4f169 3261
65f38f15
AM
3262 case R_PPC64_NONE:
3263 case R_PPC_GNU_VTINHERIT:
3264 case R_PPC_GNU_VTENTRY:
3265 continue;
5bd4f169
AM
3266
3267 /* GOT16 relocations. Like an ADDR16 using the symbol's
3268 address in the GOT as relocation value instead of the
3269 symbols value itself. Also, create a GOT entry for the
3270 symbol and put the symbol value there. */
65f38f15
AM
3271 case R_PPC64_GOT16:
3272 case R_PPC64_GOT16_LO:
3273 case R_PPC64_GOT16_HI:
3274 case R_PPC64_GOT16_HA:
3275 case R_PPC64_GOT16_DS:
3276 case R_PPC64_GOT16_LO_DS:
5bd4f169
AM
3277 {
3278 /* Relocation is to the entry for this symbol in the global
3279 offset table. */
3280 bfd_vma off;
65f38f15
AM
3281
3282 if (htab->sgot == NULL)
3283 abort ();
5bd4f169
AM
3284
3285 if (h != NULL)
3286 {
65f38f15 3287 boolean dyn;
5bd4f169 3288
65f38f15
AM
3289 off = h->got.offset;
3290 dyn = htab->elf.dynamic_sections_created;
3291 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
5bd4f169 3292 || (info->shared
65f38f15
AM
3293 && (info->symbolic
3294 || h->dynindx == -1
3295 || (h->elf_link_hash_flags
3296 & ELF_LINK_FORCED_LOCAL))
5bd4f169
AM
3297 && (h->elf_link_hash_flags
3298 & ELF_LINK_HASH_DEF_REGULAR)))
3299 {
3300 /* This is actually a static link, or it is a
3301 -Bsymbolic link and the symbol is defined
65f38f15
AM
3302 locally, or the symbol was forced to be local
3303 because of a version file. We must initialize
3304 this entry in the global offset table. Since the
3305 offset must always be a multiple of 8, we use the
3306 least significant bit to record whether we have
5bd4f169
AM
3307 initialized it already.
3308
65f38f15 3309 When doing a dynamic link, we create a .rel.got
5bd4f169
AM
3310 relocation entry to initialize the value. This
3311 is done in the finish_dynamic_symbol routine. */
3312 if ((off & 1) != 0)
3313 off &= ~1;
3314 else
3315 {
3316 bfd_put_64 (output_bfd, relocation,
65f38f15 3317 htab->sgot->contents + off);
5bd4f169
AM
3318 h->got.offset |= 1;
3319 }
3320 }
65f38f15
AM
3321 else
3322 unresolved_reloc = false;
5bd4f169
AM
3323 }
3324 else
3325 {
65f38f15
AM
3326 if (local_got_offsets == NULL)
3327 abort ();
5bd4f169
AM
3328
3329 off = local_got_offsets[r_symndx];
3330
65f38f15 3331 /* The offset must always be a multiple of 8. We use
5bd4f169
AM
3332 the least significant bit to record whether we have
3333 already processed this entry. */
3334 if ((off & 1) != 0)
3335 off &= ~1;
3336 else
3337 {
65f38f15
AM
3338 bfd_put_64 (output_bfd, relocation,
3339 htab->sgot->contents + off);
5bd4f169
AM
3340
3341 if (info->shared)
3342 {
5bd4f169 3343 Elf_Internal_Rela outrel;
65f38f15 3344 Elf64_External_Rela *loc;
5bd4f169
AM
3345
3346 /* We need to generate a R_PPC64_RELATIVE reloc
3347 for the dynamic linker. */
65f38f15
AM
3348 outrel.r_offset = (htab->sgot->output_section->vma
3349 + htab->sgot->output_offset
5bd4f169
AM
3350 + off);
3351 outrel.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE);
3352 outrel.r_addend = relocation;
65f38f15
AM
3353 loc = (Elf64_External_Rela *) htab->srelgot->contents;
3354 loc += htab->srelgot->reloc_count++;
3355 bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
5bd4f169
AM
3356 }
3357
3358 local_got_offsets[r_symndx] |= 1;
3359 }
3360 }
3361
65f38f15
AM
3362 if (off >= (bfd_vma) -2)
3363 abort ();
3364
3365 relocation = htab->sgot->output_offset + off;
3366
5bd4f169
AM
3367 /* TOC base (r2) is TOC start plus 0x8000. */
3368 addend -= TOC_BASE_OFF;
5bd4f169 3369 }
65f38f15
AM
3370 break;
3371
3372 case R_PPC64_PLT16_HA:
3373 case R_PPC64_PLT16_HI:
3374 case R_PPC64_PLT16_LO:
3375 case R_PPC64_PLT32:
3376 case R_PPC64_PLT64:
3377 /* Relocation is to the entry for this symbol in the
3378 procedure linkage table. */
3379
3380 /* Resolve a PLT reloc against a local symbol directly,
3381 without using the procedure linkage table. */
3382 if (h == NULL)
3383 break;
3384
3385 if (h->plt.offset == (bfd_vma) -1
3386 || htab->splt == NULL)
3387 {
3388 /* We didn't make a PLT entry for this symbol. This
3389 happens when statically linking PIC code, or when
3390 using -Bsymbolic. */
3391 break;
3392 }
3393
3394 relocation = (htab->splt->output_section->vma
3395 + htab->splt->output_offset
3396 + h->plt.offset);
3397 unresolved_reloc = false;
3398 break;
5bd4f169
AM
3399
3400 /* TOC16 relocs. We want the offset relative to the TOC base,
3401 which is the address of the start of the TOC plus 0x8000.
3402 The TOC consists of sections .got, .toc, .tocbss, and .plt,
3403 in this order. */
3404
65f38f15
AM
3405 case R_PPC64_TOC16:
3406 case R_PPC64_TOC16_LO:
3407 case R_PPC64_TOC16_HI:
3408 case R_PPC64_TOC16_DS:
3409 case R_PPC64_TOC16_LO_DS:
3410 case R_PPC64_TOC16_HA:
5bd4f169 3411 /* Only .got, .toc and *UND* symbols are allowed. */
65f38f15
AM
3412 BFD_ASSERT (sec != (asection *) 0
3413 && (bfd_is_und_section (sec)
3414 || strcmp (bfd_get_section_name (abfd, sec),
3415 ".toc") == 0
3416 || strcmp (bfd_get_section_name (abfd, sec),
3417 ".got") == 0));
5bd4f169
AM
3418
3419 addend -= TOCstart + TOC_BASE_OFF;
5bd4f169
AM
3420 break;
3421
3422 /* Relocate against the beginning of the section. */
65f38f15
AM
3423 case R_PPC64_SECTOFF:
3424 case R_PPC64_SECTOFF_LO:
3425 case R_PPC64_SECTOFF_HI:
3426 case R_PPC64_SECTOFF_DS:
3427 case R_PPC64_SECTOFF_LO_DS:
3428 case R_PPC64_SECTOFF_HA:
3429 if (sec != (asection *) 0)
3430 addend -= sec->output_section->vma;
5bd4f169
AM
3431 break;
3432
65f38f15
AM
3433 /* Relocations that may need to be propagated if this is a
3434 dynamic object. */
3435 case R_PPC64_REL14:
3436 case R_PPC64_REL14_BRNTAKEN:
3437 case R_PPC64_REL14_BRTAKEN:
3438 case R_PPC64_REL24:
3439 case R_PPC64_REL32:
3440 case R_PPC64_REL64:
3441 case R_PPC64_ADDR14:
3442 case R_PPC64_ADDR14_BRNTAKEN:
3443 case R_PPC64_ADDR14_BRTAKEN:
3444 case R_PPC64_ADDR16:
3445 case R_PPC64_ADDR16_DS:
3446 case R_PPC64_ADDR16_HA:
3447 case R_PPC64_ADDR16_HI:
3448 case R_PPC64_ADDR16_HIGHER:
3449 case R_PPC64_ADDR16_HIGHERA:
3450 case R_PPC64_ADDR16_HIGHEST:
3451 case R_PPC64_ADDR16_HIGHESTA:
3452 case R_PPC64_ADDR16_LO:
3453 case R_PPC64_ADDR16_LO_DS:
3454 case R_PPC64_ADDR24:
3455 case R_PPC64_ADDR30:
3456 case R_PPC64_ADDR32:
3457 case R_PPC64_ADDR64:
3458 case R_PPC64_UADDR16:
3459 case R_PPC64_UADDR32:
3460 case R_PPC64_UADDR64:
3461 case R_PPC64_TOC:
ec338859
AM
3462 /* r_symndx will be zero only for relocs against symbols
3463 from removed linkonce sections, or sections discarded by
3464 a linker script. */
3465 if (r_symndx == 0
3466 || (input_section->flags & SEC_ALLOC) == 0)
3467 break;
3468
65f38f15 3469 if ((info->shared
65f38f15
AM
3470 && (IS_ABSOLUTE_RELOC (r_type)
3471 || (h != NULL
3472 && h->dynindx != -1
3473 && (! info->symbolic
3474 || (h->elf_link_hash_flags
3475 & ELF_LINK_HASH_DEF_REGULAR) == 0))))
3476 || (!info->shared
65f38f15
AM
3477 && h != NULL
3478 && h->dynindx != -1
3479 && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
3480 && (((h->elf_link_hash_flags
3481 & ELF_LINK_HASH_DEF_DYNAMIC) != 0
3482 && (h->elf_link_hash_flags
3483 & ELF_LINK_HASH_DEF_REGULAR) == 0)
3484 || h->root.type == bfd_link_hash_undefweak
3485 || h->root.type == bfd_link_hash_undefined)))
3486 {
3487 Elf_Internal_Rela outrel;
3488 boolean skip, relocate;
3489 asection *sreloc;
3490 Elf64_External_Rela *loc;
3491
3492 /* When generating a dynamic object, these relocations
3493 are copied into the output file to be resolved at run
3494 time. */
3495
3496 skip = false;
3497
3498 if (elf_section_data (input_section)->stab_info == NULL)
3499 outrel.r_offset = offset;
3500 else
3501 {
3502 bfd_vma off;
3503
3504 off = (_bfd_stab_section_offset
3505 (output_bfd, htab->elf.stab_info, input_section,
3506 &elf_section_data (input_section)->stab_info,
3507 offset));
3508 if (off == (bfd_vma) -1)
3509 skip = true;
3510 outrel.r_offset = off;
3511 }
3512
3513 outrel.r_offset += (input_section->output_section->vma
3514 + input_section->output_offset);
3515 outrel.r_addend = addend;
3516
3517 if (skip)
3518 {
3519 relocate = false;
3520 memset (&outrel, 0, sizeof outrel);
3521 }
3522 else if (h != NULL
3523 && h->dynindx != -1
3524 && (!IS_ABSOLUTE_RELOC (r_type)
3525 || !info->shared
3526 || !info->symbolic
3527 || (h->elf_link_hash_flags
3528 & ELF_LINK_HASH_DEF_REGULAR) == 0))
3529 {
3530 relocate = false;
3531 outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
3532 }
3533 else
3534 {
3535 /* This symbol is local, or marked to become local. */
3536 outrel.r_addend += relocation;
3537 relocate = true;
3538 if (r_type == R_PPC64_ADDR64)
3539 {
3540 outrel.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE);
3541 }
3542 else
3543 {
3544 long indx = 0;
3545
3546 if (r_type == R_PPC64_TOC || bfd_is_abs_section (sec))
3547 ;
3548 else if (sec == NULL || sec->owner == NULL)
3549 {
3550 bfd_set_error (bfd_error_bad_value);
3551 return false;
3552 }
3553 else
3554 {
3555 asection *osec;
3556
3557 osec = sec->output_section;
3558 indx = elf_section_data (osec)->dynindx;
3559
3560 /* We are turning this relocation into one
3561 against a section symbol, so subtract out
3562 the output section's address but not the
3563 offset of the input section in the output
3564 section. */
3565 outrel.r_addend -= osec->vma;
3566 }
3567
3568 outrel.r_info = ELF64_R_INFO (indx, r_type);
3569 }
3570 }
3571
3572 sreloc = elf_section_data (input_section)->sreloc;
3573 if (sreloc == NULL)
3574 abort ();
3575
3576 loc = (Elf64_External_Rela *) sreloc->contents;
3577 loc += sreloc->reloc_count++;
3578 bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
3579
3580 /* If this reloc is against an external symbol, it will
3581 be computed at runtime, so there's no need to do
3582 anything now. */
3583 if (! relocate)
3584 continue;
3585 }
5bd4f169
AM
3586 break;
3587
65f38f15
AM
3588 case R_PPC64_COPY:
3589 case R_PPC64_GLOB_DAT:
3590 case R_PPC64_JMP_SLOT:
3591 case R_PPC64_RELATIVE:
3592 /* We shouldn't ever see these dynamic relocs in relocatable
3593 files. */
3594 /* Fall thru */
3595
3596 case R_PPC64_PLTGOT16:
3597 case R_PPC64_PLTGOT16_DS:
3598 case R_PPC64_PLTGOT16_HA:
3599 case R_PPC64_PLTGOT16_HI:
3600 case R_PPC64_PLTGOT16_LO:
3601 case R_PPC64_PLTGOT16_LO_DS:
3602 case R_PPC64_PLTREL32:
3603 case R_PPC64_PLTREL64:
3604 /* These ones haven't been implemented yet. */
3605
3606 (*_bfd_error_handler)
3607 (_("%s: Relocation %s is not supported for symbol %s."),
3608 bfd_archive_filename (input_bfd),
3609 ppc64_elf_howto_table[(int) r_type]->name, sym_name);
5bd4f169
AM
3610
3611 bfd_set_error (bfd_error_invalid_operation);
3612 ret = false;
3613 continue;
65f38f15 3614 }
5bd4f169 3615
65f38f15
AM
3616 /* Do any further special processing. */
3617 switch (r_type)
3618 {
3619 default:
3620 break;
3621
3622 case R_PPC64_ADDR16_HA:
3623 case R_PPC64_ADDR16_HIGHERA:
3624 case R_PPC64_ADDR16_HIGHESTA:
3625 case R_PPC64_PLT16_HA:
3626 case R_PPC64_TOC16_HA:
3627 case R_PPC64_SECTOFF_HA:
3628 /* It's just possible that this symbol is a weak symbol
3629 that's not actually defined anywhere. In that case,
3630 'sec' would be NULL, and we should leave the symbol
3631 alone (it will be set to zero elsewhere in the link). */
3632 if (sec != NULL)
3633 /* Add 0x10000 if sign bit in 0:15 is set. */
3634 addend += ((relocation + addend) & 0x8000) << 1;
3635 break;
3636
3637 case R_PPC64_ADDR16_DS:
3638 case R_PPC64_ADDR16_LO_DS:
3639 case R_PPC64_GOT16_DS:
3640 case R_PPC64_GOT16_LO_DS:
3641 case R_PPC64_PLT16_LO_DS:
3642 case R_PPC64_SECTOFF_DS:
3643 case R_PPC64_SECTOFF_LO_DS:
3644 case R_PPC64_TOC16_DS:
3645 case R_PPC64_TOC16_LO_DS:
3646 case R_PPC64_PLTGOT16_DS:
3647 case R_PPC64_PLTGOT16_LO_DS:
3648 if (((relocation + addend) & 3) != 0)
3649 {
3650 (*_bfd_error_handler)
3651 (_("%s: error: relocation %s not a multiple of 4"),
3652 bfd_archive_filename (input_bfd),
3653 ppc64_elf_howto_table[(int) r_type]->name);
3654 bfd_set_error (bfd_error_bad_value);
3655 ret = false;
3656 continue;
3657 }
3658 break;
5bd4f169
AM
3659 }
3660
65f38f15
AM
3661 /* FIXME: Why do we allow debugging sections to escape this error?
3662 More importantly, why do we not emit dynamic relocs above in
3663 debugging sections (which are ! SEC_ALLOC)? If we had
3664 emitted the dynamic reloc, we could remove the fudge here. */
3665 if (unresolved_reloc
3666 && !(info->shared
3667 && (input_section->flags & SEC_DEBUGGING) != 0
3668 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
3669 (*_bfd_error_handler)
3670 (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
3671 bfd_archive_filename (input_bfd),
3672 bfd_get_section_name (input_bfd, input_section),
3673 (long) rel->r_offset,
3674 h->root.root.string);
5bd4f169 3675
65f38f15 3676 r = _bfd_final_link_relocate (ppc64_elf_howto_table[(int) r_type],
5bd4f169
AM
3677 input_bfd,
3678 input_section,
3679 contents,
3680 offset,
3681 relocation,
3682 addend);
3683
3684 if (r == bfd_reloc_ok)
3685 ;
3686 else if (r == bfd_reloc_overflow)
3687 {
3688 const char *name;
3689
3690 if (h != NULL)
3691 {
3692 if (h->root.type == bfd_link_hash_undefweak
65f38f15 3693 && ppc64_elf_howto_table[(int) r_type]->pc_relative)
5bd4f169
AM
3694 {
3695 /* Assume this is a call protected by other code that
3696 detects the symbol is undefined. If this is the case,
3697 we can safely ignore the overflow. If not, the
3698 program is hosed anyway, and a little warning isn't
3699 going to help. */
3700
3701 continue;
3702 }
3703
3704 name = h->root.root.string;
3705 }
3706 else
3707 {
3708 name = bfd_elf_string_from_elf_section (input_bfd,
3709 symtab_hdr->sh_link,
3710 sym->st_name);
3711 if (name == NULL)
3712 continue;
3713 if (*name == '\0')
3714 name = bfd_section_name (input_bfd, sec);
3715 }
3716
65f38f15
AM
3717 if (! ((*info->callbacks->reloc_overflow)
3718 (info, name, ppc64_elf_howto_table[(int) r_type]->name,
3719 (bfd_vma) 0, input_bfd, input_section, offset)))
5bd4f169
AM
3720 return false;
3721 }
3722 else
3723 ret = false;
3724 }
3725
5bd4f169
AM
3726 return ret;
3727}
3728
3729/* Finish up dynamic symbol handling. We set the contents of various
3730 dynamic sections here. */
3731
3732static boolean
3733ppc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
3734 bfd *output_bfd;
3735 struct bfd_link_info *info;
3736 struct elf_link_hash_entry *h;
3737 Elf_Internal_Sym *sym;
3738{
65f38f15 3739 struct ppc_link_hash_table *htab;
5bd4f169
AM
3740 bfd *dynobj;
3741
65f38f15
AM
3742 htab = ppc_hash_table (info);
3743 dynobj = htab->elf.dynobj;
5bd4f169
AM
3744
3745 if (h->plt.offset != (bfd_vma) -1)
3746 {
5bd4f169 3747 struct elf_link_hash_entry *funcdesc_h;
65f38f15
AM
3748 Elf_Internal_Rela rela;
3749 Elf64_External_Rela *loc;
5bd4f169
AM
3750
3751 /* This symbol has an entry in the procedure linkage table. Set
3752 it up. */
3753
65f38f15
AM
3754 if (h->dynindx == -1
3755 || htab->splt == NULL
3756 || htab->srelplt == NULL
3757 || htab->sglink == NULL
3758 || h->root.root.string[0] != '.'
3759 || h->root.root.string[1] == '\0')
3760 abort ();
3761
3762 /* Find its corresponding function descriptor.
3763 ppc64_elf_adjust_dynamic_symbol has already set it up for us. */
5bd4f169 3764
65f38f15
AM
3765 funcdesc_h = elf_link_hash_lookup (elf_hash_table (info),
3766 h->root.root.string + 1,
3767 false, false, false);
3768
3769 if (funcdesc_h == NULL || funcdesc_h->dynindx == -1)
3770 abort ();
3771
3772 /* Create a JMP_SLOT reloc to inform the dynamic linker to
3773 fill in the PLT entry. */
5bd4f169 3774
65f38f15
AM
3775 rela.r_offset = (htab->splt->output_section->vma
3776 + htab->splt->output_offset
3777 + h->plt.offset);
3778 rela.r_info = ELF64_R_INFO (funcdesc_h->dynindx, R_PPC64_JMP_SLOT);
3779 rela.r_addend = 0;
3780
3781 loc = (Elf64_External_Rela *) htab->srelplt->contents;
3782 loc += (h->plt.offset - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE;
3783 bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
5bd4f169 3784
65f38f15
AM
3785 /* We need to create a linkage function. */
3786 if (h->root.u.def.section == htab->sglink)
5bd4f169
AM
3787 {
3788 bfd_byte *p;
3789 bfd_vma pltoff;
3790 const unsigned int *stub;
3791
3792 /* Where to write it. */
3793 p = h->root.u.def.section->contents + h->root.u.def.value;
3794
3795 /* The function descriptor is in the PLT. */
65f38f15
AM
3796 pltoff = htab->splt->output_section->vma
3797 + htab->splt->output_section->output_offset
5bd4f169
AM
3798 + h->plt.offset
3799 - elf_gp (output_bfd) - TOC_BASE_OFF;
3800
3801 if (pltoff + 0x8000 > 0xffff)
3802 {
3803 (*_bfd_error_handler)
3804 (_("linkage table overflow against `%s'"),
3805 h->root.root.string);
3806 }
3807
3808 /* Write it out. */
3809 stub = ppc64_elf_glink_code;
3810 bfd_put_32 (output_bfd, *stub | (pltoff & 0xfffc), p);
3811 while (p += 4, ++stub < (ppc64_elf_glink_code
3812 + (sizeof (ppc64_elf_glink_code)
3813 / sizeof (*ppc64_elf_glink_code))));
3814 {
dc810e39 3815 bfd_put_32 (output_bfd, (bfd_vma) *stub, p);
5bd4f169 3816 }
5bd4f169 3817 }
65f38f15
AM
3818 else
3819 abort ();
5bd4f169
AM
3820 }
3821
3822 if (h->got.offset != (bfd_vma) -1)
3823 {
5bd4f169 3824 Elf_Internal_Rela rela;
65f38f15 3825 Elf64_External_Rela *loc;
5bd4f169
AM
3826
3827 /* This symbol has an entry in the global offset table. Set it
3828 up. */
3829
65f38f15
AM
3830 if (htab->sgot == NULL || htab->srelgot == NULL)
3831 abort ();
5bd4f169 3832
65f38f15
AM
3833 rela.r_offset = (htab->sgot->output_section->vma
3834 + htab->sgot->output_offset
dc810e39 3835 + (h->got.offset &~ (bfd_vma) 1));
5bd4f169 3836
65f38f15
AM
3837 /* If this is a static link, or it is a -Bsymbolic link and the
3838 symbol is defined locally or was forced to be local because
3839 of a version file, we just want to emit a RELATIVE reloc.
3840 The entry in the global offset table will already have been
3841 initialized in the relocate_section function. */
5bd4f169 3842 if (info->shared
65f38f15
AM
3843 && (info->symbolic
3844 || h->dynindx == -1
3845 || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
5bd4f169
AM
3846 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
3847 {
65f38f15 3848 BFD_ASSERT((h->got.offset & 1) != 0);
5bd4f169
AM
3849 rela.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE);
3850 rela.r_addend = (h->root.u.def.value
3851 + h->root.u.def.section->output_section->vma
3852 + h->root.u.def.section->output_offset);
3853 }
3854 else
3855 {
3856 BFD_ASSERT ((h->got.offset & 1) == 0);
65f38f15
AM
3857 bfd_put_64 (output_bfd, (bfd_vma) 0,
3858 htab->sgot->contents + h->got.offset);
5bd4f169
AM
3859 rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_GLOB_DAT);
3860 rela.r_addend = 0;
3861 }
3862
65f38f15
AM
3863 loc = (Elf64_External_Rela *) htab->srelgot->contents;
3864 loc += htab->srelgot->reloc_count++;
3865 bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
5bd4f169
AM
3866 }
3867
3868 if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
3869 {
5bd4f169 3870 Elf_Internal_Rela rela;
65f38f15 3871 Elf64_External_Rela *loc;
5bd4f169 3872
65f38f15 3873 /* This symbol needs a copy reloc. Set it up. */
5bd4f169 3874
65f38f15
AM
3875 if (h->dynindx == -1
3876 || (h->root.type != bfd_link_hash_defined
3877 && h->root.type != bfd_link_hash_defweak)
3878 || htab->srelbss == NULL)
3879 abort ();
5bd4f169
AM
3880
3881 rela.r_offset = (h->root.u.def.value
3882 + h->root.u.def.section->output_section->vma
3883 + h->root.u.def.section->output_offset);
3884 rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_COPY);
3885 rela.r_addend = 0;
65f38f15
AM
3886 loc = (Elf64_External_Rela *) htab->srelbss->contents;
3887 loc += htab->srelbss->reloc_count++;
3888 bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
5bd4f169
AM
3889 }
3890
5bd4f169
AM
3891 /* Mark some specially defined symbols as absolute. */
3892 if (strcmp (h->root.root.string, "_DYNAMIC") == 0)
3893 sym->st_shndx = SHN_ABS;
3894
3895 return true;
3896}
3897
65f38f15
AM
3898/* Used to decide how to sort relocs in an optimal manner for the
3899 dynamic linker, before writing them out. */
3900
3901static enum elf_reloc_type_class
3902ppc64_elf_reloc_type_class (rela)
3903 const Elf_Internal_Rela *rela;
3904{
a33d1f77
AM
3905 enum elf_ppc_reloc_type r_type;
3906
3907 r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rela->r_info);
3908 switch (r_type)
65f38f15
AM
3909 {
3910 case R_PPC64_RELATIVE:
3911 return reloc_class_relative;
3912 case R_PPC64_JMP_SLOT:
3913 return reloc_class_plt;
3914 case R_PPC64_COPY:
3915 return reloc_class_copy;
3916 default:
3917 return reloc_class_normal;
3918 }
3919}
3920
5bd4f169
AM
3921/* Finish up the dynamic sections. */
3922
3923static boolean
3924ppc64_elf_finish_dynamic_sections (output_bfd, info)
3925 bfd *output_bfd;
3926 struct bfd_link_info *info;
3927{
65f38f15
AM
3928 struct ppc_link_hash_table *htab;
3929 bfd *dynobj;
5bd4f169 3930 asection *sdyn;
5bd4f169 3931
65f38f15
AM
3932 htab = ppc_hash_table (info);
3933 dynobj = htab->elf.dynobj;
5bd4f169
AM
3934 sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
3935
65f38f15 3936 if (htab->elf.dynamic_sections_created)
5bd4f169 3937 {
5bd4f169
AM
3938 Elf64_External_Dyn *dyncon, *dynconend;
3939
65f38f15
AM
3940 if (sdyn == NULL || htab->sgot == NULL)
3941 abort ();
5bd4f169
AM
3942
3943 dyncon = (Elf64_External_Dyn *) sdyn->contents;
3944 dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
3945 for (; dyncon < dynconend; dyncon++)
3946 {
3947 Elf_Internal_Dyn dyn;
5bd4f169
AM
3948
3949 bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
3950
3951 switch (dyn.d_tag)
3952 {
65f38f15
AM
3953 default:
3954 continue;
5bd4f169 3955
65f38f15
AM
3956 case DT_PLTGOT:
3957 dyn.d_un.d_ptr = htab->splt->output_section->vma;
3958 break;
3959
3960 case DT_JMPREL:
3961 dyn.d_un.d_ptr = htab->srelplt->output_section->vma;
3962 break;
5bd4f169 3963
65f38f15
AM
3964 case DT_PLTRELSZ:
3965 if (htab->srelplt->output_section->_cooked_size != 0)
3966 dyn.d_un.d_val = htab->srelplt->output_section->_cooked_size;
5bd4f169 3967 else
65f38f15
AM
3968 dyn.d_un.d_val = htab->srelplt->output_section->_raw_size;
3969 break;
5bd4f169 3970 }
5bd4f169 3971
65f38f15 3972 bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
5bd4f169 3973 }
5bd4f169
AM
3974 }
3975
3976 return true;
3977}
3978
3979#define TARGET_LITTLE_SYM bfd_elf64_powerpcle_vec
3980#define TARGET_LITTLE_NAME "elf64-powerpcle"
3981#define TARGET_BIG_SYM bfd_elf64_powerpc_vec
3982#define TARGET_BIG_NAME "elf64-powerpc"
3983#define ELF_ARCH bfd_arch_powerpc
3984#define ELF_MACHINE_CODE EM_PPC64
3985#define ELF_MAXPAGESIZE 0x10000
3986#define elf_info_to_howto ppc64_elf_info_to_howto
3987
3988#ifdef EM_CYGNUS_POWERPC
3989#define ELF_MACHINE_ALT1 EM_CYGNUS_POWERPC
3990#endif
3991
3992#ifdef EM_PPC_OLD
3993#define ELF_MACHINE_ALT2 EM_PPC_OLD
3994#endif
3995
3996#define elf_backend_want_got_sym 0
3997#define elf_backend_want_plt_sym 0
3998#define elf_backend_plt_alignment 3
3999#define elf_backend_plt_not_loaded 1
4000#define elf_backend_got_symbol_offset 0
4001#define elf_backend_got_header_size 0
4002#define elf_backend_can_gc_sections 1
65f38f15 4003#define elf_backend_can_refcount 1
5bd4f169
AM
4004
4005#define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE
4006
65f38f15
AM
4007#define bfd_elf64_bfd_reloc_type_lookup ppc64_elf_reloc_type_lookup
4008#define bfd_elf64_bfd_set_private_flags ppc64_elf_set_private_flags
4009#define bfd_elf64_bfd_copy_private_bfd_data ppc64_elf_copy_private_bfd_data
4010#define bfd_elf64_bfd_merge_private_bfd_data ppc64_elf_merge_private_bfd_data
4011#define bfd_elf64_bfd_link_hash_table_create ppc64_elf_link_hash_table_create
4012#define bfd_elf64_bfd_final_link ppc64_elf_final_link
4013
4014#define elf_backend_section_from_shdr ppc64_elf_section_from_shdr
4015#define elf_backend_create_dynamic_sections ppc64_elf_create_dynamic_sections
4016#define elf_backend_copy_indirect_symbol ppc64_elf_copy_indirect_symbol
4017#define elf_backend_check_relocs ppc64_elf_check_relocs
4018#define elf_backend_gc_mark_hook ppc64_elf_gc_mark_hook
4019#define elf_backend_gc_sweep_hook ppc64_elf_gc_sweep_hook
4020#define elf_backend_adjust_dynamic_symbol ppc64_elf_adjust_dynamic_symbol
4021#define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections
4022#define elf_backend_fake_sections ppc64_elf_fake_sections
4023#define elf_backend_relocate_section ppc64_elf_relocate_section
4024#define elf_backend_finish_dynamic_symbol ppc64_elf_finish_dynamic_symbol
4025#define elf_backend_reloc_type_class ppc64_elf_reloc_type_class
4026#define elf_backend_finish_dynamic_sections ppc64_elf_finish_dynamic_sections
5bd4f169
AM
4027
4028#include "elf64-target.h"
This page took 0.220071 seconds and 4 git commands to generate.