1 /* SuperH SH64-specific support for 64-bit ELF
2 Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
29 /* Add a suffix for datalabel indirection symbols. It must not match any
30 other symbols; user symbols with or without version or other
31 decoration. It must only be used internally and not emitted by any
33 #define DATALABEL_SUFFIX " DL"
35 #define GOT_BIAS (-((long)-32768))
37 #define PLT_ENTRY_SIZE 64
39 /* Return size of a PLT entry. */
40 #define elf_sh64_sizeof_plt(info) PLT_ENTRY_SIZE
42 /* Return offset of the PLT0 address in an absolute PLT entry. */
43 #define elf_sh64_plt_plt0_offset(info) 32
45 /* Return offset of the linker in PLT0 entry. */
46 #define elf_sh64_plt0_gotplt_offset(info) 0
48 /* Return offset of the trampoline in PLT entry */
49 #define elf_sh64_plt_temp_offset(info) 33 /* Add one because it's SHmedia. */
51 /* Return offset of the symbol in PLT entry. */
52 #define elf_sh64_plt_symbol_offset(info) 0
54 /* Return offset of the relocation in PLT entry. */
55 #define elf_sh64_plt_reloc_offset(info) (info->shared ? 52 : 44)
57 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
59 /* The sh linker needs to keep track of the number of relocs that it
60 decides to copy in check_relocs for each symbol. This is so that
61 it can discard PC relative relocs if it doesn't need them when
62 linking with -Bsymbolic. We store the information in a field
63 extending the regular ELF linker hash table. */
65 /* This structure keeps track of the number of PC relative relocs we
66 have copied for a given symbol. */
68 struct elf_sh64_pcrel_relocs_copied
71 struct elf_sh64_pcrel_relocs_copied
*next
;
72 /* A section in dynobj. */
74 /* Number of relocs copied in this section. */
78 /* sh ELF linker hash entry. */
80 struct elf_sh64_link_hash_entry
82 struct elf_link_hash_entry root
;
84 bfd_vma datalabel_got_offset
;
86 /* Number of PC relative relocs copied for this symbol. */
87 struct elf_sh64_pcrel_relocs_copied
*pcrel_relocs_copied
;
90 /* sh ELF linker hash table. */
92 struct elf_sh64_link_hash_table
94 struct elf_link_hash_table root
;
97 /* Traverse an sh ELF linker hash table. */
99 #define sh64_elf64_link_hash_traverse(table, func, info) \
100 (elf_link_hash_traverse \
102 (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \
105 /* Get the sh ELF linker hash table from a link_info structure. */
107 #define sh64_elf64_hash_table(p) \
108 ((struct elf_sh64_link_hash_table *) ((p)->hash))
110 static bfd_boolean sh_elf64_copy_private_data
112 static bfd_boolean sh_elf64_copy_private_data_internal
114 static bfd_boolean sh_elf64_merge_private_data
116 static bfd_reloc_status_type sh_elf64_ignore_reloc
117 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
118 static bfd_reloc_status_type sh_elf64_reloc
119 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
120 static reloc_howto_type
*sh_elf64_reloc_type_lookup
121 (bfd
*, bfd_reloc_code_real_type
);
122 static void sh_elf64_info_to_howto
123 (bfd
*, arelent
*, Elf_Internal_Rela
*);
124 static bfd_boolean sh_elf64_relocate_section
125 (bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
126 Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**);
127 static bfd_byte
*sh_elf64_get_relocated_section_contents
128 (bfd
*, struct bfd_link_info
*, struct bfd_link_order
*, bfd_byte
*,
129 bfd_boolean
, asymbol
**);
130 static bfd_boolean sh_elf64_set_mach_from_flags
132 static bfd_boolean sh_elf64_set_private_flags
134 static asection
*sh_elf64_gc_mark_hook
135 (asection
*, struct bfd_link_info
*, Elf_Internal_Rela
*,
136 struct elf_link_hash_entry
*, Elf_Internal_Sym
*);
137 static bfd_boolean sh_elf64_gc_sweep_hook
138 (bfd
*, struct bfd_link_info
*, asection
*, const Elf_Internal_Rela
*);
139 static bfd_boolean sh_elf64_check_relocs
140 (bfd
*, struct bfd_link_info
*, asection
*, const Elf_Internal_Rela
*);
141 static int sh64_elf64_get_symbol_type
142 (Elf_Internal_Sym
*, int);
143 static bfd_boolean sh64_elf64_add_symbol_hook
144 (bfd
*, struct bfd_link_info
*, const Elf_Internal_Sym
*, const char **,
145 flagword
*, asection
**, bfd_vma
*);
146 static bfd_boolean sh64_elf64_link_output_symbol_hook
147 (bfd
*, struct bfd_link_info
*, const char *, Elf_Internal_Sym
*,
149 static bfd_boolean sh64_elf64_fake_sections
150 (bfd
*, Elf_Internal_Shdr
*, asection
*);
151 static void sh64_elf64_final_write_processing
152 (bfd
*, bfd_boolean
);
153 static struct bfd_hash_entry
*sh64_elf64_link_hash_newfunc
154 (struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *);
155 static struct bfd_link_hash_table
*sh64_elf64_link_hash_table_create
157 inline static void movi_shori_putval
158 (bfd
*, unsigned long, char *);
159 inline static void movi_3shori_putval
160 (bfd
*, bfd_vma
, char *);
161 static bfd_boolean sh64_elf64_create_dynamic_sections
162 (bfd
*, struct bfd_link_info
*);
163 static bfd_boolean sh64_elf64_adjust_dynamic_symbol
164 (struct bfd_link_info
*info
, struct elf_link_hash_entry
*);
165 static bfd_boolean sh64_elf64_discard_copies
166 (struct elf_sh64_link_hash_entry
*, void *);
167 static bfd_boolean sh64_elf64_size_dynamic_sections
168 (bfd
*, struct bfd_link_info
*);
169 static bfd_boolean sh64_elf64_finish_dynamic_symbol
170 (bfd
*, struct bfd_link_info
*, struct elf_link_hash_entry
*,
172 static bfd_boolean sh64_elf64_finish_dynamic_sections
173 (bfd
*, struct bfd_link_info
*);
175 static reloc_howto_type sh_elf64_howto_table
[] = {
177 HOWTO (R_SH_NONE
, /* type */
179 0, /* size (0 = byte, 1 = short, 2 = long) */
181 FALSE
, /* pc_relative */
183 complain_overflow_dont
, /* complain_on_overflow */
184 sh_elf64_ignore_reloc
, /* special_function */
185 "R_SH_NONE", /* name */
186 FALSE
, /* partial_inplace */
189 FALSE
), /* pcrel_offset */
191 /* 32 bit absolute relocation. Setting partial_inplace to TRUE and
192 src_mask to a non-zero value is similar to the COFF toolchain. */
193 HOWTO (R_SH_DIR32
, /* type */
195 2, /* size (0 = byte, 1 = short, 2 = long) */
197 FALSE
, /* pc_relative */
199 complain_overflow_bitfield
, /* complain_on_overflow */
200 sh_elf64_reloc
, /* special_function */
201 "R_SH_DIR32", /* name */
202 TRUE
, /* partial_inplace */
203 0xffffffff, /* src_mask */
204 0xffffffff, /* dst_mask */
205 FALSE
), /* pcrel_offset */
207 /* 32 bit PC relative relocation. */
208 HOWTO (R_SH_REL32
, /* type */
210 2, /* size (0 = byte, 1 = short, 2 = long) */
212 TRUE
, /* pc_relative */
214 complain_overflow_signed
, /* complain_on_overflow */
215 sh_elf64_ignore_reloc
, /* special_function */
216 "R_SH_REL32", /* name */
217 FALSE
, /* partial_inplace */
219 0xffffffff, /* dst_mask */
220 TRUE
), /* pcrel_offset */
222 /* For 32-bit sh, this is R_SH_DIR8WPN. */
225 /* For 32-bit sh, this is R_SH_IND12W. */
228 /* For 32-bit sh, this is R_SH_DIR8WPL. */
231 /* For 32-bit sh, this is R_SH_DIR8WPZ. */
234 /* For 32-bit sh, this is R_SH_DIR8BP. */
237 /* For 32-bit sh, this is R_SH_DIR8W. */
240 /* For 32-bit sh, this is R_SH_DIR8L. */
259 /* The remaining relocs are a GNU extension used for relaxing. The
260 final pass of the linker never needs to do anything with any of
261 these relocs. Any required operations are handled by the
264 /* A 16 bit switch table entry. This is generated for an expression
265 such as ``.word L1 - L2''. The offset holds the difference
266 between the reloc address and L2. */
267 HOWTO (R_SH_SWITCH16
, /* type */
269 1, /* size (0 = byte, 1 = short, 2 = long) */
271 FALSE
, /* pc_relative */
273 complain_overflow_unsigned
, /* complain_on_overflow */
274 sh_elf64_ignore_reloc
, /* special_function */
275 "R_SH_SWITCH16", /* name */
276 FALSE
, /* partial_inplace */
279 TRUE
), /* pcrel_offset */
281 /* A 32 bit switch table entry. This is generated for an expression
282 such as ``.long L1 - L2''. The offset holds the difference
283 between the reloc address and L2. */
284 HOWTO (R_SH_SWITCH32
, /* type */
286 2, /* size (0 = byte, 1 = short, 2 = long) */
288 FALSE
, /* pc_relative */
290 complain_overflow_unsigned
, /* complain_on_overflow */
291 sh_elf64_ignore_reloc
, /* special_function */
292 "R_SH_SWITCH32", /* name */
293 FALSE
, /* partial_inplace */
296 TRUE
), /* pcrel_offset */
298 /* For 32-bit sh, this is R_SH_USES. */
301 /* For 32-bit sh, this is R_SH_COUNT. */
304 /* For 32-bit sh, this is R_SH_ALIGN. FIXME: For linker relaxation,
305 this might be emitted. When linker relaxation is implemented, we
306 might want to use it. */
309 /* For 32-bit sh, this is R_SH_CODE. FIXME: For linker relaxation,
310 this might be emitted. When linker relaxation is implemented, we
311 might want to use it. */
314 /* For 32-bit sh, this is R_SH_DATA. FIXME: For linker relaxation,
315 this might be emitted. When linker relaxation is implemented, we
316 might want to use it. */
319 /* For 32-bit sh, this is R_SH_LABEL. FIXME: For linker relaxation,
320 this might be emitted. When linker relaxation is implemented, we
321 might want to use it. */
324 /* An 8 bit switch table entry. This is generated for an expression
325 such as ``.word L1 - L2''. The offset holds the difference
326 between the reloc address and L2. */
327 HOWTO (R_SH_SWITCH8
, /* type */
329 0, /* size (0 = byte, 1 = short, 2 = long) */
331 FALSE
, /* pc_relative */
333 complain_overflow_unsigned
, /* complain_on_overflow */
334 sh_elf64_ignore_reloc
, /* special_function */
335 "R_SH_SWITCH8", /* name */
336 FALSE
, /* partial_inplace */
339 TRUE
), /* pcrel_offset */
341 /* GNU extension to record C++ vtable hierarchy */
342 HOWTO (R_SH_GNU_VTINHERIT
, /* type */
344 2, /* size (0 = byte, 1 = short, 2 = long) */
346 FALSE
, /* pc_relative */
348 complain_overflow_dont
, /* complain_on_overflow */
349 NULL
, /* special_function */
350 "R_SH_GNU_VTINHERIT", /* name */
351 FALSE
, /* partial_inplace */
354 FALSE
), /* pcrel_offset */
356 /* GNU extension to record C++ vtable member usage */
357 HOWTO (R_SH_GNU_VTENTRY
, /* type */
359 2, /* size (0 = byte, 1 = short, 2 = long) */
361 FALSE
, /* pc_relative */
363 complain_overflow_dont
, /* complain_on_overflow */
364 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
365 "R_SH_GNU_VTENTRY", /* name */
366 FALSE
, /* partial_inplace */
369 FALSE
), /* pcrel_offset */
371 /* For 32-bit sh, this is R_SH_LOOP_START. */
374 /* For 32-bit sh, this is R_SH_LOOP_END. */
385 /* Used in SHLLI.L and SHLRI.L. */
386 HOWTO (R_SH_DIR5U
, /* type */
388 2, /* size (0 = byte, 1 = short, 2 = long) */
390 FALSE
, /* pc_relative */
392 complain_overflow_unsigned
, /* complain_on_overflow */
393 bfd_elf_generic_reloc
, /* special_function */
394 "R_SH_DIR5U", /* name */
395 FALSE
, /* partial_inplace */
397 0xfc00, /* dst_mask */
398 FALSE
), /* pcrel_offset */
400 /* Used in SHARI, SHLLI et al. */
401 HOWTO (R_SH_DIR6U
, /* type */
403 2, /* size (0 = byte, 1 = short, 2 = long) */
405 FALSE
, /* pc_relative */
407 complain_overflow_unsigned
, /* complain_on_overflow */
408 bfd_elf_generic_reloc
, /* special_function */
409 "R_SH_DIR6U", /* name */
410 FALSE
, /* partial_inplace */
412 0xfc00, /* dst_mask */
413 FALSE
), /* pcrel_offset */
415 /* Used in BxxI, LDHI.L et al. */
416 HOWTO (R_SH_DIR6S
, /* type */
418 2, /* size (0 = byte, 1 = short, 2 = long) */
420 FALSE
, /* pc_relative */
422 complain_overflow_signed
, /* complain_on_overflow */
423 bfd_elf_generic_reloc
, /* special_function */
424 "R_SH_DIR6S", /* name */
425 FALSE
, /* partial_inplace */
427 0xfc00, /* dst_mask */
428 FALSE
), /* pcrel_offset */
430 /* Used in ADDI, ANDI et al. */
431 HOWTO (R_SH_DIR10S
, /* type */
433 2, /* size (0 = byte, 1 = short, 2 = long) */
435 FALSE
, /* pc_relative */
437 complain_overflow_signed
, /* complain_on_overflow */
438 bfd_elf_generic_reloc
, /* special_function */
439 "R_SH_DIR10S", /* name */
440 FALSE
, /* partial_inplace */
442 0xffc00, /* dst_mask */
443 FALSE
), /* pcrel_offset */
445 /* Used in LD.UW, ST.W et al. */
446 HOWTO (R_SH_DIR10SW
, /* type */
448 2, /* size (0 = byte, 1 = short, 2 = long) */
450 FALSE
, /* pc_relative */
452 complain_overflow_signed
, /* complain_on_overflow */
453 bfd_elf_generic_reloc
, /* special_function */
454 "R_SH_DIR10SW", /* name */
455 FALSE
, /* partial_inplace */
457 0xffc00, /* dst_mask */
458 FALSE
), /* pcrel_offset */
460 /* Used in LD.L, FLD.S et al. */
461 HOWTO (R_SH_DIR10SL
, /* type */
463 2, /* size (0 = byte, 1 = short, 2 = long) */
465 FALSE
, /* pc_relative */
467 complain_overflow_signed
, /* complain_on_overflow */
468 bfd_elf_generic_reloc
, /* special_function */
469 "R_SH_DIR10SL", /* name */
470 FALSE
, /* partial_inplace */
472 0xffc00, /* dst_mask */
473 FALSE
), /* pcrel_offset */
475 /* Used in FLD.D, FST.P et al. */
476 HOWTO (R_SH_DIR10SQ
, /* type */
478 2, /* size (0 = byte, 1 = short, 2 = long) */
480 FALSE
, /* pc_relative */
482 complain_overflow_signed
, /* complain_on_overflow */
483 bfd_elf_generic_reloc
, /* special_function */
484 "R_SH_DIR10SQ", /* name */
485 FALSE
, /* partial_inplace */
487 0xffc00, /* dst_mask */
488 FALSE
), /* pcrel_offset */
599 /* Relocs for dynamic linking for 32-bit SH would follow. We don't have
600 any dynamic linking support for 64-bit SH at present. */
612 /* Back to SH5 relocations. */
613 /* Used in MOVI and SHORI (x & 65536). */
614 HOWTO (R_SH_GOT_LOW16
, /* type */
616 2, /* size (0 = byte, 1 = short, 2 = long) */
618 FALSE
, /* pc_relative */
620 complain_overflow_dont
, /* complain_on_overflow */
621 bfd_elf_generic_reloc
, /* special_function */
622 "R_SH_GOT_LOW16", /* name */
623 FALSE
, /* partial_inplace */
625 0x3fffc00, /* dst_mask */
626 FALSE
), /* pcrel_offset */
628 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
629 HOWTO (R_SH_GOT_MEDLOW16
, /* type */
631 2, /* size (0 = byte, 1 = short, 2 = long) */
633 FALSE
, /* pc_relative */
635 complain_overflow_dont
, /* complain_on_overflow */
636 bfd_elf_generic_reloc
, /* special_function */
637 "R_SH_GOT_MEDLOW16", /* name */
638 FALSE
, /* partial_inplace */
640 0x3fffc00, /* dst_mask */
641 FALSE
), /* pcrel_offset */
643 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
644 HOWTO (R_SH_GOT_MEDHI16
, /* type */
646 2, /* size (0 = byte, 1 = short, 2 = long) */
648 FALSE
, /* pc_relative */
650 complain_overflow_dont
, /* complain_on_overflow */
651 bfd_elf_generic_reloc
, /* special_function */
652 "R_SH_GOT_MEDHI16", /* name */
653 FALSE
, /* partial_inplace */
655 0x3fffc00, /* dst_mask */
656 FALSE
), /* pcrel_offset */
658 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
659 HOWTO (R_SH_GOT_HI16
, /* type */
661 2, /* size (0 = byte, 1 = short, 2 = long) */
663 FALSE
, /* pc_relative */
665 complain_overflow_dont
, /* complain_on_overflow */
666 bfd_elf_generic_reloc
, /* special_function */
667 "R_SH_GOT_HI16", /* name */
668 FALSE
, /* partial_inplace */
670 0x3fffc00, /* dst_mask */
671 FALSE
), /* pcrel_offset */
673 /* Used in MOVI and SHORI (x & 65536). */
674 HOWTO (R_SH_GOTPLT_LOW16
, /* type */
676 2, /* size (0 = byte, 1 = short, 2 = long) */
678 FALSE
, /* pc_relative */
680 complain_overflow_dont
, /* complain_on_overflow */
681 bfd_elf_generic_reloc
, /* special_function */
682 "R_SH_GOTPLT_LOW16", /* name */
683 FALSE
, /* partial_inplace */
685 0x3fffc00, /* dst_mask */
686 FALSE
), /* pcrel_offset */
688 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
689 HOWTO (R_SH_GOTPLT_MEDLOW16
, /* type */
691 2, /* size (0 = byte, 1 = short, 2 = long) */
693 FALSE
, /* pc_relative */
695 complain_overflow_dont
, /* complain_on_overflow */
696 bfd_elf_generic_reloc
, /* special_function */
697 "R_SH_GOTPLT_MEDLOW16", /* name */
698 FALSE
, /* partial_inplace */
700 0x3fffc00, /* dst_mask */
701 FALSE
), /* pcrel_offset */
703 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
704 HOWTO (R_SH_GOTPLT_MEDHI16
, /* type */
706 2, /* size (0 = byte, 1 = short, 2 = long) */
708 FALSE
, /* pc_relative */
710 complain_overflow_dont
, /* complain_on_overflow */
711 bfd_elf_generic_reloc
, /* special_function */
712 "R_SH_GOTPLT_MEDHI16", /* name */
713 FALSE
, /* partial_inplace */
715 0x3fffc00, /* dst_mask */
716 FALSE
), /* pcrel_offset */
718 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
719 HOWTO (R_SH_GOTPLT_HI16
, /* type */
721 2, /* size (0 = byte, 1 = short, 2 = long) */
723 FALSE
, /* pc_relative */
725 complain_overflow_dont
, /* complain_on_overflow */
726 bfd_elf_generic_reloc
, /* special_function */
727 "R_SH_GOTPLT_HI16", /* name */
728 FALSE
, /* partial_inplace */
730 0x3fffc00, /* dst_mask */
731 FALSE
), /* pcrel_offset */
733 /* Used in MOVI and SHORI (x & 65536). */
734 HOWTO (R_SH_PLT_LOW16
, /* type */
736 2, /* size (0 = byte, 1 = short, 2 = long) */
738 TRUE
, /* pc_relative */
740 complain_overflow_dont
, /* complain_on_overflow */
741 bfd_elf_generic_reloc
, /* special_function */
742 "R_SH_PLT_LOW16", /* name */
743 FALSE
, /* partial_inplace */
745 0x3fffc00, /* dst_mask */
746 TRUE
), /* pcrel_offset */
748 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
749 HOWTO (R_SH_PLT_MEDLOW16
, /* type */
751 2, /* size (0 = byte, 1 = short, 2 = long) */
753 TRUE
, /* pc_relative */
755 complain_overflow_dont
, /* complain_on_overflow */
756 bfd_elf_generic_reloc
, /* special_function */
757 "R_SH_PLT_MEDLOW16", /* name */
758 FALSE
, /* partial_inplace */
760 0x3fffc00, /* dst_mask */
761 TRUE
), /* pcrel_offset */
763 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
764 HOWTO (R_SH_PLT_MEDHI16
, /* type */
766 2, /* size (0 = byte, 1 = short, 2 = long) */
768 TRUE
, /* pc_relative */
770 complain_overflow_dont
, /* complain_on_overflow */
771 bfd_elf_generic_reloc
, /* special_function */
772 "R_SH_PLT_MEDHI16", /* name */
773 FALSE
, /* partial_inplace */
775 0x3fffc00, /* dst_mask */
776 TRUE
), /* pcrel_offset */
778 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
779 HOWTO (R_SH_PLT_HI16
, /* type */
781 2, /* size (0 = byte, 1 = short, 2 = long) */
783 TRUE
, /* pc_relative */
785 complain_overflow_dont
, /* complain_on_overflow */
786 bfd_elf_generic_reloc
, /* special_function */
787 "R_SH_PLT_HI16", /* name */
788 FALSE
, /* partial_inplace */
790 0x3fffc00, /* dst_mask */
791 TRUE
), /* pcrel_offset */
793 /* Used in MOVI and SHORI (x & 65536). */
794 HOWTO (R_SH_GOTOFF_LOW16
, /* type */
796 2, /* size (0 = byte, 1 = short, 2 = long) */
798 FALSE
, /* pc_relative */
800 complain_overflow_dont
, /* complain_on_overflow */
801 bfd_elf_generic_reloc
, /* special_function */
802 "R_SH_GOTOFF_LOW16", /* name */
803 FALSE
, /* partial_inplace */
805 0x3fffc00, /* dst_mask */
806 FALSE
), /* pcrel_offset */
808 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
809 HOWTO (R_SH_GOTOFF_MEDLOW16
, /* type */
811 2, /* size (0 = byte, 1 = short, 2 = long) */
813 FALSE
, /* pc_relative */
815 complain_overflow_dont
, /* complain_on_overflow */
816 bfd_elf_generic_reloc
, /* special_function */
817 "R_SH_GOTOFF_MEDLOW16", /* name */
818 FALSE
, /* partial_inplace */
820 0x3fffc00, /* dst_mask */
821 FALSE
), /* pcrel_offset */
823 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
824 HOWTO (R_SH_GOTOFF_MEDHI16
, /* type */
826 2, /* size (0 = byte, 1 = short, 2 = long) */
828 FALSE
, /* pc_relative */
830 complain_overflow_dont
, /* complain_on_overflow */
831 bfd_elf_generic_reloc
, /* special_function */
832 "R_SH_GOTOFF_MEDHI16", /* name */
833 FALSE
, /* partial_inplace */
835 0x3fffc00, /* dst_mask */
836 FALSE
), /* pcrel_offset */
838 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
839 HOWTO (R_SH_GOTOFF_HI16
, /* type */
841 2, /* size (0 = byte, 1 = short, 2 = long) */
843 FALSE
, /* pc_relative */
845 complain_overflow_dont
, /* complain_on_overflow */
846 bfd_elf_generic_reloc
, /* special_function */
847 "R_SH_GOTOFF_HI16", /* name */
848 FALSE
, /* partial_inplace */
850 0x3fffc00, /* dst_mask */
851 FALSE
), /* pcrel_offset */
853 /* Used in MOVI and SHORI (x & 65536). */
854 HOWTO (R_SH_GOTPC_LOW16
, /* type */
856 2, /* size (0 = byte, 1 = short, 2 = long) */
858 TRUE
, /* pc_relative */
860 complain_overflow_dont
, /* complain_on_overflow */
861 bfd_elf_generic_reloc
, /* special_function */
862 "R_SH_GOTPC_LOW16", /* name */
863 FALSE
, /* partial_inplace */
865 0x3fffc00, /* dst_mask */
866 TRUE
), /* pcrel_offset */
868 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
869 HOWTO (R_SH_GOTPC_MEDLOW16
, /* type */
871 2, /* size (0 = byte, 1 = short, 2 = long) */
873 TRUE
, /* pc_relative */
875 complain_overflow_dont
, /* complain_on_overflow */
876 bfd_elf_generic_reloc
, /* special_function */
877 "R_SH_GOTPC_MEDLOW16", /* name */
878 FALSE
, /* partial_inplace */
880 0x3fffc00, /* dst_mask */
881 TRUE
), /* pcrel_offset */
883 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
884 HOWTO (R_SH_GOTPC_MEDHI16
, /* type */
886 2, /* size (0 = byte, 1 = short, 2 = long) */
888 TRUE
, /* pc_relative */
890 complain_overflow_dont
, /* complain_on_overflow */
891 bfd_elf_generic_reloc
, /* special_function */
892 "R_SH_GOTPC_MEDHI16", /* name */
893 FALSE
, /* partial_inplace */
895 0x3fffc00, /* dst_mask */
896 TRUE
), /* pcrel_offset */
898 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
899 HOWTO (R_SH_GOTPC_HI16
, /* type */
901 2, /* size (0 = byte, 1 = short, 2 = long) */
903 TRUE
, /* pc_relative */
905 complain_overflow_dont
, /* complain_on_overflow */
906 bfd_elf_generic_reloc
, /* special_function */
907 "R_SH_GOTPC_HI16", /* name */
908 FALSE
, /* partial_inplace */
910 0x3fffc00, /* dst_mask */
911 TRUE
), /* pcrel_offset */
913 /* Used in LD.L, FLD.S et al. */
914 HOWTO (R_SH_GOT10BY4
, /* type */
916 2, /* size (0 = byte, 1 = short, 2 = long) */
918 FALSE
, /* pc_relative */
920 complain_overflow_signed
, /* complain_on_overflow */
921 bfd_elf_generic_reloc
, /* special_function */
922 "R_SH_GOT10BY4", /* name */
923 FALSE
, /* partial_inplace */
925 0xffc00, /* dst_mask */
926 FALSE
), /* pcrel_offset */
928 /* Used in LD.L, FLD.S et al. */
929 HOWTO (R_SH_GOTPLT10BY4
, /* type */
931 2, /* size (0 = byte, 1 = short, 2 = long) */
933 FALSE
, /* pc_relative */
935 complain_overflow_signed
, /* complain_on_overflow */
936 bfd_elf_generic_reloc
, /* special_function */
937 "R_SH_GOTPLT10BY4", /* name */
938 FALSE
, /* partial_inplace */
940 0xffc00, /* dst_mask */
941 FALSE
), /* pcrel_offset */
943 /* Used in FLD.D, FST.P et al. */
944 HOWTO (R_SH_GOT10BY8
, /* type */
946 2, /* size (0 = byte, 1 = short, 2 = long) */
948 FALSE
, /* pc_relative */
950 complain_overflow_signed
, /* complain_on_overflow */
951 bfd_elf_generic_reloc
, /* special_function */
952 "R_SH_GOT10BY8", /* name */
953 FALSE
, /* partial_inplace */
955 0xffc00, /* dst_mask */
956 FALSE
), /* pcrel_offset */
958 /* Used in FLD.D, FST.P et al. */
959 HOWTO (R_SH_GOTPLT10BY8
, /* type */
961 2, /* size (0 = byte, 1 = short, 2 = long) */
963 FALSE
, /* pc_relative */
965 complain_overflow_signed
, /* complain_on_overflow */
966 bfd_elf_generic_reloc
, /* special_function */
967 "R_SH_GOTPLT10BY8", /* name */
968 FALSE
, /* partial_inplace */
970 0xffc00, /* dst_mask */
971 FALSE
), /* pcrel_offset */
973 HOWTO (R_SH_COPY64
, /* type */
975 4, /* size (0 = byte, 1 = short, 2 = long) */
977 FALSE
, /* pc_relative */
979 complain_overflow_dont
, /* complain_on_overflow */
980 bfd_elf_generic_reloc
, /* special_function */
981 "R_SH_COPY64", /* name */
982 FALSE
, /* partial_inplace */
984 ((bfd_vma
) 0) - 1, /* dst_mask */
985 FALSE
), /* pcrel_offset */
987 HOWTO (R_SH_GLOB_DAT64
, /* type */
989 4, /* size (0 = byte, 1 = short, 2 = long) */
991 FALSE
, /* pc_relative */
993 complain_overflow_dont
, /* complain_on_overflow */
994 bfd_elf_generic_reloc
, /* special_function */
995 "R_SH_GLOB_DAT64", /* name */
996 FALSE
, /* partial_inplace */
998 ((bfd_vma
) 0) - 1, /* dst_mask */
999 FALSE
), /* pcrel_offset */
1001 HOWTO (R_SH_JMP_SLOT64
, /* type */
1003 4, /* size (0 = byte, 1 = short, 2 = long) */
1005 FALSE
, /* pc_relative */
1007 complain_overflow_dont
, /* complain_on_overflow */
1008 bfd_elf_generic_reloc
, /* special_function */
1009 "R_SH_JMP_SLOT64", /* name */
1010 FALSE
, /* partial_inplace */
1012 ((bfd_vma
) 0) - 1, /* dst_mask */
1013 FALSE
), /* pcrel_offset */
1015 HOWTO (R_SH_RELATIVE64
, /* type */
1017 4, /* size (0 = byte, 1 = short, 2 = long) */
1019 FALSE
, /* pc_relative */
1021 complain_overflow_dont
, /* complain_on_overflow */
1022 bfd_elf_generic_reloc
, /* special_function */
1023 "R_SH_RELATIVE64", /* name */
1024 FALSE
, /* partial_inplace */
1026 ((bfd_vma
) 0) - 1, /* dst_mask */
1027 FALSE
), /* pcrel_offset */
1075 /* Relocations for SHmedia code. None of these are partial_inplace or
1076 use the field being relocated. */
1078 /* The assembler will generate this reloc before a block of SHmedia
1079 instructions. A section should be processed as assuming it contains
1080 data, unless this reloc is seen. Note that a block of SHcompact
1081 instructions are instead preceded by R_SH_CODE.
1082 This is currently not implemented, but should be used for SHmedia
1083 linker relaxation. */
1084 HOWTO (R_SH_SHMEDIA_CODE
, /* type */
1086 1, /* size (0 = byte, 1 = short, 2 = long) */
1088 FALSE
, /* pc_relative */
1090 complain_overflow_unsigned
, /* complain_on_overflow */
1091 sh_elf64_ignore_reloc
, /* special_function */
1092 "R_SH_SHMEDIA_CODE", /* name */
1093 FALSE
, /* partial_inplace */
1096 FALSE
), /* pcrel_offset */
1098 /* The assembler will generate this reloc at a PTA or PTB instruction,
1099 and the linker checks the right type of target, or changes a PTA to a
1100 PTB, if the original insn was PT. */
1101 HOWTO (R_SH_PT_16
, /* type */
1103 2, /* size (0 = byte, 1 = short, 2 = long) */
1105 TRUE
, /* pc_relative */
1107 complain_overflow_signed
, /* complain_on_overflow */
1108 bfd_elf_generic_reloc
, /* special_function */
1109 "R_SH_PT_16", /* name */
1110 FALSE
, /* partial_inplace */
1112 0x3fffc00, /* dst_mask */
1113 TRUE
), /* pcrel_offset */
1115 /* Used in unexpanded MOVI. */
1116 HOWTO (R_SH_IMMS16
, /* type */
1118 2, /* size (0 = byte, 1 = short, 2 = long) */
1120 FALSE
, /* pc_relative */
1122 complain_overflow_signed
, /* complain_on_overflow */
1123 bfd_elf_generic_reloc
, /* special_function */
1124 "R_SH_IMMS16", /* name */
1125 FALSE
, /* partial_inplace */
1127 0x3fffc00, /* dst_mask */
1128 FALSE
), /* pcrel_offset */
1130 /* Used in SHORI. */
1131 HOWTO (R_SH_IMMU16
, /* type */
1133 2, /* size (0 = byte, 1 = short, 2 = long) */
1135 FALSE
, /* pc_relative */
1137 complain_overflow_unsigned
, /* complain_on_overflow */
1138 bfd_elf_generic_reloc
, /* special_function */
1139 "R_SH_IMMU16", /* name */
1140 FALSE
, /* partial_inplace */
1142 0x3fffc00, /* dst_mask */
1143 FALSE
), /* pcrel_offset */
1145 /* Used in MOVI and SHORI (x & 65536). */
1146 HOWTO (R_SH_IMM_LOW16
, /* type */
1148 2, /* size (0 = byte, 1 = short, 2 = long) */
1150 FALSE
, /* pc_relative */
1152 complain_overflow_dont
, /* complain_on_overflow */
1153 bfd_elf_generic_reloc
, /* special_function */
1154 "R_SH_IMM_LOW16", /* name */
1155 FALSE
, /* partial_inplace */
1157 0x3fffc00, /* dst_mask */
1158 FALSE
), /* pcrel_offset */
1160 /* Used in MOVI and SHORI ((x - $) & 65536). */
1161 HOWTO (R_SH_IMM_LOW16_PCREL
, /* type */
1163 2, /* size (0 = byte, 1 = short, 2 = long) */
1165 TRUE
, /* pc_relative */
1167 complain_overflow_dont
, /* complain_on_overflow */
1168 bfd_elf_generic_reloc
, /* special_function */
1169 "R_SH_IMM_LOW16_PCREL", /* name */
1170 FALSE
, /* partial_inplace */
1172 0x3fffc00, /* dst_mask */
1173 TRUE
), /* pcrel_offset */
1175 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
1176 HOWTO (R_SH_IMM_MEDLOW16
, /* type */
1177 16, /* rightshift */
1178 2, /* size (0 = byte, 1 = short, 2 = long) */
1180 FALSE
, /* pc_relative */
1182 complain_overflow_dont
, /* complain_on_overflow */
1183 bfd_elf_generic_reloc
, /* special_function */
1184 "R_SH_IMM_MEDLOW16", /* name */
1185 FALSE
, /* partial_inplace */
1187 0x3fffc00, /* dst_mask */
1188 FALSE
), /* pcrel_offset */
1190 /* Used in MOVI and SHORI (((x - $) >> 16) & 65536). */
1191 HOWTO (R_SH_IMM_MEDLOW16_PCREL
, /* type */
1192 16, /* rightshift */
1193 2, /* size (0 = byte, 1 = short, 2 = long) */
1195 TRUE
, /* pc_relative */
1197 complain_overflow_dont
, /* complain_on_overflow */
1198 bfd_elf_generic_reloc
, /* special_function */
1199 "R_SH_IMM_MEDLOW16_PCREL", /* name */
1200 FALSE
, /* partial_inplace */
1202 0x3fffc00, /* dst_mask */
1203 TRUE
), /* pcrel_offset */
1205 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
1206 HOWTO (R_SH_IMM_MEDHI16
, /* type */
1207 32, /* rightshift */
1208 2, /* size (0 = byte, 1 = short, 2 = long) */
1210 FALSE
, /* pc_relative */
1212 complain_overflow_dont
, /* complain_on_overflow */
1213 bfd_elf_generic_reloc
, /* special_function */
1214 "R_SH_IMM_MEDHI16", /* name */
1215 FALSE
, /* partial_inplace */
1217 0x3fffc00, /* dst_mask */
1218 FALSE
), /* pcrel_offset */
1220 /* Used in MOVI and SHORI (((x - $) >> 32) & 65536). */
1221 HOWTO (R_SH_IMM_MEDHI16_PCREL
, /* type */
1222 32, /* rightshift */
1223 2, /* size (0 = byte, 1 = short, 2 = long) */
1225 TRUE
, /* pc_relative */
1227 complain_overflow_dont
, /* complain_on_overflow */
1228 bfd_elf_generic_reloc
, /* special_function */
1229 "R_SH_IMM_MEDHI16_PCREL", /* name */
1230 FALSE
, /* partial_inplace */
1232 0x3fffc00, /* dst_mask */
1233 TRUE
), /* pcrel_offset */
1235 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
1236 HOWTO (R_SH_IMM_HI16
, /* type */
1237 48, /* rightshift */
1238 2, /* size (0 = byte, 1 = short, 2 = long) */
1240 FALSE
, /* pc_relative */
1242 complain_overflow_dont
, /* complain_on_overflow */
1243 bfd_elf_generic_reloc
, /* special_function */
1244 "R_SH_IMM_HI16", /* name */
1245 FALSE
, /* partial_inplace */
1247 0x3fffc00, /* dst_mask */
1248 FALSE
), /* pcrel_offset */
1250 /* Used in MOVI and SHORI (((x - $) >> 48) & 65536). */
1251 HOWTO (R_SH_IMM_HI16_PCREL
, /* type */
1252 48, /* rightshift */
1253 2, /* size (0 = byte, 1 = short, 2 = long) */
1255 TRUE
, /* pc_relative */
1257 complain_overflow_dont
, /* complain_on_overflow */
1258 bfd_elf_generic_reloc
, /* special_function */
1259 "R_SH_IMM_HI16_PCREL", /* name */
1260 FALSE
, /* partial_inplace */
1262 0x3fffc00, /* dst_mask */
1263 TRUE
), /* pcrel_offset */
1265 /* For the .uaquad pseudo. */
1266 HOWTO (R_SH_64
, /* type */
1268 4, /* size (0 = byte, 1 = short, 2 = long) */
1270 FALSE
, /* pc_relative */
1272 complain_overflow_dont
, /* complain_on_overflow */
1273 bfd_elf_generic_reloc
, /* special_function */
1274 "R_SH_64", /* name */
1275 FALSE
, /* partial_inplace */
1277 ((bfd_vma
) 0) - 1, /* dst_mask */
1278 FALSE
), /* pcrel_offset */
1280 /* For the .uaquad pseudo, (x - $). */
1281 HOWTO (R_SH_64_PCREL
, /* type */
1282 48, /* rightshift */
1283 2, /* size (0 = byte, 1 = short, 2 = long) */
1285 TRUE
, /* pc_relative */
1287 complain_overflow_dont
, /* complain_on_overflow */
1288 bfd_elf_generic_reloc
, /* special_function */
1289 "R_SH_64_PCREL", /* name */
1290 FALSE
, /* partial_inplace */
1292 ((bfd_vma
) 0) - 1, /* dst_mask */
1293 TRUE
), /* pcrel_offset */
1297 /* This function is used for relocs which are only used for relaxing,
1298 which the linker should otherwise ignore. */
1300 static bfd_reloc_status_type
1301 sh_elf64_ignore_reloc (bfd
*abfd ATTRIBUTE_UNUSED
, arelent
*reloc_entry
,
1302 asymbol
*symbol ATTRIBUTE_UNUSED
,
1303 void *data ATTRIBUTE_UNUSED
, asection
*input_section
,
1305 char **error_message ATTRIBUTE_UNUSED
)
1307 if (output_bfd
!= NULL
)
1308 reloc_entry
->address
+= input_section
->output_offset
;
1309 return bfd_reloc_ok
;
1312 /* This function is used for normal relocs. This used to be like the COFF
1313 function, and is almost certainly incorrect for other ELF targets.
1315 See sh_elf_reloc in elf32-sh.c for the original. */
1317 static bfd_reloc_status_type
1318 sh_elf64_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol_in
,
1319 void *data
, asection
*input_section
, bfd
*output_bfd
,
1320 char **error_message ATTRIBUTE_UNUSED
)
1324 enum elf_sh_reloc_type r_type
;
1325 bfd_vma addr
= reloc_entry
->address
;
1326 bfd_byte
*hit_data
= addr
+ (bfd_byte
*) data
;
1328 r_type
= (enum elf_sh_reloc_type
) reloc_entry
->howto
->type
;
1330 if (output_bfd
!= NULL
)
1332 /* Partial linking--do nothing. */
1333 reloc_entry
->address
+= input_section
->output_offset
;
1334 return bfd_reloc_ok
;
1337 if (symbol_in
!= NULL
1338 && bfd_is_und_section (symbol_in
->section
))
1339 return bfd_reloc_undefined
;
1341 if (bfd_is_com_section (symbol_in
->section
))
1344 sym_value
= (symbol_in
->value
+
1345 symbol_in
->section
->output_section
->vma
+
1346 symbol_in
->section
->output_offset
);
1351 insn
= bfd_get_32 (abfd
, hit_data
);
1352 insn
+= sym_value
+ reloc_entry
->addend
;
1353 bfd_put_32 (abfd
, insn
, hit_data
);
1361 return bfd_reloc_ok
;
1364 /* This structure is used to map BFD reloc codes to SH ELF relocs. */
1366 struct elf_reloc_map
1368 bfd_reloc_code_real_type bfd_reloc_val
;
1369 unsigned char elf_reloc_val
;
1372 /* An array mapping BFD reloc codes to SH ELF relocs. */
1374 static const struct elf_reloc_map sh64_reloc_map
[] =
1376 { BFD_RELOC_NONE
, R_SH_NONE
},
1377 { BFD_RELOC_32
, R_SH_DIR32
},
1378 { BFD_RELOC_CTOR
, R_SH_DIR32
},
1379 { BFD_RELOC_32_PCREL
, R_SH_REL32
},
1380 { BFD_RELOC_8_PCREL
, R_SH_SWITCH8
},
1381 { BFD_RELOC_SH_SWITCH16
, R_SH_SWITCH16
},
1382 { BFD_RELOC_SH_SWITCH32
, R_SH_SWITCH32
},
1383 { BFD_RELOC_VTABLE_INHERIT
, R_SH_GNU_VTINHERIT
},
1384 { BFD_RELOC_VTABLE_ENTRY
, R_SH_GNU_VTENTRY
},
1385 { BFD_RELOC_SH_GOT_LOW16
, R_SH_GOT_LOW16
},
1386 { BFD_RELOC_SH_GOT_MEDLOW16
, R_SH_GOT_MEDLOW16
},
1387 { BFD_RELOC_SH_GOT_MEDHI16
, R_SH_GOT_MEDHI16
},
1388 { BFD_RELOC_SH_GOT_HI16
, R_SH_GOT_HI16
},
1389 { BFD_RELOC_SH_GOTPLT_LOW16
, R_SH_GOTPLT_LOW16
},
1390 { BFD_RELOC_SH_GOTPLT_MEDLOW16
, R_SH_GOTPLT_MEDLOW16
},
1391 { BFD_RELOC_SH_GOTPLT_MEDHI16
, R_SH_GOTPLT_MEDHI16
},
1392 { BFD_RELOC_SH_GOTPLT_HI16
, R_SH_GOTPLT_HI16
},
1393 { BFD_RELOC_SH_PLT_LOW16
, R_SH_PLT_LOW16
},
1394 { BFD_RELOC_SH_PLT_MEDLOW16
, R_SH_PLT_MEDLOW16
},
1395 { BFD_RELOC_SH_PLT_MEDHI16
, R_SH_PLT_MEDHI16
},
1396 { BFD_RELOC_SH_PLT_HI16
, R_SH_PLT_HI16
},
1397 { BFD_RELOC_SH_GOTOFF_LOW16
, R_SH_GOTOFF_LOW16
},
1398 { BFD_RELOC_SH_GOTOFF_MEDLOW16
, R_SH_GOTOFF_MEDLOW16
},
1399 { BFD_RELOC_SH_GOTOFF_MEDHI16
, R_SH_GOTOFF_MEDHI16
},
1400 { BFD_RELOC_SH_GOTOFF_HI16
, R_SH_GOTOFF_HI16
},
1401 { BFD_RELOC_SH_GOTPC_LOW16
, R_SH_GOTPC_LOW16
},
1402 { BFD_RELOC_SH_GOTPC_MEDLOW16
, R_SH_GOTPC_MEDLOW16
},
1403 { BFD_RELOC_SH_GOTPC_MEDHI16
, R_SH_GOTPC_MEDHI16
},
1404 { BFD_RELOC_SH_GOTPC_HI16
, R_SH_GOTPC_HI16
},
1405 { BFD_RELOC_SH_COPY64
, R_SH_COPY64
},
1406 { BFD_RELOC_SH_GLOB_DAT64
, R_SH_GLOB_DAT64
},
1407 { BFD_RELOC_SH_JMP_SLOT64
, R_SH_JMP_SLOT64
},
1408 { BFD_RELOC_SH_RELATIVE64
, R_SH_RELATIVE64
},
1409 { BFD_RELOC_SH_GOT10BY4
, R_SH_GOT10BY4
},
1410 { BFD_RELOC_SH_GOT10BY8
, R_SH_GOT10BY8
},
1411 { BFD_RELOC_SH_GOTPLT10BY4
, R_SH_GOTPLT10BY4
},
1412 { BFD_RELOC_SH_GOTPLT10BY8
, R_SH_GOTPLT10BY8
},
1413 { BFD_RELOC_SH_PT_16
, R_SH_PT_16
},
1414 { BFD_RELOC_SH_SHMEDIA_CODE
, R_SH_SHMEDIA_CODE
},
1415 { BFD_RELOC_SH_IMMU5
, R_SH_DIR5U
},
1416 { BFD_RELOC_SH_IMMS6
, R_SH_DIR6S
},
1417 { BFD_RELOC_SH_IMMU6
, R_SH_DIR6U
},
1418 { BFD_RELOC_SH_IMMS10
, R_SH_DIR10S
},
1419 { BFD_RELOC_SH_IMMS10BY2
, R_SH_DIR10SW
},
1420 { BFD_RELOC_SH_IMMS10BY4
, R_SH_DIR10SL
},
1421 { BFD_RELOC_SH_IMMS10BY8
, R_SH_DIR10SQ
},
1422 { BFD_RELOC_SH_IMMS16
, R_SH_IMMS16
},
1423 { BFD_RELOC_SH_IMMU16
, R_SH_IMMU16
},
1424 { BFD_RELOC_SH_IMM_LOW16
, R_SH_IMM_LOW16
},
1425 { BFD_RELOC_SH_IMM_LOW16_PCREL
, R_SH_IMM_LOW16_PCREL
},
1426 { BFD_RELOC_SH_IMM_MEDLOW16
, R_SH_IMM_MEDLOW16
},
1427 { BFD_RELOC_SH_IMM_MEDLOW16_PCREL
, R_SH_IMM_MEDLOW16_PCREL
},
1428 { BFD_RELOC_SH_IMM_MEDHI16
, R_SH_IMM_MEDHI16
},
1429 { BFD_RELOC_SH_IMM_MEDHI16_PCREL
, R_SH_IMM_MEDHI16_PCREL
},
1430 { BFD_RELOC_SH_IMM_HI16
, R_SH_IMM_HI16
},
1431 { BFD_RELOC_SH_IMM_HI16_PCREL
, R_SH_IMM_HI16_PCREL
},
1432 { BFD_RELOC_64
, R_SH_64
},
1433 { BFD_RELOC_64_PCREL
, R_SH_64_PCREL
},
1436 /* Given a BFD reloc code, return the howto structure for the
1437 corresponding SH ELf reloc. */
1439 static reloc_howto_type
*
1440 sh_elf64_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1441 bfd_reloc_code_real_type code
)
1445 for (i
= 0; i
< sizeof (sh64_reloc_map
) / sizeof (struct elf_reloc_map
); i
++)
1447 if (sh64_reloc_map
[i
].bfd_reloc_val
== code
)
1448 return &sh_elf64_howto_table
[(int) sh64_reloc_map
[i
].elf_reloc_val
];
1454 /* Given an ELF reloc, fill in the howto field of a relent.
1456 See sh_elf_info_to_howto in elf32-sh.c for the original. */
1459 sh_elf64_info_to_howto (bfd
*abfd ATTRIBUTE_UNUSED
, arelent
*cache_ptr
,
1460 Elf_Internal_Rela
*dst
)
1464 r
= ELF64_R_TYPE (dst
->r_info
);
1466 BFD_ASSERT (r
<= (unsigned int) R_SH_64_PCREL
);
1467 BFD_ASSERT (r
< R_SH_FIRST_INVALID_RELOC
|| r
> R_SH_LAST_INVALID_RELOC
);
1468 BFD_ASSERT (r
< R_SH_DIR8WPN
|| r
> R_SH_LAST_INVALID_RELOC_2
);
1469 BFD_ASSERT (r
< R_SH_FIRST_INVALID_RELOC_3
|| r
> R_SH_GOTPLT32
);
1470 BFD_ASSERT (r
< R_SH_FIRST_INVALID_RELOC_4
|| r
> R_SH_LAST_INVALID_RELOC_4
);
1472 cache_ptr
->howto
= &sh_elf64_howto_table
[r
];
1475 /* Relocate an SH ELF section.
1477 See sh_elf_info_to_howto in elf32-sh.c for the original. */
1480 sh_elf64_relocate_section (bfd
*output_bfd ATTRIBUTE_UNUSED
,
1481 struct bfd_link_info
*info
, bfd
*input_bfd
,
1482 asection
*input_section
, bfd_byte
*contents
,
1483 Elf_Internal_Rela
*relocs
,
1484 Elf_Internal_Sym
*local_syms
,
1485 asection
**local_sections
)
1487 Elf_Internal_Shdr
*symtab_hdr
;
1488 struct elf_link_hash_entry
**sym_hashes
;
1489 Elf_Internal_Rela
*rel
, *relend
;
1491 bfd_vma
*local_got_offsets
;
1496 bfd_vma disp
, dropped
;
1498 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
1499 sym_hashes
= elf_sym_hashes (input_bfd
);
1500 dynobj
= elf_hash_table (info
)->dynobj
;
1501 local_got_offsets
= elf_local_got_offsets (input_bfd
);
1509 relend
= relocs
+ input_section
->reloc_count
;
1510 for (; rel
< relend
; rel
++)
1513 reloc_howto_type
*howto
;
1514 unsigned long r_symndx
;
1515 Elf_Internal_Sym
*sym
;
1517 struct elf_link_hash_entry
*h
;
1519 bfd_vma addend
= (bfd_vma
)0;
1520 bfd_reloc_status_type r
;
1521 int seen_stt_datalabel
= 0;
1523 r_symndx
= ELF64_R_SYM (rel
->r_info
);
1525 r_type
= ELF64_R_TYPE (rel
->r_info
);
1527 if (r_type
== (int) R_SH_NONE
)
1531 || r_type
> R_SH_64_PCREL
1532 || (r_type
>= (int) R_SH_FIRST_INVALID_RELOC
1533 && r_type
<= (int) R_SH_LAST_INVALID_RELOC
)
1534 || (r_type
>= (int) R_SH_DIR8WPN
1535 && r_type
<= (int) R_SH_LAST_INVALID_RELOC_2
)
1536 || (r_type
>= (int) R_SH_FIRST_INVALID_RELOC_3
1537 && r_type
<= R_SH_GOTPLT32
)
1538 || (r_type
>= (int) R_SH_FIRST_INVALID_RELOC_4
1539 && r_type
<= (int) R_SH_LAST_INVALID_RELOC_4
))
1541 bfd_set_error (bfd_error_bad_value
);
1545 howto
= sh_elf64_howto_table
+ r_type
;
1547 /* This is a final link. */
1551 if (r_symndx
< symtab_hdr
->sh_info
)
1553 sym
= local_syms
+ r_symndx
;
1554 sec
= local_sections
[r_symndx
];
1555 relocation
= ((sec
->output_section
->vma
1556 + sec
->output_offset
1558 | ((sym
->st_other
& STO_SH5_ISA32
) != 0));
1560 /* A local symbol never has STO_SH5_ISA32, so we don't need
1561 datalabel processing here. Make sure this does not change
1563 if ((sym
->st_other
& STO_SH5_ISA32
) != 0)
1564 ((*info
->callbacks
->reloc_dangerous
)
1566 _("Unexpected STO_SH5_ISA32 on local symbol is not handled"),
1567 input_bfd
, input_section
, rel
->r_offset
));
1569 if (info
->relocatable
)
1571 /* This is a relocatable link. We don't have to change
1572 anything, unless the reloc is against a section symbol,
1573 in which case we have to adjust according to where the
1574 section symbol winds up in the output section. */
1575 sym
= local_syms
+ r_symndx
;
1576 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1577 goto final_link_relocate
;
1581 else if (! howto
->partial_inplace
)
1583 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, sec
, rel
);
1584 relocation
|= ((sym
->st_other
& STO_SH5_ISA32
) != 0);
1586 else if ((sec
->flags
& SEC_MERGE
)
1587 && ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1591 if (howto
->rightshift
|| howto
->src_mask
!= 0xffffffff)
1593 (*_bfd_error_handler
)
1594 (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
1595 bfd_archive_filename (input_bfd
),
1596 bfd_get_section_name (input_bfd
, input_section
),
1597 (long) rel
->r_offset
, howto
->name
);
1601 addend
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
1604 _bfd_elf_rel_local_sym (output_bfd
, sym
, &msec
, addend
)
1606 addend
+= msec
->output_section
->vma
+ msec
->output_offset
;
1607 bfd_put_32 (input_bfd
, addend
, contents
+ rel
->r_offset
);
1613 /* ??? Could we use the RELOC_FOR_GLOBAL_SYMBOL macro here ? */
1615 /* Section symbols are never (?) placed in the hash table, so
1616 we can just ignore hash relocations when creating a
1617 relocatable object file. */
1618 if (info
->relocatable
)
1621 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1622 while (h
->root
.type
== bfd_link_hash_indirect
1623 || h
->root
.type
== bfd_link_hash_warning
)
1625 /* If the reference passes a symbol marked with
1626 STT_DATALABEL, then any STO_SH5_ISA32 on the final value
1628 seen_stt_datalabel
|= h
->type
== STT_DATALABEL
;
1629 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1632 if (h
->root
.type
== bfd_link_hash_defined
1633 || h
->root
.type
== bfd_link_hash_defweak
)
1635 sec
= h
->root
.u
.def
.section
;
1636 /* In these cases, we don't need the relocation value.
1637 We check specially because in some obscure cases
1638 sec->output_section will be NULL. */
1639 if (r_type
== R_SH_GOTPC_LOW16
1640 || r_type
== R_SH_GOTPC_MEDLOW16
1641 || r_type
== R_SH_GOTPC_MEDHI16
1642 || r_type
== R_SH_GOTPC_HI16
1643 || ((r_type
== R_SH_PLT_LOW16
1644 || r_type
== R_SH_PLT_MEDLOW16
1645 || r_type
== R_SH_PLT_MEDHI16
1646 || r_type
== R_SH_PLT_HI16
)
1647 && h
->plt
.offset
!= (bfd_vma
) -1)
1648 || ((r_type
== R_SH_GOT_LOW16
1649 || r_type
== R_SH_GOT_MEDLOW16
1650 || r_type
== R_SH_GOT_MEDHI16
1651 || r_type
== R_SH_GOT_HI16
)
1652 && elf_hash_table (info
)->dynamic_sections_created
1654 || (! info
->symbolic
&& h
->dynindx
!= -1)
1655 || (h
->elf_link_hash_flags
1656 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
1657 /* The cases above are those in which relocation is
1658 overwritten in the switch block below. The cases
1659 below are those in which we must defer relocation
1660 to run-time, because we can't resolve absolute
1661 addresses when creating a shared library. */
1663 && ((! info
->symbolic
&& h
->dynindx
!= -1)
1664 || (h
->elf_link_hash_flags
1665 & ELF_LINK_HASH_DEF_REGULAR
) == 0)
1666 && ((r_type
== R_SH_64
1667 && !(ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
1668 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
))
1669 || r_type
== R_SH_64_PCREL
)
1670 && ((input_section
->flags
& SEC_ALLOC
) != 0
1671 /* DWARF will emit R_SH_DIR32 relocations in its
1672 sections against symbols defined externally
1673 in shared libraries. We can't do anything
1675 || (input_section
->flags
& SEC_DEBUGGING
) != 0))
1676 /* Dynamic relocs are not propagated for SEC_DEBUGGING
1677 sections because such sections are not SEC_ALLOC and
1678 thus ld.so will not process them. */
1679 || (sec
->output_section
== NULL
1680 && ((input_section
->flags
& SEC_DEBUGGING
) != 0
1681 && (h
->elf_link_hash_flags
1682 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0)))
1684 else if (sec
->output_section
== NULL
)
1686 (*_bfd_error_handler
)
1687 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1688 bfd_get_filename (input_bfd
), h
->root
.root
.string
,
1689 bfd_get_section_name (input_bfd
, input_section
));
1693 relocation
= ((h
->root
.u
.def
.value
1694 + sec
->output_section
->vma
1695 + sec
->output_offset
)
1696 /* A STO_SH5_ISA32 causes a "bitor 1" to the
1697 symbol value, unless we've seen
1698 STT_DATALABEL on the way to it. */
1699 | ((h
->other
& STO_SH5_ISA32
) != 0
1700 && ! seen_stt_datalabel
));
1702 else if (h
->root
.type
== bfd_link_hash_undefweak
)
1704 else if (info
->shared
1706 && info
->unresolved_syms_in_objects
== RM_IGNORE
)
1710 if (! ((*info
->callbacks
->undefined_symbol
)
1711 (info
, h
->root
.root
.string
, input_bfd
,
1712 input_section
, rel
->r_offset
, TRUE
)))
1719 - input_section
->output_section
->vma
1720 - input_section
->output_offset
1723 switch ((int)r_type
)
1725 case R_SH_PT_16
: dropped
= disp
& 2; break;
1726 case R_SH_DIR10SW
: dropped
= disp
& 1; break;
1727 case R_SH_DIR10SL
: dropped
= disp
& 3; break;
1728 case R_SH_DIR10SQ
: dropped
= disp
& 7; break;
1732 (*_bfd_error_handler
)
1733 (_("%s: error: unaligned relocation type %d at %08x reloc %08x\n"),
1734 bfd_get_filename (input_bfd
), (int)r_type
, (unsigned)rel
->r_offset
, (unsigned)relocation
);
1735 bfd_set_error (bfd_error_bad_value
);
1738 switch ((int)r_type
)
1743 && (input_section
->flags
& SEC_ALLOC
) != 0
1744 && (r_type
!= R_SH_64_PCREL
1747 && (! info
->symbolic
1748 || (h
->elf_link_hash_flags
1749 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
1751 Elf_Internal_Rela outrel
;
1753 bfd_boolean skip
, relocate
;
1755 /* When generating a shared object, these relocations
1756 are copied into the output file to be resolved at run
1763 name
= (bfd_elf_string_from_elf_section
1765 elf_elfheader (input_bfd
)->e_shstrndx
,
1766 elf_section_data (input_section
)->rel_hdr
.sh_name
));
1770 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
1771 && strcmp (bfd_get_section_name (input_bfd
,
1775 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1776 BFD_ASSERT (sreloc
!= NULL
);
1783 = _bfd_elf_section_offset (output_bfd
, info
,
1784 input_section
, rel
->r_offset
);
1786 if (outrel
.r_offset
== (bfd_vma
) -1)
1788 else if (outrel
.r_offset
== (bfd_vma
) -2)
1789 skip
= TRUE
, relocate
= TRUE
;
1791 outrel
.r_offset
+= (input_section
->output_section
->vma
1792 + input_section
->output_offset
);
1795 memset (&outrel
, 0, sizeof outrel
);
1796 else if (r_type
== R_SH_64_PCREL
)
1798 BFD_ASSERT (h
!= NULL
&& h
->dynindx
!= -1);
1799 outrel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_SH_64_PCREL
);
1800 outrel
.r_addend
= rel
->r_addend
;
1804 /* h->dynindx may be -1 if this symbol was marked to
1807 || ((info
->symbolic
|| h
->dynindx
== -1)
1808 && (h
->elf_link_hash_flags
1809 & ELF_LINK_HASH_DEF_REGULAR
) != 0))
1812 outrel
.r_info
= ELF64_R_INFO (0, R_SH_RELATIVE64
);
1813 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1817 BFD_ASSERT (h
->dynindx
!= -1);
1818 outrel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_SH_64
);
1819 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1823 loc
= sreloc
->contents
;
1824 loc
+= sreloc
->reloc_count
++ * sizeof (Elf64_External_Rela
);
1825 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
1827 /* If this reloc is against an external symbol, we do
1828 not want to fiddle with the addend. Otherwise, we
1829 need to include the symbol value so that it becomes
1830 an addend for the dynamic reloc. */
1834 else if (r_type
== R_SH_64
)
1835 addend
= rel
->r_addend
;
1836 goto final_link_relocate
;
1838 case R_SH_GOTPLT_LOW16
:
1839 case R_SH_GOTPLT_MEDLOW16
:
1840 case R_SH_GOTPLT_MEDHI16
:
1841 case R_SH_GOTPLT_HI16
:
1842 case R_SH_GOTPLT10BY4
:
1843 case R_SH_GOTPLT10BY8
:
1844 /* Relocation is to the entry for this symbol in the
1845 procedure linkage table. */
1848 || ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
1849 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
1853 || h
->plt
.offset
== (bfd_vma
) -1
1854 || h
->got
.offset
!= (bfd_vma
) -1)
1857 /* Relocation is to the entry for this symbol in the global
1858 offset table extension for the procedure linkage table. */
1859 if (sgotplt
== NULL
)
1861 sgotplt
= bfd_get_section_by_name (dynobj
, ".got.plt");
1862 BFD_ASSERT (sgotplt
!= NULL
);
1865 relocation
= (sgotplt
->output_offset
1866 + ((h
->plt
.offset
/ elf_sh64_sizeof_plt (info
)
1869 relocation
-= GOT_BIAS
;
1871 goto final_link_relocate
;
1874 case R_SH_GOT_LOW16
:
1875 case R_SH_GOT_MEDLOW16
:
1876 case R_SH_GOT_MEDHI16
:
1880 /* Relocation is to the entry for this symbol in the global
1884 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1885 BFD_ASSERT (sgot
!= NULL
);
1892 off
= h
->got
.offset
;
1893 if (seen_stt_datalabel
)
1895 struct elf_sh64_link_hash_entry
*hsh
;
1897 hsh
= (struct elf_sh64_link_hash_entry
*)h
;
1898 off
= hsh
->datalabel_got_offset
;
1900 BFD_ASSERT (off
!= (bfd_vma
) -1);
1902 if (! elf_hash_table (info
)->dynamic_sections_created
1904 && (info
->symbolic
|| h
->dynindx
== -1
1905 || ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
1906 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
)
1907 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)))
1909 /* This is actually a static link, or it is a
1910 -Bsymbolic link and the symbol is defined
1911 locally, or the symbol was forced to be local
1912 because of a version file. We must initialize
1913 this entry in the global offset table. Since the
1914 offset must always be a multiple of 4, we use the
1915 least significant bit to record whether we have
1916 initialized it already.
1918 When doing a dynamic link, we create a .rela.got
1919 relocation entry to initialize the value. This
1920 is done in the finish_dynamic_symbol routine. */
1925 bfd_put_64 (output_bfd
, relocation
,
1926 sgot
->contents
+ off
);
1927 if (seen_stt_datalabel
)
1929 struct elf_sh64_link_hash_entry
*hsh
;
1931 hsh
= (struct elf_sh64_link_hash_entry
*)h
;
1932 hsh
->datalabel_got_offset
|= 1;
1939 relocation
= sgot
->output_offset
+ off
;
1947 BFD_ASSERT (local_got_offsets
!= NULL
1948 && (local_got_offsets
[symtab_hdr
->sh_info
1952 off
= local_got_offsets
[symtab_hdr
->sh_info
1957 BFD_ASSERT (local_got_offsets
!= NULL
1958 && local_got_offsets
[r_symndx
] != (bfd_vma
) -1);
1960 off
= local_got_offsets
[r_symndx
];
1963 /* The offset must always be a multiple of 8. We use
1964 the least significant bit to record whether we have
1965 already generated the necessary reloc. */
1970 bfd_put_64 (output_bfd
, relocation
, sgot
->contents
+ off
);
1975 Elf_Internal_Rela outrel
;
1978 s
= bfd_get_section_by_name (dynobj
, ".rela.got");
1979 BFD_ASSERT (s
!= NULL
);
1981 outrel
.r_offset
= (sgot
->output_section
->vma
1982 + sgot
->output_offset
1984 outrel
.r_info
= ELF64_R_INFO (0, R_SH_RELATIVE64
);
1985 outrel
.r_addend
= relocation
;
1987 loc
+= s
->reloc_count
++ * sizeof (Elf64_External_Rela
);
1988 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
1992 local_got_offsets
[symtab_hdr
->sh_info
+ r_symndx
] |= 1;
1994 local_got_offsets
[r_symndx
] |= 1;
1997 relocation
= sgot
->output_offset
+ off
;
2000 relocation
-= GOT_BIAS
;
2002 goto final_link_relocate
;
2004 case R_SH_GOTOFF_LOW16
:
2005 case R_SH_GOTOFF_MEDLOW16
:
2006 case R_SH_GOTOFF_MEDHI16
:
2007 case R_SH_GOTOFF_HI16
:
2008 /* Relocation is relative to the start of the global offset
2013 sgot
= bfd_get_section_by_name (dynobj
, ".got");
2014 BFD_ASSERT (sgot
!= NULL
);
2017 /* Note that sgot->output_offset is not involved in this
2018 calculation. We always want the start of .got. If we
2019 defined _GLOBAL_OFFSET_TABLE in a different way, as is
2020 permitted by the ABI, we might have to change this
2022 relocation
-= sgot
->output_section
->vma
;
2024 relocation
-= GOT_BIAS
;
2026 addend
= rel
->r_addend
;
2028 goto final_link_relocate
;
2030 case R_SH_GOTPC_LOW16
:
2031 case R_SH_GOTPC_MEDLOW16
:
2032 case R_SH_GOTPC_MEDHI16
:
2033 case R_SH_GOTPC_HI16
:
2034 /* Use global offset table as symbol value. */
2038 sgot
= bfd_get_section_by_name (dynobj
, ".got");
2039 BFD_ASSERT (sgot
!= NULL
);
2042 relocation
= sgot
->output_section
->vma
;
2044 relocation
+= GOT_BIAS
;
2046 addend
= rel
->r_addend
;
2048 goto final_link_relocate
;
2050 case R_SH_PLT_LOW16
:
2051 case R_SH_PLT_MEDLOW16
:
2052 case R_SH_PLT_MEDHI16
:
2054 /* Relocation is to the entry for this symbol in the
2055 procedure linkage table. */
2057 /* Resolve a PLT reloc against a local symbol directly,
2058 without using the procedure linkage table. */
2060 goto final_link_relocate
;
2062 if (ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
2063 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
)
2064 goto final_link_relocate
;
2066 if (h
->plt
.offset
== (bfd_vma
) -1)
2068 /* We didn't make a PLT entry for this symbol. This
2069 happens when statically linking PIC code, or when
2070 using -Bsymbolic. */
2071 goto final_link_relocate
;
2076 splt
= bfd_get_section_by_name (dynobj
, ".plt");
2077 BFD_ASSERT (splt
!= NULL
);
2080 relocation
= (splt
->output_section
->vma
2081 + splt
->output_offset
2085 addend
= rel
->r_addend
;
2087 goto final_link_relocate
;
2090 case R_SH_SHMEDIA_CODE
:
2101 case R_SH_IMM_LOW16
:
2102 case R_SH_IMM_LOW16_PCREL
:
2103 case R_SH_IMM_MEDLOW16
:
2104 case R_SH_IMM_MEDLOW16_PCREL
:
2105 case R_SH_IMM_MEDHI16
:
2106 case R_SH_IMM_MEDHI16_PCREL
:
2108 case R_SH_IMM_HI16_PCREL
:
2109 addend
= rel
->r_addend
;
2112 final_link_relocate
:
2113 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
2114 contents
, rel
->r_offset
,
2115 relocation
, addend
);
2119 bfd_set_error (bfd_error_bad_value
);
2124 if (r
!= bfd_reloc_ok
)
2129 case bfd_reloc_outofrange
:
2131 case bfd_reloc_overflow
:
2136 name
= h
->root
.root
.string
;
2139 name
= (bfd_elf_string_from_elf_section
2140 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
));
2144 name
= bfd_section_name (input_bfd
, sec
);
2146 if (! ((*info
->callbacks
->reloc_overflow
)
2147 (info
, name
, howto
->name
, (bfd_vma
) 0,
2148 input_bfd
, input_section
, rel
->r_offset
)))
2159 /* This is a version of bfd_generic_get_relocated_section_contents
2160 that uses sh_elf64_relocate_section.
2162 See sh_elf_relocate_section in elf32-sh.c for the original. */
2165 sh_elf64_get_relocated_section_contents (bfd
*output_bfd
,
2166 struct bfd_link_info
*link_info
,
2167 struct bfd_link_order
*link_order
,
2169 bfd_boolean relocatable
,
2172 Elf_Internal_Shdr
*symtab_hdr
;
2173 asection
*input_section
= link_order
->u
.indirect
.section
;
2174 bfd
*input_bfd
= input_section
->owner
;
2175 asection
**sections
= NULL
;
2176 Elf_Internal_Rela
*internal_relocs
= NULL
;
2177 Elf_Internal_Sym
*isymbuf
= NULL
;
2179 /* We only need to handle the case of relaxing, or of having a
2180 particular set of section contents, specially. */
2182 || elf_section_data (input_section
)->this_hdr
.contents
== NULL
)
2183 return bfd_generic_get_relocated_section_contents (output_bfd
, link_info
,
2188 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
2190 memcpy (data
, elf_section_data (input_section
)->this_hdr
.contents
,
2191 input_section
->_raw_size
);
2193 if ((input_section
->flags
& SEC_RELOC
) != 0
2194 && input_section
->reloc_count
> 0)
2196 Elf_Internal_Sym
*isymp
;
2197 Elf_Internal_Sym
*isymend
;
2200 /* Read this BFD's local symbols. */
2201 if (symtab_hdr
->sh_info
!= 0)
2203 isymbuf
= (Elf_Internal_Sym
*) symtab_hdr
->contents
;
2204 if (isymbuf
== NULL
)
2205 isymbuf
= bfd_elf_get_elf_syms (input_bfd
, symtab_hdr
,
2206 symtab_hdr
->sh_info
, 0,
2208 if (isymbuf
== NULL
)
2212 internal_relocs
= (_bfd_elf_link_read_relocs
2213 (input_bfd
, input_section
, NULL
,
2214 (Elf_Internal_Rela
*) NULL
, FALSE
));
2215 if (internal_relocs
== NULL
)
2218 sections
= (asection
**) bfd_malloc (symtab_hdr
->sh_info
2219 * sizeof (asection
*));
2220 if (sections
== NULL
&& symtab_hdr
->sh_info
> 0)
2224 isymend
= isymbuf
+ symtab_hdr
->sh_info
;
2225 for (isymp
= isymbuf
; isymp
< isymend
; ++isymp
, ++secpp
)
2229 if (isymp
->st_shndx
== SHN_UNDEF
)
2230 isec
= bfd_und_section_ptr
;
2231 else if (isymp
->st_shndx
> 0 && isymp
->st_shndx
< SHN_LORESERVE
)
2232 isec
= bfd_section_from_elf_index (input_bfd
, isymp
->st_shndx
);
2233 else if (isymp
->st_shndx
== SHN_ABS
)
2234 isec
= bfd_abs_section_ptr
;
2235 else if (isymp
->st_shndx
== SHN_COMMON
)
2236 isec
= bfd_com_section_ptr
;
2246 if (! sh_elf64_relocate_section (output_bfd
, link_info
, input_bfd
,
2247 input_section
, data
, internal_relocs
,
2251 if (sections
!= NULL
)
2253 if (internal_relocs
!= elf_section_data (input_section
)->relocs
)
2254 free (internal_relocs
);
2256 && (unsigned char *) isymbuf
!= symtab_hdr
->contents
)
2263 if (sections
!= NULL
)
2265 if (internal_relocs
!= NULL
2266 && internal_relocs
!= elf_section_data (input_section
)->relocs
)
2267 free (internal_relocs
);
2269 && (unsigned char *) isymbuf
!= symtab_hdr
->contents
)
2274 /* Set the SHF_SH5_ISA32 flag for ISA SHmedia code sections. */
2277 sh64_elf64_fake_sections (bfd
*output_bfd ATTRIBUTE_UNUSED
,
2278 Elf_Internal_Shdr
*elf_section_hdr
,
2281 /* Code sections can only contain SH64 code, so mark them as such. */
2282 if (bfd_get_section_flags (output_bfd
, asect
) & SEC_CODE
)
2283 elf_section_hdr
->sh_flags
|= SHF_SH5_ISA32
;
2289 sh_elf64_set_mach_from_flags (bfd
*abfd
)
2291 flagword flags
= elf_elfheader (abfd
)->e_flags
;
2293 switch (flags
& EF_SH_MACH_MASK
)
2296 /* Just one, but keep the switch construct to make additions easy. */
2297 bfd_default_set_arch_mach (abfd
, bfd_arch_sh
, bfd_mach_sh5
);
2301 bfd_set_error (bfd_error_wrong_format
);
2307 /* Function to keep SH64 specific file flags.
2309 See sh64_elf_set_private_flags in elf32-sh64.c for the original. */
2312 sh_elf64_set_private_flags (bfd
*abfd
, flagword flags
)
2314 BFD_ASSERT (! elf_flags_init (abfd
)
2315 || elf_elfheader (abfd
)->e_flags
== flags
);
2317 elf_elfheader (abfd
)->e_flags
= flags
;
2318 elf_flags_init (abfd
) = TRUE
;
2319 return sh_elf64_set_mach_from_flags (abfd
);
2322 /* Copy the SHF_SH5_ISA32 attribute that we keep on all sections with
2323 code, to keep attributes the same as for SHmedia in 32-bit ELF. */
2326 sh_elf64_copy_private_data_internal (bfd
*ibfd
, bfd
*obfd
)
2328 Elf_Internal_Shdr
**o_shdrp
;
2332 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
2333 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
2336 o_shdrp
= elf_elfsections (obfd
);
2337 for (osec
= obfd
->sections
; osec
; osec
= osec
->next
)
2339 int oIndex
= ((struct bfd_elf_section_data
*) elf_section_data (osec
))->this_idx
;
2340 for (isec
= ibfd
->sections
; isec
; isec
= isec
->next
)
2342 if (strcmp (osec
->name
, isec
->name
) == 0)
2344 /* Note that we're not disallowing mixing data and code. */
2345 if ((elf_section_data (isec
)->this_hdr
.sh_flags
2346 & SHF_SH5_ISA32
) != 0)
2347 o_shdrp
[oIndex
]->sh_flags
|= SHF_SH5_ISA32
;
2353 return sh_elf64_set_private_flags (obfd
, elf_elfheader (ibfd
)->e_flags
);
2357 sh_elf64_copy_private_data (bfd
*ibfd
, bfd
*obfd
)
2359 return sh_elf64_copy_private_data_internal (ibfd
, obfd
);
2363 sh_elf64_merge_private_data (bfd
*ibfd
, bfd
*obfd
)
2365 flagword old_flags
, new_flags
;
2367 if (! _bfd_generic_verify_endian_match (ibfd
, obfd
))
2370 if ( bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
2371 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
2374 if (bfd_get_arch_size (ibfd
) != bfd_get_arch_size (obfd
))
2378 if (bfd_get_arch_size (ibfd
) == 32
2379 && bfd_get_arch_size (obfd
) == 64)
2380 msg
= _("%s: compiled as 32-bit object and %s is 64-bit");
2381 else if (bfd_get_arch_size (ibfd
) == 64
2382 && bfd_get_arch_size (obfd
) == 32)
2383 msg
= _("%s: compiled as 64-bit object and %s is 32-bit");
2385 msg
= _("%s: object size does not match that of target %s");
2387 (*_bfd_error_handler
) (msg
, bfd_get_filename (ibfd
),
2388 bfd_get_filename (obfd
));
2389 bfd_set_error (bfd_error_wrong_format
);
2393 old_flags
= elf_elfheader (obfd
)->e_flags
;
2394 new_flags
= elf_elfheader (ibfd
)->e_flags
;
2395 if (! elf_flags_init (obfd
))
2397 /* This happens when ld starts out with a 'blank' output file. */
2398 elf_flags_init (obfd
) = TRUE
;
2399 elf_elfheader (obfd
)->e_flags
= old_flags
= new_flags
;
2401 /* We don't allow linking in anything else than SH64 code, and since
2402 this is a 64-bit ELF, we assume the 64-bit ABI is used. Add code
2403 here as things change. */
2404 else if ((new_flags
& EF_SH_MACH_MASK
) != EF_SH5
)
2406 (*_bfd_error_handler
)
2407 ("%s: does not use the SH64 64-bit ABI as previous modules do",
2408 bfd_get_filename (ibfd
));
2409 bfd_set_error (bfd_error_bad_value
);
2413 sh_elf64_copy_private_data_internal (ibfd
, obfd
);
2415 /* I can't think of anything sane other than old_flags being EF_SH5 and
2416 that we need to preserve that. */
2417 elf_elfheader (obfd
)->e_flags
= old_flags
;
2419 return sh_elf64_set_mach_from_flags (obfd
);
2422 /* Return the section that should be marked against GC for a given
2426 sh_elf64_gc_mark_hook (asection
*sec
,
2427 struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
2428 Elf_Internal_Rela
*rel
,
2429 struct elf_link_hash_entry
*h
,
2430 Elf_Internal_Sym
*sym
)
2434 switch (ELF64_R_TYPE (rel
->r_info
))
2436 case R_SH_GNU_VTINHERIT
:
2437 case R_SH_GNU_VTENTRY
:
2441 while (h
->root
.type
== bfd_link_hash_indirect
2442 && h
->root
.u
.i
.link
)
2443 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
2444 switch (h
->root
.type
)
2446 case bfd_link_hash_defined
:
2447 case bfd_link_hash_defweak
:
2448 return h
->root
.u
.def
.section
;
2450 case bfd_link_hash_common
:
2451 return h
->root
.u
.c
.p
->section
;
2459 return bfd_section_from_elf_index (sec
->owner
, sym
->st_shndx
);
2464 /* Update the got entry reference counts for the section being removed. */
2467 sh_elf64_gc_sweep_hook (bfd
*abfd ATTRIBUTE_UNUSED
,
2468 struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
2469 asection
*sec ATTRIBUTE_UNUSED
,
2470 const Elf_Internal_Rela
*relocs ATTRIBUTE_UNUSED
)
2472 /* No got and plt entries for 64-bit SH at present. */
2476 /* Look through the relocs for a section during the first phase.
2477 Since we don't do .gots or .plts, we just need to consider the
2478 virtual table relocs for gc. */
2481 sh_elf64_check_relocs (bfd
*abfd
, struct bfd_link_info
*info
,
2482 asection
*sec
, const Elf_Internal_Rela
*relocs
)
2484 Elf_Internal_Shdr
*symtab_hdr
;
2485 struct elf_link_hash_entry
**sym_hashes
, **sym_hashes_end
;
2486 const Elf_Internal_Rela
*rel
;
2487 const Elf_Internal_Rela
*rel_end
;
2489 bfd_vma
*local_got_offsets
;
2498 if (info
->relocatable
)
2501 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
2502 sym_hashes
= elf_sym_hashes (abfd
);
2503 sym_hashes_end
= sym_hashes
+ symtab_hdr
->sh_size
/sizeof(Elf64_External_Sym
);
2504 if (!elf_bad_symtab (abfd
))
2505 sym_hashes_end
-= symtab_hdr
->sh_info
;
2507 dynobj
= elf_hash_table (info
)->dynobj
;
2508 local_got_offsets
= elf_local_got_offsets (abfd
);
2510 rel_end
= relocs
+ sec
->reloc_count
;
2511 for (rel
= relocs
; rel
< rel_end
; rel
++)
2513 struct elf_link_hash_entry
*h
;
2514 unsigned long r_symndx
;
2516 r_symndx
= ELF64_R_SYM (rel
->r_info
);
2517 if (r_symndx
< symtab_hdr
->sh_info
)
2520 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
2522 /* Some relocs require a global offset table. */
2525 switch (ELF64_R_TYPE (rel
->r_info
))
2527 case R_SH_GOTPLT_LOW16
:
2528 case R_SH_GOTPLT_MEDLOW16
:
2529 case R_SH_GOTPLT_MEDHI16
:
2530 case R_SH_GOTPLT_HI16
:
2531 case R_SH_GOTPLT10BY4
:
2532 case R_SH_GOTPLT10BY8
:
2533 case R_SH_GOT_LOW16
:
2534 case R_SH_GOT_MEDLOW16
:
2535 case R_SH_GOT_MEDHI16
:
2539 case R_SH_GOTOFF_LOW16
:
2540 case R_SH_GOTOFF_MEDLOW16
:
2541 case R_SH_GOTOFF_MEDHI16
:
2542 case R_SH_GOTOFF_HI16
:
2543 case R_SH_GOTPC_LOW16
:
2544 case R_SH_GOTPC_MEDLOW16
:
2545 case R_SH_GOTPC_MEDHI16
:
2546 case R_SH_GOTPC_HI16
:
2547 elf_hash_table (info
)->dynobj
= dynobj
= abfd
;
2548 if (! _bfd_elf_create_got_section (dynobj
, info
))
2557 switch (ELF64_R_TYPE (rel
->r_info
))
2559 /* This relocation describes the C++ object vtable hierarchy.
2560 Reconstruct it for later use during GC. */
2561 case R_SH_GNU_VTINHERIT
:
2562 if (!_bfd_elf64_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
2566 /* This relocation describes which C++ vtable entries are actually
2567 used. Record for later use during GC. */
2568 case R_SH_GNU_VTENTRY
:
2569 if (!_bfd_elf64_gc_record_vtentry (abfd
, sec
, h
, rel
->r_addend
))
2574 case R_SH_GOT_LOW16
:
2575 case R_SH_GOT_MEDLOW16
:
2576 case R_SH_GOT_MEDHI16
:
2580 /* This symbol requires a global offset table entry. */
2584 sgot
= bfd_get_section_by_name (dynobj
, ".got");
2585 BFD_ASSERT (sgot
!= NULL
);
2589 && (h
!= NULL
|| info
->shared
))
2591 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
2592 if (srelgot
== NULL
)
2594 srelgot
= bfd_make_section (dynobj
, ".rela.got");
2596 || ! bfd_set_section_flags (dynobj
, srelgot
,
2601 | SEC_LINKER_CREATED
2603 || ! bfd_set_section_alignment (dynobj
, srelgot
, 2))
2610 if (h
->type
== STT_DATALABEL
)
2612 struct elf_sh64_link_hash_entry
*hsh
;
2614 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
2615 hsh
= (struct elf_sh64_link_hash_entry
*)h
;
2616 if (hsh
->datalabel_got_offset
!= (bfd_vma
) -1)
2619 hsh
->datalabel_got_offset
= sgot
->_raw_size
;
2623 if (h
->got
.offset
!= (bfd_vma
) -1)
2625 /* We have already allocated space in the .got. */
2628 h
->got
.offset
= sgot
->_raw_size
;
2631 /* Make sure this symbol is output as a dynamic symbol. */
2632 if (h
->dynindx
== -1)
2634 if (! bfd_elf64_link_record_dynamic_symbol (info
, h
))
2638 srelgot
->_raw_size
+= sizeof (Elf64_External_Rela
);
2642 /* This is a global offset table entry for a local
2644 if (local_got_offsets
== NULL
)
2647 register unsigned int i
;
2649 size
= symtab_hdr
->sh_info
* sizeof (bfd_vma
);
2650 /* Reserve space for both the datalabel and
2651 codelabel local GOT offsets. */
2653 local_got_offsets
= (bfd_vma
*) bfd_alloc (abfd
, size
);
2654 if (local_got_offsets
== NULL
)
2656 elf_local_got_offsets (abfd
) = local_got_offsets
;
2657 for (i
= 0; i
< symtab_hdr
->sh_info
; i
++)
2658 local_got_offsets
[i
] = (bfd_vma
) -1;
2659 for (; i
< 2 * symtab_hdr
->sh_info
; i
++)
2660 local_got_offsets
[i
] = (bfd_vma
) -1;
2662 if ((rel
->r_addend
& 1) != 0)
2664 if (local_got_offsets
[symtab_hdr
->sh_info
2665 + r_symndx
] != (bfd_vma
) -1)
2667 /* We have already allocated space in the .got. */
2670 local_got_offsets
[symtab_hdr
->sh_info
2671 + r_symndx
] = sgot
->_raw_size
;
2675 if (local_got_offsets
[r_symndx
] != (bfd_vma
) -1)
2677 /* We have already allocated space in the .got. */
2680 local_got_offsets
[r_symndx
] = sgot
->_raw_size
;
2685 /* If we are generating a shared object, we need to
2686 output a R_SH_RELATIVE reloc so that the dynamic
2687 linker can adjust this GOT entry. */
2688 srelgot
->_raw_size
+= sizeof (Elf64_External_Rela
);
2692 sgot
->_raw_size
+= 8;
2696 case R_SH_GOTPLT_LOW16
:
2697 case R_SH_GOTPLT_MEDLOW16
:
2698 case R_SH_GOTPLT_MEDHI16
:
2699 case R_SH_GOTPLT_HI16
:
2700 case R_SH_GOTPLT10BY4
:
2701 case R_SH_GOTPLT10BY8
:
2702 /* If this is a local symbol, we resolve it directly without
2703 creating a procedure linkage table entry. */
2706 || ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
2707 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
2711 || h
->got
.offset
!= (bfd_vma
) -1)
2714 /* Make sure this symbol is output as a dynamic symbol. */
2715 if (h
->dynindx
== -1)
2717 if (! bfd_elf64_link_record_dynamic_symbol (info
, h
))
2721 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
2725 case R_SH_PLT_LOW16
:
2726 case R_SH_PLT_MEDLOW16
:
2727 case R_SH_PLT_MEDHI16
:
2729 /* This symbol requires a procedure linkage table entry. We
2730 actually build the entry in adjust_dynamic_symbol,
2731 because this might be a case of linking PIC code which is
2732 never referenced by a dynamic object, in which case we
2733 don't need to generate a procedure linkage table entry
2736 /* If this is a local symbol, we resolve it directly without
2737 creating a procedure linkage table entry. */
2741 if (ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
2742 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
)
2745 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
2752 h
->elf_link_hash_flags
|= ELF_LINK_NON_GOT_REF
;
2754 /* If we are creating a shared library, and this is a reloc
2755 against a global symbol, or a non PC relative reloc
2756 against a local symbol, then we need to copy the reloc
2757 into the shared library. However, if we are linking with
2758 -Bsymbolic, we do not need to copy a reloc against a
2759 global symbol which is defined in an object we are
2760 including in the link (i.e., DEF_REGULAR is set). At
2761 this point we have not seen all the input files, so it is
2762 possible that DEF_REGULAR is not set now but will be set
2763 later (it is never cleared). We account for that
2764 possibility below by storing information in the
2765 pcrel_relocs_copied field of the hash table entry. */
2767 && (sec
->flags
& SEC_ALLOC
) != 0
2768 && (ELF32_R_TYPE (rel
->r_info
) != R_SH_64_PCREL
2770 && (! info
->symbolic
2771 || (h
->elf_link_hash_flags
2772 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
2774 /* When creating a shared object, we must copy these
2775 reloc types into the output file. We create a reloc
2776 section in dynobj and make room for this reloc. */
2781 name
= (bfd_elf_string_from_elf_section
2783 elf_elfheader (abfd
)->e_shstrndx
,
2784 elf_section_data (sec
)->rel_hdr
.sh_name
));
2788 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
2789 && strcmp (bfd_get_section_name (abfd
, sec
),
2792 sreloc
= bfd_get_section_by_name (dynobj
, name
);
2797 sreloc
= bfd_make_section (dynobj
, name
);
2798 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
2799 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
2800 if ((sec
->flags
& SEC_ALLOC
) != 0)
2801 flags
|= SEC_ALLOC
| SEC_LOAD
;
2803 || ! bfd_set_section_flags (dynobj
, sreloc
, flags
)
2804 || ! bfd_set_section_alignment (dynobj
, sreloc
, 2))
2809 sreloc
->_raw_size
+= sizeof (Elf64_External_Rela
);
2811 /* If we are linking with -Bsymbolic, and this is a
2812 global symbol, we count the number of PC relative
2813 relocations we have entered for this symbol, so that
2814 we can discard them again if the symbol is later
2815 defined by a regular object. Note that this function
2816 is only called if we are using an elf_sh linker
2817 hash table, which means that h is really a pointer to
2818 an elf_sh_link_hash_entry. */
2819 if (h
!= NULL
&& info
->symbolic
2820 && ELF64_R_TYPE (rel
->r_info
) == R_SH_64_PCREL
)
2822 struct elf_sh64_link_hash_entry
*eh
;
2823 struct elf_sh64_pcrel_relocs_copied
*p
;
2825 eh
= (struct elf_sh64_link_hash_entry
*) h
;
2827 for (p
= eh
->pcrel_relocs_copied
; p
!= NULL
; p
= p
->next
)
2828 if (p
->section
== sreloc
)
2833 p
= ((struct elf_sh64_pcrel_relocs_copied
*)
2834 bfd_alloc (dynobj
, sizeof *p
));
2837 p
->next
= eh
->pcrel_relocs_copied
;
2838 eh
->pcrel_relocs_copied
= p
;
2839 p
->section
= sreloc
;
2855 sh64_elf64_get_symbol_type (Elf_Internal_Sym
* elf_sym
, int type
)
2857 if (ELF_ST_TYPE (elf_sym
->st_info
) == STT_DATALABEL
)
2858 return STT_DATALABEL
;
2863 /* FIXME: This is a copy of sh64_elf_add_symbol_hook in elf32-sh64.c.
2864 Either file can presumably exist without the other, but do not differ
2865 in elf-size-ness. How to share?
2867 Hook called by the linker routine which adds symbols from an object
2868 file. We must make indirect symbols for undefined symbols marked with
2869 STT_DATALABEL, so relocations passing them will pick up that attribute
2870 and neutralize STO_SH5_ISA32 found on the symbol definition.
2872 There is a problem, though: We want to fill in the hash-table entry for
2873 this symbol and signal to the caller that no further processing is
2874 needed. But we don't have the index for this hash-table entry. We
2875 rely here on that the current entry is the first hash-entry with NULL,
2876 which seems brittle. Also, iterating over the hash-table to find that
2877 entry is a linear operation on the number of symbols in this input
2878 file, and this function should take constant time, so that's not good
2879 too. Only comfort is that DataLabel references should only be found in
2880 hand-written assembly code and thus be rare. FIXME: Talk maintainers
2881 into adding an option to elf_add_symbol_hook (preferably) for the index
2882 or the hash entry, alternatively adding the index to Elf_Internal_Sym
2886 sh64_elf64_add_symbol_hook (bfd
*abfd
, struct bfd_link_info
*info
,
2887 const Elf_Internal_Sym
*sym
, const char **namep
,
2888 flagword
*flagsp ATTRIBUTE_UNUSED
,
2889 asection
**secp
, bfd_vma
*valp
)
2891 /* We want to do this for relocatable as well as final linking. */
2892 if (ELF_ST_TYPE (sym
->st_info
) == STT_DATALABEL
2893 && info
->hash
->creator
->flavour
== bfd_target_elf_flavour
)
2895 struct elf_link_hash_entry
*h
;
2897 /* For relocatable links, we register the DataLabel sym in its own
2898 right, and tweak the name when it's output. Otherwise, we make
2899 an indirect symbol of it. */
2901 = info
->relocatable
|| info
->emitrelocations
2902 ? BSF_GLOBAL
: BSF_GLOBAL
| BSF_INDIRECT
;
2905 = bfd_malloc (strlen (*namep
) + sizeof (DATALABEL_SUFFIX
));
2906 struct elf_link_hash_entry
** sym_hash
= elf_sym_hashes (abfd
);
2908 BFD_ASSERT (sym_hash
!= NULL
);
2910 /* Allocation may fail. */
2911 if (dl_name
== NULL
)
2914 strcpy (dl_name
, *namep
);
2915 strcat (dl_name
, DATALABEL_SUFFIX
);
2917 h
= (struct elf_link_hash_entry
*)
2918 bfd_link_hash_lookup (info
->hash
, dl_name
, FALSE
, FALSE
, FALSE
);
2922 /* No previous datalabel symbol. Make one. */
2923 struct bfd_link_hash_entry
*bh
= NULL
;
2924 const struct elf_backend_data
*bed
= get_elf_backend_data (abfd
);
2926 if (! _bfd_generic_link_add_one_symbol (info
, abfd
, dl_name
,
2927 flags
, *secp
, *valp
,
2935 h
= (struct elf_link_hash_entry
*) bh
;
2936 h
->elf_link_hash_flags
&=~ ELF_LINK_NON_ELF
;
2937 h
->type
= STT_DATALABEL
;
2940 /* If a new symbol was created, it holds the allocated name.
2941 Otherwise, we don't need it anymore and should deallocate it. */
2944 if (h
->type
!= STT_DATALABEL
2945 || ((info
->relocatable
|| info
->emitrelocations
)
2946 && h
->root
.type
!= bfd_link_hash_undefined
)
2947 || (! info
->relocatable
&& !info
->emitrelocations
2948 && h
->root
.type
!= bfd_link_hash_indirect
))
2950 /* Make sure we don't get confused on invalid input. */
2951 (*_bfd_error_handler
)
2952 (_("%s: encountered datalabel symbol in input"),
2953 bfd_get_filename (abfd
));
2954 bfd_set_error (bfd_error_bad_value
);
2958 /* Now find the hash-table slot for this entry and fill it in. */
2959 while (*sym_hash
!= NULL
)
2963 /* Signal to caller to skip this symbol - we've handled it. */
2970 /* This hook function is called before the linker writes out a global
2971 symbol. For relocatable links, DataLabel symbols will be present in
2972 linker output. We cut off the special suffix on those symbols, so the
2973 right name appears in the output.
2975 When linking and emitting relocations, there can appear global symbols
2976 that are not referenced by relocs, but rather only implicitly through
2977 DataLabel references, a relation that is not visible to the linker.
2978 Since no stripping of global symbols in done when doing such linking,
2979 we don't need to look up and make sure to emit the main symbol for each
2980 DataLabel symbol. */
2983 sh64_elf64_link_output_symbol_hook (bfd
*abfd ATTRIBUTE_UNUSED
,
2984 struct bfd_link_info
*info
,
2986 Elf_Internal_Sym
*sym
,
2987 asection
*input_sec ATTRIBUTE_UNUSED
)
2989 char *name
= (char *) cname
;
2991 if (info
->relocatable
|| info
->emitrelocations
)
2993 if (ELF_ST_TYPE (sym
->st_info
) == STT_DATALABEL
)
2994 name
[strlen (name
) - strlen (DATALABEL_SUFFIX
)] = 0;
3000 /* Set bit 0 on the entry address; it always points to SHmedia code. This
3001 is mostly for symmetry with the 32-bit format, where code can be
3002 SHcompact and we need to make a distinction to make sure execution
3003 starts in the right ISA mode. It is also convenient for a loader,
3004 which would otherwise have to set this bit when loading a TR register
3005 before jumping to the program entry. */
3008 sh64_elf64_final_write_processing (bfd
*abfd
,
3009 bfd_boolean linker ATTRIBUTE_UNUSED
)
3011 /* FIXME: Perhaps we shouldn't do this if the entry address was supplied
3012 numerically, but we currently lack the infrastructure to recognize
3013 that: The entry symbol, and info whether it is numeric or a symbol
3014 name is kept private in the linker. */
3015 if (elf_elfheader (abfd
)->e_type
== ET_EXEC
)
3016 elf_elfheader (abfd
)->e_entry
|= 1;
3019 /* First entry in an absolute procedure linkage table look like this. */
3021 static const bfd_byte elf_sh64_plt0_entry_be
[PLT_ENTRY_SIZE
] =
3023 0xcc, 0x00, 0x01, 0x10, /* movi .got.plt >> 48, r17 */
3024 0xc8, 0x00, 0x01, 0x10, /* shori (.got.plt >> 32) & 65535, r17 */
3025 0xc8, 0x00, 0x01, 0x10, /* shori (.got.plt >> 16) & 65535, r17 */
3026 0xc8, 0x00, 0x01, 0x10, /* shori .got.plt & 65535, r17 */
3027 0x8d, 0x10, 0x09, 0x90, /* ld.q r17, 16, r25 */
3028 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
3029 0x8d, 0x10, 0x05, 0x10, /* ld.q r17, 8, r17 */
3030 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
3031 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3032 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3033 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3034 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3035 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3036 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3037 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3038 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3041 static const bfd_byte elf_sh64_plt0_entry_le
[PLT_ENTRY_SIZE
] =
3043 0x10, 0x01, 0x00, 0xcc, /* movi .got.plt >> 16, r17 */
3044 0x10, 0x01, 0x00, 0xc8, /* shori (.got.plt >> 32) & 65535, r17 */
3045 0x10, 0x01, 0x00, 0xc8, /* shori (.got.plt >> 16) & 65535, r17 */
3046 0x10, 0x01, 0x00, 0xc8, /* shori .got.plt & 65535, r17 */
3047 0x90, 0x09, 0x10, 0x8d, /* ld.q r17, 16, r25 */
3048 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
3049 0x10, 0x05, 0x10, 0x8d, /* ld.q r17, 8, r17 */
3050 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
3051 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3052 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3053 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3054 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3055 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3056 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3057 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3058 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3061 /* Sebsequent entries in an absolute procedure linkage table look like
3064 static const bfd_byte elf_sh64_plt_entry_be
[PLT_ENTRY_SIZE
] =
3066 0xcc, 0x00, 0x01, 0x90, /* movi nameN-in-GOT >> 48, r25 */
3067 0xc8, 0x00, 0x01, 0x90, /* shori (nameN-in-GOT >> 32) & 65535, r25 */
3068 0xc8, 0x00, 0x01, 0x90, /* shori (nameN-in-GOT >> 16) & 65535, r25 */
3069 0xc8, 0x00, 0x01, 0x90, /* shori nameN-in-GOT & 65535, r25 */
3070 0x8d, 0x90, 0x01, 0x90, /* ld.q r25, 0, r25 */
3071 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
3072 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
3073 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3074 0xcc, 0x00, 0x01, 0x90, /* movi (.+8-.PLT0) >> 16, r25 */
3075 0xc8, 0x00, 0x01, 0x90, /* shori (.+4-.PLT0) & 65535, r25 */
3076 0x6b, 0xf5, 0x66, 0x00, /* ptrel r25, tr0 */
3077 0xcc, 0x00, 0x01, 0x50, /* movi reloc-offset >> 16, r21 */
3078 0xc8, 0x00, 0x01, 0x50, /* shori reloc-offset & 65535, r21 */
3079 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
3080 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3081 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3084 static const bfd_byte elf_sh64_plt_entry_le
[PLT_ENTRY_SIZE
] =
3086 0x90, 0x01, 0x00, 0xcc, /* movi nameN-in-GOT >> 16, r25 */
3087 0x90, 0x01, 0x00, 0xc8, /* shori nameN-in-GOT & 65535, r25 */
3088 0x90, 0x01, 0x00, 0xc8, /* shori nameN-in-GOT & 65535, r25 */
3089 0x90, 0x01, 0x00, 0xc8, /* shori nameN-in-GOT & 65535, r25 */
3090 0x90, 0x01, 0x90, 0x8d, /* ld.q r25, 0, r25 */
3091 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
3092 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
3093 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3094 0x90, 0x01, 0x00, 0xcc, /* movi (.+8-.PLT0) >> 16, r25 */
3095 0x90, 0x01, 0x00, 0xc8, /* shori (.+4-.PLT0) & 65535, r25 */
3096 0x00, 0x66, 0xf5, 0x6b, /* ptrel r25, tr0 */
3097 0x50, 0x01, 0x00, 0xcc, /* movi reloc-offset >> 16, r21 */
3098 0x50, 0x01, 0x00, 0xc8, /* shori reloc-offset & 65535, r21 */
3099 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
3100 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3101 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3104 /* Entries in a PIC procedure linkage table look like this. */
3106 static const bfd_byte elf_sh64_pic_plt_entry_be
[PLT_ENTRY_SIZE
] =
3108 0xcc, 0x00, 0x01, 0x90, /* movi nameN@GOT >> 16, r25 */
3109 0xc8, 0x00, 0x01, 0x90, /* shori nameN@GOT & 65535, r25 */
3110 0x40, 0xc3, 0x65, 0x90, /* ldx.q r12, r25, r25 */
3111 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
3112 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
3113 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3114 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3115 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3116 0xce, 0x00, 0x01, 0x10, /* movi -GOT_BIAS, r17 */
3117 0x00, 0xc9, 0x45, 0x10, /* add r12, r17, r17 */
3118 0x8d, 0x10, 0x09, 0x90, /* ld.q r17, 16, r25 */
3119 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
3120 0x8d, 0x10, 0x05, 0x10, /* ld.q r17, 8, r17 */
3121 0xcc, 0x00, 0x01, 0x50, /* movi reloc-offset >> 16, r21 */
3122 0xc8, 0x00, 0x01, 0x50, /* shori reloc-offset & 65535, r21 */
3123 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
3126 static const bfd_byte elf_sh64_pic_plt_entry_le
[PLT_ENTRY_SIZE
] =
3128 0x90, 0x01, 0x00, 0xcc, /* movi nameN@GOT >> 16, r25 */
3129 0x90, 0x01, 0x00, 0xc8, /* shori nameN@GOT & 65535, r25 */
3130 0x90, 0x65, 0xc3, 0x40, /* ldx.q r12, r25, r25 */
3131 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
3132 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
3133 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3134 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3135 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3136 0x10, 0x01, 0x00, 0xce, /* movi -GOT_BIAS, r17 */
3137 0x10, 0x45, 0xc9, 0x00, /* add r12, r17, r17 */
3138 0x90, 0x09, 0x10, 0x8d, /* ld.q r17, 16, r25 */
3139 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
3140 0x10, 0x05, 0x10, 0x8d, /* ld.q r17, 8, r17 */
3141 0x50, 0x01, 0x00, 0xcc, /* movi reloc-offset >> 16, r21 */
3142 0x50, 0x01, 0x00, 0xc8, /* shori reloc-offset & 65535, r21 */
3143 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
3146 static const bfd_byte
*elf_sh64_plt0_entry
;
3147 static const bfd_byte
*elf_sh64_plt_entry
;
3148 static const bfd_byte
*elf_sh64_pic_plt_entry
;
3150 /* Create an entry in an sh ELF linker hash table. */
3152 static struct bfd_hash_entry
*
3153 sh64_elf64_link_hash_newfunc (struct bfd_hash_entry
*entry
,
3154 struct bfd_hash_table
*table
,
3157 struct elf_sh64_link_hash_entry
*ret
=
3158 (struct elf_sh64_link_hash_entry
*) entry
;
3160 /* Allocate the structure if it has not already been allocated by a
3162 if (ret
== (struct elf_sh64_link_hash_entry
*) NULL
)
3163 ret
= ((struct elf_sh64_link_hash_entry
*)
3164 bfd_hash_allocate (table
,
3165 sizeof (struct elf_sh64_link_hash_entry
)));
3166 if (ret
== (struct elf_sh64_link_hash_entry
*) NULL
)
3167 return (struct bfd_hash_entry
*) ret
;
3169 /* Call the allocation method of the superclass. */
3170 ret
= ((struct elf_sh64_link_hash_entry
*)
3171 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
3173 if (ret
!= (struct elf_sh64_link_hash_entry
*) NULL
)
3175 ret
->pcrel_relocs_copied
= NULL
;
3176 ret
->datalabel_got_offset
= (bfd_vma
) -1;
3179 return (struct bfd_hash_entry
*) ret
;
3182 /* Create an sh64 ELF linker hash table. */
3184 static struct bfd_link_hash_table
*
3185 sh64_elf64_link_hash_table_create (bfd
*abfd
)
3187 struct elf_sh64_link_hash_table
*ret
;
3189 ret
= ((struct elf_sh64_link_hash_table
*)
3190 bfd_malloc (sizeof (struct elf_sh64_link_hash_table
)));
3191 if (ret
== (struct elf_sh64_link_hash_table
*) NULL
)
3194 if (! _bfd_elf_link_hash_table_init (&ret
->root
, abfd
,
3195 sh64_elf64_link_hash_newfunc
))
3201 return &ret
->root
.root
;
3205 movi_shori_putval (bfd
*output_bfd
, unsigned long value
, char *addr
)
3207 bfd_put_32 (output_bfd
,
3208 bfd_get_32 (output_bfd
, addr
)
3209 | ((value
>> 6) & 0x3fffc00),
3211 bfd_put_32 (output_bfd
,
3212 bfd_get_32 (output_bfd
, addr
+ 4)
3213 | ((value
<< 10) & 0x3fffc00),
3218 movi_3shori_putval (bfd
*output_bfd
, bfd_vma value
, char *addr
)
3220 bfd_put_32 (output_bfd
,
3221 bfd_get_32 (output_bfd
, addr
)
3222 | ((value
>> 38) & 0x3fffc00),
3224 bfd_put_32 (output_bfd
,
3225 bfd_get_32 (output_bfd
, addr
+ 4)
3226 | ((value
>> 22) & 0x3fffc00),
3228 bfd_put_32 (output_bfd
,
3229 bfd_get_32 (output_bfd
, addr
+ 8)
3230 | ((value
>> 6) & 0x3fffc00),
3232 bfd_put_32 (output_bfd
,
3233 bfd_get_32 (output_bfd
, addr
+ 12)
3234 | ((value
<< 10) & 0x3fffc00),
3238 /* Create dynamic sections when linking against a dynamic object. */
3241 sh64_elf64_create_dynamic_sections (bfd
*abfd
, struct bfd_link_info
*info
)
3243 flagword flags
, pltflags
;
3244 register asection
*s
;
3245 const struct elf_backend_data
*bed
= get_elf_backend_data (abfd
);
3248 switch (bed
->s
->arch_size
)
3259 bfd_set_error (bfd_error_bad_value
);
3263 /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and
3264 .rel[a].bss sections. */
3266 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
3267 | SEC_LINKER_CREATED
);
3270 pltflags
|= SEC_CODE
;
3271 if (bed
->plt_not_loaded
)
3272 pltflags
&= ~ (SEC_LOAD
| SEC_HAS_CONTENTS
);
3273 if (bed
->plt_readonly
)
3274 pltflags
|= SEC_READONLY
;
3276 s
= bfd_make_section (abfd
, ".plt");
3278 || ! bfd_set_section_flags (abfd
, s
, pltflags
)
3279 || ! bfd_set_section_alignment (abfd
, s
, bed
->plt_alignment
))
3282 if (bed
->want_plt_sym
)
3284 /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
3286 struct elf_link_hash_entry
*h
;
3287 struct bfd_link_hash_entry
*bh
= NULL
;
3289 if (! (_bfd_generic_link_add_one_symbol
3290 (info
, abfd
, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL
, s
,
3291 (bfd_vma
) 0, (const char *) NULL
, FALSE
, bed
->collect
, &bh
)))
3294 h
= (struct elf_link_hash_entry
*) bh
;
3295 h
->elf_link_hash_flags
|= ELF_LINK_HASH_DEF_REGULAR
;
3296 h
->type
= STT_OBJECT
;
3299 && ! _bfd_elf_link_record_dynamic_symbol (info
, h
))
3303 s
= bfd_make_section (abfd
,
3304 bed
->default_use_rela_p
? ".rela.plt" : ".rel.plt");
3306 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
)
3307 || ! bfd_set_section_alignment (abfd
, s
, ptralign
))
3310 if (! _bfd_elf_create_got_section (abfd
, info
))
3314 const char *secname
;
3319 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3321 secflags
= bfd_get_section_flags (abfd
, sec
);
3322 if ((secflags
& (SEC_DATA
| SEC_LINKER_CREATED
))
3323 || ((secflags
& SEC_HAS_CONTENTS
) != SEC_HAS_CONTENTS
))
3325 secname
= bfd_get_section_name (abfd
, sec
);
3326 relname
= (char *) bfd_malloc (strlen (secname
) + 6);
3327 strcpy (relname
, ".rela");
3328 strcat (relname
, secname
);
3329 s
= bfd_make_section (abfd
, relname
);
3331 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
)
3332 || ! bfd_set_section_alignment (abfd
, s
, ptralign
))
3337 if (bed
->want_dynbss
)
3339 /* The .dynbss section is a place to put symbols which are defined
3340 by dynamic objects, are referenced by regular objects, and are
3341 not functions. We must allocate space for them in the process
3342 image and use a R_*_COPY reloc to tell the dynamic linker to
3343 initialize them at run time. The linker script puts the .dynbss
3344 section into the .bss section of the final image. */
3345 s
= bfd_make_section (abfd
, ".dynbss");
3347 || ! bfd_set_section_flags (abfd
, s
, SEC_ALLOC
))
3350 /* The .rel[a].bss section holds copy relocs. This section is not
3351 normally needed. We need to create it here, though, so that the
3352 linker will map it to an output section. We can't just create it
3353 only if we need it, because we will not know whether we need it
3354 until we have seen all the input files, and the first time the
3355 main linker code calls BFD after examining all the input files
3356 (size_dynamic_sections) the input sections have already been
3357 mapped to the output sections. If the section turns out not to
3358 be needed, we can discard it later. We will never need this
3359 section when generating a shared object, since they do not use
3363 s
= bfd_make_section (abfd
,
3364 (bed
->default_use_rela_p
3365 ? ".rela.bss" : ".rel.bss"));
3367 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
)
3368 || ! bfd_set_section_alignment (abfd
, s
, ptralign
))
3376 /* Adjust a symbol defined by a dynamic object and referenced by a
3377 regular object. The current definition is in some section of the
3378 dynamic object, but we're not including those sections. We have to
3379 change the definition to something the rest of the link can
3383 sh64_elf64_adjust_dynamic_symbol (struct bfd_link_info
*info
,
3384 struct elf_link_hash_entry
*h
)
3388 unsigned int power_of_two
;
3390 dynobj
= elf_hash_table (info
)->dynobj
;
3392 /* Make sure we know what is going on here. */
3393 BFD_ASSERT (dynobj
!= NULL
3394 && ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
)
3395 || h
->weakdef
!= NULL
3396 || ((h
->elf_link_hash_flags
3397 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0
3398 && (h
->elf_link_hash_flags
3399 & ELF_LINK_HASH_REF_REGULAR
) != 0
3400 && (h
->elf_link_hash_flags
3401 & ELF_LINK_HASH_DEF_REGULAR
) == 0)));
3403 /* If this is a function, put it in the procedure linkage table. We
3404 will fill in the contents of the procedure linkage table later,
3405 when we know the address of the .got section. */
3406 if (h
->type
== STT_FUNC
3407 || (h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0)
3410 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_DYNAMIC
) == 0
3411 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_REF_DYNAMIC
) == 0)
3413 /* This case can occur if we saw a PLT reloc in an input
3414 file, but the symbol was never referred to by a dynamic
3415 object. In such a case, we don't actually need to build
3416 a procedure linkage table, and we can just do a REL64
3418 BFD_ASSERT ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0);
3422 /* Make sure this symbol is output as a dynamic symbol. */
3423 if (h
->dynindx
== -1)
3425 if (! bfd_elf64_link_record_dynamic_symbol (info
, h
))
3429 s
= bfd_get_section_by_name (dynobj
, ".plt");
3430 BFD_ASSERT (s
!= NULL
);
3432 /* If this is the first .plt entry, make room for the special
3434 if (s
->_raw_size
== 0)
3435 s
->_raw_size
+= PLT_ENTRY_SIZE
;
3437 /* If this symbol is not defined in a regular file, and we are
3438 not generating a shared library, then set the symbol to this
3439 location in the .plt. This is required to make function
3440 pointers compare as equal between the normal executable and
3441 the shared library. */
3443 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
3445 h
->root
.u
.def
.section
= s
;
3446 h
->root
.u
.def
.value
= s
->_raw_size
;
3449 h
->plt
.offset
= s
->_raw_size
;
3451 /* Make room for this entry. */
3452 s
->_raw_size
+= elf_sh64_sizeof_plt (info
);
3454 /* We also need to make an entry in the .got.plt section, which
3455 will be placed in the .got section by the linker script. */
3457 s
= bfd_get_section_by_name (dynobj
, ".got.plt");
3458 BFD_ASSERT (s
!= NULL
);
3461 /* We also need to make an entry in the .rela.plt section. */
3463 s
= bfd_get_section_by_name (dynobj
, ".rela.plt");
3464 BFD_ASSERT (s
!= NULL
);
3465 s
->_raw_size
+= sizeof (Elf64_External_Rela
);
3470 /* If this is a weak symbol, and there is a real definition, the
3471 processor independent code will have arranged for us to see the
3472 real definition first, and we can just use the same value. */
3473 if (h
->weakdef
!= NULL
)
3475 BFD_ASSERT (h
->weakdef
->root
.type
== bfd_link_hash_defined
3476 || h
->weakdef
->root
.type
== bfd_link_hash_defweak
);
3477 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
3478 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
3482 /* This is a reference to a symbol defined by a dynamic object which
3483 is not a function. */
3485 /* If we are creating a shared library, we must presume that the
3486 only references to the symbol are via the global offset table.
3487 For such cases we need not do anything here; the relocations will
3488 be handled correctly by relocate_section. */
3492 /* If there are no references to this symbol that do not use the
3493 GOT, we don't need to generate a copy reloc. */
3494 if ((h
->elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0)
3497 /* We must allocate the symbol in our .dynbss section, which will
3498 become part of the .bss section of the executable. There will be
3499 an entry for this symbol in the .dynsym section. The dynamic
3500 object will contain position independent code, so all references
3501 from the dynamic object to this symbol will go through the global
3502 offset table. The dynamic linker will use the .dynsym entry to
3503 determine the address it must put in the global offset table, so
3504 both the dynamic object and the regular object will refer to the
3505 same memory location for the variable. */
3507 s
= bfd_get_section_by_name (dynobj
, ".dynbss");
3508 BFD_ASSERT (s
!= NULL
);
3510 /* We must generate a R_SH_COPY reloc to tell the dynamic linker to
3511 copy the initial value out of the dynamic object and into the
3512 runtime process image. We need to remember the offset into the
3513 .rela.bss section we are going to use. */
3514 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
3518 srel
= bfd_get_section_by_name (dynobj
, ".rela.bss");
3519 BFD_ASSERT (srel
!= NULL
);
3520 srel
->_raw_size
+= sizeof (Elf64_External_Rela
);
3521 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_COPY
;
3524 /* We need to figure out the alignment required for this symbol. I
3525 have no idea how ELF linkers handle this. */
3526 power_of_two
= bfd_log2 (h
->size
);
3527 if (power_of_two
> 3)
3530 /* Apply the required alignment. */
3531 s
->_raw_size
= BFD_ALIGN (s
->_raw_size
,
3532 (bfd_size_type
) (1 << power_of_two
));
3533 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
3535 if (! bfd_set_section_alignment (dynobj
, s
, power_of_two
))
3539 /* Define the symbol as being at this point in the section. */
3540 h
->root
.u
.def
.section
= s
;
3541 h
->root
.u
.def
.value
= s
->_raw_size
;
3543 /* Increment the section size to make room for the symbol. */
3544 s
->_raw_size
+= h
->size
;
3549 /* This function is called via sh_elf_link_hash_traverse if we are
3550 creating a shared object with -Bsymbolic. It discards the space
3551 allocated to copy PC relative relocs against symbols which are
3552 defined in regular objects. We allocated space for them in the
3553 check_relocs routine, but we won't fill them in in the
3554 relocate_section routine. */
3557 sh64_elf64_discard_copies (struct elf_sh64_link_hash_entry
*h
,
3558 void *ignore ATTRIBUTE_UNUSED
)
3560 struct elf_sh64_pcrel_relocs_copied
*s
;
3562 if (h
->root
.root
.type
== bfd_link_hash_warning
)
3563 h
= (struct elf_sh64_link_hash_entry
*) h
->root
.root
.u
.i
.link
;
3565 /* We only discard relocs for symbols defined in a regular object. */
3566 if ((h
->root
.elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
3569 for (s
= h
->pcrel_relocs_copied
; s
!= NULL
; s
= s
->next
)
3570 s
->section
->_raw_size
-= s
->count
* sizeof (Elf64_External_Rela
);
3575 /* Set the sizes of the dynamic sections. */
3578 sh64_elf64_size_dynamic_sections (bfd
*output_bfd
,
3579 struct bfd_link_info
*info
)
3585 bfd_boolean reltext
;
3587 dynobj
= elf_hash_table (info
)->dynobj
;
3588 BFD_ASSERT (dynobj
!= NULL
);
3590 if (elf_hash_table (info
)->dynamic_sections_created
)
3592 /* Set the contents of the .interp section to the interpreter. */
3593 if (info
->executable
)
3595 s
= bfd_get_section_by_name (dynobj
, ".interp");
3596 BFD_ASSERT (s
!= NULL
);
3597 s
->_raw_size
= sizeof ELF_DYNAMIC_INTERPRETER
;
3598 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
3603 /* We may have created entries in the .rela.got section.
3604 However, if we are not creating the dynamic sections, we will
3605 not actually use these entries. Reset the size of .rela.got,
3606 which will cause it to get stripped from the output file
3608 s
= bfd_get_section_by_name (dynobj
, ".rela.got");
3613 /* If this is a -Bsymbolic shared link, then we need to discard all
3614 PC relative relocs against symbols defined in a regular object.
3615 We allocated space for them in the check_relocs routine, but we
3616 will not fill them in in the relocate_section routine. */
3617 if (info
->shared
&& info
->symbolic
)
3618 sh64_elf64_link_hash_traverse (sh64_elf64_hash_table (info
),
3619 sh64_elf64_discard_copies
, NULL
);
3621 /* The check_relocs and adjust_dynamic_symbol entry points have
3622 determined the sizes of the various dynamic sections. Allocate
3627 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
3632 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
3635 /* It's OK to base decisions on the section name, because none
3636 of the dynobj section names depend upon the input files. */
3637 name
= bfd_get_section_name (dynobj
, s
);
3641 if (strcmp (name
, ".plt") == 0)
3643 if (s
->_raw_size
== 0)
3645 /* Strip this section if we don't need it; see the
3651 /* Remember whether there is a PLT. */
3655 else if (strncmp (name
, ".rela", 5) == 0)
3657 if (s
->_raw_size
== 0)
3659 /* If we don't need this section, strip it from the
3660 output file. This is mostly to handle .rela.bss and
3661 .rela.plt. We must create both sections in
3662 create_dynamic_sections, because they must be created
3663 before the linker maps input sections to output
3664 sections. The linker does that before
3665 adjust_dynamic_symbol is called, and it is that
3666 function which decides whether anything needs to go
3667 into these sections. */
3674 /* Remember whether there are any reloc sections other
3676 if (strcmp (name
, ".rela.plt") != 0)
3678 const char *outname
;
3682 /* If this relocation section applies to a read only
3683 section, then we probably need a DT_TEXTREL
3684 entry. The entries in the .rela.plt section
3685 really apply to the .got section, which we
3686 created ourselves and so know is not readonly. */
3687 outname
= bfd_get_section_name (output_bfd
,
3689 target
= bfd_get_section_by_name (output_bfd
, outname
+ 5);
3691 && (target
->flags
& SEC_READONLY
) != 0
3692 && (target
->flags
& SEC_ALLOC
) != 0)
3696 /* We use the reloc_count field as a counter if we need
3697 to copy relocs into the output file. */
3701 else if (strncmp (name
, ".got", 4) != 0)
3703 /* It's not one of our sections, so don't allocate space. */
3709 _bfd_strip_section_from_output (info
, s
);
3713 /* Allocate memory for the section contents. */
3714 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->_raw_size
);
3715 if (s
->contents
== NULL
&& s
->_raw_size
!= 0)
3719 if (elf_hash_table (info
)->dynamic_sections_created
)
3721 /* Add some entries to the .dynamic section. We fill in the
3722 values later, in sh64_elf64_finish_dynamic_sections, but we
3723 must add the entries now so that we get the correct size for
3724 the .dynamic section. The DT_DEBUG entry is filled in by the
3725 dynamic linker and used by the debugger. */
3726 if (info
->executable
)
3728 if (! bfd_elf64_add_dynamic_entry (info
, DT_DEBUG
, 0))
3734 if (! bfd_elf64_add_dynamic_entry (info
, DT_PLTGOT
, 0)
3735 || ! bfd_elf64_add_dynamic_entry (info
, DT_PLTRELSZ
, 0)
3736 || ! bfd_elf64_add_dynamic_entry (info
, DT_PLTREL
, DT_RELA
)
3737 || ! bfd_elf64_add_dynamic_entry (info
, DT_JMPREL
, 0))
3743 if (! bfd_elf64_add_dynamic_entry (info
, DT_RELA
, 0)
3744 || ! bfd_elf64_add_dynamic_entry (info
, DT_RELASZ
, 0)
3745 || ! bfd_elf64_add_dynamic_entry (info
, DT_RELAENT
,
3746 sizeof (Elf64_External_Rela
)))
3752 if (! bfd_elf64_add_dynamic_entry (info
, DT_TEXTREL
, 0))
3760 /* Finish up dynamic symbol handling. We set the contents of various
3761 dynamic sections here. */
3764 sh64_elf64_finish_dynamic_symbol (bfd
*output_bfd
,
3765 struct bfd_link_info
*info
,
3766 struct elf_link_hash_entry
*h
,
3767 Elf_Internal_Sym
*sym
)
3771 dynobj
= elf_hash_table (info
)->dynobj
;
3773 if (h
->plt
.offset
!= (bfd_vma
) -1)
3781 Elf_Internal_Rela rel
;
3784 /* This symbol has an entry in the procedure linkage table. Set
3787 BFD_ASSERT (h
->dynindx
!= -1);
3789 splt
= bfd_get_section_by_name (dynobj
, ".plt");
3790 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
3791 srel
= bfd_get_section_by_name (dynobj
, ".rela.plt");
3792 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srel
!= NULL
);
3794 /* Get the index in the procedure linkage table which
3795 corresponds to this symbol. This is the index of this symbol
3796 in all the symbols for which we are making plt entries. The
3797 first entry in the procedure linkage table is reserved. */
3798 plt_index
= h
->plt
.offset
/ elf_sh64_sizeof_plt (info
) - 1;
3800 /* Get the offset into the .got table of the entry that
3801 corresponds to this function. Each .got entry is 8 bytes.
3802 The first three are reserved. */
3803 got_offset
= (plt_index
+ 3) * 8;
3806 got_offset
-= GOT_BIAS
;
3808 /* Fill in the entry in the procedure linkage table. */
3811 if (elf_sh64_plt_entry
== NULL
)
3813 elf_sh64_plt_entry
= (bfd_big_endian (output_bfd
) ?
3814 elf_sh64_plt_entry_be
: elf_sh64_plt_entry_le
);
3816 memcpy (splt
->contents
+ h
->plt
.offset
, elf_sh64_plt_entry
,
3817 elf_sh64_sizeof_plt (info
));
3818 movi_3shori_putval (output_bfd
,
3819 (sgot
->output_section
->vma
3820 + sgot
->output_offset
3822 (splt
->contents
+ h
->plt
.offset
3823 + elf_sh64_plt_symbol_offset (info
)));
3825 /* Set bottom bit because its for a branch to SHmedia */
3826 movi_shori_putval (output_bfd
,
3828 + elf_sh64_plt_plt0_offset (info
) + 8)
3830 (splt
->contents
+ h
->plt
.offset
3831 + elf_sh64_plt_plt0_offset (info
)));
3835 if (elf_sh64_pic_plt_entry
== NULL
)
3837 elf_sh64_pic_plt_entry
= (bfd_big_endian (output_bfd
) ?
3838 elf_sh64_pic_plt_entry_be
:
3839 elf_sh64_pic_plt_entry_le
);
3841 memcpy (splt
->contents
+ h
->plt
.offset
, elf_sh64_pic_plt_entry
,
3842 elf_sh64_sizeof_plt (info
));
3843 movi_shori_putval (output_bfd
, got_offset
,
3844 (splt
->contents
+ h
->plt
.offset
3845 + elf_sh64_plt_symbol_offset (info
)));
3849 got_offset
+= GOT_BIAS
;
3851 movi_shori_putval (output_bfd
,
3852 plt_index
* sizeof (Elf64_External_Rela
),
3853 (splt
->contents
+ h
->plt
.offset
3854 + elf_sh64_plt_reloc_offset (info
)));
3856 /* Fill in the entry in the global offset table. */
3857 bfd_put_64 (output_bfd
,
3858 (splt
->output_section
->vma
3859 + splt
->output_offset
3861 + elf_sh64_plt_temp_offset (info
)),
3862 sgot
->contents
+ got_offset
);
3864 /* Fill in the entry in the .rela.plt section. */
3865 rel
.r_offset
= (sgot
->output_section
->vma
3866 + sgot
->output_offset
3868 rel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_SH_JMP_SLOT64
);
3870 rel
.r_addend
= GOT_BIAS
;
3871 loc
= srel
->contents
+ plt_index
* sizeof (Elf64_External_Rela
);
3872 bfd_elf64_swap_reloca_out (output_bfd
, &rel
, loc
);
3874 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
3876 /* Mark the symbol as undefined, rather than as defined in
3877 the .plt section. Leave the value alone. */
3878 sym
->st_shndx
= SHN_UNDEF
;
3882 if (h
->got
.offset
!= (bfd_vma
) -1)
3886 Elf_Internal_Rela rel
;
3889 /* This symbol has an entry in the global offset table. Set it
3892 sgot
= bfd_get_section_by_name (dynobj
, ".got");
3893 srel
= bfd_get_section_by_name (dynobj
, ".rela.got");
3894 BFD_ASSERT (sgot
!= NULL
&& srel
!= NULL
);
3896 rel
.r_offset
= (sgot
->output_section
->vma
3897 + sgot
->output_offset
3898 + (h
->got
.offset
&~ 1));
3900 /* If this is a -Bsymbolic link, and the symbol is defined
3901 locally, we just want to emit a RELATIVE reloc. Likewise if
3902 the symbol was forced to be local because of a version file.
3903 The entry in the global offset table will already have been
3904 initialized in the relocate_section function. */
3906 && (info
->symbolic
|| h
->dynindx
== -1)
3907 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
))
3909 rel
.r_info
= ELF64_R_INFO (0, R_SH_RELATIVE64
);
3910 rel
.r_addend
= (h
->root
.u
.def
.value
3911 + h
->root
.u
.def
.section
->output_section
->vma
3912 + h
->root
.u
.def
.section
->output_offset
);
3916 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ h
->got
.offset
);
3917 rel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_SH_GLOB_DAT64
);
3921 loc
= srel
->contents
;
3922 loc
+= srel
->reloc_count
++ * sizeof (Elf64_External_Rela
);
3923 bfd_elf64_swap_reloca_out (output_bfd
, &rel
, loc
);
3926 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_COPY
) != 0)
3929 Elf_Internal_Rela rel
;
3932 /* This symbol needs a copy reloc. Set it up. */
3934 BFD_ASSERT (h
->dynindx
!= -1
3935 && (h
->root
.type
== bfd_link_hash_defined
3936 || h
->root
.type
== bfd_link_hash_defweak
));
3938 s
= bfd_get_section_by_name (h
->root
.u
.def
.section
->owner
,
3940 BFD_ASSERT (s
!= NULL
);
3942 rel
.r_offset
= (h
->root
.u
.def
.value
3943 + h
->root
.u
.def
.section
->output_section
->vma
3944 + h
->root
.u
.def
.section
->output_offset
);
3945 rel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_SH_COPY64
);
3948 loc
+= s
->reloc_count
++ * sizeof (Elf64_External_Rela
);
3949 bfd_elf64_swap_reloca_out (output_bfd
, &rel
, loc
);
3952 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
3953 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
3954 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0)
3955 sym
->st_shndx
= SHN_ABS
;
3960 /* Finish up the dynamic sections. */
3963 sh64_elf64_finish_dynamic_sections (bfd
*output_bfd
,
3964 struct bfd_link_info
*info
)
3970 dynobj
= elf_hash_table (info
)->dynobj
;
3972 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
3973 BFD_ASSERT (sgot
!= NULL
);
3974 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
3976 if (elf_hash_table (info
)->dynamic_sections_created
)
3979 Elf64_External_Dyn
*dyncon
, *dynconend
;
3981 BFD_ASSERT (sdyn
!= NULL
);
3983 dyncon
= (Elf64_External_Dyn
*) sdyn
->contents
;
3984 dynconend
= (Elf64_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
3985 for (; dyncon
< dynconend
; dyncon
++)
3987 Elf_Internal_Dyn dyn
;
3990 struct elf_link_hash_entry
*h
;
3992 bfd_elf64_swap_dyn_in (dynobj
, dyncon
, &dyn
);
4000 name
= info
->init_function
;
4004 name
= info
->fini_function
;
4006 if (dyn
.d_un
.d_val
!= 0)
4008 h
= elf_link_hash_lookup (elf_hash_table (info
), name
,
4009 FALSE
, FALSE
, TRUE
);
4010 if (h
!= NULL
&& (h
->other
& STO_SH5_ISA32
))
4012 dyn
.d_un
.d_val
|= 1;
4013 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4025 s
= bfd_get_section_by_name (output_bfd
, name
);
4026 BFD_ASSERT (s
!= NULL
);
4027 dyn
.d_un
.d_ptr
= s
->vma
;
4028 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4032 s
= bfd_get_section_by_name (output_bfd
, ".rela.plt");
4033 BFD_ASSERT (s
!= NULL
);
4034 if (s
->_cooked_size
!= 0)
4035 dyn
.d_un
.d_val
= s
->_cooked_size
;
4037 dyn
.d_un
.d_val
= s
->_raw_size
;
4038 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4042 /* My reading of the SVR4 ABI indicates that the
4043 procedure linkage table relocs (DT_JMPREL) should be
4044 included in the overall relocs (DT_RELA). This is
4045 what Solaris does. However, UnixWare can not handle
4046 that case. Therefore, we override the DT_RELASZ entry
4047 here to make it not include the JMPREL relocs. Since
4048 the linker script arranges for .rela.plt to follow all
4049 other relocation sections, we don't have to worry
4050 about changing the DT_RELA entry. */
4051 s
= bfd_get_section_by_name (output_bfd
, ".rela.plt");
4054 if (s
->_cooked_size
!= 0)
4055 dyn
.d_un
.d_val
-= s
->_cooked_size
;
4057 dyn
.d_un
.d_val
-= s
->_raw_size
;
4059 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4064 /* Fill in the first entry in the procedure linkage table. */
4065 splt
= bfd_get_section_by_name (dynobj
, ".plt");
4066 if (splt
&& splt
->_raw_size
> 0)
4070 if (elf_sh64_pic_plt_entry
== NULL
)
4072 elf_sh64_pic_plt_entry
= (bfd_big_endian (output_bfd
) ?
4073 elf_sh64_pic_plt_entry_be
:
4074 elf_sh64_pic_plt_entry_le
);
4076 memcpy (splt
->contents
, elf_sh64_pic_plt_entry
,
4077 elf_sh64_sizeof_plt (info
));
4081 if (elf_sh64_plt0_entry
== NULL
)
4083 elf_sh64_plt0_entry
= (bfd_big_endian (output_bfd
) ?
4084 elf_sh64_plt0_entry_be
:
4085 elf_sh64_plt0_entry_le
);
4087 memcpy (splt
->contents
, elf_sh64_plt0_entry
, PLT_ENTRY_SIZE
);
4088 movi_3shori_putval (output_bfd
,
4089 sgot
->output_section
->vma
4090 + sgot
->output_offset
,
4092 + elf_sh64_plt0_gotplt_offset (info
));
4095 /* UnixWare sets the entsize of .plt to 8, although that doesn't
4096 really seem like the right value. */
4097 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
= 8;
4101 /* Fill in the first three entries in the global offset table. */
4102 if (sgot
->_raw_size
> 0)
4105 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
);
4107 bfd_put_64 (output_bfd
,
4108 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
4110 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 8);
4111 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 16);
4114 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 8;
4119 static struct bfd_elf_special_section
const sh64_elf64_special_sections
[]=
4121 { ".cranges", 8, 0, SHT_PROGBITS
, 0 },
4122 { NULL
, 0, 0, 0, 0 }
4125 #define TARGET_BIG_SYM bfd_elf64_sh64_vec
4126 #define TARGET_BIG_NAME "elf64-sh64"
4127 #define TARGET_LITTLE_SYM bfd_elf64_sh64l_vec
4128 #define TARGET_LITTLE_NAME "elf64-sh64l"
4129 #define ELF_ARCH bfd_arch_sh
4130 #define ELF_MACHINE_CODE EM_SH
4131 #define ELF_MAXPAGESIZE 128
4133 #define elf_symbol_leading_char '_'
4135 #define bfd_elf64_bfd_reloc_type_lookup sh_elf64_reloc_type_lookup
4136 #define elf_info_to_howto sh_elf64_info_to_howto
4138 /* Note: there's no relaxation at present. */
4140 #define elf_backend_relocate_section sh_elf64_relocate_section
4141 #define bfd_elf64_bfd_get_relocated_section_contents \
4142 sh_elf64_get_relocated_section_contents
4143 #define elf_backend_object_p sh_elf64_set_mach_from_flags
4144 #define bfd_elf64_bfd_set_private_flags \
4145 sh_elf64_set_private_flags
4146 #define bfd_elf64_bfd_copy_private_bfd_data \
4147 sh_elf64_copy_private_data
4148 #define bfd_elf64_bfd_merge_private_bfd_data \
4149 sh_elf64_merge_private_data
4150 #define elf_backend_fake_sections sh64_elf64_fake_sections
4152 #define elf_backend_gc_mark_hook sh_elf64_gc_mark_hook
4153 #define elf_backend_gc_sweep_hook sh_elf64_gc_sweep_hook
4154 #define elf_backend_check_relocs sh_elf64_check_relocs
4156 #define elf_backend_can_gc_sections 1
4158 #define elf_backend_get_symbol_type sh64_elf64_get_symbol_type
4160 #define elf_backend_add_symbol_hook sh64_elf64_add_symbol_hook
4162 #define elf_backend_link_output_symbol_hook \
4163 sh64_elf64_link_output_symbol_hook
4165 #define elf_backend_final_write_processing \
4166 sh64_elf64_final_write_processing
4168 #define elf_backend_create_dynamic_sections \
4169 sh64_elf64_create_dynamic_sections
4170 #define bfd_elf64_bfd_link_hash_table_create \
4171 sh64_elf64_link_hash_table_create
4172 #define elf_backend_adjust_dynamic_symbol \
4173 sh64_elf64_adjust_dynamic_symbol
4174 #define elf_backend_size_dynamic_sections \
4175 sh64_elf64_size_dynamic_sections
4176 #define elf_backend_finish_dynamic_symbol \
4177 sh64_elf64_finish_dynamic_symbol
4178 #define elf_backend_finish_dynamic_sections \
4179 sh64_elf64_finish_dynamic_sections
4180 #define elf_backend_special_sections sh64_elf64_special_sections
4182 #define elf_backend_want_got_plt 1
4183 #define elf_backend_plt_readonly 1
4184 #define elf_backend_want_plt_sym 0
4185 #define elf_backend_got_header_size 24
4186 #define elf_backend_plt_header_size PLT_ENTRY_SIZE
4188 #include "elf64-target.h"
4190 /* NetBSD support. */
4191 #undef TARGET_BIG_SYM
4192 #define TARGET_BIG_SYM bfd_elf64_sh64nbsd_vec
4193 #undef TARGET_BIG_NAME
4194 #define TARGET_BIG_NAME "elf64-sh64-nbsd"
4195 #undef TARGET_LITTLE_SYM
4196 #define TARGET_LITTLE_SYM bfd_elf64_sh64lnbsd_vec
4197 #undef TARGET_LITTLE_NAME
4198 #define TARGET_LITTLE_NAME "elf64-sh64l-nbsd"
4199 #undef ELF_MAXPAGESIZE
4200 #define ELF_MAXPAGESIZE 0x10000
4201 #undef elf_symbol_leading_char
4202 #define elf_symbol_leading_char 0
4204 #define elf64_bed elf64_sh64_nbsd_bed
4206 #include "elf64-target.h"
4208 /* Linux support. */
4209 #undef TARGET_BIG_SYM
4210 #define TARGET_BIG_SYM bfd_elf64_sh64blin_vec
4211 #undef TARGET_BIG_NAME
4212 #define TARGET_BIG_NAME "elf64-sh64big-linux"
4213 #undef TARGET_LITTLE_SYM
4214 #define TARGET_LITTLE_SYM bfd_elf64_sh64lin_vec
4215 #undef TARGET_LITTLE_NAME
4216 #define TARGET_LITTLE_NAME "elf64-sh64-linux"
4218 #define INCLUDED_TARGET_FILE
4219 #include "elf64-target.h"