1 /* PowerPC-specific support for 32-bit ELF
2 Copyright 1994, 1995 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 /* This file is based on a preliminary PowerPC ELF ABI. The
22 information may not match the final PowerPC ELF ABI. It includes
23 suggestions from the in-progress Embedded PowerPC ABI, and that
24 information may also not match. */
33 #define USE_RELA /* we want RELA relocations, not REL */
35 /* PowerPC relocations defined by the ABIs */
46 R_PPC_ADDR14_BRTAKEN = 8,
47 R_PPC_ADDR14_BRNTAKEN = 9,
50 R_PPC_REL14_BRTAKEN = 12,
51 R_PPC_REL14_BRNTAKEN = 13,
72 R_PPC_SECTOFF_LO = 34,
73 R_PPC_SECTOFF_HI = 35,
74 R_PPC_SECTOFF_HA = 36,
76 /* The remaining relocs are from the Embedded ELF ABI, and are not
77 in the SVR4 ELF ABI. */
78 R_PPC_EMB_NADDR32 = 101,
79 R_PPC_EMB_NADDR16 = 102,
80 R_PPC_EMB_NADDR16_LO = 103,
81 R_PPC_EMB_NADDR16_HI = 104,
82 R_PPC_EMB_NADDR16_HA = 105,
83 R_PPC_EMB_SDAI16 = 106,
84 R_PPC_EMB_SDA2I16 = 107,
85 R_PPC_EMB_SDA2REL = 108,
86 R_PPC_EMB_SDA21 = 109,
87 R_PPC_EMB_MRKREF = 110,
88 R_PPC_EMB_RELSEC16 = 111,
89 R_PPC_EMB_RELST_LO = 112,
90 R_PPC_EMB_RELST_HI = 113,
91 R_PPC_EMB_RELST_HA = 114,
92 R_PPC_EMB_BIT_FLD = 115,
93 R_PPC_EMB_RELSDA = 116,
95 /* This is a phony reloc to handle any old fashioned TOC16 references
96 that may still be in object files. */
102 static bfd_reloc_status_type ppc_elf_unsupported_reloc
103 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
104 static bfd_reloc_status_type ppc_elf_std_reloc
105 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
107 static bfd_vma ppc_elf_addr16_ha_inner PARAMS ((bfd_vma));
108 static bfd_reloc_status_type ppc_elf_addr16_ha_reloc
109 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
110 static bfd_vma ppc_elf_got16_inner PARAMS ((asection *sec));
111 static bfd_reloc_status_type ppc_elf_got16_reloc
112 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
113 static bfd_vma ppc_elf_toc16_inner PARAMS ((asection *sec));
114 static bfd_reloc_status_type ppc_elf_toc16_reloc
115 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
116 static bfd_vma ppc_elf_brtaken_inner PARAMS ((bfd_vma, enum ppc_reloc_type));
117 static bfd_reloc_status_type ppc_elf_brtaken_reloc
118 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
119 static reloc_howto_type *ppc_elf_reloc_type_lookup
120 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
121 static void ppc_elf_info_to_howto
122 PARAMS ((bfd *abfd, arelent *cache_ptr, Elf32_Internal_Rela *dst));
123 static void ppc_elf_howto_init PARAMS ((void));
124 static boolean ppc_elf_set_private_flags PARAMS ((bfd *, flagword));
125 static boolean ppc_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
126 static boolean ppc_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
128 static boolean ppc_elf_check_relocs PARAMS ((bfd *,
129 struct bfd_link_info *,
131 const Elf_Internal_Rela *));
133 static boolean ppc_elf_adjust_dynamic_symbol PARAMS ((struct bfd_link_info *,
134 struct elf_link_hash_entry *));
136 static boolean ppc_elf_adjust_dynindx PARAMS ((struct elf_link_hash_entry *, PTR));
138 static boolean ppc_elf_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
140 static boolean ppc_elf_relocate_section PARAMS ((bfd *,
141 struct bfd_link_info *info,
145 Elf_Internal_Rela *relocs,
146 Elf_Internal_Sym *local_syms,
149 static boolean ppc_elf_finish_dynamic_symbol PARAMS ((bfd *,
150 struct bfd_link_info *,
151 struct elf_link_hash_entry *,
152 Elf_Internal_Sym *));
154 static boolean ppc_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
156 #define BRANCH_PREDICT_BIT 0x200000
158 /* The name of the dynamic interpreter. This is put in the .interp
161 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
164 static reloc_howto_type *ppc_elf_howto_table[ (int)R_PPC_max ];
166 static reloc_howto_type ppc_elf_howto_raw[] =
168 /* This reloc does nothing. */
169 HOWTO (R_PPC_NONE, /* type */
171 2, /* size (0 = byte, 1 = short, 2 = long) */
173 false, /* pc_relative */
175 complain_overflow_bitfield, /* complain_on_overflow */
176 ppc_elf_std_reloc, /* special_function */
177 "R_PPC_NONE", /* name */
178 false, /* partial_inplace */
181 false), /* pcrel_offset */
183 /* A standard 32 bit relocation. */
184 HOWTO (R_PPC_ADDR32, /* type */
186 2, /* size (0 = byte, 1 = short, 2 = long) */
188 false, /* pc_relative */
190 complain_overflow_bitfield, /* complain_on_overflow */
191 ppc_elf_std_reloc, /* special_function */
192 "R_PPC_ADDR32", /* name */
193 false, /* partial_inplace */
195 0xffffffff, /* dst_mask */
196 false), /* pcrel_offset */
198 /* An absolute 26 bit branch; the lower two bits must be zero.
199 FIXME: we don't check that, we just clear them. */
200 HOWTO (R_PPC_ADDR24, /* type */
202 2, /* size (0 = byte, 1 = short, 2 = long) */
204 false, /* pc_relative */
206 complain_overflow_bitfield, /* complain_on_overflow */
207 ppc_elf_std_reloc, /* special_function */
208 "R_PPC_ADDR24", /* name */
209 false, /* partial_inplace */
211 0x3fffffc, /* dst_mask */
212 false), /* pcrel_offset */
214 /* A standard 16 bit relocation. */
215 HOWTO (R_PPC_ADDR16, /* type */
217 1, /* size (0 = byte, 1 = short, 2 = long) */
219 false, /* pc_relative */
221 complain_overflow_bitfield, /* complain_on_overflow */
222 ppc_elf_std_reloc, /* special_function */
223 "R_PPC_ADDR16", /* name */
224 false, /* partial_inplace */
226 0xffff, /* dst_mask */
227 false), /* pcrel_offset */
229 /* A 16 bit relocation without overflow. */
230 HOWTO (R_PPC_ADDR16_LO, /* type */
232 1, /* size (0 = byte, 1 = short, 2 = long) */
234 false, /* pc_relative */
236 complain_overflow_dont,/* complain_on_overflow */
237 ppc_elf_std_reloc, /* special_function */
238 "R_PPC_ADDR16_LO", /* name */
239 false, /* partial_inplace */
241 0xffff, /* dst_mask */
242 false), /* pcrel_offset */
244 /* The high order 16 bits of an address. */
245 HOWTO (R_PPC_ADDR16_HI, /* type */
247 1, /* size (0 = byte, 1 = short, 2 = long) */
249 false, /* pc_relative */
251 complain_overflow_dont, /* complain_on_overflow */
252 ppc_elf_std_reloc, /* special_function */
253 "R_PPC_ADDR16_HI", /* name */
254 false, /* partial_inplace */
256 0xffff, /* dst_mask */
257 false), /* pcrel_offset */
259 /* The high order 16 bits of an address, plus 1 if the contents of
260 the low 16 bits, treated as a signed number, is negative. */
261 HOWTO (R_PPC_ADDR16_HA, /* type */
263 1, /* size (0 = byte, 1 = short, 2 = long) */
265 false, /* pc_relative */
267 complain_overflow_dont, /* complain_on_overflow */
268 ppc_elf_addr16_ha_reloc, /* special_function */
269 "R_PPC_ADDR16_HA", /* name */
270 false, /* partial_inplace */
272 0xffff, /* dst_mask */
273 false), /* pcrel_offset */
275 /* An absolute 16 bit branch; the lower two bits must be zero.
276 FIXME: we don't check that, we just clear them. */
277 HOWTO (R_PPC_ADDR14, /* type */
279 2, /* size (0 = byte, 1 = short, 2 = long) */
281 false, /* pc_relative */
283 complain_overflow_bitfield, /* complain_on_overflow */
284 ppc_elf_std_reloc, /* special_function */
285 "R_PPC_ADDR14", /* name */
286 false, /* partial_inplace */
288 0xfffc, /* dst_mask */
289 false), /* pcrel_offset */
291 /* An absolute 16 bit branch, for which bit 10 should be set to
292 indicate that the branch is expected to be taken. The lower two
293 bits must be zero. */
294 HOWTO (R_PPC_ADDR14_BRTAKEN, /* type */
296 2, /* size (0 = byte, 1 = short, 2 = long) */
298 false, /* pc_relative */
300 complain_overflow_bitfield, /* complain_on_overflow */
301 ppc_elf_brtaken_reloc, /* special_function */
302 "R_PPC_ADDR14_BRTAKEN",/* name */
303 false, /* partial_inplace */
305 0xfffc, /* dst_mask */
306 false), /* pcrel_offset */
308 /* An absolute 16 bit branch, for which bit 10 should be set to
309 indicate that the branch is not expected to be taken. The lower
310 two bits must be zero. */
311 HOWTO (R_PPC_ADDR14_BRNTAKEN, /* type */
313 2, /* size (0 = byte, 1 = short, 2 = long) */
315 false, /* pc_relative */
317 complain_overflow_bitfield, /* complain_on_overflow */
318 ppc_elf_brtaken_reloc, /* special_function */
319 "R_PPC_ADDR14_BRNTAKEN",/* name */
320 false, /* partial_inplace */
322 0xfffc, /* dst_mask */
323 false), /* pcrel_offset */
325 /* A relative 26 bit branch; the lower two bits must be zero. */
326 HOWTO (R_PPC_REL24, /* type */
328 2, /* size (0 = byte, 1 = short, 2 = long) */
330 true, /* pc_relative */
332 complain_overflow_signed, /* complain_on_overflow */
333 ppc_elf_std_reloc, /* special_function */
334 "R_PPC_REL24", /* name */
335 false, /* partial_inplace */
337 0x3fffffc, /* dst_mask */
338 true), /* pcrel_offset */
340 /* A relative 16 bit branch; the lower two bits must be zero. */
341 HOWTO (R_PPC_REL14, /* type */
343 2, /* size (0 = byte, 1 = short, 2 = long) */
345 true, /* pc_relative */
347 complain_overflow_signed, /* complain_on_overflow */
348 ppc_elf_std_reloc, /* special_function */
349 "R_PPC_REL14", /* name */
350 false, /* partial_inplace */
352 0xfffc, /* dst_mask */
353 true), /* pcrel_offset */
355 /* A relative 16 bit branch. Bit 10 should be set to indicate that
356 the branch is expected to be taken. The lower two bits must be
358 HOWTO (R_PPC_REL14_BRTAKEN, /* type */
360 2, /* size (0 = byte, 1 = short, 2 = long) */
362 true, /* pc_relative */
364 complain_overflow_signed, /* complain_on_overflow */
365 ppc_elf_brtaken_reloc, /* special_function */
366 "R_PPC_REL14_BRTAKEN", /* name */
367 false, /* partial_inplace */
369 0xfffc, /* dst_mask */
370 true), /* pcrel_offset */
372 /* A relative 16 bit branch. Bit 10 should be set to indicate that
373 the branch is not expected to be taken. The lower two bits must
375 HOWTO (R_PPC_REL14_BRNTAKEN, /* type */
377 2, /* size (0 = byte, 1 = short, 2 = long) */
379 true, /* pc_relative */
381 complain_overflow_signed, /* complain_on_overflow */
382 ppc_elf_brtaken_reloc, /* special_function */
383 "R_PPC_REL14_BRNTAKEN",/* name */
384 false, /* partial_inplace */
386 0xfffc, /* dst_mask */
387 true), /* pcrel_offset */
389 /* Like R_PPC_ADDR16, but referring to the GOT table entry for the
391 HOWTO (R_PPC_GOT16, /* type */
393 1, /* size (0 = byte, 1 = short, 2 = long) */
395 false, /* pc_relative */
397 complain_overflow_signed, /* complain_on_overflow */
398 ppc_elf_got16_reloc, /* special_function */
399 "R_PPC_GOT16", /* name */
400 false, /* partial_inplace */
402 0xffff, /* dst_mask */
403 false), /* pcrel_offset */
405 /* Like R_PPC_ADDR16_LO, but referring to the GOT table entry for
407 HOWTO (R_PPC_GOT16_LO, /* type */
409 1, /* size (0 = byte, 1 = short, 2 = long) */
411 false, /* pc_relative */
413 complain_overflow_bitfield, /* complain_on_overflow */
414 ppc_elf_got16_reloc, /* special_function */
415 "R_PPC_GOT16_LO", /* name */
416 false, /* partial_inplace */
418 0xffff, /* dst_mask */
419 false), /* pcrel_offset */
421 /* Like R_PPC_ADDR16_HI, but referring to the GOT table entry for
423 HOWTO (R_PPC_GOT16_HI, /* type */
425 1, /* size (0 = byte, 1 = short, 2 = long) */
427 false, /* pc_relative */
429 complain_overflow_bitfield, /* complain_on_overflow */
430 ppc_elf_got16_reloc, /* special_function */
431 "R_PPC_GOT16_HI", /* name */
432 false, /* partial_inplace */
434 0xffff, /* dst_mask */
435 false), /* pcrel_offset */
437 /* Like R_PPC_ADDR16_HA, but referring to the GOT table entry for
438 the symbol. FIXME: Not supported. */
439 HOWTO (R_PPC_GOT16_HA, /* type */
441 1, /* size (0 = byte, 1 = short, 2 = long) */
443 false, /* pc_relative */
445 complain_overflow_bitfield, /* complain_on_overflow */
446 ppc_elf_unsupported_reloc, /* special_function */
447 "R_PPC_GOT16_HA", /* name */
448 false, /* partial_inplace */
450 0xffff, /* dst_mask */
451 false), /* pcrel_offset */
453 /* Like R_PPC_REL24, but referring to the procedure linkage table
454 entry for the symbol. FIXME: Not supported. */
455 HOWTO (R_PPC_PLTREL24, /* type */
457 2, /* size (0 = byte, 1 = short, 2 = long) */
459 true, /* pc_relative */
461 complain_overflow_signed, /* complain_on_overflow */
462 ppc_elf_unsupported_reloc, /* special_function */
463 "R_PPC_PLTREL24", /* name */
464 false, /* partial_inplace */
466 0x3fffffc, /* dst_mask */
467 true), /* pcrel_offset */
469 /* This is used only by the dynamic linker. The symbol should exist
470 both in the object being run and in some shared library. The
471 dynamic linker copies the data addressed by the symbol from the
472 shared library into the object. I have no idea what the purpose
474 HOWTO (R_PPC_COPY, /* type */
476 2, /* size (0 = byte, 1 = short, 2 = long) */
478 false, /* pc_relative */
480 complain_overflow_bitfield, /* complain_on_overflow */
481 ppc_elf_unsupported_reloc, /* special_function */
482 "R_PPC_COPY", /* name */
483 false, /* partial_inplace */
486 false), /* pcrel_offset */
488 /* Like R_PPC_ADDR32, but used when setting global offset table
490 HOWTO (R_PPC_GLOB_DAT, /* type */
492 2, /* size (0 = byte, 1 = short, 2 = long) */
494 false, /* pc_relative */
496 complain_overflow_bitfield, /* complain_on_overflow */
497 ppc_elf_unsupported_reloc, /* special_function */
498 "R_PPC_GLOB_DAT", /* name */
499 false, /* partial_inplace */
501 0xffffffff, /* dst_mask */
502 false), /* pcrel_offset */
504 /* Marks a procedure linkage table entry for a symbol. */
505 HOWTO (R_PPC_JMP_SLOT, /* type */
507 2, /* size (0 = byte, 1 = short, 2 = long) */
509 false, /* pc_relative */
511 complain_overflow_bitfield, /* complain_on_overflow */
512 ppc_elf_unsupported_reloc, /* special_function */
513 "R_PPC_JMP_SLOT", /* name */
514 false, /* partial_inplace */
517 false), /* pcrel_offset */
519 /* Used only by the dynamic linker. When the object is run, this
520 longword is set to the load address of the object, plus the
522 HOWTO (R_PPC_RELATIVE, /* type */
524 2, /* size (0 = byte, 1 = short, 2 = long) */
526 false, /* pc_relative */
528 complain_overflow_bitfield, /* complain_on_overflow */
529 ppc_elf_unsupported_reloc, /* special_function */
530 "R_PPC_RELATIVE", /* name */
531 false, /* partial_inplace */
533 0xffffffff, /* dst_mask */
534 false), /* pcrel_offset */
536 /* Like R_PPC_REL24, but uses the value of the symbol within the
537 object rather than the final value. Normally used for
538 _GLOBAL_OFFSET_TABLE_. FIXME: Not supported. */
539 HOWTO (R_PPC_LOCAL24PC, /* type */
541 2, /* size (0 = byte, 1 = short, 2 = long) */
543 true, /* pc_relative */
545 complain_overflow_signed, /* complain_on_overflow */
546 ppc_elf_unsupported_reloc, /* special_function */
547 "R_PPC_LOCAL24PC", /* name */
548 false, /* partial_inplace */
550 0x3fffffc, /* dst_mask */
551 true), /* pcrel_offset */
553 /* Like R_PPC_ADDR32, but may be unaligned. */
554 HOWTO (R_PPC_UADDR32, /* type */
556 2, /* size (0 = byte, 1 = short, 2 = long) */
558 false, /* pc_relative */
560 complain_overflow_bitfield, /* complain_on_overflow */
561 ppc_elf_std_reloc, /* special_function */
562 "R_PPC_UADDR32", /* name */
563 false, /* partial_inplace */
565 0xffffffff, /* dst_mask */
566 false), /* pcrel_offset */
568 /* Like R_PPC_ADDR16, but may be unaligned. */
569 HOWTO (R_PPC_UADDR16, /* type */
571 1, /* size (0 = byte, 1 = short, 2 = long) */
573 false, /* pc_relative */
575 complain_overflow_bitfield, /* complain_on_overflow */
576 ppc_elf_std_reloc, /* special_function */
577 "R_PPC_UADDR16", /* name */
578 false, /* partial_inplace */
580 0xffff, /* dst_mask */
581 false), /* pcrel_offset */
583 /* 32-bit PC relative */
584 HOWTO (R_PPC_REL32, /* type */
586 2, /* size (0 = byte, 1 = short, 2 = long) */
588 true, /* pc_relative */
590 complain_overflow_bitfield, /* complain_on_overflow */
591 ppc_elf_std_reloc, /* special_function */
592 "R_PPC_REL32", /* name */
593 false, /* partial_inplace */
595 0xffffffff, /* dst_mask */
596 true), /* pcrel_offset */
598 /* 32-bit relocation to the symbol's procedure linkage table.
599 FIXEME: not supported. */
600 HOWTO (R_PPC_PLT32, /* type */
602 2, /* size (0 = byte, 1 = short, 2 = long) */
604 false, /* pc_relative */
606 complain_overflow_bitfield, /* complain_on_overflow */
607 ppc_elf_unsupported_reloc, /* special_function */
608 "R_PPC_PLT32", /* name */
609 false, /* partial_inplace */
612 false), /* pcrel_offset */
614 /* 32-bit PC relative relocation to the symbol's procedure linkage table.
615 FIXEME: not supported. */
616 HOWTO (R_PPC_PLTREL32, /* type */
618 2, /* size (0 = byte, 1 = short, 2 = long) */
620 true, /* pc_relative */
622 complain_overflow_bitfield, /* complain_on_overflow */
623 ppc_elf_unsupported_reloc, /* special_function */
624 "R_PPC_PLTREL32", /* name */
625 false, /* partial_inplace */
628 true), /* pcrel_offset */
630 /* Like R_PPC_ADDR16_LO, but referring to the PLT table entry for
632 HOWTO (R_PPC_PLT16_LO, /* type */
634 1, /* size (0 = byte, 1 = short, 2 = long) */
636 false, /* pc_relative */
638 complain_overflow_bitfield, /* complain_on_overflow */
639 ppc_elf_unsupported_reloc, /* special_function */
640 "R_PPC_PLT16_LO", /* name */
641 false, /* partial_inplace */
643 0xffff, /* dst_mask */
644 false), /* pcrel_offset */
646 /* Like R_PPC_ADDR16_HI, but referring to the PLT table entry for
648 HOWTO (R_PPC_PLT16_HI, /* type */
650 1, /* size (0 = byte, 1 = short, 2 = long) */
652 false, /* pc_relative */
654 complain_overflow_bitfield, /* complain_on_overflow */
655 ppc_elf_unsupported_reloc, /* special_function */
656 "R_PPC_PLT16_HI", /* name */
657 false, /* partial_inplace */
659 0xffff, /* dst_mask */
660 false), /* pcrel_offset */
662 /* Like R_PPC_ADDR16_HA, but referring to the PLT table entry for
663 the symbol. FIXME: Not supported. */
664 HOWTO (R_PPC_PLT16_HA, /* type */
666 1, /* size (0 = byte, 1 = short, 2 = long) */
668 false, /* pc_relative */
670 complain_overflow_bitfield, /* complain_on_overflow */
671 ppc_elf_unsupported_reloc, /* special_function */
672 "R_PPC_PLT16_HA", /* name */
673 false, /* partial_inplace */
675 0xffff, /* dst_mask */
676 false), /* pcrel_offset */
678 /* A sign-extended 16 bit value relative to _SDA_BASE, for use with
680 HOWTO (R_PPC_SDAREL16, /* type */
682 1, /* size (0 = byte, 1 = short, 2 = long) */
684 false, /* pc_relative */
686 complain_overflow_signed, /* complain_on_overflow */
687 ppc_elf_got16_reloc, /* special_function */
688 "R_PPC_SDAREL16", /* name */
689 false, /* partial_inplace */
691 0xffff, /* dst_mask */
692 false), /* pcrel_offset */
694 /* These next 4 relocations were added by Sun. */
695 /* 32-bit section relative relocation. FIXME: not supported. */
696 HOWTO (R_PPC_SECTOFF, /* type */
698 2, /* size (0 = byte, 1 = short, 2 = long) */
700 true, /* pc_relative */
702 complain_overflow_bitfield, /* complain_on_overflow */
703 ppc_elf_unsupported_reloc, /* special_function */
704 "R_PPC_SECTOFF", /* name */
705 false, /* partial_inplace */
708 true), /* pcrel_offset */
710 /* 16-bit lower half section relative relocation. FIXME: not supported. */
711 HOWTO (R_PPC_SECTOFF_LO, /* type */
713 1, /* size (0 = byte, 1 = short, 2 = long) */
715 false, /* pc_relative */
717 complain_overflow_bitfield, /* complain_on_overflow */
718 ppc_elf_unsupported_reloc, /* special_function */
719 "R_PPC_SECTOFF_LO", /* name */
720 false, /* partial_inplace */
722 0xffff, /* dst_mask */
723 false), /* pcrel_offset */
725 /* 16-bit upper half section relative relocation. FIXME: not supported. */
726 HOWTO (R_PPC_SECTOFF_HI, /* type */
728 1, /* size (0 = byte, 1 = short, 2 = long) */
730 false, /* pc_relative */
732 complain_overflow_bitfield, /* complain_on_overflow */
733 ppc_elf_unsupported_reloc, /* special_function */
734 "R_PPC_SECTOFF_HI", /* name */
735 false, /* partial_inplace */
737 0xffff, /* dst_mask */
738 false), /* pcrel_offset */
740 /* 16-bit upper half adjusted section relative relocation. FIXME: not supported. */
741 HOWTO (R_PPC_SECTOFF_HA, /* type */
743 1, /* size (0 = byte, 1 = short, 2 = long) */
745 false, /* pc_relative */
747 complain_overflow_bitfield, /* complain_on_overflow */
748 ppc_elf_unsupported_reloc, /* special_function */
749 "R_PPC_SECTOFF_HA", /* name */
750 false, /* partial_inplace */
752 0xffff, /* dst_mask */
753 false), /* pcrel_offset */
755 /* The remaining relocs are from the Embedded ELF ABI, and are not
756 in the SVR4 ELF ABI. */
758 /* 32 bit value resulting from the addend minus the symbol */
759 HOWTO (R_PPC_EMB_NADDR32, /* type */
761 2, /* size (0 = byte, 1 = short, 2 = long) */
763 false, /* pc_relative */
765 complain_overflow_bitfield, /* complain_on_overflow */
766 ppc_elf_unsupported_reloc, /* special_function */
767 "R_PPC_EMB_NADDR32", /* name */
768 false, /* partial_inplace */
770 0xffffffff, /* dst_mask */
771 false), /* pcrel_offset */
773 /* 16 bit value resulting from the addend minus the symbol */
774 HOWTO (R_PPC_EMB_NADDR16, /* type */
776 1, /* size (0 = byte, 1 = short, 2 = long) */
778 false, /* pc_relative */
780 complain_overflow_bitfield, /* complain_on_overflow */
781 ppc_elf_unsupported_reloc, /* special_function */
782 "R_PPC_EMB_NADDR16", /* name */
783 false, /* partial_inplace */
785 0xffff, /* dst_mask */
786 false), /* pcrel_offset */
788 /* 16 bit value resulting from the addend minus the symbol */
789 HOWTO (R_PPC_EMB_NADDR16_LO, /* type */
791 1, /* size (0 = byte, 1 = short, 2 = long) */
793 false, /* pc_relative */
795 complain_overflow_dont,/* complain_on_overflow */
796 ppc_elf_unsupported_reloc, /* special_function */
797 "R_PPC_EMB_ADDR16_LO", /* name */
798 false, /* partial_inplace */
800 0xffff, /* dst_mask */
801 false), /* pcrel_offset */
803 /* The high order 16 bits of the addend minus the symbol */
804 HOWTO (R_PPC_EMB_NADDR16_HI, /* type */
806 1, /* size (0 = byte, 1 = short, 2 = long) */
808 false, /* pc_relative */
810 complain_overflow_dont, /* complain_on_overflow */
811 ppc_elf_unsupported_reloc, /* special_function */
812 "R_PPC_EMB_NADDR16_HI", /* name */
813 false, /* partial_inplace */
815 0xffff, /* dst_mask */
816 false), /* pcrel_offset */
818 /* The high order 16 bits of the result of the addend minus the address,
819 plus 1 if the contents of the low 16 bits, treated as a signed number,
821 HOWTO (R_PPC_EMB_NADDR16_HA, /* type */
823 1, /* size (0 = byte, 1 = short, 2 = long) */
825 false, /* pc_relative */
827 complain_overflow_dont, /* complain_on_overflow */
828 ppc_elf_unsupported_reloc, /* special_function */
829 "R_PPC_EMB_NADDR16_HA", /* name */
830 false, /* partial_inplace */
832 0xffff, /* dst_mask */
833 false), /* pcrel_offset */
835 /* Phony reloc to handle AIX style TOC entries */
836 HOWTO (R_PPC_TOC16, /* type */
838 1, /* size (0 = byte, 1 = short, 2 = long) */
840 false, /* pc_relative */
842 complain_overflow_signed, /* complain_on_overflow */
843 ppc_elf_toc16_reloc, /* special_function */
844 "R_PPC_TOC16", /* name */
845 false, /* partial_inplace */
847 0xffff, /* dst_mask */
848 false), /* pcrel_offset */
852 /* Initialize the ppc_elf_howto_table, so that linear accesses can be done. */
855 ppc_elf_howto_init ()
857 unsigned int i, type;
859 for (i = 0; i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); i++)
861 type = ppc_elf_howto_raw[i].type;
862 BFD_ASSERT (type < sizeof(ppc_elf_howto_table) / sizeof(ppc_elf_howto_table[0]));
863 ppc_elf_howto_table[type] = &ppc_elf_howto_raw[i];
868 static reloc_howto_type *
869 ppc_elf_reloc_type_lookup (abfd, code)
871 bfd_reloc_code_real_type code;
873 enum ppc_reloc_type ppc_reloc = R_PPC_NONE;
875 if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
876 ppc_elf_howto_init ();
881 return (reloc_howto_type *)NULL;
883 case BFD_RELOC_NONE: ppc_reloc = R_PPC_NONE; break;
884 case BFD_RELOC_32: ppc_reloc = R_PPC_ADDR32; break;
885 case BFD_RELOC_PPC_BA26: ppc_reloc = R_PPC_ADDR24; break;
886 case BFD_RELOC_16: ppc_reloc = R_PPC_ADDR16; break;
887 case BFD_RELOC_LO16: ppc_reloc = R_PPC_ADDR16_LO; break;
888 case BFD_RELOC_HI16: ppc_reloc = R_PPC_ADDR16_HI; break;
889 case BFD_RELOC_HI16_S: ppc_reloc = R_PPC_ADDR16_HA; break;
890 case BFD_RELOC_PPC_BA16: ppc_reloc = R_PPC_ADDR14; break;
891 case BFD_RELOC_PPC_BA16_BRTAKEN: ppc_reloc = R_PPC_ADDR14_BRTAKEN; break;
892 case BFD_RELOC_PPC_BA16_BRNTAKEN: ppc_reloc = R_PPC_ADDR14_BRNTAKEN; break;
893 case BFD_RELOC_PPC_B26: ppc_reloc = R_PPC_REL24; break;
894 case BFD_RELOC_PPC_B16: ppc_reloc = R_PPC_REL14; break;
895 case BFD_RELOC_PPC_B16_BRTAKEN: ppc_reloc = R_PPC_REL14_BRTAKEN; break;
896 case BFD_RELOC_PPC_B16_BRNTAKEN: ppc_reloc = R_PPC_REL14_BRNTAKEN; break;
897 case BFD_RELOC_16_GOTOFF: ppc_reloc = R_PPC_GOT16; break;
898 case BFD_RELOC_LO16_GOTOFF: ppc_reloc = R_PPC_GOT16_LO; break;
899 case BFD_RELOC_HI16_GOTOFF: ppc_reloc = R_PPC_GOT16_HI; break;
900 case BFD_RELOC_HI16_S_GOTOFF: ppc_reloc = R_PPC_GOT16_HA; break;
901 case BFD_RELOC_24_PLT_PCREL: ppc_reloc = R_PPC_PLTREL24; break;
902 case BFD_RELOC_PPC_COPY: ppc_reloc = R_PPC_COPY; break;
903 case BFD_RELOC_PPC_GLOB_DAT: ppc_reloc = R_PPC_GLOB_DAT; break;
904 case BFD_RELOC_PPC_LOCAL24PC: ppc_reloc = R_PPC_LOCAL24PC; break;
905 case BFD_RELOC_32_PCREL: ppc_reloc = R_PPC_REL32; break;
906 case BFD_RELOC_32_PLTOFF: ppc_reloc = R_PPC_PLT32; break;
907 case BFD_RELOC_32_PLT_PCREL: ppc_reloc = R_PPC_PLTREL32; break;
908 case BFD_RELOC_LO16_PLTOFF: ppc_reloc = R_PPC_PLT16_LO; break;
909 case BFD_RELOC_HI16_PLTOFF: ppc_reloc = R_PPC_PLT16_HI; break;
910 case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC_PLT16_HA; break;
911 case BFD_RELOC_GPREL16: ppc_reloc = R_PPC_SDAREL16; break;
912 case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC_SECTOFF; break;
913 case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC_SECTOFF_LO; break;
914 case BFD_RELOC_HI16_BASEREL: ppc_reloc = R_PPC_SECTOFF_HI; break;
915 case BFD_RELOC_HI16_S_BASEREL: ppc_reloc = R_PPC_SECTOFF_HA; break;
916 case BFD_RELOC_CTOR: ppc_reloc = R_PPC_ADDR32; break;
917 case BFD_RELOC_PPC_TOC16: ppc_reloc = R_PPC_TOC16; break;
920 return ppc_elf_howto_table[ (int)ppc_reloc ];
923 /* Set the howto pointer for a PowerPC ELF reloc. */
926 ppc_elf_info_to_howto (abfd, cache_ptr, dst)
929 Elf32_Internal_Rela *dst;
931 if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
932 ppc_elf_howto_init ();
934 BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_PPC_max);
935 cache_ptr->howto = ppc_elf_howto_table[ELF32_R_TYPE (dst->r_info)];
938 /* Function to set whether a module needs the -mrelocatable bit set. */
941 ppc_elf_set_private_flags (abfd, flags)
945 BFD_ASSERT (!elf_ppc_flags_init (abfd)
946 || elf_elfheader (abfd)->e_flags == flags);
948 elf_elfheader (abfd)->e_flags = flags;
949 elf_ppc_flags_init (abfd) = true;
953 /* Copy backend specific data from one object module to another */
955 ppc_elf_copy_private_bfd_data (ibfd, obfd)
959 /* This function is selected based on the input vector. We only
960 want to copy information over if the output BFD also uses Elf
962 if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
965 BFD_ASSERT (!elf_ppc_flags_init (obfd)
966 || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);
968 elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
969 elf_ppc_flags_init (obfd) = true;
973 /* Merge backend specific data from an object file to the output
974 object file when linking */
976 ppc_elf_merge_private_bfd_data (ibfd, obfd)
984 /* Check if we have the same endianess */
985 if (ibfd->xvec->byteorder != obfd->xvec->byteorder)
987 (*_bfd_error_handler)
988 ("%s: compiled for a %s endian system and target is %s endian.\n",
989 bfd_get_filename (ibfd),
990 bfd_big_endian (ibfd) ? "big" : "little",
991 bfd_big_endian (obfd) ? "big" : "little");
993 bfd_set_error (bfd_error_wrong_format);
997 /* This function is selected based on the input vector. We only
998 want to copy information over if the output BFD also uses Elf
1000 if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
1003 new_flags = elf_elfheader (ibfd)->e_flags;
1004 old_flags = elf_elfheader (obfd)->e_flags;
1005 if (!elf_ppc_flags_init (obfd)) /* First call, no flags set */
1007 elf_ppc_flags_init (obfd) = true;
1008 elf_elfheader (obfd)->e_flags = new_flags;
1011 else if (new_flags == old_flags) /* Compatible flags are ok */
1014 else /* Incompatible flags */
1016 /* Warn about -mrelocatable mismatch. Allow -mrelocatable-lib to be linked
1019 if ((new_flags & EF_PPC_RELOCATABLE) != 0
1020 && (old_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0)
1023 (*_bfd_error_handler)
1024 ("%s: compiled with -mrelocatable and linked with modules compiled normally\n",
1025 bfd_get_filename (ibfd));
1027 else if ((new_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0
1028 && (old_flags & EF_PPC_RELOCATABLE) != 0)
1031 (*_bfd_error_handler)
1032 ("%s: compiled normally and linked with modules compiled with -mrelocatable\n",
1033 bfd_get_filename (ibfd));
1035 else if ((new_flags & EF_PPC_RELOCATABLE_LIB) != 0)
1036 elf_elfheader (obfd)->e_flags |= EF_PPC_RELOCATABLE_LIB;
1038 new_flags &= ~ (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB);
1039 old_flags &= ~ (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB);
1041 /* Warn about eabi vs. V.4 mismatch */
1042 if ((new_flags & EF_PPC_EMB) != 0 && (old_flags & EF_PPC_EMB) == 0)
1044 new_flags &= ~EF_PPC_EMB;
1046 (*_bfd_error_handler)
1047 ("%s: compiled for the eabi and linked with modules compiled for System V\n",
1048 bfd_get_filename (ibfd));
1050 else if ((new_flags & EF_PPC_EMB) == 0 && (old_flags & EF_PPC_EMB) != 0)
1052 old_flags &= ~EF_PPC_EMB;
1054 (*_bfd_error_handler)
1055 ("%s: compiled for System V and linked with modules compiled for eabi\n",
1056 bfd_get_filename (ibfd));
1059 /* Warn about any other mismatches */
1060 if (new_flags != old_flags)
1063 (*_bfd_error_handler)
1064 ("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)\n",
1065 bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
1070 bfd_set_error (bfd_error_bad_value);
1079 /* ELF relocs are against symbols. If we are producing relocateable
1080 output, and the reloc is against an external symbol, and nothing
1081 has given us any additional addend, the resulting reloc will also
1082 be against the same symbol. In such a case, we don't want to
1083 change anything about the way the reloc is handled, since it will
1084 all be done at final link time. Rather than put special case code
1085 into bfd_perform_relocation, all the reloc types use this howto
1086 function. It just short circuits the reloc if producing
1087 relocateable output against an external symbol. */
1090 static bfd_reloc_status_type
1091 ppc_elf_std_reloc (abfd,
1099 arelent *reloc_entry;
1102 asection *input_section;
1104 char **error_message;
1106 if (output_bfd != (bfd *) NULL
1107 && (symbol->flags & BSF_SECTION_SYM) == 0
1108 && (! reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
1110 reloc_entry->address += input_section->output_offset;
1111 return bfd_reloc_ok;
1114 return bfd_reloc_continue;
1117 /* Don't pretend we can deal with unsupported relocs. */
1120 static bfd_reloc_status_type
1121 ppc_elf_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section,
1122 output_bfd, error_message)
1124 arelent *reloc_entry;
1127 asection *input_section;
1129 char **error_message;
1131 BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
1132 (*_bfd_error_handler)
1133 ("%s: Relocation %s (%d) is not currently supported.\n",
1134 bfd_get_filename (abfd),
1135 reloc_entry->howto->name,
1136 reloc_entry->howto->type);
1138 return bfd_reloc_notsupported;
1141 /* Internal function to return the adjustment to the addend for relocations
1142 that return the upper 16 bits after sign extending the lower 16 bits, ie
1143 for use with a ADDIS instruction followed by a memory reference using the
1148 ppc_elf_addr16_ha_inner (relocation)
1151 return (relocation & 0x8000) << 1;
1154 /* Handle the ADDR16_HA reloc by adjusting the reloc addend. */
1157 static bfd_reloc_status_type
1158 ppc_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section,
1159 output_bfd, error_message)
1161 arelent *reloc_entry;
1164 asection *input_section;
1166 char **error_message;
1171 if (output_bfd != (bfd *) NULL)
1172 return ppc_elf_std_reloc (abfd, reloc_entry, symbol, data,
1173 input_section, output_bfd, error_message);
1175 sec = symbol->section;
1176 relocation = (((bfd_is_com_section (sec)) ? 0 : symbol->value)
1177 + sec->output_section->vma
1178 + sec->output_offset
1179 + reloc_entry->addend);
1181 reloc_entry->addend += ppc_elf_addr16_ha_inner (relocation);
1182 return bfd_reloc_continue;
1185 /* Internal function to return the addjustment to the addend for GOT16
1190 ppc_elf_got16_inner (sec)
1194 fprintf (stderr, "ppc_elf_got16_inner called for %s\n", sec->name);
1196 return -(sec->output_section->vma + 0x8000);
1199 /* Handle the GOT16 reloc. We want to use the offset within the .got
1200 section, not the actual VMA. */
1203 static bfd_reloc_status_type
1204 ppc_elf_got16_reloc (abfd, reloc_entry, symbol, data, input_section,
1205 output_bfd, error_message)
1207 arelent *reloc_entry;
1210 asection *input_section;
1212 char **error_message;
1214 if (output_bfd != (bfd *) NULL)
1215 return ppc_elf_std_reloc (abfd, reloc_entry, symbol, data,
1216 input_section, output_bfd, error_message);
1219 fprintf (stderr, "ppc_elf_got16_reloc called for %s in %s\n", (*reloc_entry->sym_ptr_ptr)->name, input_section->name);
1221 reloc_entry->addend += ppc_elf_got16_inner (bfd_get_section (*reloc_entry->sym_ptr_ptr));
1222 return bfd_reloc_continue;
1225 /* Internal function to return the addjustment to the addend for TOC16
1230 ppc_elf_toc16_inner (sec)
1233 BFD_ASSERT (bfd_is_und_section (sec)
1234 || strcmp (bfd_get_section_name (abfd, sec), ".got") == 0
1235 || strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0
1236 || strcmp (bfd_get_section_name (abfd, sec), ".sdata") == 0
1237 || strcmp (bfd_get_section_name (abfd, sec), ".sbss") == 0)
1239 return -(sec->output_section->vma + 0x8000);
1242 /* Handle the TOC16 reloc. We want to use the offset within the .got
1243 section, not the actual VMA. This is appropriate when generating
1244 an embedded ELF object, for which the .got section acts like the
1245 AIX .toc section. */
1248 static bfd_reloc_status_type
1249 ppc_elf_toc16_reloc (abfd, reloc_entry, symbol, data, input_section,
1250 output_bfd, error_message)
1252 arelent *reloc_entry;
1255 asection *input_section;
1257 char **error_message;
1259 if (output_bfd != (bfd *) NULL)
1260 return ppc_elf_std_reloc (abfd, reloc_entry, symbol, data,
1261 input_section, output_bfd, error_message);
1263 reloc_entry->addend += ppc_elf_toc16_inner (bfd_get_section (*reloc_entry->sym_ptr_ptr));
1264 return bfd_reloc_continue;
1267 /* Internal function to return the adjustment for relocations that set the
1268 branch taken bit or branch not taken in B0 for conditional branches.
1269 The dst_mask for these relocations allows this bit to be set as part
1274 ppc_elf_brtaken_inner (relocation, ppc_reloc)
1276 enum ppc_reloc_type ppc_reloc;
1278 if (ppc_reloc == R_PPC_ADDR14_BRTAKEN || ppc_reloc == R_PPC_REL14_BRTAKEN)
1279 return (relocation & 0x8000) ? 0 : BRANCH_PREDICT_BIT; /* branch taken */
1281 return (relocation & 0x8000) ? BRANCH_PREDICT_BIT : 0; /* branch not taken */
1284 /* Handle the R_PPC_{ADDR,REL}14_BR{,N}TAKEN relocs by setting bit 10 to indicate
1285 whether the branch is taken or not. */
1288 static bfd_reloc_status_type
1289 ppc_elf_brtaken_reloc (abfd, reloc_entry, symbol, data, input_section,
1290 output_bfd, error_message)
1292 arelent *reloc_entry;
1295 asection *input_section;
1297 char **error_message;
1303 if (output_bfd != (bfd *) NULL)
1304 return ppc_elf_std_reloc (abfd, reloc_entry, symbol, data,
1305 input_section, output_bfd, error_message);
1307 sec = symbol->section;
1308 relocation = (((bfd_is_com_section (sec)) ? 0 : symbol->value)
1309 + sec->output_section->vma
1310 + sec->output_offset
1311 + reloc_entry->addend);
1313 /* Set the branch prediction bit */
1314 insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1315 insn &= ~BRANCH_PREDICT_BIT;
1316 insn |= ppc_elf_brtaken_inner (relocation - reloc_entry->address,
1317 (enum ppc_reloc_type)reloc_entry->howto->type);
1318 bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
1320 return bfd_reloc_continue;
1324 /* Adjust a symbol defined by a dynamic object and referenced by a
1325 regular object. The current definition is in some section of the
1326 dynamic object, but we're not including those sections. We have to
1327 change the definition to something the rest of the link can
1331 ppc_elf_adjust_dynamic_symbol (info, h)
1332 struct bfd_link_info *info;
1333 struct elf_link_hash_entry *h;
1336 fprintf (stderr, "ppc_elf_adjust_dynamic_symbol called\n");
1342 /* Increment the index of a dynamic symbol by a given amount. Called
1343 via elf_link_hash_traverse. */
1346 ppc_elf_adjust_dynindx (h, cparg)
1347 struct elf_link_hash_entry *h;
1350 int *cp = (int *) cparg;
1353 fprintf (stderr, "ppc_elf_adjust_dynindx called, h->dynindx = %d, *cp = %d\n", h->dynindx, *cp);
1356 if (h->dynindx != -1)
1363 /* Set the sizes of the dynamic sections. */
1366 ppc_elf_size_dynamic_sections (output_bfd, info)
1368 struct bfd_link_info *info;
1376 fprintf (stderr, "ppc_elf_size_dynamic_sections called\n");
1379 dynobj = elf_hash_table (info)->dynobj;
1380 BFD_ASSERT (dynobj != NULL);
1382 if (elf_hash_table (info)->dynamic_sections_created)
1384 /* Set the contents of the .interp section to the interpreter. */
1387 s = bfd_get_section_by_name (dynobj, ".interp");
1388 BFD_ASSERT (s != NULL);
1389 s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
1390 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
1393 /* Make space for the trailing nop in .plt. */
1394 s = bfd_get_section_by_name (dynobj, ".plt");
1395 BFD_ASSERT (s != NULL);
1396 if (s->_raw_size > 0)
1401 /* We may have created entries in the .rela.got section.
1402 However, if we are not creating the dynamic sections, we will
1403 not actually use these entries. Reset the size of .rela.got,
1404 which will cause it to get stripped from the output file
1406 s = bfd_get_section_by_name (dynobj, ".rela.got");
1411 /* The check_relocs and adjust_dynamic_symbol entry points have
1412 determined the sizes of the various dynamic sections. Allocate
1416 for (s = dynobj->sections; s != NULL; s = s->next)
1421 if ((s->flags & SEC_IN_MEMORY) == 0)
1424 /* It's OK to base decisions on the section name, because none
1425 of the dynobj section names depend upon the input files. */
1426 name = bfd_get_section_name (dynobj, s);
1430 if (strncmp (name, ".rela", 5) == 0)
1432 if (s->_raw_size == 0)
1434 /* If we don't need this section, strip it from the
1435 output file. This is to handle .rela.bss and
1436 .rel.plt. We must create it in
1437 create_dynamic_sections, because it must be created
1438 before the linker maps input sections to output
1439 sections. The linker does that before
1440 adjust_dynamic_symbol is called, and it is that
1441 function which decides whether anything needs to go
1442 into these sections. */
1449 /* If this relocation section applies to a read only
1450 section, then we probably need a DT_TEXTREL entry. */
1451 target = bfd_get_section_by_name (output_bfd, name + 5);
1453 && (target->flags & SEC_READONLY) != 0)
1456 if (strcmp (name, ".rela.plt") == 0)
1459 /* We use the reloc_count field as a counter if we need
1460 to copy relocs into the output file. */
1464 else if (strcmp (name, ".plt") != 0
1465 && strcmp (name, ".got") != 0)
1467 /* It's not one of our sections, so don't allocate space. */
1475 for (spp = &s->output_section->owner->sections;
1476 *spp != s->output_section;
1477 spp = &(*spp)->next)
1479 *spp = s->output_section->next;
1480 --s->output_section->owner->section_count;
1485 /* Allocate memory for the section contents. */
1486 s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
1487 if (s->contents == NULL && s->_raw_size != 0)
1491 if (elf_hash_table (info)->dynamic_sections_created)
1493 /* Add some entries to the .dynamic section. We fill in the
1494 values later, in ppc_elf_finish_dynamic_sections, but we
1495 must add the entries now so that we get the correct size for
1496 the .dynamic section. The DT_DEBUG entry is filled in by the
1497 dynamic linker and used by the debugger. */
1500 if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
1504 if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0))
1509 if (! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
1510 || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
1511 || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
1515 if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
1516 || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
1517 || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
1518 sizeof (Elf32_External_Rela)))
1523 if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
1528 /* If we are generating a shared library, we generate a section
1529 symbol for each output section. These are local symbols, which
1530 means that they must come first in the dynamic symbol table.
1531 That means we must increment the dynamic symbol index of every
1532 other dynamic symbol. */
1537 c = bfd_count_sections (output_bfd);
1538 elf_link_hash_traverse (elf_hash_table (info),
1539 ppc_elf_adjust_dynindx,
1541 elf_hash_table (info)->dynsymcount += c;
1543 for (i = 1, s = output_bfd->sections; s != NULL; s = s->next, i++)
1545 elf_section_data (s)->dynindx = i;
1546 /* These symbols will have no names, so we don't need to
1547 fiddle with dynstr_index. */
1555 /* Look through the relocs for a section during the first phase, and
1556 allocate space in the global offset table or procedure linkage
1560 ppc_elf_check_relocs (abfd, info, sec, relocs)
1562 struct bfd_link_info *info;
1564 const Elf_Internal_Rela *relocs;
1567 Elf_Internal_Shdr *symtab_hdr;
1568 struct elf_link_hash_entry **sym_hashes;
1569 bfd_vma *local_got_offsets;
1570 const Elf_Internal_Rela *rel;
1571 const Elf_Internal_Rela *rel_end;
1576 if (info->relocateable)
1580 fprintf (stderr, "ppc_elf_check_relocs called for section %s\n", sec->name);
1583 dynobj = elf_hash_table (info)->dynobj;
1584 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
1585 sym_hashes = elf_sym_hashes (abfd);
1586 local_got_offsets = elf_local_got_offsets (abfd);
1592 rel_end = relocs + sec->reloc_count;
1593 for (rel = relocs; rel < rel_end; rel++)
1595 unsigned long r_symndx;
1596 struct elf_link_hash_entry *h;
1598 r_symndx = ELF32_R_SYM (rel->r_info);
1599 if (r_symndx < symtab_hdr->sh_info)
1602 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
1604 switch (ELF32_R_TYPE (rel->r_info))
1607 case R_PPC_GOT16_LO:
1608 case R_PPC_GOT16_HI:
1609 case R_PPC_GOT16_HA:
1611 fprintf (stderr, "Reloc requires a GOT entry\n");
1613 /* This symbol requires a global offset table entry. */
1617 /* Create the .got section. */
1618 elf_hash_table (info)->dynobj = dynobj = abfd;
1619 if (! _bfd_elf_create_got_section (dynobj, info))
1625 sgot = bfd_get_section_by_name (dynobj, ".got");
1626 BFD_ASSERT (sgot != NULL);
1630 && (h != NULL || info->shared))
1632 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
1633 if (srelgot == NULL)
1635 srelgot = bfd_make_section (dynobj, ".rela.got");
1637 || ! bfd_set_section_flags (dynobj, srelgot,
1643 || ! bfd_set_section_alignment (dynobj, srelgot, 2))
1650 if (h->got_offset != (bfd_vma) -1)
1652 /* We have already allocated space in the .got. */
1655 h->got_offset = sgot->_raw_size;
1657 /* Make sure this symbol is output as a dynamic symbol. */
1658 if (h->dynindx == -1)
1660 if (! bfd_elf32_link_record_dynamic_symbol (info, h))
1664 srelgot->_raw_size += sizeof (Elf32_External_Rela);
1668 /* This is a global offset table entry for a local
1670 if (local_got_offsets == NULL)
1673 register unsigned int i;
1675 size = symtab_hdr->sh_info * sizeof (bfd_vma);
1676 local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
1677 if (local_got_offsets == NULL)
1679 elf_local_got_offsets (abfd) = local_got_offsets;
1680 for (i = 0; i < symtab_hdr->sh_info; i++)
1681 local_got_offsets[i] = (bfd_vma) -1;
1683 if (local_got_offsets[r_symndx] != (bfd_vma) -1)
1685 /* We have already allocated space in the .got. */
1688 local_got_offsets[r_symndx] = sgot->_raw_size;
1692 /* If we are generating a shared object, we need to
1693 output a R_SPARC_RELATIVE reloc so that the
1694 dynamic linker can adjust this GOT entry. */
1695 srelgot->_raw_size += sizeof (Elf32_External_Rela);
1699 sgot->_raw_size += 4;
1704 case R_PPC_PLTREL24:
1705 case R_PPC_PLT16_LO:
1706 case R_PPC_PLT16_HI:
1707 case R_PPC_PLT16_HA:
1709 fprintf (stderr, "Reloc requires a PLT entry\n");
1711 /* This symbol requires a procedure linkage table entry. We
1712 actually build the entry in adjust_dynamic_symbol,
1713 because this might be a case of linking PIC code without
1714 linking in any dynamic objects, in which case we don't
1715 need to generate a procedure linkage table after all. */
1719 /* It does not make sense to have a procedure linkage
1720 table entry for a local symbol. */
1721 bfd_set_error (bfd_error_bad_value);
1725 /* Make sure this symbol is output as a dynamic symbol. */
1726 if (h->dynindx == -1)
1728 if (! bfd_elf32_link_record_dynamic_symbol (info, h))
1732 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
1739 && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
1743 case R_SPARC_DISP16:
1744 case R_SPARC_DISP32:
1745 case R_SPARC_WDISP30:
1746 case R_SPARC_WDISP22:
1759 && (sec->flags & SEC_ALLOC) != 0)
1761 /* When creating a shared object, we must copy these
1762 relocs into the output file. We create a reloc
1763 section in dynobj and make room for the reloc. */
1768 name = (bfd_elf_string_from_elf_section
1770 elf_elfheader (abfd)->e_shstrndx,
1771 elf_section_data (sec)->rel_hdr.sh_name));
1775 BFD_ASSERT (strncmp (name, ".rela", 5) == 0
1776 && strcmp (bfd_get_section_name (abfd, sec),
1779 sreloc = bfd_get_section_by_name (dynobj, name);
1782 sreloc = bfd_make_section (dynobj, name);
1784 || ! bfd_set_section_flags (dynobj, sreloc,
1790 || ! bfd_set_section_alignment (dynobj, sreloc, 2))
1795 sreloc->_raw_size += sizeof (Elf32_External_Rela);
1810 /* Finish up dynamic symbol handling. We set the contents of various
1811 dynamic sections here. */
1814 ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
1816 struct bfd_link_info *info;
1817 struct elf_link_hash_entry *h;
1818 Elf_Internal_Sym *sym;
1823 fprintf (stderr, "ppc_elf_finish_dynamic_symbol called\n");
1826 dynobj = elf_hash_table (info)->dynobj;
1828 if (h->plt_offset != (bfd_vma) -1)
1832 Elf_Internal_Rela rela;
1834 /* This symbol has an entry in the procedure linkage table. Set
1837 BFD_ASSERT (h->dynindx != -1);
1839 splt = bfd_get_section_by_name (dynobj, ".plt");
1840 srela = bfd_get_section_by_name (dynobj, ".rela.plt");
1841 BFD_ASSERT (splt != NULL && srela != NULL);
1843 /* Fill in the entry in the procedure linkage table. */
1845 bfd_put_32 (output_bfd,
1846 PLT_ENTRY_WORD0 + h->plt_offset,
1847 splt->contents + h->plt_offset);
1848 bfd_put_32 (output_bfd,
1850 + (((- (h->plt_offset + 4)) >> 2) & 0x3fffff)),
1851 splt->contents + h->plt_offset + 4);
1852 bfd_put_32 (output_bfd, PLT_ENTRY_WORD2,
1853 splt->contents + h->plt_offset + 8);
1855 /* Fill in the entry in the .rela.plt section. */
1856 rela.r_offset = (splt->output_section->vma
1857 + splt->output_offset
1859 rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_JMP_SLOT);
1861 bfd_elf32_swap_reloca_out (output_bfd, &rela,
1862 ((Elf32_External_Rela *) srela->contents
1863 + h->plt_offset / PLT_ENTRY_SIZE - 4));
1866 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
1868 /* Mark the symbol as undefined, rather than as defined in
1869 the .plt section. Leave the value alone. */
1870 sym->st_shndx = SHN_UNDEF;
1874 if (h->got_offset != (bfd_vma) -1)
1878 Elf_Internal_Rela rela;
1880 /* This symbol has an entry in the global offset table. Set it
1883 BFD_ASSERT (h->dynindx != -1);
1885 sgot = bfd_get_section_by_name (dynobj, ".got");
1886 srela = bfd_get_section_by_name (dynobj, ".rela.got");
1887 BFD_ASSERT (sgot != NULL && srela != NULL);
1889 rela.r_offset = (sgot->output_section->vma
1890 + sgot->output_offset
1891 + (h->got_offset &~ 1));
1893 /* If this is a -Bsymbolic link, and the symbol is defined
1894 locally, we just want to emit a RELATIVE reloc. The entry in
1895 the global offset table will already have been initialized in
1896 the relocate_section function. */
1899 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
1900 rela.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);
1903 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got_offset);
1904 rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_GLOB_DAT);
1908 bfd_elf32_swap_reloca_out (output_bfd, &rela,
1909 ((Elf32_External_Rela *) srela->contents
1910 + srela->reloc_count));
1911 ++srela->reloc_count;
1914 if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
1917 Elf_Internal_Rela rela;
1919 /* This symbols needs a copy reloc. Set it up. */
1921 BFD_ASSERT (h->dynindx != -1);
1923 s = bfd_get_section_by_name (h->root.u.def.section->owner,
1925 BFD_ASSERT (s != NULL);
1927 rela.r_offset = (h->root.u.def.value
1928 + h->root.u.def.section->output_section->vma
1929 + h->root.u.def.section->output_offset);
1930 rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_COPY);
1932 bfd_elf32_swap_reloca_out (output_bfd, &rela,
1933 ((Elf32_External_Rela *) s->contents
1938 /* Mark some specially defined symbols as absolute. */
1939 if (strcmp (h->root.root.string, "_DYNAMIC") == 0
1940 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
1941 || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
1942 sym->st_shndx = SHN_ABS;
1948 /* Finish up the dynamic sections. */
1951 ppc_elf_finish_dynamic_sections (output_bfd, info)
1953 struct bfd_link_info *info;
1960 fprintf (stderr, "ppc_elf_finish_dynamic_sections called\n");
1963 dynobj = elf_hash_table (info)->dynobj;
1965 sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
1967 if (elf_hash_table (info)->dynamic_sections_created)
1970 Elf32_External_Dyn *dyncon, *dynconend;
1972 splt = bfd_get_section_by_name (dynobj, ".plt");
1973 BFD_ASSERT (splt != NULL && sdyn != NULL);
1975 dyncon = (Elf32_External_Dyn *) sdyn->contents;
1976 dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
1977 for (; dyncon < dynconend; dyncon++)
1979 Elf_Internal_Dyn dyn;
1983 bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
1987 case DT_PLTGOT: name = ".plt"; size = false; break;
1988 case DT_PLTRELSZ: name = ".rela.plt"; size = true; break;
1989 case DT_JMPREL: name = ".rela.plt"; size = false; break;
1990 default: name = NULL; size = false; break;
1997 s = bfd_get_section_by_name (output_bfd, name);
2003 dyn.d_un.d_ptr = s->vma;
2006 if (s->_cooked_size != 0)
2007 dyn.d_un.d_val = s->_cooked_size;
2009 dyn.d_un.d_val = s->_raw_size;
2012 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
2016 /* Clear the first four entries in the procedure linkage table,
2017 and put a nop in the last four bytes. */
2019 if (splt->_raw_size > 0)
2021 memset (splt->contents, 0, 4 * PLT_ENTRY_SIZE);
2022 bfd_put_32 (output_bfd, SPARC_NOP,
2023 splt->contents + splt->_raw_size - 4);
2026 elf_section_data (splt->output_section)->this_hdr.sh_entsize =
2031 /* Set the first entry in the global offset table to the address of
2032 the dynamic section. */
2033 sgot = bfd_get_section_by_name (dynobj, ".got");
2034 BFD_ASSERT (sgot != NULL);
2035 if (sgot->_raw_size > 0)
2038 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
2040 bfd_put_32 (output_bfd,
2041 sdyn->output_section->vma + sdyn->output_offset,
2045 elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
2051 Elf_Internal_Sym sym;
2053 /* Set up the section symbols for the output sections. */
2055 sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
2056 BFD_ASSERT (sdynsym != NULL);
2060 sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
2063 for (s = output_bfd->sections; s != NULL; s = s->next)
2067 sym.st_value = s->vma;
2069 indx = elf_section_data (s)->this_idx;
2070 BFD_ASSERT (indx > 0);
2071 sym.st_shndx = indx;
2073 bfd_elf32_swap_symbol_out (output_bfd, &sym,
2074 (PTR) (((Elf32_External_Sym *)
2076 + elf_section_data (s)->dynindx));
2079 /* Set the sh_info field of the output .dynsym section to the
2080 index of the first global symbol. */
2081 elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
2082 bfd_count_sections (output_bfd) + 1;
2089 /* The RELOCATE_SECTION function is called by the ELF backend linker
2090 to handle the relocations for a section.
2092 The relocs are always passed as Rela structures; if the section
2093 actually uses Rel structures, the r_addend field will always be
2096 This function is responsible for adjust the section contents as
2097 necessary, and (if using Rela relocs and generating a
2098 relocateable output file) adjusting the reloc addend as
2101 This function does not have to worry about setting the reloc
2102 address or the reloc symbol index.
2104 LOCAL_SYMS is a pointer to the swapped in local symbols.
2106 LOCAL_SECTIONS is an array giving the section in the input file
2107 corresponding to the st_shndx field of each local symbol.
2109 The global hash table entry for the global symbols can be found
2110 via elf_sym_hashes (input_bfd).
2112 When generating relocateable output, this function must handle
2113 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
2114 going to be the section symbol corresponding to the output
2115 section, which means that the addend must be adjusted
2119 ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
2120 contents, relocs, local_syms, local_sections)
2122 struct bfd_link_info *info;
2124 asection *input_section;
2126 Elf_Internal_Rela *relocs;
2127 Elf_Internal_Sym *local_syms;
2128 asection **local_sections;
2130 Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
2131 struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
2132 bfd *dynobj = elf_hash_table (info)->dynobj;
2133 bfd_vma *local_got_offsets = elf_local_got_offsets (input_bfd);
2137 Elf_Internal_Rela *rel = relocs;
2138 Elf_Internal_Rela *relend = relocs + input_section->reloc_count;
2143 fprintf (stderr, "ppc_elf_relocate_section called for %s section %s, %ld relocations%s\n",
2144 bfd_get_filename (input_bfd),
2145 bfd_section_name(input_bfd, input_section),
2146 (long)input_section->reloc_count,
2147 (info->relocateable) ? " (relocatable)" : "");
2150 if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
2151 ppc_elf_howto_init ();
2153 for (; rel < relend; rel++)
2155 enum ppc_reloc_type r_type = (enum ppc_reloc_type)ELF32_R_TYPE (rel->r_info);
2156 bfd_vma offset = rel->r_offset;
2157 bfd_vma addend = rel->r_addend;
2158 bfd_reloc_status_type r = bfd_reloc_other;
2159 Elf_Internal_Sym *sym = (Elf_Internal_Sym *)0;
2160 asection *sec = (asection *)0;
2161 struct elf_link_hash_entry *h = (struct elf_link_hash_entry *)0;
2162 reloc_howto_type *howto;
2163 unsigned long r_symndx;
2166 /* Unknown relocation handling */
2167 if ((unsigned)r_type >= (unsigned)R_PPC_max || !ppc_elf_howto_table[(int)r_type])
2169 (*_bfd_error_handler)
2170 ("%s: Unknown relocation type %d\n",
2171 bfd_get_filename (input_bfd),
2174 bfd_set_error (bfd_error_bad_value);
2179 howto = ppc_elf_howto_table[(int)r_type];
2180 r_symndx = ELF32_R_SYM (rel->r_info);
2182 if (info->relocateable)
2184 /* This is a relocateable link. We don't have to change
2185 anything, unless the reloc is against a section symbol,
2186 in which case we have to adjust according to where the
2187 section symbol winds up in the output section. */
2188 if (r_symndx < symtab_hdr->sh_info)
2190 sym = local_syms + r_symndx;
2191 if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)
2193 sec = local_sections[r_symndx];
2194 addend = rel->r_addend += sec->output_offset + sym->st_value;
2199 fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
2209 /* This is a final link. */
2211 /* Complain about known relocation that are not yet supported */
2212 if (howto->special_function == ppc_elf_unsupported_reloc)
2214 (*_bfd_error_handler)
2215 ("%s: Relocation %s (%d) is not currently supported.\n",
2216 bfd_get_filename (input_bfd),
2220 bfd_set_error (bfd_error_bad_value);
2225 if (r_symndx < symtab_hdr->sh_info)
2227 sym = local_syms + r_symndx;
2228 sec = local_sections[r_symndx];
2229 relocation = (sec->output_section->vma
2230 + sec->output_offset
2235 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
2236 if (h->root.type == bfd_link_hash_defined
2237 || h->root.type == bfd_link_hash_defweak)
2239 sec = h->root.u.def.section;
2240 relocation = (h->root.u.def.value
2241 + sec->output_section->vma
2242 + sec->output_offset);
2244 else if (h->root.type == bfd_link_hash_undefweak)
2246 else if (info->shared)
2250 (*info->callbacks->undefined_symbol)(info,
2251 h->root.root.string,
2260 switch ((int)r_type)
2265 case (int)R_PPC_ADDR14_BRTAKEN: /* branch prediction relocations */
2266 case (int)R_PPC_ADDR14_BRNTAKEN:
2267 case (int)R_PPC_REL14_BRTAKEN:
2268 case (int)R_PPC_REL14_BRNTAKEN:
2269 BFD_ASSERT (sec != (asection *)0);
2270 insn = bfd_get_32 (output_bfd, contents + offset);
2271 insn &= ~BRANCH_PREDICT_BIT;
2272 insn |= ppc_elf_brtaken_inner (relocation - offset, r_type);
2273 bfd_put_32 (output_bfd, insn, contents + offset);
2276 case (int)R_PPC_GOT16: /* GOT16 relocations */
2277 case (int)R_PPC_GOT16_LO:
2278 case (int)R_PPC_GOT16_HI:
2279 case (int)R_PPC_SDAREL16:
2280 BFD_ASSERT (sec != (asection *)0);
2281 addend += ppc_elf_got16_inner (sec);
2284 case (int)R_PPC_TOC16: /* phony GOT16 relocations */
2285 BFD_ASSERT (sec != (asection *)0);
2286 addend += ppc_elf_toc16_inner (sec);
2289 case (int)R_PPC_ADDR16_HA: /* arithmetic adjust relocations */
2290 BFD_ASSERT (sec != (asection *)0);
2291 addend += ppc_elf_addr16_ha_inner (relocation + addend);
2297 fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
2305 r = _bfd_final_link_relocate (howto,
2313 if (r != bfd_reloc_ok)
2321 case bfd_reloc_overflow:
2326 name = h->root.root.string;
2329 name = bfd_elf_string_from_elf_section (input_bfd,
2330 symtab_hdr->sh_link,
2336 name = bfd_section_name (input_bfd, sec);
2339 (*info->callbacks->reloc_overflow)(info,
2355 fprintf (stderr, "\n");
2361 #define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec
2362 #define TARGET_LITTLE_NAME "elf32-powerpcle"
2363 #define TARGET_BIG_SYM bfd_elf32_powerpc_vec
2364 #define TARGET_BIG_NAME "elf32-powerpc"
2365 #define ELF_ARCH bfd_arch_powerpc
2366 #define ELF_MACHINE_CODE EM_PPC
2367 #define ELF_MAXPAGESIZE 0x10000
2368 #define elf_info_to_howto ppc_elf_info_to_howto
2370 #ifdef EM_CYGNUS_POWERPC
2371 #define ELF_MACHINE_ALT1 EM_CYGNUS_POWERPC
2375 #define ELF_MACHINE_ALT2 EM_PPC_OLD
2378 #define bfd_elf32_bfd_copy_private_bfd_data ppc_elf_copy_private_bfd_data
2379 #define bfd_elf32_bfd_merge_private_bfd_data ppc_elf_merge_private_bfd_data
2380 #define bfd_elf32_bfd_set_private_flags ppc_elf_set_private_flags
2381 #define bfd_elf32_bfd_reloc_type_lookup ppc_elf_reloc_type_lookup
2382 #define elf_backend_relocate_section ppc_elf_relocate_section
2383 #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
2384 #define elf_backend_check_relocs ppc_elf_check_relocs
2385 #define elf_backend_adjust_dynamic_symbol ppc_elf_adjust_dynamic_symbol
2386 #define elf_backend_size_dynamic_sections ppc_elf_size_dynamic_sections
2387 #define elf_backend_finish_dynamic_symbol ppc_elf_finish_dynamic_symbol
2388 #define elf_backend_finish_dynamic_sections ppc_elf_finish_dynamic_sections
2390 #include "elf32-target.h"