1 /* Hitachi SH64-specific support for 64-bit ELF
2 Copyright (C) 2000, 2001, 2002 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 (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (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 boolean sh_elf64_copy_private_data
PARAMS ((bfd
*, bfd
*));
111 static boolean sh_elf64_copy_private_data_internal
PARAMS ((bfd
*, bfd
*));
112 static boolean sh_elf64_merge_private_data
PARAMS ((bfd
*, bfd
*));
113 static bfd_reloc_status_type sh_elf64_ignore_reloc
114 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
115 static bfd_reloc_status_type sh_elf64_reloc
116 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
117 static reloc_howto_type
*sh_elf64_reloc_type_lookup
118 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
119 static void sh_elf64_info_to_howto
120 PARAMS ((bfd
*, arelent
*, Elf_Internal_Rela
*));
121 static boolean sh_elf64_relocate_section
122 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
123 Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**));
124 static bfd_byte
*sh_elf64_get_relocated_section_contents
125 PARAMS ((bfd
*, struct bfd_link_info
*, struct bfd_link_order
*,
126 bfd_byte
*, boolean
, asymbol
**));
127 static boolean sh_elf64_set_mach_from_flags
PARAMS ((bfd
*));
128 static boolean sh_elf64_set_private_flags
PARAMS ((bfd
*, flagword
));
129 static asection
*sh_elf64_gc_mark_hook
130 PARAMS ((asection
*, struct bfd_link_info
*, Elf_Internal_Rela
*,
131 struct elf_link_hash_entry
*, Elf_Internal_Sym
*));
132 static boolean sh_elf64_gc_sweep_hook
133 PARAMS ((bfd
*, struct bfd_link_info
*, asection
*,
134 const Elf_Internal_Rela
*));
135 static boolean sh_elf64_check_relocs
136 PARAMS ((bfd
*, struct bfd_link_info
*, asection
*,
137 const Elf_Internal_Rela
*));
138 static int sh64_elf64_get_symbol_type
PARAMS ((Elf_Internal_Sym
*, int));
139 static boolean sh64_elf64_add_symbol_hook
140 PARAMS ((bfd
*, struct bfd_link_info
*, const Elf_Internal_Sym
*,
141 const char **, flagword
*, asection
**, bfd_vma
*));
142 static boolean sh64_elf64_link_output_symbol_hook
143 PARAMS ((bfd
*, struct bfd_link_info
*, const char *, Elf_Internal_Sym
*,
145 static boolean sh64_elf64_fake_sections
146 PARAMS ((bfd
*, Elf_Internal_Shdr
*, asection
*));
147 static void sh64_elf64_final_write_processing
PARAMS ((bfd
*, boolean
));
148 static struct bfd_hash_entry
*sh64_elf64_link_hash_newfunc
149 PARAMS ((struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *));
150 static struct bfd_link_hash_table
*sh64_elf64_link_hash_table_create
152 inline static void movi_shori_putval
PARAMS ((bfd
*, unsigned long, char *));
153 inline static void movi_3shori_putval
PARAMS ((bfd
*, bfd_vma
, char *));
154 static boolean sh64_elf64_create_dynamic_sections
155 PARAMS ((bfd
*, struct bfd_link_info
*));
156 static boolean sh64_elf64_adjust_dynamic_symbol
157 PARAMS ((struct bfd_link_info
*info
, struct elf_link_hash_entry
*));
158 static boolean sh64_elf64_discard_copies
159 PARAMS ((struct elf_sh64_link_hash_entry
*, PTR
));
160 static boolean sh64_elf64_size_dynamic_sections
161 PARAMS ((bfd
*, struct bfd_link_info
*));
162 static boolean sh64_elf64_finish_dynamic_symbol
163 PARAMS ((bfd
*, struct bfd_link_info
*, struct elf_link_hash_entry
*,
164 Elf_Internal_Sym
*));
165 static boolean sh64_elf64_finish_dynamic_sections
166 PARAMS ((bfd
*, struct bfd_link_info
*));
168 static reloc_howto_type sh_elf64_howto_table
[] = {
170 HOWTO (R_SH_NONE
, /* type */
172 0, /* size (0 = byte, 1 = short, 2 = long) */
174 false, /* pc_relative */
176 complain_overflow_dont
, /* complain_on_overflow */
177 sh_elf64_ignore_reloc
, /* special_function */
178 "R_SH_NONE", /* name */
179 false, /* partial_inplace */
182 false), /* pcrel_offset */
184 /* 32 bit absolute relocation. Setting partial_inplace to true and
185 src_mask to a non-zero value is similar to the COFF toolchain. */
186 HOWTO (R_SH_DIR32
, /* type */
188 2, /* size (0 = byte, 1 = short, 2 = long) */
190 false, /* pc_relative */
192 complain_overflow_bitfield
, /* complain_on_overflow */
193 sh_elf64_reloc
, /* special_function */
194 "R_SH_DIR32", /* name */
195 true, /* partial_inplace */
196 0xffffffff, /* src_mask */
197 0xffffffff, /* dst_mask */
198 false), /* pcrel_offset */
200 /* 32 bit PC relative relocation. */
201 HOWTO (R_SH_REL32
, /* type */
203 2, /* size (0 = byte, 1 = short, 2 = long) */
205 true, /* pc_relative */
207 complain_overflow_signed
, /* complain_on_overflow */
208 sh_elf64_ignore_reloc
, /* special_function */
209 "R_SH_REL32", /* name */
210 false, /* partial_inplace */
212 0xffffffff, /* dst_mask */
213 true), /* pcrel_offset */
215 /* For 32-bit sh, this is R_SH_DIR8WPN. */
218 /* For 32-bit sh, this is R_SH_IND12W. */
221 /* For 32-bit sh, this is R_SH_DIR8WPL. */
224 /* For 32-bit sh, this is R_SH_DIR8WPZ. */
227 /* For 32-bit sh, this is R_SH_DIR8BP. */
230 /* For 32-bit sh, this is R_SH_DIR8W. */
233 /* For 32-bit sh, this is R_SH_DIR8L. */
252 /* The remaining relocs are a GNU extension used for relaxing. The
253 final pass of the linker never needs to do anything with any of
254 these relocs. Any required operations are handled by the
257 /* A 16 bit switch table entry. This is generated for an expression
258 such as ``.word L1 - L2''. The offset holds the difference
259 between the reloc address and L2. */
260 HOWTO (R_SH_SWITCH16
, /* type */
262 1, /* size (0 = byte, 1 = short, 2 = long) */
264 false, /* pc_relative */
266 complain_overflow_unsigned
, /* complain_on_overflow */
267 sh_elf64_ignore_reloc
, /* special_function */
268 "R_SH_SWITCH16", /* name */
269 false, /* partial_inplace */
272 true), /* pcrel_offset */
274 /* A 32 bit switch table entry. This is generated for an expression
275 such as ``.long L1 - L2''. The offset holds the difference
276 between the reloc address and L2. */
277 HOWTO (R_SH_SWITCH32
, /* type */
279 2, /* size (0 = byte, 1 = short, 2 = long) */
281 false, /* pc_relative */
283 complain_overflow_unsigned
, /* complain_on_overflow */
284 sh_elf64_ignore_reloc
, /* special_function */
285 "R_SH_SWITCH32", /* name */
286 false, /* partial_inplace */
289 true), /* pcrel_offset */
291 /* For 32-bit sh, this is R_SH_USES. */
294 /* For 32-bit sh, this is R_SH_COUNT. */
297 /* For 32-bit sh, this is R_SH_ALIGN. FIXME: For linker relaxation,
298 this might be emitted. When linker relaxation is implemented, we
299 might want to use it. */
302 /* For 32-bit sh, this is R_SH_CODE. FIXME: For linker relaxation,
303 this might be emitted. When linker relaxation is implemented, we
304 might want to use it. */
307 /* For 32-bit sh, this is R_SH_DATA. FIXME: For linker relaxation,
308 this might be emitted. When linker relaxation is implemented, we
309 might want to use it. */
312 /* For 32-bit sh, this is R_SH_LABEL. FIXME: For linker relaxation,
313 this might be emitted. When linker relaxation is implemented, we
314 might want to use it. */
317 /* An 8 bit switch table entry. This is generated for an expression
318 such as ``.word L1 - L2''. The offset holds the difference
319 between the reloc address and L2. */
320 HOWTO (R_SH_SWITCH8
, /* type */
322 0, /* size (0 = byte, 1 = short, 2 = long) */
324 false, /* pc_relative */
326 complain_overflow_unsigned
, /* complain_on_overflow */
327 sh_elf64_ignore_reloc
, /* special_function */
328 "R_SH_SWITCH8", /* name */
329 false, /* partial_inplace */
332 true), /* pcrel_offset */
334 /* GNU extension to record C++ vtable hierarchy */
335 HOWTO (R_SH_GNU_VTINHERIT
, /* type */
337 2, /* size (0 = byte, 1 = short, 2 = long) */
339 false, /* pc_relative */
341 complain_overflow_dont
, /* complain_on_overflow */
342 NULL
, /* special_function */
343 "R_SH_GNU_VTINHERIT", /* name */
344 false, /* partial_inplace */
347 false), /* pcrel_offset */
349 /* GNU extension to record C++ vtable member usage */
350 HOWTO (R_SH_GNU_VTENTRY
, /* type */
352 2, /* size (0 = byte, 1 = short, 2 = long) */
354 false, /* pc_relative */
356 complain_overflow_dont
, /* complain_on_overflow */
357 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
358 "R_SH_GNU_VTENTRY", /* name */
359 false, /* partial_inplace */
362 false), /* pcrel_offset */
364 /* For 32-bit sh, this is R_SH_LOOP_START. */
367 /* For 32-bit sh, this is R_SH_LOOP_END. */
378 /* Used in SHLLI.L and SHLRI.L. */
379 HOWTO (R_SH_DIR5U
, /* type */
381 2, /* size (0 = byte, 1 = short, 2 = long) */
383 false, /* pc_relative */
385 complain_overflow_unsigned
, /* complain_on_overflow */
386 bfd_elf_generic_reloc
, /* special_function */
387 "R_SH_DIR5U", /* name */
388 false, /* partial_inplace */
390 0xfc00, /* dst_mask */
391 false), /* pcrel_offset */
393 /* Used in SHARI, SHLLI et al. */
394 HOWTO (R_SH_DIR6U
, /* type */
396 2, /* size (0 = byte, 1 = short, 2 = long) */
398 false, /* pc_relative */
400 complain_overflow_unsigned
, /* complain_on_overflow */
401 bfd_elf_generic_reloc
, /* special_function */
402 "R_SH_DIR6U", /* name */
403 false, /* partial_inplace */
405 0xfc00, /* dst_mask */
406 false), /* pcrel_offset */
408 /* Used in BxxI, LDHI.L et al. */
409 HOWTO (R_SH_DIR6S
, /* type */
411 2, /* size (0 = byte, 1 = short, 2 = long) */
413 false, /* pc_relative */
415 complain_overflow_signed
, /* complain_on_overflow */
416 bfd_elf_generic_reloc
, /* special_function */
417 "R_SH_DIR6S", /* name */
418 false, /* partial_inplace */
420 0xfc00, /* dst_mask */
421 false), /* pcrel_offset */
423 /* Used in ADDI, ANDI et al. */
424 HOWTO (R_SH_DIR10S
, /* type */
426 2, /* size (0 = byte, 1 = short, 2 = long) */
428 false, /* pc_relative */
430 complain_overflow_signed
, /* complain_on_overflow */
431 bfd_elf_generic_reloc
, /* special_function */
432 "R_SH_DIR10S", /* name */
433 false, /* partial_inplace */
435 0xffc00, /* dst_mask */
436 false), /* pcrel_offset */
438 /* Used in LD.UW, ST.W et al. */
439 HOWTO (R_SH_DIR10SW
, /* type */
441 2, /* size (0 = byte, 1 = short, 2 = long) */
443 false, /* pc_relative */
445 complain_overflow_signed
, /* complain_on_overflow */
446 bfd_elf_generic_reloc
, /* special_function */
447 "R_SH_DIR10SW", /* name */
448 false, /* partial_inplace */
450 0xffc00, /* dst_mask */
451 false), /* pcrel_offset */
453 /* Used in LD.L, FLD.S et al. */
454 HOWTO (R_SH_DIR10SL
, /* type */
456 2, /* size (0 = byte, 1 = short, 2 = long) */
458 false, /* pc_relative */
460 complain_overflow_signed
, /* complain_on_overflow */
461 bfd_elf_generic_reloc
, /* special_function */
462 "R_SH_DIR10SL", /* name */
463 false, /* partial_inplace */
465 0xffc00, /* dst_mask */
466 false), /* pcrel_offset */
468 /* Used in FLD.D, FST.P et al. */
469 HOWTO (R_SH_DIR10SQ
, /* type */
471 2, /* size (0 = byte, 1 = short, 2 = long) */
473 false, /* pc_relative */
475 complain_overflow_signed
, /* complain_on_overflow */
476 bfd_elf_generic_reloc
, /* special_function */
477 "R_SH_DIR10SQ", /* name */
478 false, /* partial_inplace */
480 0xffc00, /* dst_mask */
481 false), /* pcrel_offset */
592 /* Relocs for dynamic linking for 32-bit SH would follow. We don't have
593 any dynamic linking support for 64-bit SH at present. */
605 /* Back to SH5 relocations. */
606 /* Used in MOVI and SHORI (x & 65536). */
607 HOWTO (R_SH_GOT_LOW16
, /* type */
609 2, /* size (0 = byte, 1 = short, 2 = long) */
611 false, /* pc_relative */
613 complain_overflow_dont
, /* complain_on_overflow */
614 bfd_elf_generic_reloc
, /* special_function */
615 "R_SH_GOT_LOW16", /* name */
616 false, /* partial_inplace */
618 0x3fffc00, /* dst_mask */
619 false), /* pcrel_offset */
621 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
622 HOWTO (R_SH_GOT_MEDLOW16
, /* type */
624 2, /* size (0 = byte, 1 = short, 2 = long) */
626 false, /* pc_relative */
628 complain_overflow_dont
, /* complain_on_overflow */
629 bfd_elf_generic_reloc
, /* special_function */
630 "R_SH_GOT_MEDLOW16", /* name */
631 false, /* partial_inplace */
633 0x3fffc00, /* dst_mask */
634 false), /* pcrel_offset */
636 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
637 HOWTO (R_SH_GOT_MEDHI16
, /* type */
639 2, /* size (0 = byte, 1 = short, 2 = long) */
641 false, /* pc_relative */
643 complain_overflow_dont
, /* complain_on_overflow */
644 bfd_elf_generic_reloc
, /* special_function */
645 "R_SH_GOT_MEDHI16", /* name */
646 false, /* partial_inplace */
648 0x3fffc00, /* dst_mask */
649 false), /* pcrel_offset */
651 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
652 HOWTO (R_SH_GOT_HI16
, /* type */
654 2, /* size (0 = byte, 1 = short, 2 = long) */
656 false, /* pc_relative */
658 complain_overflow_dont
, /* complain_on_overflow */
659 bfd_elf_generic_reloc
, /* special_function */
660 "R_SH_GOT_HI16", /* name */
661 false, /* partial_inplace */
663 0x3fffc00, /* dst_mask */
664 false), /* pcrel_offset */
666 /* Used in MOVI and SHORI (x & 65536). */
667 HOWTO (R_SH_GOTPLT_LOW16
, /* type */
669 2, /* size (0 = byte, 1 = short, 2 = long) */
671 false, /* pc_relative */
673 complain_overflow_dont
, /* complain_on_overflow */
674 bfd_elf_generic_reloc
, /* special_function */
675 "R_SH_GOTPLT_LOW16", /* name */
676 false, /* partial_inplace */
678 0x3fffc00, /* dst_mask */
679 false), /* pcrel_offset */
681 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
682 HOWTO (R_SH_GOTPLT_MEDLOW16
, /* type */
684 2, /* size (0 = byte, 1 = short, 2 = long) */
686 false, /* pc_relative */
688 complain_overflow_dont
, /* complain_on_overflow */
689 bfd_elf_generic_reloc
, /* special_function */
690 "R_SH_GOTPLT_MEDLOW16", /* name */
691 false, /* partial_inplace */
693 0x3fffc00, /* dst_mask */
694 false), /* pcrel_offset */
696 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
697 HOWTO (R_SH_GOTPLT_MEDHI16
, /* type */
699 2, /* size (0 = byte, 1 = short, 2 = long) */
701 false, /* pc_relative */
703 complain_overflow_dont
, /* complain_on_overflow */
704 bfd_elf_generic_reloc
, /* special_function */
705 "R_SH_GOTPLT_MEDHI16", /* name */
706 false, /* partial_inplace */
708 0x3fffc00, /* dst_mask */
709 false), /* pcrel_offset */
711 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
712 HOWTO (R_SH_GOTPLT_HI16
, /* type */
714 2, /* size (0 = byte, 1 = short, 2 = long) */
716 false, /* pc_relative */
718 complain_overflow_dont
, /* complain_on_overflow */
719 bfd_elf_generic_reloc
, /* special_function */
720 "R_SH_GOTPLT_HI16", /* name */
721 false, /* partial_inplace */
723 0x3fffc00, /* dst_mask */
724 false), /* pcrel_offset */
726 /* Used in MOVI and SHORI (x & 65536). */
727 HOWTO (R_SH_PLT_LOW16
, /* type */
729 2, /* size (0 = byte, 1 = short, 2 = long) */
731 true, /* pc_relative */
733 complain_overflow_dont
, /* complain_on_overflow */
734 bfd_elf_generic_reloc
, /* special_function */
735 "R_SH_PLT_LOW16", /* name */
736 false, /* partial_inplace */
738 0x3fffc00, /* dst_mask */
739 true), /* pcrel_offset */
741 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
742 HOWTO (R_SH_PLT_MEDLOW16
, /* type */
744 2, /* size (0 = byte, 1 = short, 2 = long) */
746 true, /* pc_relative */
748 complain_overflow_dont
, /* complain_on_overflow */
749 bfd_elf_generic_reloc
, /* special_function */
750 "R_SH_PLT_MEDLOW16", /* name */
751 false, /* partial_inplace */
753 0x3fffc00, /* dst_mask */
754 true), /* pcrel_offset */
756 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
757 HOWTO (R_SH_PLT_MEDHI16
, /* type */
759 2, /* size (0 = byte, 1 = short, 2 = long) */
761 true, /* pc_relative */
763 complain_overflow_dont
, /* complain_on_overflow */
764 bfd_elf_generic_reloc
, /* special_function */
765 "R_SH_PLT_MEDHI16", /* name */
766 false, /* partial_inplace */
768 0x3fffc00, /* dst_mask */
769 true), /* pcrel_offset */
771 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
772 HOWTO (R_SH_PLT_HI16
, /* type */
774 2, /* size (0 = byte, 1 = short, 2 = long) */
776 true, /* pc_relative */
778 complain_overflow_dont
, /* complain_on_overflow */
779 bfd_elf_generic_reloc
, /* special_function */
780 "R_SH_PLT_HI16", /* name */
781 false, /* partial_inplace */
783 0x3fffc00, /* dst_mask */
784 true), /* pcrel_offset */
786 /* Used in MOVI and SHORI (x & 65536). */
787 HOWTO (R_SH_GOTOFF_LOW16
, /* type */
789 2, /* size (0 = byte, 1 = short, 2 = long) */
791 false, /* pc_relative */
793 complain_overflow_dont
, /* complain_on_overflow */
794 bfd_elf_generic_reloc
, /* special_function */
795 "R_SH_GOTOFF_LOW16", /* name */
796 false, /* partial_inplace */
798 0x3fffc00, /* dst_mask */
799 false), /* pcrel_offset */
801 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
802 HOWTO (R_SH_GOTOFF_MEDLOW16
, /* type */
804 2, /* size (0 = byte, 1 = short, 2 = long) */
806 false, /* pc_relative */
808 complain_overflow_dont
, /* complain_on_overflow */
809 bfd_elf_generic_reloc
, /* special_function */
810 "R_SH_GOTOFF_MEDLOW16", /* name */
811 false, /* partial_inplace */
813 0x3fffc00, /* dst_mask */
814 false), /* pcrel_offset */
816 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
817 HOWTO (R_SH_GOTOFF_MEDHI16
, /* type */
819 2, /* size (0 = byte, 1 = short, 2 = long) */
821 false, /* pc_relative */
823 complain_overflow_dont
, /* complain_on_overflow */
824 bfd_elf_generic_reloc
, /* special_function */
825 "R_SH_GOTOFF_MEDHI16", /* name */
826 false, /* partial_inplace */
828 0x3fffc00, /* dst_mask */
829 false), /* pcrel_offset */
831 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
832 HOWTO (R_SH_GOTOFF_HI16
, /* type */
834 2, /* size (0 = byte, 1 = short, 2 = long) */
836 false, /* pc_relative */
838 complain_overflow_dont
, /* complain_on_overflow */
839 bfd_elf_generic_reloc
, /* special_function */
840 "R_SH_GOTOFF_HI16", /* name */
841 false, /* partial_inplace */
843 0x3fffc00, /* dst_mask */
844 false), /* pcrel_offset */
846 /* Used in MOVI and SHORI (x & 65536). */
847 HOWTO (R_SH_GOTPC_LOW16
, /* type */
849 2, /* size (0 = byte, 1 = short, 2 = long) */
851 true, /* pc_relative */
853 complain_overflow_dont
, /* complain_on_overflow */
854 bfd_elf_generic_reloc
, /* special_function */
855 "R_SH_GOTPC_LOW16", /* name */
856 false, /* partial_inplace */
858 0x3fffc00, /* dst_mask */
859 true), /* pcrel_offset */
861 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
862 HOWTO (R_SH_GOTPC_MEDLOW16
, /* type */
864 2, /* size (0 = byte, 1 = short, 2 = long) */
866 true, /* pc_relative */
868 complain_overflow_dont
, /* complain_on_overflow */
869 bfd_elf_generic_reloc
, /* special_function */
870 "R_SH_GOTPC_MEDLOW16", /* name */
871 false, /* partial_inplace */
873 0x3fffc00, /* dst_mask */
874 true), /* pcrel_offset */
876 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
877 HOWTO (R_SH_GOTPC_MEDHI16
, /* type */
879 2, /* size (0 = byte, 1 = short, 2 = long) */
881 true, /* pc_relative */
883 complain_overflow_dont
, /* complain_on_overflow */
884 bfd_elf_generic_reloc
, /* special_function */
885 "R_SH_GOTPC_MEDHI16", /* name */
886 false, /* partial_inplace */
888 0x3fffc00, /* dst_mask */
889 true), /* pcrel_offset */
891 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
892 HOWTO (R_SH_GOTPC_HI16
, /* type */
894 2, /* size (0 = byte, 1 = short, 2 = long) */
896 true, /* pc_relative */
898 complain_overflow_dont
, /* complain_on_overflow */
899 bfd_elf_generic_reloc
, /* special_function */
900 "R_SH_GOTPC_HI16", /* name */
901 false, /* partial_inplace */
903 0x3fffc00, /* dst_mask */
904 true), /* pcrel_offset */
906 /* Used in LD.L, FLD.S et al. */
907 HOWTO (R_SH_GOT10BY4
, /* type */
909 2, /* size (0 = byte, 1 = short, 2 = long) */
911 false, /* pc_relative */
913 complain_overflow_signed
, /* complain_on_overflow */
914 bfd_elf_generic_reloc
, /* special_function */
915 "R_SH_GOT10BY4", /* name */
916 false, /* partial_inplace */
918 0xffc00, /* dst_mask */
919 false), /* pcrel_offset */
921 /* Used in LD.L, FLD.S et al. */
922 HOWTO (R_SH_GOTPLT10BY4
, /* type */
924 2, /* size (0 = byte, 1 = short, 2 = long) */
926 false, /* pc_relative */
928 complain_overflow_signed
, /* complain_on_overflow */
929 bfd_elf_generic_reloc
, /* special_function */
930 "R_SH_GOTPLT10BY4", /* name */
931 false, /* partial_inplace */
933 0xffc00, /* dst_mask */
934 false), /* pcrel_offset */
936 /* Used in FLD.D, FST.P et al. */
937 HOWTO (R_SH_GOT10BY8
, /* type */
939 2, /* size (0 = byte, 1 = short, 2 = long) */
941 false, /* pc_relative */
943 complain_overflow_signed
, /* complain_on_overflow */
944 bfd_elf_generic_reloc
, /* special_function */
945 "R_SH_GOT10BY8", /* name */
946 false, /* partial_inplace */
948 0xffc00, /* dst_mask */
949 false), /* pcrel_offset */
951 /* Used in FLD.D, FST.P et al. */
952 HOWTO (R_SH_GOTPLT10BY8
, /* type */
954 2, /* size (0 = byte, 1 = short, 2 = long) */
956 false, /* pc_relative */
958 complain_overflow_signed
, /* complain_on_overflow */
959 bfd_elf_generic_reloc
, /* special_function */
960 "R_SH_GOTPLT10BY8", /* name */
961 false, /* partial_inplace */
963 0xffc00, /* dst_mask */
964 false), /* pcrel_offset */
966 HOWTO (R_SH_COPY64
, /* type */
968 4, /* size (0 = byte, 1 = short, 2 = long) */
970 false, /* pc_relative */
972 complain_overflow_dont
, /* complain_on_overflow */
973 bfd_elf_generic_reloc
, /* special_function */
974 "R_SH_COPY64", /* name */
975 false, /* partial_inplace */
977 ((bfd_vma
) 0) - 1, /* dst_mask */
978 false), /* pcrel_offset */
980 HOWTO (R_SH_GLOB_DAT64
, /* type */
982 4, /* size (0 = byte, 1 = short, 2 = long) */
984 false, /* pc_relative */
986 complain_overflow_dont
, /* complain_on_overflow */
987 bfd_elf_generic_reloc
, /* special_function */
988 "R_SH_GLOB_DAT64", /* name */
989 false, /* partial_inplace */
991 ((bfd_vma
) 0) - 1, /* dst_mask */
992 false), /* pcrel_offset */
994 HOWTO (R_SH_JMP_SLOT64
, /* type */
996 4, /* size (0 = byte, 1 = short, 2 = long) */
998 false, /* pc_relative */
1000 complain_overflow_dont
, /* complain_on_overflow */
1001 bfd_elf_generic_reloc
, /* special_function */
1002 "R_SH_JMP_SLOT64", /* name */
1003 false, /* partial_inplace */
1005 ((bfd_vma
) 0) - 1, /* dst_mask */
1006 false), /* pcrel_offset */
1008 HOWTO (R_SH_RELATIVE64
, /* type */
1010 4, /* size (0 = byte, 1 = short, 2 = long) */
1012 false, /* pc_relative */
1014 complain_overflow_dont
, /* complain_on_overflow */
1015 bfd_elf_generic_reloc
, /* special_function */
1016 "R_SH_RELATIVE64", /* name */
1017 false, /* partial_inplace */
1019 ((bfd_vma
) 0) - 1, /* dst_mask */
1020 false), /* pcrel_offset */
1068 /* Relocations for SHmedia code. None of these are partial_inplace or
1069 use the field being relocated. */
1071 /* The assembler will generate this reloc before a block of SHmedia
1072 instructions. A section should be processed as assuming it contains
1073 data, unless this reloc is seen. Note that a block of SHcompact
1074 instructions are instead preceded by R_SH_CODE.
1075 This is currently not implemented, but should be used for SHmedia
1076 linker relaxation. */
1077 HOWTO (R_SH_SHMEDIA_CODE
, /* type */
1079 1, /* size (0 = byte, 1 = short, 2 = long) */
1081 false, /* pc_relative */
1083 complain_overflow_unsigned
, /* complain_on_overflow */
1084 sh_elf64_ignore_reloc
, /* special_function */
1085 "R_SH_SHMEDIA_CODE", /* name */
1086 false, /* partial_inplace */
1089 false), /* pcrel_offset */
1091 /* The assembler will generate this reloc at a PTA or PTB instruction,
1092 and the linker checks the right type of target, or changes a PTA to a
1093 PTB, if the original insn was PT. */
1094 HOWTO (R_SH_PT_16
, /* type */
1096 2, /* size (0 = byte, 1 = short, 2 = long) */
1098 true, /* pc_relative */
1100 complain_overflow_signed
, /* complain_on_overflow */
1101 bfd_elf_generic_reloc
, /* special_function */
1102 "R_SH_PT_16", /* name */
1103 false, /* partial_inplace */
1105 0x3fffc00, /* dst_mask */
1106 true), /* pcrel_offset */
1108 /* Used in unexpanded MOVI. */
1109 HOWTO (R_SH_IMMS16
, /* type */
1111 2, /* size (0 = byte, 1 = short, 2 = long) */
1113 false, /* pc_relative */
1115 complain_overflow_signed
, /* complain_on_overflow */
1116 bfd_elf_generic_reloc
, /* special_function */
1117 "R_SH_IMMS16", /* name */
1118 false, /* partial_inplace */
1120 0x3fffc00, /* dst_mask */
1121 false), /* pcrel_offset */
1123 /* Used in SHORI. */
1124 HOWTO (R_SH_IMMU16
, /* type */
1126 2, /* size (0 = byte, 1 = short, 2 = long) */
1128 false, /* pc_relative */
1130 complain_overflow_unsigned
, /* complain_on_overflow */
1131 bfd_elf_generic_reloc
, /* special_function */
1132 "R_SH_IMMU16", /* name */
1133 false, /* partial_inplace */
1135 0x3fffc00, /* dst_mask */
1136 false), /* pcrel_offset */
1138 /* Used in MOVI and SHORI (x & 65536). */
1139 HOWTO (R_SH_IMM_LOW16
, /* type */
1141 2, /* size (0 = byte, 1 = short, 2 = long) */
1143 false, /* pc_relative */
1145 complain_overflow_dont
, /* complain_on_overflow */
1146 bfd_elf_generic_reloc
, /* special_function */
1147 "R_SH_IMM_LOW16", /* name */
1148 false, /* partial_inplace */
1150 0x3fffc00, /* dst_mask */
1151 false), /* pcrel_offset */
1153 /* Used in MOVI and SHORI ((x - $) & 65536). */
1154 HOWTO (R_SH_IMM_LOW16_PCREL
, /* type */
1156 2, /* size (0 = byte, 1 = short, 2 = long) */
1158 true, /* pc_relative */
1160 complain_overflow_dont
, /* complain_on_overflow */
1161 bfd_elf_generic_reloc
, /* special_function */
1162 "R_SH_IMM_LOW16_PCREL", /* name */
1163 false, /* partial_inplace */
1165 0x3fffc00, /* dst_mask */
1166 true), /* pcrel_offset */
1168 /* Used in MOVI and SHORI ((x >> 16) & 65536). */
1169 HOWTO (R_SH_IMM_MEDLOW16
, /* type */
1170 16, /* rightshift */
1171 2, /* size (0 = byte, 1 = short, 2 = long) */
1173 false, /* pc_relative */
1175 complain_overflow_dont
, /* complain_on_overflow */
1176 bfd_elf_generic_reloc
, /* special_function */
1177 "R_SH_IMM_MEDLOW16", /* name */
1178 false, /* partial_inplace */
1180 0x3fffc00, /* dst_mask */
1181 false), /* pcrel_offset */
1183 /* Used in MOVI and SHORI (((x - $) >> 16) & 65536). */
1184 HOWTO (R_SH_IMM_MEDLOW16_PCREL
, /* type */
1185 16, /* rightshift */
1186 2, /* size (0 = byte, 1 = short, 2 = long) */
1188 true, /* pc_relative */
1190 complain_overflow_dont
, /* complain_on_overflow */
1191 bfd_elf_generic_reloc
, /* special_function */
1192 "R_SH_IMM_MEDLOW16_PCREL", /* name */
1193 false, /* partial_inplace */
1195 0x3fffc00, /* dst_mask */
1196 true), /* pcrel_offset */
1198 /* Used in MOVI and SHORI ((x >> 32) & 65536). */
1199 HOWTO (R_SH_IMM_MEDHI16
, /* type */
1200 32, /* rightshift */
1201 2, /* size (0 = byte, 1 = short, 2 = long) */
1203 false, /* pc_relative */
1205 complain_overflow_dont
, /* complain_on_overflow */
1206 bfd_elf_generic_reloc
, /* special_function */
1207 "R_SH_IMM_MEDHI16", /* name */
1208 false, /* partial_inplace */
1210 0x3fffc00, /* dst_mask */
1211 false), /* pcrel_offset */
1213 /* Used in MOVI and SHORI (((x - $) >> 32) & 65536). */
1214 HOWTO (R_SH_IMM_MEDHI16_PCREL
, /* type */
1215 32, /* rightshift */
1216 2, /* size (0 = byte, 1 = short, 2 = long) */
1218 true, /* pc_relative */
1220 complain_overflow_dont
, /* complain_on_overflow */
1221 bfd_elf_generic_reloc
, /* special_function */
1222 "R_SH_IMM_MEDHI16_PCREL", /* name */
1223 false, /* partial_inplace */
1225 0x3fffc00, /* dst_mask */
1226 true), /* pcrel_offset */
1228 /* Used in MOVI and SHORI ((x >> 48) & 65536). */
1229 HOWTO (R_SH_IMM_HI16
, /* type */
1230 48, /* rightshift */
1231 2, /* size (0 = byte, 1 = short, 2 = long) */
1233 false, /* pc_relative */
1235 complain_overflow_dont
, /* complain_on_overflow */
1236 bfd_elf_generic_reloc
, /* special_function */
1237 "R_SH_IMM_HI16", /* name */
1238 false, /* partial_inplace */
1240 0x3fffc00, /* dst_mask */
1241 false), /* pcrel_offset */
1243 /* Used in MOVI and SHORI (((x - $) >> 48) & 65536). */
1244 HOWTO (R_SH_IMM_HI16_PCREL
, /* type */
1245 48, /* rightshift */
1246 2, /* size (0 = byte, 1 = short, 2 = long) */
1248 true, /* pc_relative */
1250 complain_overflow_dont
, /* complain_on_overflow */
1251 bfd_elf_generic_reloc
, /* special_function */
1252 "R_SH_IMM_HI16_PCREL", /* name */
1253 false, /* partial_inplace */
1255 0x3fffc00, /* dst_mask */
1256 true), /* pcrel_offset */
1258 /* For the .uaquad pseudo. */
1259 HOWTO (R_SH_64
, /* type */
1261 4, /* size (0 = byte, 1 = short, 2 = long) */
1263 false, /* pc_relative */
1265 complain_overflow_dont
, /* complain_on_overflow */
1266 bfd_elf_generic_reloc
, /* special_function */
1267 "R_SH_64", /* name */
1268 false, /* partial_inplace */
1270 ((bfd_vma
) 0) - 1, /* dst_mask */
1271 false), /* pcrel_offset */
1273 /* For the .uaquad pseudo, (x - $). */
1274 HOWTO (R_SH_64_PCREL
, /* type */
1275 48, /* rightshift */
1276 2, /* size (0 = byte, 1 = short, 2 = long) */
1278 true, /* pc_relative */
1280 complain_overflow_dont
, /* complain_on_overflow */
1281 bfd_elf_generic_reloc
, /* special_function */
1282 "R_SH_64_PCREL", /* name */
1283 false, /* partial_inplace */
1285 ((bfd_vma
) 0) - 1, /* dst_mask */
1286 true), /* pcrel_offset */
1290 /* This function is used for relocs which are only used for relaxing,
1291 which the linker should otherwise ignore. */
1293 static bfd_reloc_status_type
1294 sh_elf64_ignore_reloc (abfd
, reloc_entry
, symbol
, data
, input_section
,
1295 output_bfd
, error_message
)
1296 bfd
*abfd ATTRIBUTE_UNUSED
;
1297 arelent
*reloc_entry
;
1298 asymbol
*symbol ATTRIBUTE_UNUSED
;
1299 PTR data ATTRIBUTE_UNUSED
;
1300 asection
*input_section
;
1302 char **error_message ATTRIBUTE_UNUSED
;
1304 if (output_bfd
!= NULL
)
1305 reloc_entry
->address
+= input_section
->output_offset
;
1306 return bfd_reloc_ok
;
1309 /* This function is used for normal relocs. This used to be like the COFF
1310 function, and is almost certainly incorrect for other ELF targets.
1312 See sh_elf_reloc in elf32-sh.c for the original. */
1314 static bfd_reloc_status_type
1315 sh_elf64_reloc (abfd
, reloc_entry
, symbol_in
, data
, input_section
, output_bfd
,
1318 arelent
*reloc_entry
;
1321 asection
*input_section
;
1323 char **error_message ATTRIBUTE_UNUSED
;
1327 enum elf_sh_reloc_type r_type
;
1328 bfd_vma addr
= reloc_entry
->address
;
1329 bfd_byte
*hit_data
= addr
+ (bfd_byte
*) data
;
1331 r_type
= (enum elf_sh_reloc_type
) reloc_entry
->howto
->type
;
1333 if (output_bfd
!= NULL
)
1335 /* Partial linking--do nothing. */
1336 reloc_entry
->address
+= input_section
->output_offset
;
1337 return bfd_reloc_ok
;
1340 if (symbol_in
!= NULL
1341 && bfd_is_und_section (symbol_in
->section
))
1342 return bfd_reloc_undefined
;
1344 if (bfd_is_com_section (symbol_in
->section
))
1347 sym_value
= (symbol_in
->value
+
1348 symbol_in
->section
->output_section
->vma
+
1349 symbol_in
->section
->output_offset
);
1354 insn
= bfd_get_32 (abfd
, hit_data
);
1355 insn
+= sym_value
+ reloc_entry
->addend
;
1356 bfd_put_32 (abfd
, insn
, hit_data
);
1364 return bfd_reloc_ok
;
1367 /* This structure is used to map BFD reloc codes to SH ELF relocs. */
1369 struct elf_reloc_map
1371 bfd_reloc_code_real_type bfd_reloc_val
;
1372 unsigned char elf_reloc_val
;
1375 /* An array mapping BFD reloc codes to SH ELF relocs. */
1377 static const struct elf_reloc_map sh64_reloc_map
[] =
1379 { BFD_RELOC_NONE
, R_SH_NONE
},
1380 { BFD_RELOC_32
, R_SH_DIR32
},
1381 { BFD_RELOC_CTOR
, R_SH_DIR32
},
1382 { BFD_RELOC_32_PCREL
, R_SH_REL32
},
1383 { BFD_RELOC_8_PCREL
, R_SH_SWITCH8
},
1384 { BFD_RELOC_SH_SWITCH16
, R_SH_SWITCH16
},
1385 { BFD_RELOC_SH_SWITCH32
, R_SH_SWITCH32
},
1386 { BFD_RELOC_VTABLE_INHERIT
, R_SH_GNU_VTINHERIT
},
1387 { BFD_RELOC_VTABLE_ENTRY
, R_SH_GNU_VTENTRY
},
1388 { BFD_RELOC_SH_GOT_LOW16
, R_SH_GOT_LOW16
},
1389 { BFD_RELOC_SH_GOT_MEDLOW16
, R_SH_GOT_MEDLOW16
},
1390 { BFD_RELOC_SH_GOT_MEDHI16
, R_SH_GOT_MEDHI16
},
1391 { BFD_RELOC_SH_GOT_HI16
, R_SH_GOT_HI16
},
1392 { BFD_RELOC_SH_GOTPLT_LOW16
, R_SH_GOTPLT_LOW16
},
1393 { BFD_RELOC_SH_GOTPLT_MEDLOW16
, R_SH_GOTPLT_MEDLOW16
},
1394 { BFD_RELOC_SH_GOTPLT_MEDHI16
, R_SH_GOTPLT_MEDHI16
},
1395 { BFD_RELOC_SH_GOTPLT_HI16
, R_SH_GOTPLT_HI16
},
1396 { BFD_RELOC_SH_PLT_LOW16
, R_SH_PLT_LOW16
},
1397 { BFD_RELOC_SH_PLT_MEDLOW16
, R_SH_PLT_MEDLOW16
},
1398 { BFD_RELOC_SH_PLT_MEDHI16
, R_SH_PLT_MEDHI16
},
1399 { BFD_RELOC_SH_PLT_HI16
, R_SH_PLT_HI16
},
1400 { BFD_RELOC_SH_GOTOFF_LOW16
, R_SH_GOTOFF_LOW16
},
1401 { BFD_RELOC_SH_GOTOFF_MEDLOW16
, R_SH_GOTOFF_MEDLOW16
},
1402 { BFD_RELOC_SH_GOTOFF_MEDHI16
, R_SH_GOTOFF_MEDHI16
},
1403 { BFD_RELOC_SH_GOTOFF_HI16
, R_SH_GOTOFF_HI16
},
1404 { BFD_RELOC_SH_GOTPC_LOW16
, R_SH_GOTPC_LOW16
},
1405 { BFD_RELOC_SH_GOTPC_MEDLOW16
, R_SH_GOTPC_MEDLOW16
},
1406 { BFD_RELOC_SH_GOTPC_MEDHI16
, R_SH_GOTPC_MEDHI16
},
1407 { BFD_RELOC_SH_GOTPC_HI16
, R_SH_GOTPC_HI16
},
1408 { BFD_RELOC_SH_COPY64
, R_SH_COPY64
},
1409 { BFD_RELOC_SH_GLOB_DAT64
, R_SH_GLOB_DAT64
},
1410 { BFD_RELOC_SH_JMP_SLOT64
, R_SH_JMP_SLOT64
},
1411 { BFD_RELOC_SH_RELATIVE64
, R_SH_RELATIVE64
},
1412 { BFD_RELOC_SH_GOT10BY4
, R_SH_GOT10BY4
},
1413 { BFD_RELOC_SH_GOT10BY8
, R_SH_GOT10BY8
},
1414 { BFD_RELOC_SH_GOTPLT10BY4
, R_SH_GOTPLT10BY4
},
1415 { BFD_RELOC_SH_GOTPLT10BY8
, R_SH_GOTPLT10BY8
},
1416 { BFD_RELOC_SH_PT_16
, R_SH_PT_16
},
1417 { BFD_RELOC_SH_SHMEDIA_CODE
, R_SH_SHMEDIA_CODE
},
1418 { BFD_RELOC_SH_IMMU5
, R_SH_DIR5U
},
1419 { BFD_RELOC_SH_IMMS6
, R_SH_DIR6S
},
1420 { BFD_RELOC_SH_IMMU6
, R_SH_DIR6U
},
1421 { BFD_RELOC_SH_IMMS10
, R_SH_DIR10S
},
1422 { BFD_RELOC_SH_IMMS10BY2
, R_SH_DIR10SW
},
1423 { BFD_RELOC_SH_IMMS10BY4
, R_SH_DIR10SL
},
1424 { BFD_RELOC_SH_IMMS10BY8
, R_SH_DIR10SQ
},
1425 { BFD_RELOC_SH_IMMS16
, R_SH_IMMS16
},
1426 { BFD_RELOC_SH_IMMU16
, R_SH_IMMU16
},
1427 { BFD_RELOC_SH_IMM_LOW16
, R_SH_IMM_LOW16
},
1428 { BFD_RELOC_SH_IMM_LOW16_PCREL
, R_SH_IMM_LOW16_PCREL
},
1429 { BFD_RELOC_SH_IMM_MEDLOW16
, R_SH_IMM_MEDLOW16
},
1430 { BFD_RELOC_SH_IMM_MEDLOW16_PCREL
, R_SH_IMM_MEDLOW16_PCREL
},
1431 { BFD_RELOC_SH_IMM_MEDHI16
, R_SH_IMM_MEDHI16
},
1432 { BFD_RELOC_SH_IMM_MEDHI16_PCREL
, R_SH_IMM_MEDHI16_PCREL
},
1433 { BFD_RELOC_SH_IMM_HI16
, R_SH_IMM_HI16
},
1434 { BFD_RELOC_SH_IMM_HI16_PCREL
, R_SH_IMM_HI16_PCREL
},
1435 { BFD_RELOC_64
, R_SH_64
},
1436 { BFD_RELOC_64_PCREL
, R_SH_64_PCREL
},
1439 /* Given a BFD reloc code, return the howto structure for the
1440 corresponding SH ELf reloc. */
1442 static reloc_howto_type
*
1443 sh_elf64_reloc_type_lookup (abfd
, code
)
1444 bfd
*abfd ATTRIBUTE_UNUSED
;
1445 bfd_reloc_code_real_type code
;
1449 for (i
= 0; i
< sizeof (sh64_reloc_map
) / sizeof (struct elf_reloc_map
); i
++)
1451 if (sh64_reloc_map
[i
].bfd_reloc_val
== code
)
1452 return &sh_elf64_howto_table
[(int) sh64_reloc_map
[i
].elf_reloc_val
];
1458 /* Given an ELF reloc, fill in the howto field of a relent.
1460 See sh_elf_info_to_howto in elf32-sh.c for the original. */
1463 sh_elf64_info_to_howto (abfd
, cache_ptr
, dst
)
1464 bfd
*abfd ATTRIBUTE_UNUSED
;
1466 Elf_Internal_Rela
*dst
;
1470 r
= ELF64_R_TYPE (dst
->r_info
);
1472 BFD_ASSERT (r
<= (unsigned int) R_SH_64_PCREL
);
1473 BFD_ASSERT (r
< R_SH_FIRST_INVALID_RELOC
|| r
> R_SH_LAST_INVALID_RELOC
);
1474 BFD_ASSERT (r
< R_SH_DIR8WPN
|| r
> R_SH_LAST_INVALID_RELOC_2
);
1475 BFD_ASSERT (r
< R_SH_FIRST_INVALID_RELOC_3
|| r
> R_SH_GOTPLT32
);
1476 BFD_ASSERT (r
< R_SH_FIRST_INVALID_RELOC_4
|| r
> R_SH_LAST_INVALID_RELOC_4
);
1478 cache_ptr
->howto
= &sh_elf64_howto_table
[r
];
1481 /* Relocate an SH ELF section.
1483 See sh_elf_info_to_howto in elf32-sh.c for the original. */
1486 sh_elf64_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
1487 contents
, relocs
, local_syms
, local_sections
)
1488 bfd
*output_bfd ATTRIBUTE_UNUSED
;
1489 struct bfd_link_info
*info
;
1491 asection
*input_section
;
1493 Elf_Internal_Rela
*relocs
;
1494 Elf_Internal_Sym
*local_syms
;
1495 asection
**local_sections
;
1497 Elf_Internal_Shdr
*symtab_hdr
;
1498 struct elf_link_hash_entry
**sym_hashes
;
1499 Elf_Internal_Rela
*rel
, *relend
;
1501 bfd_vma
*local_got_offsets
;
1506 bfd_vma disp
, dropped
;
1508 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
1509 sym_hashes
= elf_sym_hashes (input_bfd
);
1510 dynobj
= elf_hash_table (info
)->dynobj
;
1511 local_got_offsets
= elf_local_got_offsets (input_bfd
);
1519 relend
= relocs
+ input_section
->reloc_count
;
1520 for (; rel
< relend
; rel
++)
1523 reloc_howto_type
*howto
;
1524 unsigned long r_symndx
;
1525 Elf_Internal_Sym
*sym
;
1527 struct elf_link_hash_entry
*h
;
1529 bfd_vma addend
= (bfd_vma
)0;
1530 bfd_reloc_status_type r
;
1531 int seen_stt_datalabel
= 0;
1533 r_symndx
= ELF64_R_SYM (rel
->r_info
);
1535 r_type
= ELF64_R_TYPE (rel
->r_info
);
1537 if (r_type
== (int) R_SH_NONE
)
1541 || r_type
> R_SH_64_PCREL
1542 || (r_type
>= (int) R_SH_FIRST_INVALID_RELOC
1543 && r_type
<= (int) R_SH_LAST_INVALID_RELOC
)
1544 || (r_type
>= (int) R_SH_DIR8WPN
1545 && r_type
<= (int) R_SH_LAST_INVALID_RELOC_2
)
1546 || (r_type
>= (int) R_SH_FIRST_INVALID_RELOC_3
1547 && r_type
<= R_SH_GOTPLT32
)
1548 || (r_type
>= (int) R_SH_FIRST_INVALID_RELOC_4
1549 && r_type
<= (int) R_SH_LAST_INVALID_RELOC_4
))
1551 bfd_set_error (bfd_error_bad_value
);
1555 howto
= sh_elf64_howto_table
+ r_type
;
1557 /* This is a final link. */
1561 if (r_symndx
< symtab_hdr
->sh_info
)
1563 sym
= local_syms
+ r_symndx
;
1564 sec
= local_sections
[r_symndx
];
1565 relocation
= ((sec
->output_section
->vma
1566 + sec
->output_offset
1568 | ((sym
->st_other
& STO_SH5_ISA32
) != 0));
1570 /* A local symbol never has STO_SH5_ISA32, so we don't need
1571 datalabel processing here. Make sure this does not change
1573 if ((sym
->st_other
& STO_SH5_ISA32
) != 0)
1574 ((*info
->callbacks
->reloc_dangerous
)
1576 _("Unexpected STO_SH5_ISA32 on local symbol is not handled"),
1577 input_bfd
, input_section
, rel
->r_offset
));
1579 if (info
->relocateable
)
1581 /* This is a relocateable link. We don't have to change
1582 anything, unless the reloc is against a section symbol,
1583 in which case we have to adjust according to where the
1584 section symbol winds up in the output section. */
1585 sym
= local_syms
+ r_symndx
;
1586 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1587 goto final_link_relocate
;
1591 else if (! howto
->partial_inplace
)
1593 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, sec
, rel
);
1594 relocation
|= ((sym
->st_other
& STO_SH5_ISA32
) != 0);
1596 else if ((sec
->flags
& SEC_MERGE
)
1597 && ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1601 if (howto
->rightshift
|| howto
->src_mask
!= 0xffffffff)
1603 (*_bfd_error_handler
)
1604 (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
1605 bfd_archive_filename (input_bfd
),
1606 bfd_get_section_name (input_bfd
, input_section
),
1607 (long) rel
->r_offset
, howto
->name
);
1611 addend
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
1614 _bfd_elf_rel_local_sym (output_bfd
, sym
, &msec
, addend
)
1616 addend
+= msec
->output_section
->vma
+ msec
->output_offset
;
1617 bfd_put_32 (input_bfd
, addend
, contents
+ rel
->r_offset
);
1623 /* Section symbols are never (?) placed in the hash table, so
1624 we can just ignore hash relocations when creating a
1625 relocateable object file. */
1626 if (info
->relocateable
)
1629 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1630 while (h
->root
.type
== bfd_link_hash_indirect
1631 || h
->root
.type
== bfd_link_hash_warning
)
1633 /* If the reference passes a symbol marked with
1634 STT_DATALABEL, then any STO_SH5_ISA32 on the final value
1636 seen_stt_datalabel
|= h
->type
== STT_DATALABEL
;
1637 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1640 if (h
->root
.type
== bfd_link_hash_defined
1641 || h
->root
.type
== bfd_link_hash_defweak
)
1643 sec
= h
->root
.u
.def
.section
;
1644 /* In these cases, we don't need the relocation value.
1645 We check specially because in some obscure cases
1646 sec->output_section will be NULL. */
1647 if (r_type
== R_SH_GOTPC_LOW16
1648 || r_type
== R_SH_GOTPC_MEDLOW16
1649 || r_type
== R_SH_GOTPC_MEDHI16
1650 || r_type
== R_SH_GOTPC_HI16
1651 || ((r_type
== R_SH_PLT_LOW16
1652 || r_type
== R_SH_PLT_MEDLOW16
1653 || r_type
== R_SH_PLT_MEDHI16
1654 || r_type
== R_SH_PLT_HI16
)
1655 && h
->plt
.offset
!= (bfd_vma
) -1)
1656 || ((r_type
== R_SH_GOT_LOW16
1657 || r_type
== R_SH_GOT_MEDLOW16
1658 || r_type
== R_SH_GOT_MEDHI16
1659 || r_type
== R_SH_GOT_HI16
)
1660 && elf_hash_table (info
)->dynamic_sections_created
1662 || (! info
->symbolic
&& h
->dynindx
!= -1)
1663 || (h
->elf_link_hash_flags
1664 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
1665 /* The cases above are those in which relocation is
1666 overwritten in the switch block below. The cases
1667 below are those in which we must defer relocation
1668 to run-time, because we can't resolve absolute
1669 addresses when creating a shared library. */
1671 && ((! info
->symbolic
&& h
->dynindx
!= -1)
1672 || (h
->elf_link_hash_flags
1673 & ELF_LINK_HASH_DEF_REGULAR
) == 0)
1674 && ((r_type
== R_SH_64
1675 && !(ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
1676 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
))
1677 || r_type
== R_SH_64_PCREL
)
1678 && ((input_section
->flags
& SEC_ALLOC
) != 0
1679 /* DWARF will emit R_SH_DIR32 relocations in its
1680 sections against symbols defined externally
1681 in shared libraries. We can't do anything
1683 || (input_section
->flags
& SEC_DEBUGGING
) != 0))
1684 /* Dynamic relocs are not propagated for SEC_DEBUGGING
1685 sections because such sections are not SEC_ALLOC and
1686 thus ld.so will not process them. */
1687 || (sec
->output_section
== NULL
1688 && ((input_section
->flags
& SEC_DEBUGGING
) != 0
1689 && (h
->elf_link_hash_flags
1690 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0)))
1692 else if (sec
->output_section
== NULL
)
1694 (*_bfd_error_handler
)
1695 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1696 bfd_get_filename (input_bfd
), h
->root
.root
.string
,
1697 bfd_get_section_name (input_bfd
, input_section
));
1701 relocation
= ((h
->root
.u
.def
.value
1702 + sec
->output_section
->vma
1703 + sec
->output_offset
)
1704 /* A STO_SH5_ISA32 causes a "bitor 1" to the
1705 symbol value, unless we've seen
1706 STT_DATALABEL on the way to it. */
1707 | ((h
->other
& STO_SH5_ISA32
) != 0
1708 && ! seen_stt_datalabel
));
1710 else if (h
->root
.type
== bfd_link_hash_undefweak
)
1712 else if (info
->shared
&& !info
->symbolic
&& !info
->no_undefined
)
1716 if (! ((*info
->callbacks
->undefined_symbol
)
1717 (info
, h
->root
.root
.string
, input_bfd
,
1718 input_section
, rel
->r_offset
, true)))
1725 - input_section
->output_section
->vma
1726 - input_section
->output_offset
1729 switch ((int)r_type
)
1731 case R_SH_PT_16
: dropped
= disp
& 2; break;
1732 case R_SH_DIR10SW
: dropped
= disp
& 1; break;
1733 case R_SH_DIR10SL
: dropped
= disp
& 3; break;
1734 case R_SH_DIR10SQ
: dropped
= disp
& 7; break;
1738 (*_bfd_error_handler
)
1739 (_("%s: error: unaligned relocation type %d at %08x reloc %08x\n"),
1740 bfd_get_filename (input_bfd
), (int)r_type
, (unsigned)rel
->r_offset
, (unsigned)relocation
);
1741 bfd_set_error (bfd_error_bad_value
);
1744 switch ((int)r_type
)
1749 && (input_section
->flags
& SEC_ALLOC
) != 0
1750 && (r_type
!= R_SH_64_PCREL
1753 && (! info
->symbolic
1754 || (h
->elf_link_hash_flags
1755 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
1757 Elf_Internal_Rela outrel
;
1759 boolean skip
, relocate
;
1761 /* When generating a shared object, these relocations
1762 are copied into the output file to be resolved at run
1769 name
= (bfd_elf_string_from_elf_section
1771 elf_elfheader (input_bfd
)->e_shstrndx
,
1772 elf_section_data (input_section
)->rel_hdr
.sh_name
));
1776 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
1777 && strcmp (bfd_get_section_name (input_bfd
,
1781 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1782 BFD_ASSERT (sreloc
!= NULL
);
1789 = _bfd_elf_section_offset (output_bfd
, info
,
1790 input_section
, rel
->r_offset
);
1792 if (outrel
.r_offset
== (bfd_vma
) -1)
1794 else if (outrel
.r_offset
== (bfd_vma
) -2)
1795 skip
= true, relocate
= true;
1797 outrel
.r_offset
+= (input_section
->output_section
->vma
1798 + input_section
->output_offset
);
1801 memset (&outrel
, 0, sizeof outrel
);
1802 else if (r_type
== R_SH_64_PCREL
)
1804 BFD_ASSERT (h
!= NULL
&& h
->dynindx
!= -1);
1805 outrel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_SH_64_PCREL
);
1806 outrel
.r_addend
= rel
->r_addend
;
1810 /* h->dynindx may be -1 if this symbol was marked to
1813 || ((info
->symbolic
|| h
->dynindx
== -1)
1814 && (h
->elf_link_hash_flags
1815 & ELF_LINK_HASH_DEF_REGULAR
) != 0))
1818 outrel
.r_info
= ELF64_R_INFO (0, R_SH_RELATIVE64
);
1819 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1823 BFD_ASSERT (h
->dynindx
!= -1);
1824 outrel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_SH_64
);
1825 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1829 loc
= sreloc
->contents
;
1830 loc
+= sreloc
->reloc_count
++ * sizeof (Elf64_External_Rela
);
1831 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
1833 /* If this reloc is against an external symbol, we do
1834 not want to fiddle with the addend. Otherwise, we
1835 need to include the symbol value so that it becomes
1836 an addend for the dynamic reloc. */
1840 else if (r_type
== R_SH_64
)
1841 addend
= rel
->r_addend
;
1842 goto final_link_relocate
;
1844 case R_SH_GOTPLT_LOW16
:
1845 case R_SH_GOTPLT_MEDLOW16
:
1846 case R_SH_GOTPLT_MEDHI16
:
1847 case R_SH_GOTPLT_HI16
:
1848 case R_SH_GOTPLT10BY4
:
1849 case R_SH_GOTPLT10BY8
:
1850 /* Relocation is to the entry for this symbol in the
1851 procedure linkage table. */
1854 || ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
1855 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
1859 || h
->plt
.offset
== (bfd_vma
) -1
1860 || h
->got
.offset
!= (bfd_vma
) -1)
1863 /* Relocation is to the entry for this symbol in the global
1864 offset table extension for the procedure linkage table. */
1865 if (sgotplt
== NULL
)
1867 sgotplt
= bfd_get_section_by_name (dynobj
, ".got.plt");
1868 BFD_ASSERT (sgotplt
!= NULL
);
1871 relocation
= (sgotplt
->output_offset
1872 + ((h
->plt
.offset
/ elf_sh64_sizeof_plt (info
)
1875 relocation
-= GOT_BIAS
;
1877 goto final_link_relocate
;
1880 case R_SH_GOT_LOW16
:
1881 case R_SH_GOT_MEDLOW16
:
1882 case R_SH_GOT_MEDHI16
:
1886 /* Relocation is to the entry for this symbol in the global
1890 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1891 BFD_ASSERT (sgot
!= NULL
);
1898 off
= h
->got
.offset
;
1899 if (seen_stt_datalabel
)
1901 struct elf_sh64_link_hash_entry
*hsh
;
1903 hsh
= (struct elf_sh64_link_hash_entry
*)h
;
1904 off
= hsh
->datalabel_got_offset
;
1906 BFD_ASSERT (off
!= (bfd_vma
) -1);
1908 if (! elf_hash_table (info
)->dynamic_sections_created
1910 && (info
->symbolic
|| h
->dynindx
== -1
1911 || ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
1912 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
)
1913 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)))
1915 /* This is actually a static link, or it is a
1916 -Bsymbolic link and the symbol is defined
1917 locally, or the symbol was forced to be local
1918 because of a version file. We must initialize
1919 this entry in the global offset table. Since the
1920 offset must always be a multiple of 4, we use the
1921 least significant bit to record whether we have
1922 initialized it already.
1924 When doing a dynamic link, we create a .rela.got
1925 relocation entry to initialize the value. This
1926 is done in the finish_dynamic_symbol routine. */
1931 bfd_put_64 (output_bfd
, relocation
,
1932 sgot
->contents
+ off
);
1933 if (seen_stt_datalabel
)
1935 struct elf_sh64_link_hash_entry
*hsh
;
1937 hsh
= (struct elf_sh64_link_hash_entry
*)h
;
1938 hsh
->datalabel_got_offset
|= 1;
1945 relocation
= sgot
->output_offset
+ off
;
1953 BFD_ASSERT (local_got_offsets
!= NULL
1954 && (local_got_offsets
[symtab_hdr
->sh_info
1958 off
= local_got_offsets
[symtab_hdr
->sh_info
1963 BFD_ASSERT (local_got_offsets
!= NULL
1964 && local_got_offsets
[r_symndx
] != (bfd_vma
) -1);
1966 off
= local_got_offsets
[r_symndx
];
1969 /* The offset must always be a multiple of 8. We use
1970 the least significant bit to record whether we have
1971 already generated the necessary reloc. */
1976 bfd_put_64 (output_bfd
, relocation
, sgot
->contents
+ off
);
1981 Elf_Internal_Rela outrel
;
1984 s
= bfd_get_section_by_name (dynobj
, ".rela.got");
1985 BFD_ASSERT (s
!= NULL
);
1987 outrel
.r_offset
= (sgot
->output_section
->vma
1988 + sgot
->output_offset
1990 outrel
.r_info
= ELF64_R_INFO (0, R_SH_RELATIVE64
);
1991 outrel
.r_addend
= relocation
;
1993 loc
+= s
->reloc_count
++ * sizeof (Elf64_External_Rela
);
1994 bfd_elf64_swap_reloca_out (output_bfd
, &outrel
, loc
);
1998 local_got_offsets
[symtab_hdr
->sh_info
+ r_symndx
] |= 1;
2000 local_got_offsets
[r_symndx
] |= 1;
2003 relocation
= sgot
->output_offset
+ off
;
2006 relocation
-= GOT_BIAS
;
2008 goto final_link_relocate
;
2010 case R_SH_GOTOFF_LOW16
:
2011 case R_SH_GOTOFF_MEDLOW16
:
2012 case R_SH_GOTOFF_MEDHI16
:
2013 case R_SH_GOTOFF_HI16
:
2014 /* Relocation is relative to the start of the global offset
2019 sgot
= bfd_get_section_by_name (dynobj
, ".got");
2020 BFD_ASSERT (sgot
!= NULL
);
2023 /* Note that sgot->output_offset is not involved in this
2024 calculation. We always want the start of .got. If we
2025 defined _GLOBAL_OFFSET_TABLE in a different way, as is
2026 permitted by the ABI, we might have to change this
2028 relocation
-= sgot
->output_section
->vma
;
2030 relocation
-= GOT_BIAS
;
2032 addend
= rel
->r_addend
;
2034 goto final_link_relocate
;
2036 case R_SH_GOTPC_LOW16
:
2037 case R_SH_GOTPC_MEDLOW16
:
2038 case R_SH_GOTPC_MEDHI16
:
2039 case R_SH_GOTPC_HI16
:
2040 /* Use global offset table as symbol value. */
2044 sgot
= bfd_get_section_by_name (dynobj
, ".got");
2045 BFD_ASSERT (sgot
!= NULL
);
2048 relocation
= sgot
->output_section
->vma
;
2050 relocation
+= GOT_BIAS
;
2052 addend
= rel
->r_addend
;
2054 goto final_link_relocate
;
2056 case R_SH_PLT_LOW16
:
2057 case R_SH_PLT_MEDLOW16
:
2058 case R_SH_PLT_MEDHI16
:
2060 /* Relocation is to the entry for this symbol in the
2061 procedure linkage table. */
2063 /* Resolve a PLT reloc against a local symbol directly,
2064 without using the procedure linkage table. */
2066 goto final_link_relocate
;
2068 if (ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
2069 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
)
2070 goto final_link_relocate
;
2072 if (h
->plt
.offset
== (bfd_vma
) -1)
2074 /* We didn't make a PLT entry for this symbol. This
2075 happens when statically linking PIC code, or when
2076 using -Bsymbolic. */
2077 goto final_link_relocate
;
2082 splt
= bfd_get_section_by_name (dynobj
, ".plt");
2083 BFD_ASSERT (splt
!= NULL
);
2086 relocation
= (splt
->output_section
->vma
2087 + splt
->output_offset
2091 addend
= rel
->r_addend
;
2093 goto final_link_relocate
;
2096 case R_SH_SHMEDIA_CODE
:
2107 case R_SH_IMM_LOW16
:
2108 case R_SH_IMM_LOW16_PCREL
:
2109 case R_SH_IMM_MEDLOW16
:
2110 case R_SH_IMM_MEDLOW16_PCREL
:
2111 case R_SH_IMM_MEDHI16
:
2112 case R_SH_IMM_MEDHI16_PCREL
:
2114 case R_SH_IMM_HI16_PCREL
:
2115 addend
= rel
->r_addend
;
2118 final_link_relocate
:
2119 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
2120 contents
, rel
->r_offset
,
2121 relocation
, addend
);
2125 bfd_set_error (bfd_error_bad_value
);
2130 if (r
!= bfd_reloc_ok
)
2135 case bfd_reloc_outofrange
:
2137 case bfd_reloc_overflow
:
2142 name
= h
->root
.root
.string
;
2145 name
= (bfd_elf_string_from_elf_section
2146 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
));
2150 name
= bfd_section_name (input_bfd
, sec
);
2152 if (! ((*info
->callbacks
->reloc_overflow
)
2153 (info
, name
, howto
->name
, (bfd_vma
) 0,
2154 input_bfd
, input_section
, rel
->r_offset
)))
2165 /* This is a version of bfd_generic_get_relocated_section_contents
2166 that uses sh_elf64_relocate_section.
2168 See sh_elf_relocate_section in elf32-sh.c for the original. */
2171 sh_elf64_get_relocated_section_contents (output_bfd
, link_info
, link_order
,
2172 data
, relocateable
, symbols
)
2174 struct bfd_link_info
*link_info
;
2175 struct bfd_link_order
*link_order
;
2177 boolean relocateable
;
2180 Elf_Internal_Shdr
*symtab_hdr
;
2181 asection
*input_section
= link_order
->u
.indirect
.section
;
2182 bfd
*input_bfd
= input_section
->owner
;
2183 asection
**sections
= NULL
;
2184 Elf_Internal_Rela
*internal_relocs
= NULL
;
2185 Elf_Internal_Sym
*isymbuf
= NULL
;
2187 /* We only need to handle the case of relaxing, or of having a
2188 particular set of section contents, specially. */
2190 || elf_section_data (input_section
)->this_hdr
.contents
== NULL
)
2191 return bfd_generic_get_relocated_section_contents (output_bfd
, link_info
,
2196 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
2198 memcpy (data
, elf_section_data (input_section
)->this_hdr
.contents
,
2199 input_section
->_raw_size
);
2201 if ((input_section
->flags
& SEC_RELOC
) != 0
2202 && input_section
->reloc_count
> 0)
2204 Elf_Internal_Sym
*isymp
;
2205 Elf_Internal_Sym
*isymend
;
2208 /* Read this BFD's local symbols. */
2209 if (symtab_hdr
->sh_info
!= 0)
2211 isymbuf
= (Elf_Internal_Sym
*) symtab_hdr
->contents
;
2212 if (isymbuf
== NULL
)
2213 isymbuf
= bfd_elf_get_elf_syms (input_bfd
, symtab_hdr
,
2214 symtab_hdr
->sh_info
, 0,
2216 if (isymbuf
== NULL
)
2220 internal_relocs
= (_bfd_elf64_link_read_relocs
2221 (input_bfd
, input_section
, (PTR
) NULL
,
2222 (Elf_Internal_Rela
*) NULL
, false));
2223 if (internal_relocs
== NULL
)
2226 sections
= (asection
**) bfd_malloc (symtab_hdr
->sh_info
2227 * sizeof (asection
*));
2228 if (sections
== NULL
&& symtab_hdr
->sh_info
> 0)
2232 isymend
= isymbuf
+ symtab_hdr
->sh_info
;
2233 for (isymp
= isymbuf
; isymp
< isymend
; ++isymp
, ++secpp
)
2237 if (isymp
->st_shndx
== SHN_UNDEF
)
2238 isec
= bfd_und_section_ptr
;
2239 else if (isymp
->st_shndx
> 0 && isymp
->st_shndx
< SHN_LORESERVE
)
2240 isec
= bfd_section_from_elf_index (input_bfd
, isymp
->st_shndx
);
2241 else if (isymp
->st_shndx
== SHN_ABS
)
2242 isec
= bfd_abs_section_ptr
;
2243 else if (isymp
->st_shndx
== SHN_COMMON
)
2244 isec
= bfd_com_section_ptr
;
2254 if (! sh_elf64_relocate_section (output_bfd
, link_info
, input_bfd
,
2255 input_section
, data
, internal_relocs
,
2259 if (sections
!= NULL
)
2261 if (internal_relocs
!= elf_section_data (input_section
)->relocs
)
2262 free (internal_relocs
);
2264 && (unsigned char *) isymbuf
!= symtab_hdr
->contents
)
2271 if (sections
!= NULL
)
2273 if (internal_relocs
!= NULL
2274 && internal_relocs
!= elf_section_data (input_section
)->relocs
)
2275 free (internal_relocs
);
2277 && (unsigned char *) isymbuf
!= symtab_hdr
->contents
)
2282 /* Set the SHF_SH5_ISA32 flag for ISA SHmedia code sections. */
2285 sh64_elf64_fake_sections (output_bfd
, elf_section_hdr
, asect
)
2286 bfd
*output_bfd ATTRIBUTE_UNUSED
;
2287 Elf_Internal_Shdr
*elf_section_hdr
;
2290 /* Code sections can only contain SH64 code, so mark them as such. */
2291 if (bfd_get_section_flags (output_bfd
, asect
) & SEC_CODE
)
2292 elf_section_hdr
->sh_flags
|= SHF_SH5_ISA32
;
2298 sh_elf64_set_mach_from_flags (abfd
)
2301 flagword flags
= elf_elfheader (abfd
)->e_flags
;
2303 switch (flags
& EF_SH_MACH_MASK
)
2306 /* Just one, but keep the switch construct to make additions easy. */
2307 bfd_default_set_arch_mach (abfd
, bfd_arch_sh
, bfd_mach_sh5
);
2311 bfd_set_error (bfd_error_wrong_format
);
2317 /* Function to keep SH64 specific file flags.
2319 See sh64_elf_set_private_flags in elf32-sh64.c for the original. */
2322 sh_elf64_set_private_flags (abfd
, flags
)
2326 BFD_ASSERT (! elf_flags_init (abfd
)
2327 || elf_elfheader (abfd
)->e_flags
== flags
);
2329 elf_elfheader (abfd
)->e_flags
= flags
;
2330 elf_flags_init (abfd
) = true;
2331 return sh_elf64_set_mach_from_flags (abfd
);
2334 /* Copy the SHF_SH5_ISA32 attribute that we keep on all sections with
2335 code, to keep attributes the same as for SHmedia in 32-bit ELF. */
2338 sh_elf64_copy_private_data_internal (ibfd
, obfd
)
2342 Elf_Internal_Shdr
**o_shdrp
;
2346 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
2347 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
2350 o_shdrp
= elf_elfsections (obfd
);
2351 for (osec
= obfd
->sections
; osec
; osec
= osec
->next
)
2353 int oIndex
= ((struct bfd_elf_section_data
*) elf_section_data (osec
))->this_idx
;
2354 for (isec
= ibfd
->sections
; isec
; isec
= isec
->next
)
2356 if (strcmp (osec
->name
, isec
->name
) == 0)
2358 /* Note that we're not disallowing mixing data and code. */
2359 if ((elf_section_data (isec
)->this_hdr
.sh_flags
2360 & SHF_SH5_ISA32
) != 0)
2361 o_shdrp
[oIndex
]->sh_flags
|= SHF_SH5_ISA32
;
2367 return sh_elf64_set_private_flags (obfd
, elf_elfheader (ibfd
)->e_flags
);
2371 sh_elf64_copy_private_data (ibfd
, obfd
)
2375 return sh_elf64_copy_private_data_internal (ibfd
, obfd
);
2379 sh_elf64_merge_private_data (ibfd
, obfd
)
2383 flagword old_flags
, new_flags
;
2385 if (! _bfd_generic_verify_endian_match (ibfd
, obfd
))
2388 if ( bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
2389 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
2392 if (bfd_get_arch_size (ibfd
) != bfd_get_arch_size (obfd
))
2396 if (bfd_get_arch_size (ibfd
) == 32
2397 && bfd_get_arch_size (obfd
) == 64)
2398 msg
= _("%s: compiled as 32-bit object and %s is 64-bit");
2399 else if (bfd_get_arch_size (ibfd
) == 64
2400 && bfd_get_arch_size (obfd
) == 32)
2401 msg
= _("%s: compiled as 64-bit object and %s is 32-bit");
2403 msg
= _("%s: object size does not match that of target %s");
2405 (*_bfd_error_handler
) (msg
, bfd_get_filename (ibfd
),
2406 bfd_get_filename (obfd
));
2407 bfd_set_error (bfd_error_wrong_format
);
2411 old_flags
= elf_elfheader (obfd
)->e_flags
;
2412 new_flags
= elf_elfheader (ibfd
)->e_flags
;
2413 if (! elf_flags_init (obfd
))
2415 /* This happens when ld starts out with a 'blank' output file. */
2416 elf_flags_init (obfd
) = true;
2417 elf_elfheader (obfd
)->e_flags
= old_flags
= new_flags
;
2419 /* We don't allow linking in anything else than SH64 code, and since
2420 this is a 64-bit ELF, we assume the 64-bit ABI is used. Add code
2421 here as things change. */
2422 else if ((new_flags
& EF_SH_MACH_MASK
) != EF_SH5
)
2424 (*_bfd_error_handler
)
2425 ("%s: does not use the SH64 64-bit ABI as previous modules do",
2426 bfd_get_filename (ibfd
));
2427 bfd_set_error (bfd_error_bad_value
);
2431 sh_elf64_copy_private_data_internal (ibfd
, obfd
);
2433 /* I can't think of anything sane other than old_flags being EF_SH5 and
2434 that we need to preserve that. */
2435 elf_elfheader (obfd
)->e_flags
= old_flags
;
2437 return sh_elf64_set_mach_from_flags (obfd
);
2440 /* Return the section that should be marked against GC for a given
2444 sh_elf64_gc_mark_hook (sec
, info
, rel
, h
, sym
)
2446 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
2447 Elf_Internal_Rela
*rel
;
2448 struct elf_link_hash_entry
*h
;
2449 Elf_Internal_Sym
*sym
;
2453 switch (ELF64_R_TYPE (rel
->r_info
))
2455 case R_SH_GNU_VTINHERIT
:
2456 case R_SH_GNU_VTENTRY
:
2460 while (h
->root
.type
== bfd_link_hash_indirect
2461 && h
->root
.u
.i
.link
)
2462 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
2463 switch (h
->root
.type
)
2465 case bfd_link_hash_defined
:
2466 case bfd_link_hash_defweak
:
2467 return h
->root
.u
.def
.section
;
2469 case bfd_link_hash_common
:
2470 return h
->root
.u
.c
.p
->section
;
2478 return bfd_section_from_elf_index (sec
->owner
, sym
->st_shndx
);
2483 /* Update the got entry reference counts for the section being removed. */
2486 sh_elf64_gc_sweep_hook (abfd
, info
, sec
, relocs
)
2487 bfd
*abfd ATTRIBUTE_UNUSED
;
2488 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
2489 asection
*sec ATTRIBUTE_UNUSED
;
2490 const Elf_Internal_Rela
*relocs ATTRIBUTE_UNUSED
;
2492 /* No got and plt entries for 64-bit SH at present. */
2496 /* Look through the relocs for a section during the first phase.
2497 Since we don't do .gots or .plts, we just need to consider the
2498 virtual table relocs for gc. */
2501 sh_elf64_check_relocs (abfd
, info
, sec
, relocs
)
2503 struct bfd_link_info
*info
;
2505 const Elf_Internal_Rela
*relocs
;
2507 Elf_Internal_Shdr
*symtab_hdr
;
2508 struct elf_link_hash_entry
**sym_hashes
, **sym_hashes_end
;
2509 const Elf_Internal_Rela
*rel
;
2510 const Elf_Internal_Rela
*rel_end
;
2512 bfd_vma
*local_got_offsets
;
2521 if (info
->relocateable
)
2524 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
2525 sym_hashes
= elf_sym_hashes (abfd
);
2526 sym_hashes_end
= sym_hashes
+ symtab_hdr
->sh_size
/sizeof(Elf64_External_Sym
);
2527 if (!elf_bad_symtab (abfd
))
2528 sym_hashes_end
-= symtab_hdr
->sh_info
;
2530 dynobj
= elf_hash_table (info
)->dynobj
;
2531 local_got_offsets
= elf_local_got_offsets (abfd
);
2533 rel_end
= relocs
+ sec
->reloc_count
;
2534 for (rel
= relocs
; rel
< rel_end
; rel
++)
2536 struct elf_link_hash_entry
*h
;
2537 unsigned long r_symndx
;
2539 r_symndx
= ELF64_R_SYM (rel
->r_info
);
2540 if (r_symndx
< symtab_hdr
->sh_info
)
2543 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
2545 /* Some relocs require a global offset table. */
2548 switch (ELF64_R_TYPE (rel
->r_info
))
2550 case R_SH_GOTPLT_LOW16
:
2551 case R_SH_GOTPLT_MEDLOW16
:
2552 case R_SH_GOTPLT_MEDHI16
:
2553 case R_SH_GOTPLT_HI16
:
2554 case R_SH_GOTPLT10BY4
:
2555 case R_SH_GOTPLT10BY8
:
2556 case R_SH_GOT_LOW16
:
2557 case R_SH_GOT_MEDLOW16
:
2558 case R_SH_GOT_MEDHI16
:
2562 case R_SH_GOTOFF_LOW16
:
2563 case R_SH_GOTOFF_MEDLOW16
:
2564 case R_SH_GOTOFF_MEDHI16
:
2565 case R_SH_GOTOFF_HI16
:
2566 case R_SH_GOTPC_LOW16
:
2567 case R_SH_GOTPC_MEDLOW16
:
2568 case R_SH_GOTPC_MEDHI16
:
2569 case R_SH_GOTPC_HI16
:
2570 elf_hash_table (info
)->dynobj
= dynobj
= abfd
;
2571 if (! _bfd_elf_create_got_section (dynobj
, info
))
2580 switch (ELF64_R_TYPE (rel
->r_info
))
2582 /* This relocation describes the C++ object vtable hierarchy.
2583 Reconstruct it for later use during GC. */
2584 case R_SH_GNU_VTINHERIT
:
2585 if (!_bfd_elf64_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
2589 /* This relocation describes which C++ vtable entries are actually
2590 used. Record for later use during GC. */
2591 case R_SH_GNU_VTENTRY
:
2592 if (!_bfd_elf64_gc_record_vtentry (abfd
, sec
, h
, rel
->r_addend
))
2597 case R_SH_GOT_LOW16
:
2598 case R_SH_GOT_MEDLOW16
:
2599 case R_SH_GOT_MEDHI16
:
2603 /* This symbol requires a global offset table entry. */
2607 sgot
= bfd_get_section_by_name (dynobj
, ".got");
2608 BFD_ASSERT (sgot
!= NULL
);
2612 && (h
!= NULL
|| info
->shared
))
2614 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
2615 if (srelgot
== NULL
)
2617 srelgot
= bfd_make_section (dynobj
, ".rela.got");
2619 || ! bfd_set_section_flags (dynobj
, srelgot
,
2624 | SEC_LINKER_CREATED
2626 || ! bfd_set_section_alignment (dynobj
, srelgot
, 2))
2633 if (h
->type
== STT_DATALABEL
)
2635 struct elf_sh64_link_hash_entry
*hsh
;
2637 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
2638 hsh
= (struct elf_sh64_link_hash_entry
*)h
;
2639 if (hsh
->datalabel_got_offset
!= (bfd_vma
) -1)
2642 hsh
->datalabel_got_offset
= sgot
->_raw_size
;
2646 if (h
->got
.offset
!= (bfd_vma
) -1)
2648 /* We have already allocated space in the .got. */
2651 h
->got
.offset
= sgot
->_raw_size
;
2654 /* Make sure this symbol is output as a dynamic symbol. */
2655 if (h
->dynindx
== -1)
2657 if (! bfd_elf64_link_record_dynamic_symbol (info
, h
))
2661 srelgot
->_raw_size
+= sizeof (Elf64_External_Rela
);
2665 /* This is a global offset table entry for a local
2667 if (local_got_offsets
== NULL
)
2670 register unsigned int i
;
2672 size
= symtab_hdr
->sh_info
* sizeof (bfd_vma
);
2673 /* Reserve space for both the datalabel and
2674 codelabel local GOT offsets. */
2676 local_got_offsets
= (bfd_vma
*) bfd_alloc (abfd
, size
);
2677 if (local_got_offsets
== NULL
)
2679 elf_local_got_offsets (abfd
) = local_got_offsets
;
2680 for (i
= 0; i
< symtab_hdr
->sh_info
; i
++)
2681 local_got_offsets
[i
] = (bfd_vma
) -1;
2682 for (; i
< 2 * symtab_hdr
->sh_info
; i
++)
2683 local_got_offsets
[i
] = (bfd_vma
) -1;
2685 if ((rel
->r_addend
& 1) != 0)
2687 if (local_got_offsets
[symtab_hdr
->sh_info
2688 + r_symndx
] != (bfd_vma
) -1)
2690 /* We have already allocated space in the .got. */
2693 local_got_offsets
[symtab_hdr
->sh_info
2694 + r_symndx
] = sgot
->_raw_size
;
2698 if (local_got_offsets
[r_symndx
] != (bfd_vma
) -1)
2700 /* We have already allocated space in the .got. */
2703 local_got_offsets
[r_symndx
] = sgot
->_raw_size
;
2708 /* If we are generating a shared object, we need to
2709 output a R_SH_RELATIVE reloc so that the dynamic
2710 linker can adjust this GOT entry. */
2711 srelgot
->_raw_size
+= sizeof (Elf64_External_Rela
);
2715 sgot
->_raw_size
+= 8;
2719 case R_SH_GOTPLT_LOW16
:
2720 case R_SH_GOTPLT_MEDLOW16
:
2721 case R_SH_GOTPLT_MEDHI16
:
2722 case R_SH_GOTPLT_HI16
:
2723 case R_SH_GOTPLT10BY4
:
2724 case R_SH_GOTPLT10BY8
:
2725 /* If this is a local symbol, we resolve it directly without
2726 creating a procedure linkage table entry. */
2729 || ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
2730 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
2734 || h
->got
.offset
!= (bfd_vma
) -1)
2737 /* Make sure this symbol is output as a dynamic symbol. */
2738 if (h
->dynindx
== -1)
2740 if (! bfd_elf64_link_record_dynamic_symbol (info
, h
))
2744 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
2748 case R_SH_PLT_LOW16
:
2749 case R_SH_PLT_MEDLOW16
:
2750 case R_SH_PLT_MEDHI16
:
2752 /* This symbol requires a procedure linkage table entry. We
2753 actually build the entry in adjust_dynamic_symbol,
2754 because this might be a case of linking PIC code which is
2755 never referenced by a dynamic object, in which case we
2756 don't need to generate a procedure linkage table entry
2759 /* If this is a local symbol, we resolve it directly without
2760 creating a procedure linkage table entry. */
2764 if (ELF_ST_VISIBILITY (h
->other
) == STV_INTERNAL
2765 || ELF_ST_VISIBILITY (h
->other
) == STV_HIDDEN
)
2768 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
2775 h
->elf_link_hash_flags
|= ELF_LINK_NON_GOT_REF
;
2777 /* If we are creating a shared library, and this is a reloc
2778 against a global symbol, or a non PC relative reloc
2779 against a local symbol, then we need to copy the reloc
2780 into the shared library. However, if we are linking with
2781 -Bsymbolic, we do not need to copy a reloc against a
2782 global symbol which is defined in an object we are
2783 including in the link (i.e., DEF_REGULAR is set). At
2784 this point we have not seen all the input files, so it is
2785 possible that DEF_REGULAR is not set now but will be set
2786 later (it is never cleared). We account for that
2787 possibility below by storing information in the
2788 pcrel_relocs_copied field of the hash table entry. */
2790 && (sec
->flags
& SEC_ALLOC
) != 0
2791 && (ELF32_R_TYPE (rel
->r_info
) != R_SH_64_PCREL
2793 && (! info
->symbolic
2794 || (h
->elf_link_hash_flags
2795 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
2797 /* When creating a shared object, we must copy these
2798 reloc types into the output file. We create a reloc
2799 section in dynobj and make room for this reloc. */
2804 name
= (bfd_elf_string_from_elf_section
2806 elf_elfheader (abfd
)->e_shstrndx
,
2807 elf_section_data (sec
)->rel_hdr
.sh_name
));
2811 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
2812 && strcmp (bfd_get_section_name (abfd
, sec
),
2815 sreloc
= bfd_get_section_by_name (dynobj
, name
);
2820 sreloc
= bfd_make_section (dynobj
, name
);
2821 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
2822 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
2823 if ((sec
->flags
& SEC_ALLOC
) != 0)
2824 flags
|= SEC_ALLOC
| SEC_LOAD
;
2826 || ! bfd_set_section_flags (dynobj
, sreloc
, flags
)
2827 || ! bfd_set_section_alignment (dynobj
, sreloc
, 2))
2832 sreloc
->_raw_size
+= sizeof (Elf64_External_Rela
);
2834 /* If we are linking with -Bsymbolic, and this is a
2835 global symbol, we count the number of PC relative
2836 relocations we have entered for this symbol, so that
2837 we can discard them again if the symbol is later
2838 defined by a regular object. Note that this function
2839 is only called if we are using an elf_sh linker
2840 hash table, which means that h is really a pointer to
2841 an elf_sh_link_hash_entry. */
2842 if (h
!= NULL
&& info
->symbolic
2843 && ELF64_R_TYPE (rel
->r_info
) == R_SH_64_PCREL
)
2845 struct elf_sh64_link_hash_entry
*eh
;
2846 struct elf_sh64_pcrel_relocs_copied
*p
;
2848 eh
= (struct elf_sh64_link_hash_entry
*) h
;
2850 for (p
= eh
->pcrel_relocs_copied
; p
!= NULL
; p
= p
->next
)
2851 if (p
->section
== sreloc
)
2856 p
= ((struct elf_sh64_pcrel_relocs_copied
*)
2857 bfd_alloc (dynobj
, sizeof *p
));
2860 p
->next
= eh
->pcrel_relocs_copied
;
2861 eh
->pcrel_relocs_copied
= p
;
2862 p
->section
= sreloc
;
2878 sh64_elf64_get_symbol_type (elf_sym
, type
)
2879 Elf_Internal_Sym
* elf_sym
;
2882 if (ELF_ST_TYPE (elf_sym
->st_info
) == STT_DATALABEL
)
2883 return STT_DATALABEL
;
2888 /* FIXME: This is a copy of sh64_elf_add_symbol_hook in elf32-sh64.c.
2889 Either file can presumably exist without the other, but do not differ
2890 in elf-size-ness. How to share?
2892 Hook called by the linker routine which adds symbols from an object
2893 file. We must make indirect symbols for undefined symbols marked with
2894 STT_DATALABEL, so relocations passing them will pick up that attribute
2895 and neutralize STO_SH5_ISA32 found on the symbol definition.
2897 There is a problem, though: We want to fill in the hash-table entry for
2898 this symbol and signal to the caller that no further processing is
2899 needed. But we don't have the index for this hash-table entry. We
2900 rely here on that the current entry is the first hash-entry with NULL,
2901 which seems brittle. Also, iterating over the hash-table to find that
2902 entry is a linear operation on the number of symbols in this input
2903 file, and this function should take constant time, so that's not good
2904 too. Only comfort is that DataLabel references should only be found in
2905 hand-written assembly code and thus be rare. FIXME: Talk maintainers
2906 into adding an option to elf_add_symbol_hook (preferably) for the index
2907 or the hash entry, alternatively adding the index to Elf_Internal_Sym
2911 sh64_elf64_add_symbol_hook (abfd
, info
, sym
, namep
, flagsp
, secp
, valp
)
2913 struct bfd_link_info
*info
;
2914 const Elf_Internal_Sym
*sym
;
2916 flagword
*flagsp ATTRIBUTE_UNUSED
;
2920 /* We want to do this for relocatable as well as final linking. */
2921 if (ELF_ST_TYPE (sym
->st_info
) == STT_DATALABEL
2922 && info
->hash
->creator
->flavour
== bfd_target_elf_flavour
)
2924 struct elf_link_hash_entry
*h
;
2926 /* For relocateable links, we register the DataLabel sym in its own
2927 right, and tweak the name when it's output. Otherwise, we make
2928 an indirect symbol of it. */
2930 = info
->relocateable
|| info
->emitrelocations
2931 ? BSF_GLOBAL
: BSF_GLOBAL
| BSF_INDIRECT
;
2934 = bfd_malloc (strlen (*namep
) + sizeof (DATALABEL_SUFFIX
));
2935 struct elf_link_hash_entry
** sym_hash
= elf_sym_hashes (abfd
);
2937 BFD_ASSERT (sym_hash
!= NULL
);
2939 /* Allocation may fail. */
2940 if (dl_name
== NULL
)
2943 strcpy (dl_name
, *namep
);
2944 strcat (dl_name
, DATALABEL_SUFFIX
);
2946 h
= (struct elf_link_hash_entry
*)
2947 bfd_link_hash_lookup (info
->hash
, dl_name
, false, false, false);
2951 /* No previous datalabel symbol. Make one. */
2952 struct bfd_link_hash_entry
*bh
= NULL
;
2953 struct elf_backend_data
*bed
= get_elf_backend_data (abfd
);
2955 if (! _bfd_generic_link_add_one_symbol (info
, abfd
, dl_name
,
2956 flags
, *secp
, *valp
,
2964 h
= (struct elf_link_hash_entry
*) bh
;
2965 h
->elf_link_hash_flags
&=~ ELF_LINK_NON_ELF
;
2966 h
->type
= STT_DATALABEL
;
2969 /* If a new symbol was created, it holds the allocated name.
2970 Otherwise, we don't need it anymore and should deallocate it. */
2973 if (h
->type
!= STT_DATALABEL
2974 || ((info
->relocateable
|| info
->emitrelocations
)
2975 && h
->root
.type
!= bfd_link_hash_undefined
)
2976 || (! info
->relocateable
&& !info
->emitrelocations
2977 && h
->root
.type
!= bfd_link_hash_indirect
))
2979 /* Make sure we don't get confused on invalid input. */
2980 (*_bfd_error_handler
)
2981 (_("%s: encountered datalabel symbol in input"),
2982 bfd_get_filename (abfd
));
2983 bfd_set_error (bfd_error_bad_value
);
2987 /* Now find the hash-table slot for this entry and fill it in. */
2988 while (*sym_hash
!= NULL
)
2992 /* Signal to caller to skip this symbol - we've handled it. */
2999 /* This hook function is called before the linker writes out a global
3000 symbol. For relocatable links, DataLabel symbols will be present in
3001 linker output. We cut off the special suffix on those symbols, so the
3002 right name appears in the output.
3004 When linking and emitting relocations, there can appear global symbols
3005 that are not referenced by relocs, but rather only implicitly through
3006 DataLabel references, a relation that is not visible to the linker.
3007 Since no stripping of global symbols in done when doing such linking,
3008 we don't need to look up and make sure to emit the main symbol for each
3009 DataLabel symbol. */
3012 sh64_elf64_link_output_symbol_hook (abfd
, info
, cname
, sym
, input_sec
)
3013 bfd
*abfd ATTRIBUTE_UNUSED
;
3014 struct bfd_link_info
*info
;
3016 Elf_Internal_Sym
*sym
;
3017 asection
*input_sec ATTRIBUTE_UNUSED
;
3019 char *name
= (char *) cname
;
3021 if (info
->relocateable
|| info
->emitrelocations
)
3023 if (ELF_ST_TYPE (sym
->st_info
) == STT_DATALABEL
)
3024 name
[strlen (name
) - strlen (DATALABEL_SUFFIX
)] = 0;
3030 /* Set bit 0 on the entry address; it always points to SHmedia code. This
3031 is mostly for symmetry with the 32-bit format, where code can be
3032 SHcompact and we need to make a distinction to make sure execution
3033 starts in the right ISA mode. It is also convenient for a loader,
3034 which would otherwise have to set this bit when loading a TR register
3035 before jumping to the program entry. */
3038 sh64_elf64_final_write_processing (abfd
, linker
)
3040 boolean linker ATTRIBUTE_UNUSED
;
3042 /* FIXME: Perhaps we shouldn't do this if the entry address was supplied
3043 numerically, but we currently lack the infrastructure to recognize
3044 that: The entry symbol, and info whether it is numeric or a symbol
3045 name is kept private in the linker. */
3046 if (elf_elfheader (abfd
)->e_type
== ET_EXEC
)
3047 elf_elfheader (abfd
)->e_entry
|= 1;
3050 /* First entry in an absolute procedure linkage table look like this. */
3052 static const bfd_byte elf_sh64_plt0_entry_be
[PLT_ENTRY_SIZE
] =
3054 0xcc, 0x00, 0x01, 0x10, /* movi .got.plt >> 48, r17 */
3055 0xc8, 0x00, 0x01, 0x10, /* shori (.got.plt >> 32) & 65535, r17 */
3056 0xc8, 0x00, 0x01, 0x10, /* shori (.got.plt >> 16) & 65535, r17 */
3057 0xc8, 0x00, 0x01, 0x10, /* shori .got.plt & 65535, r17 */
3058 0x8d, 0x10, 0x09, 0x90, /* ld.q r17, 16, r25 */
3059 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
3060 0x8d, 0x10, 0x05, 0x10, /* ld.q r17, 8, r17 */
3061 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
3062 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3063 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3064 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3065 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3066 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3067 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3068 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3069 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3072 static const bfd_byte elf_sh64_plt0_entry_le
[PLT_ENTRY_SIZE
] =
3074 0x10, 0x01, 0x00, 0xcc, /* movi .got.plt >> 16, r17 */
3075 0x10, 0x01, 0x00, 0xc8, /* shori (.got.plt >> 32) & 65535, r17 */
3076 0x10, 0x01, 0x00, 0xc8, /* shori (.got.plt >> 16) & 65535, r17 */
3077 0x10, 0x01, 0x00, 0xc8, /* shori .got.plt & 65535, r17 */
3078 0x90, 0x09, 0x10, 0x8d, /* ld.q r17, 16, r25 */
3079 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
3080 0x10, 0x05, 0x10, 0x8d, /* ld.q r17, 8, r17 */
3081 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
3082 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3083 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3084 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3085 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3086 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3087 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3088 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3089 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3092 /* Sebsequent entries in an absolute procedure linkage table look like
3095 static const bfd_byte elf_sh64_plt_entry_be
[PLT_ENTRY_SIZE
] =
3097 0xcc, 0x00, 0x01, 0x90, /* movi nameN-in-GOT >> 48, r25 */
3098 0xc8, 0x00, 0x01, 0x90, /* shori (nameN-in-GOT >> 32) & 65535, r25 */
3099 0xc8, 0x00, 0x01, 0x90, /* shori (nameN-in-GOT >> 16) & 65535, r25 */
3100 0xc8, 0x00, 0x01, 0x90, /* shori nameN-in-GOT & 65535, r25 */
3101 0x8d, 0x90, 0x01, 0x90, /* ld.q r25, 0, r25 */
3102 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
3103 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
3104 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3105 0xcc, 0x00, 0x01, 0x90, /* movi (.+8-.PLT0) >> 16, r25 */
3106 0xc8, 0x00, 0x01, 0x90, /* shori (.+4-.PLT0) & 65535, r25 */
3107 0x6b, 0xf5, 0x66, 0x00, /* ptrel r25, tr0 */
3108 0xcc, 0x00, 0x01, 0x50, /* movi reloc-offset >> 16, r21 */
3109 0xc8, 0x00, 0x01, 0x50, /* shori reloc-offset & 65535, r21 */
3110 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
3111 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3112 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3115 static const bfd_byte elf_sh64_plt_entry_le
[PLT_ENTRY_SIZE
] =
3117 0x90, 0x01, 0x00, 0xcc, /* movi nameN-in-GOT >> 16, r25 */
3118 0x90, 0x01, 0x00, 0xc8, /* shori nameN-in-GOT & 65535, r25 */
3119 0x90, 0x01, 0x00, 0xc8, /* shori nameN-in-GOT & 65535, r25 */
3120 0x90, 0x01, 0x00, 0xc8, /* shori nameN-in-GOT & 65535, r25 */
3121 0x90, 0x01, 0x90, 0x8d, /* ld.q r25, 0, r25 */
3122 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
3123 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
3124 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3125 0x90, 0x01, 0x00, 0xcc, /* movi (.+8-.PLT0) >> 16, r25 */
3126 0x90, 0x01, 0x00, 0xc8, /* shori (.+4-.PLT0) & 65535, r25 */
3127 0x00, 0x66, 0xf5, 0x6b, /* ptrel r25, tr0 */
3128 0x50, 0x01, 0x00, 0xcc, /* movi reloc-offset >> 16, r21 */
3129 0x50, 0x01, 0x00, 0xc8, /* shori reloc-offset & 65535, r21 */
3130 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
3131 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3132 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3135 /* Entries in a PIC procedure linkage table look like this. */
3137 static const bfd_byte elf_sh64_pic_plt_entry_be
[PLT_ENTRY_SIZE
] =
3139 0xcc, 0x00, 0x01, 0x90, /* movi nameN@GOT >> 16, r25 */
3140 0xc8, 0x00, 0x01, 0x90, /* shori nameN@GOT & 65535, r25 */
3141 0x40, 0xc3, 0x65, 0x90, /* ldx.q r12, r25, r25 */
3142 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
3143 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
3144 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3145 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3146 0x6f, 0xf0, 0xff, 0xf0, /* nop */
3147 0xce, 0x00, 0x01, 0x10, /* movi -GOT_BIAS, r17 */
3148 0x00, 0xc9, 0x45, 0x10, /* add r12, r17, r17 */
3149 0x8d, 0x10, 0x09, 0x90, /* ld.q r17, 16, r25 */
3150 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
3151 0x8d, 0x10, 0x05, 0x10, /* ld.q r17, 8, r17 */
3152 0xcc, 0x00, 0x01, 0x50, /* movi reloc-offset >> 16, r21 */
3153 0xc8, 0x00, 0x01, 0x50, /* shori reloc-offset & 65535, r21 */
3154 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
3157 static const bfd_byte elf_sh64_pic_plt_entry_le
[PLT_ENTRY_SIZE
] =
3159 0x90, 0x01, 0x00, 0xcc, /* movi nameN@GOT >> 16, r25 */
3160 0x90, 0x01, 0x00, 0xc8, /* shori nameN@GOT & 65535, r25 */
3161 0x90, 0x65, 0xc3, 0x40, /* ldx.q r12, r25, r25 */
3162 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
3163 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
3164 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3165 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3166 0xf0, 0xff, 0xf0, 0x6f, /* nop */
3167 0x10, 0x01, 0x00, 0xce, /* movi -GOT_BIAS, r17 */
3168 0x10, 0x45, 0xc9, 0x00, /* add r12, r17, r17 */
3169 0x90, 0x09, 0x10, 0x8d, /* ld.q r17, 16, r25 */
3170 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
3171 0x10, 0x05, 0x10, 0x8d, /* ld.q r17, 8, r17 */
3172 0x50, 0x01, 0x00, 0xcc, /* movi reloc-offset >> 16, r21 */
3173 0x50, 0x01, 0x00, 0xc8, /* shori reloc-offset & 65535, r21 */
3174 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
3177 static const bfd_byte
*elf_sh64_plt0_entry
;
3178 static const bfd_byte
*elf_sh64_plt_entry
;
3179 static const bfd_byte
*elf_sh64_pic_plt_entry
;
3181 /* Create an entry in an sh ELF linker hash table. */
3183 static struct bfd_hash_entry
*
3184 sh64_elf64_link_hash_newfunc (entry
, table
, string
)
3185 struct bfd_hash_entry
*entry
;
3186 struct bfd_hash_table
*table
;
3189 struct elf_sh64_link_hash_entry
*ret
=
3190 (struct elf_sh64_link_hash_entry
*) entry
;
3192 /* Allocate the structure if it has not already been allocated by a
3194 if (ret
== (struct elf_sh64_link_hash_entry
*) NULL
)
3195 ret
= ((struct elf_sh64_link_hash_entry
*)
3196 bfd_hash_allocate (table
,
3197 sizeof (struct elf_sh64_link_hash_entry
)));
3198 if (ret
== (struct elf_sh64_link_hash_entry
*) NULL
)
3199 return (struct bfd_hash_entry
*) ret
;
3201 /* Call the allocation method of the superclass. */
3202 ret
= ((struct elf_sh64_link_hash_entry
*)
3203 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
3205 if (ret
!= (struct elf_sh64_link_hash_entry
*) NULL
)
3207 ret
->pcrel_relocs_copied
= NULL
;
3208 ret
->datalabel_got_offset
= (bfd_vma
) -1;
3211 return (struct bfd_hash_entry
*) ret
;
3214 /* Create an sh64 ELF linker hash table. */
3216 static struct bfd_link_hash_table
*
3217 sh64_elf64_link_hash_table_create (abfd
)
3220 struct elf_sh64_link_hash_table
*ret
;
3222 ret
= ((struct elf_sh64_link_hash_table
*)
3223 bfd_malloc (sizeof (struct elf_sh64_link_hash_table
)));
3224 if (ret
== (struct elf_sh64_link_hash_table
*) NULL
)
3227 if (! _bfd_elf_link_hash_table_init (&ret
->root
, abfd
,
3228 sh64_elf64_link_hash_newfunc
))
3234 return &ret
->root
.root
;
3238 movi_shori_putval (output_bfd
, value
, addr
)
3240 unsigned long value
;
3243 bfd_put_32 (output_bfd
,
3244 bfd_get_32 (output_bfd
, addr
)
3245 | ((value
>> 6) & 0x3fffc00),
3247 bfd_put_32 (output_bfd
,
3248 bfd_get_32 (output_bfd
, addr
+ 4)
3249 | ((value
<< 10) & 0x3fffc00),
3254 movi_3shori_putval (output_bfd
, value
, addr
)
3259 bfd_put_32 (output_bfd
,
3260 bfd_get_32 (output_bfd
, addr
)
3261 | ((value
>> 38) & 0x3fffc00),
3263 bfd_put_32 (output_bfd
,
3264 bfd_get_32 (output_bfd
, addr
+ 4)
3265 | ((value
>> 22) & 0x3fffc00),
3267 bfd_put_32 (output_bfd
,
3268 bfd_get_32 (output_bfd
, addr
+ 8)
3269 | ((value
>> 6) & 0x3fffc00),
3271 bfd_put_32 (output_bfd
,
3272 bfd_get_32 (output_bfd
, addr
+ 12)
3273 | ((value
<< 10) & 0x3fffc00),
3277 /* Create dynamic sections when linking against a dynamic object. */
3280 sh64_elf64_create_dynamic_sections (abfd
, info
)
3282 struct bfd_link_info
*info
;
3284 flagword flags
, pltflags
;
3285 register asection
*s
;
3286 struct elf_backend_data
*bed
= get_elf_backend_data (abfd
);
3289 switch (bed
->s
->arch_size
)
3300 bfd_set_error (bfd_error_bad_value
);
3304 /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and
3305 .rel[a].bss sections. */
3307 flags
= (SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
3308 | SEC_LINKER_CREATED
);
3311 pltflags
|= SEC_CODE
;
3312 if (bed
->plt_not_loaded
)
3313 pltflags
&= ~ (SEC_LOAD
| SEC_HAS_CONTENTS
);
3314 if (bed
->plt_readonly
)
3315 pltflags
|= SEC_READONLY
;
3317 s
= bfd_make_section (abfd
, ".plt");
3319 || ! bfd_set_section_flags (abfd
, s
, pltflags
)
3320 || ! bfd_set_section_alignment (abfd
, s
, bed
->plt_alignment
))
3323 if (bed
->want_plt_sym
)
3325 /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
3327 struct elf_link_hash_entry
*h
;
3328 struct bfd_link_hash_entry
*bh
= NULL
;
3330 if (! (_bfd_generic_link_add_one_symbol
3331 (info
, abfd
, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL
, s
,
3332 (bfd_vma
) 0, (const char *) NULL
, false, bed
->collect
, &bh
)))
3335 h
= (struct elf_link_hash_entry
*) bh
;
3336 h
->elf_link_hash_flags
|= ELF_LINK_HASH_DEF_REGULAR
;
3337 h
->type
= STT_OBJECT
;
3340 && ! _bfd_elf_link_record_dynamic_symbol (info
, h
))
3344 s
= bfd_make_section (abfd
,
3345 bed
->default_use_rela_p
? ".rela.plt" : ".rel.plt");
3347 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
)
3348 || ! bfd_set_section_alignment (abfd
, s
, ptralign
))
3351 if (! _bfd_elf_create_got_section (abfd
, info
))
3355 const char *secname
;
3360 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3362 secflags
= bfd_get_section_flags (abfd
, sec
);
3363 if ((secflags
& (SEC_DATA
| SEC_LINKER_CREATED
))
3364 || ((secflags
& SEC_HAS_CONTENTS
) != SEC_HAS_CONTENTS
))
3366 secname
= bfd_get_section_name (abfd
, sec
);
3367 relname
= (char *) bfd_malloc (strlen (secname
) + 6);
3368 strcpy (relname
, ".rela");
3369 strcat (relname
, secname
);
3370 s
= bfd_make_section (abfd
, relname
);
3372 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
)
3373 || ! bfd_set_section_alignment (abfd
, s
, ptralign
))
3378 if (bed
->want_dynbss
)
3380 /* The .dynbss section is a place to put symbols which are defined
3381 by dynamic objects, are referenced by regular objects, and are
3382 not functions. We must allocate space for them in the process
3383 image and use a R_*_COPY reloc to tell the dynamic linker to
3384 initialize them at run time. The linker script puts the .dynbss
3385 section into the .bss section of the final image. */
3386 s
= bfd_make_section (abfd
, ".dynbss");
3388 || ! bfd_set_section_flags (abfd
, s
, SEC_ALLOC
))
3391 /* The .rel[a].bss section holds copy relocs. This section is not
3392 normally needed. We need to create it here, though, so that the
3393 linker will map it to an output section. We can't just create it
3394 only if we need it, because we will not know whether we need it
3395 until we have seen all the input files, and the first time the
3396 main linker code calls BFD after examining all the input files
3397 (size_dynamic_sections) the input sections have already been
3398 mapped to the output sections. If the section turns out not to
3399 be needed, we can discard it later. We will never need this
3400 section when generating a shared object, since they do not use
3404 s
= bfd_make_section (abfd
,
3405 (bed
->default_use_rela_p
3406 ? ".rela.bss" : ".rel.bss"));
3408 || ! bfd_set_section_flags (abfd
, s
, flags
| SEC_READONLY
)
3409 || ! bfd_set_section_alignment (abfd
, s
, ptralign
))
3417 /* Adjust a symbol defined by a dynamic object and referenced by a
3418 regular object. The current definition is in some section of the
3419 dynamic object, but we're not including those sections. We have to
3420 change the definition to something the rest of the link can
3424 sh64_elf64_adjust_dynamic_symbol (info
, h
)
3425 struct bfd_link_info
*info
;
3426 struct elf_link_hash_entry
*h
;
3430 unsigned int power_of_two
;
3432 dynobj
= elf_hash_table (info
)->dynobj
;
3434 /* Make sure we know what is going on here. */
3435 BFD_ASSERT (dynobj
!= NULL
3436 && ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
)
3437 || h
->weakdef
!= NULL
3438 || ((h
->elf_link_hash_flags
3439 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0
3440 && (h
->elf_link_hash_flags
3441 & ELF_LINK_HASH_REF_REGULAR
) != 0
3442 && (h
->elf_link_hash_flags
3443 & ELF_LINK_HASH_DEF_REGULAR
) == 0)));
3445 /* If this is a function, put it in the procedure linkage table. We
3446 will fill in the contents of the procedure linkage table later,
3447 when we know the address of the .got section. */
3448 if (h
->type
== STT_FUNC
3449 || (h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0)
3452 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_DYNAMIC
) == 0
3453 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_REF_DYNAMIC
) == 0)
3455 /* This case can occur if we saw a PLT reloc in an input
3456 file, but the symbol was never referred to by a dynamic
3457 object. In such a case, we don't actually need to build
3458 a procedure linkage table, and we can just do a REL64
3460 BFD_ASSERT ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0);
3464 /* Make sure this symbol is output as a dynamic symbol. */
3465 if (h
->dynindx
== -1)
3467 if (! bfd_elf64_link_record_dynamic_symbol (info
, h
))
3471 s
= bfd_get_section_by_name (dynobj
, ".plt");
3472 BFD_ASSERT (s
!= NULL
);
3474 /* If this is the first .plt entry, make room for the special
3476 if (s
->_raw_size
== 0)
3477 s
->_raw_size
+= PLT_ENTRY_SIZE
;
3479 /* If this symbol is not defined in a regular file, and we are
3480 not generating a shared library, then set the symbol to this
3481 location in the .plt. This is required to make function
3482 pointers compare as equal between the normal executable and
3483 the shared library. */
3485 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
3487 h
->root
.u
.def
.section
= s
;
3488 h
->root
.u
.def
.value
= s
->_raw_size
;
3491 h
->plt
.offset
= s
->_raw_size
;
3493 /* Make room for this entry. */
3494 s
->_raw_size
+= elf_sh64_sizeof_plt (info
);
3496 /* We also need to make an entry in the .got.plt section, which
3497 will be placed in the .got section by the linker script. */
3499 s
= bfd_get_section_by_name (dynobj
, ".got.plt");
3500 BFD_ASSERT (s
!= NULL
);
3503 /* We also need to make an entry in the .rela.plt section. */
3505 s
= bfd_get_section_by_name (dynobj
, ".rela.plt");
3506 BFD_ASSERT (s
!= NULL
);
3507 s
->_raw_size
+= sizeof (Elf64_External_Rela
);
3512 /* If this is a weak symbol, and there is a real definition, the
3513 processor independent code will have arranged for us to see the
3514 real definition first, and we can just use the same value. */
3515 if (h
->weakdef
!= NULL
)
3517 BFD_ASSERT (h
->weakdef
->root
.type
== bfd_link_hash_defined
3518 || h
->weakdef
->root
.type
== bfd_link_hash_defweak
);
3519 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
3520 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
3524 /* This is a reference to a symbol defined by a dynamic object which
3525 is not a function. */
3527 /* If we are creating a shared library, we must presume that the
3528 only references to the symbol are via the global offset table.
3529 For such cases we need not do anything here; the relocations will
3530 be handled correctly by relocate_section. */
3534 /* If there are no references to this symbol that do not use the
3535 GOT, we don't need to generate a copy reloc. */
3536 if ((h
->elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0)
3539 /* We must allocate the symbol in our .dynbss section, which will
3540 become part of the .bss section of the executable. There will be
3541 an entry for this symbol in the .dynsym section. The dynamic
3542 object will contain position independent code, so all references
3543 from the dynamic object to this symbol will go through the global
3544 offset table. The dynamic linker will use the .dynsym entry to
3545 determine the address it must put in the global offset table, so
3546 both the dynamic object and the regular object will refer to the
3547 same memory location for the variable. */
3549 s
= bfd_get_section_by_name (dynobj
, ".dynbss");
3550 BFD_ASSERT (s
!= NULL
);
3552 /* We must generate a R_SH_COPY reloc to tell the dynamic linker to
3553 copy the initial value out of the dynamic object and into the
3554 runtime process image. We need to remember the offset into the
3555 .rela.bss section we are going to use. */
3556 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
3560 srel
= bfd_get_section_by_name (dynobj
, ".rela.bss");
3561 BFD_ASSERT (srel
!= NULL
);
3562 srel
->_raw_size
+= sizeof (Elf64_External_Rela
);
3563 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_COPY
;
3566 /* We need to figure out the alignment required for this symbol. I
3567 have no idea how ELF linkers handle this. */
3568 power_of_two
= bfd_log2 (h
->size
);
3569 if (power_of_two
> 3)
3572 /* Apply the required alignment. */
3573 s
->_raw_size
= BFD_ALIGN (s
->_raw_size
,
3574 (bfd_size_type
) (1 << power_of_two
));
3575 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
3577 if (! bfd_set_section_alignment (dynobj
, s
, power_of_two
))
3581 /* Define the symbol as being at this point in the section. */
3582 h
->root
.u
.def
.section
= s
;
3583 h
->root
.u
.def
.value
= s
->_raw_size
;
3585 /* Increment the section size to make room for the symbol. */
3586 s
->_raw_size
+= h
->size
;
3591 /* This function is called via sh_elf_link_hash_traverse if we are
3592 creating a shared object with -Bsymbolic. It discards the space
3593 allocated to copy PC relative relocs against symbols which are
3594 defined in regular objects. We allocated space for them in the
3595 check_relocs routine, but we won't fill them in in the
3596 relocate_section routine. */
3599 sh64_elf64_discard_copies (h
, ignore
)
3600 struct elf_sh64_link_hash_entry
*h
;
3601 PTR ignore ATTRIBUTE_UNUSED
;
3603 struct elf_sh64_pcrel_relocs_copied
*s
;
3605 if (h
->root
.root
.type
== bfd_link_hash_warning
)
3606 h
= (struct elf_sh64_link_hash_entry
*) h
->root
.root
.u
.i
.link
;
3608 /* We only discard relocs for symbols defined in a regular object. */
3609 if ((h
->root
.elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
3612 for (s
= h
->pcrel_relocs_copied
; s
!= NULL
; s
= s
->next
)
3613 s
->section
->_raw_size
-= s
->count
* sizeof (Elf64_External_Rela
);
3618 /* Set the sizes of the dynamic sections. */
3621 sh64_elf64_size_dynamic_sections (output_bfd
, info
)
3623 struct bfd_link_info
*info
;
3631 dynobj
= elf_hash_table (info
)->dynobj
;
3632 BFD_ASSERT (dynobj
!= NULL
);
3634 if (elf_hash_table (info
)->dynamic_sections_created
)
3636 /* Set the contents of the .interp section to the interpreter. */
3639 s
= bfd_get_section_by_name (dynobj
, ".interp");
3640 BFD_ASSERT (s
!= NULL
);
3641 s
->_raw_size
= sizeof ELF_DYNAMIC_INTERPRETER
;
3642 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
3647 /* We may have created entries in the .rela.got section.
3648 However, if we are not creating the dynamic sections, we will
3649 not actually use these entries. Reset the size of .rela.got,
3650 which will cause it to get stripped from the output file
3652 s
= bfd_get_section_by_name (dynobj
, ".rela.got");
3657 /* If this is a -Bsymbolic shared link, then we need to discard all
3658 PC relative relocs against symbols defined in a regular object.
3659 We allocated space for them in the check_relocs routine, but we
3660 will not fill them in in the relocate_section routine. */
3661 if (info
->shared
&& info
->symbolic
)
3662 sh64_elf64_link_hash_traverse (sh64_elf64_hash_table (info
),
3663 sh64_elf64_discard_copies
,
3666 /* The check_relocs and adjust_dynamic_symbol entry points have
3667 determined the sizes of the various dynamic sections. Allocate
3672 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
3677 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
3680 /* It's OK to base decisions on the section name, because none
3681 of the dynobj section names depend upon the input files. */
3682 name
= bfd_get_section_name (dynobj
, s
);
3686 if (strcmp (name
, ".plt") == 0)
3688 if (s
->_raw_size
== 0)
3690 /* Strip this section if we don't need it; see the
3696 /* Remember whether there is a PLT. */
3700 else if (strncmp (name
, ".rela", 5) == 0)
3702 if (s
->_raw_size
== 0)
3704 /* If we don't need this section, strip it from the
3705 output file. This is mostly to handle .rela.bss and
3706 .rela.plt. We must create both sections in
3707 create_dynamic_sections, because they must be created
3708 before the linker maps input sections to output
3709 sections. The linker does that before
3710 adjust_dynamic_symbol is called, and it is that
3711 function which decides whether anything needs to go
3712 into these sections. */
3719 /* Remember whether there are any reloc sections other
3721 if (strcmp (name
, ".rela.plt") != 0)
3723 const char *outname
;
3727 /* If this relocation section applies to a read only
3728 section, then we probably need a DT_TEXTREL
3729 entry. The entries in the .rela.plt section
3730 really apply to the .got section, which we
3731 created ourselves and so know is not readonly. */
3732 outname
= bfd_get_section_name (output_bfd
,
3734 target
= bfd_get_section_by_name (output_bfd
, outname
+ 5);
3736 && (target
->flags
& SEC_READONLY
) != 0
3737 && (target
->flags
& SEC_ALLOC
) != 0)
3741 /* We use the reloc_count field as a counter if we need
3742 to copy relocs into the output file. */
3746 else if (strncmp (name
, ".got", 4) != 0)
3748 /* It's not one of our sections, so don't allocate space. */
3754 _bfd_strip_section_from_output (info
, s
);
3758 /* Allocate memory for the section contents. */
3759 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->_raw_size
);
3760 if (s
->contents
== NULL
&& s
->_raw_size
!= 0)
3764 if (elf_hash_table (info
)->dynamic_sections_created
)
3766 /* Add some entries to the .dynamic section. We fill in the
3767 values later, in sh64_elf64_finish_dynamic_sections, but we
3768 must add the entries now so that we get the correct size for
3769 the .dynamic section. The DT_DEBUG entry is filled in by the
3770 dynamic linker and used by the debugger. */
3773 if (! bfd_elf64_add_dynamic_entry (info
, DT_DEBUG
, 0))
3779 if (! bfd_elf64_add_dynamic_entry (info
, DT_PLTGOT
, 0)
3780 || ! bfd_elf64_add_dynamic_entry (info
, DT_PLTRELSZ
, 0)
3781 || ! bfd_elf64_add_dynamic_entry (info
, DT_PLTREL
, DT_RELA
)
3782 || ! bfd_elf64_add_dynamic_entry (info
, DT_JMPREL
, 0))
3788 if (! bfd_elf64_add_dynamic_entry (info
, DT_RELA
, 0)
3789 || ! bfd_elf64_add_dynamic_entry (info
, DT_RELASZ
, 0)
3790 || ! bfd_elf64_add_dynamic_entry (info
, DT_RELAENT
,
3791 sizeof (Elf64_External_Rela
)))
3797 if (! bfd_elf64_add_dynamic_entry (info
, DT_TEXTREL
, 0))
3805 /* Finish up dynamic symbol handling. We set the contents of various
3806 dynamic sections here. */
3809 sh64_elf64_finish_dynamic_symbol (output_bfd
, info
, h
, sym
)
3811 struct bfd_link_info
*info
;
3812 struct elf_link_hash_entry
*h
;
3813 Elf_Internal_Sym
*sym
;
3817 dynobj
= elf_hash_table (info
)->dynobj
;
3819 if (h
->plt
.offset
!= (bfd_vma
) -1)
3827 Elf_Internal_Rela rel
;
3830 /* This symbol has an entry in the procedure linkage table. Set
3833 BFD_ASSERT (h
->dynindx
!= -1);
3835 splt
= bfd_get_section_by_name (dynobj
, ".plt");
3836 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
3837 srel
= bfd_get_section_by_name (dynobj
, ".rela.plt");
3838 BFD_ASSERT (splt
!= NULL
&& sgot
!= NULL
&& srel
!= NULL
);
3840 /* Get the index in the procedure linkage table which
3841 corresponds to this symbol. This is the index of this symbol
3842 in all the symbols for which we are making plt entries. The
3843 first entry in the procedure linkage table is reserved. */
3844 plt_index
= h
->plt
.offset
/ elf_sh64_sizeof_plt (info
) - 1;
3846 /* Get the offset into the .got table of the entry that
3847 corresponds to this function. Each .got entry is 8 bytes.
3848 The first three are reserved. */
3849 got_offset
= (plt_index
+ 3) * 8;
3852 got_offset
-= GOT_BIAS
;
3854 /* Fill in the entry in the procedure linkage table. */
3857 if (elf_sh64_plt_entry
== NULL
)
3859 elf_sh64_plt_entry
= (bfd_big_endian (output_bfd
) ?
3860 elf_sh64_plt_entry_be
: elf_sh64_plt_entry_le
);
3862 memcpy (splt
->contents
+ h
->plt
.offset
, elf_sh64_plt_entry
,
3863 elf_sh64_sizeof_plt (info
));
3864 movi_3shori_putval (output_bfd
,
3865 (sgot
->output_section
->vma
3866 + sgot
->output_offset
3868 (splt
->contents
+ h
->plt
.offset
3869 + elf_sh64_plt_symbol_offset (info
)));
3871 /* Set bottom bit because its for a branch to SHmedia */
3872 movi_shori_putval (output_bfd
,
3874 + elf_sh64_plt_plt0_offset (info
) + 8)
3876 (splt
->contents
+ h
->plt
.offset
3877 + elf_sh64_plt_plt0_offset (info
)));
3881 if (elf_sh64_pic_plt_entry
== NULL
)
3883 elf_sh64_pic_plt_entry
= (bfd_big_endian (output_bfd
) ?
3884 elf_sh64_pic_plt_entry_be
:
3885 elf_sh64_pic_plt_entry_le
);
3887 memcpy (splt
->contents
+ h
->plt
.offset
, elf_sh64_pic_plt_entry
,
3888 elf_sh64_sizeof_plt (info
));
3889 movi_shori_putval (output_bfd
, got_offset
,
3890 (splt
->contents
+ h
->plt
.offset
3891 + elf_sh64_plt_symbol_offset (info
)));
3895 got_offset
+= GOT_BIAS
;
3897 movi_shori_putval (output_bfd
,
3898 plt_index
* sizeof (Elf64_External_Rela
),
3899 (splt
->contents
+ h
->plt
.offset
3900 + elf_sh64_plt_reloc_offset (info
)));
3902 /* Fill in the entry in the global offset table. */
3903 bfd_put_64 (output_bfd
,
3904 (splt
->output_section
->vma
3905 + splt
->output_offset
3907 + elf_sh64_plt_temp_offset (info
)),
3908 sgot
->contents
+ got_offset
);
3910 /* Fill in the entry in the .rela.plt section. */
3911 rel
.r_offset
= (sgot
->output_section
->vma
3912 + sgot
->output_offset
3914 rel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_SH_JMP_SLOT64
);
3916 rel
.r_addend
= GOT_BIAS
;
3917 loc
= srel
->contents
+ plt_index
* sizeof (Elf64_External_Rela
);
3918 bfd_elf64_swap_reloca_out (output_bfd
, &rel
, loc
);
3920 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
3922 /* Mark the symbol as undefined, rather than as defined in
3923 the .plt section. Leave the value alone. */
3924 sym
->st_shndx
= SHN_UNDEF
;
3928 if (h
->got
.offset
!= (bfd_vma
) -1)
3932 Elf_Internal_Rela rel
;
3935 /* This symbol has an entry in the global offset table. Set it
3938 sgot
= bfd_get_section_by_name (dynobj
, ".got");
3939 srel
= bfd_get_section_by_name (dynobj
, ".rela.got");
3940 BFD_ASSERT (sgot
!= NULL
&& srel
!= NULL
);
3942 rel
.r_offset
= (sgot
->output_section
->vma
3943 + sgot
->output_offset
3944 + (h
->got
.offset
&~ 1));
3946 /* If this is a -Bsymbolic link, and the symbol is defined
3947 locally, we just want to emit a RELATIVE reloc. Likewise if
3948 the symbol was forced to be local because of a version file.
3949 The entry in the global offset table will already have been
3950 initialized in the relocate_section function. */
3952 && (info
->symbolic
|| h
->dynindx
== -1)
3953 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
))
3955 rel
.r_info
= ELF64_R_INFO (0, R_SH_RELATIVE64
);
3956 rel
.r_addend
= (h
->root
.u
.def
.value
3957 + h
->root
.u
.def
.section
->output_section
->vma
3958 + h
->root
.u
.def
.section
->output_offset
);
3962 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ h
->got
.offset
);
3963 rel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_SH_GLOB_DAT64
);
3967 loc
= srel
->contents
;
3968 loc
+= srel
->reloc_count
++ * sizeof (Elf64_External_Rela
);
3969 bfd_elf64_swap_reloca_out (output_bfd
, &rel
, loc
);
3972 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_COPY
) != 0)
3975 Elf_Internal_Rela rel
;
3978 /* This symbol needs a copy reloc. Set it up. */
3980 BFD_ASSERT (h
->dynindx
!= -1
3981 && (h
->root
.type
== bfd_link_hash_defined
3982 || h
->root
.type
== bfd_link_hash_defweak
));
3984 s
= bfd_get_section_by_name (h
->root
.u
.def
.section
->owner
,
3986 BFD_ASSERT (s
!= NULL
);
3988 rel
.r_offset
= (h
->root
.u
.def
.value
3989 + h
->root
.u
.def
.section
->output_section
->vma
3990 + h
->root
.u
.def
.section
->output_offset
);
3991 rel
.r_info
= ELF64_R_INFO (h
->dynindx
, R_SH_COPY64
);
3994 loc
+= s
->reloc_count
++ * sizeof (Elf64_External_Rela
);
3995 bfd_elf64_swap_reloca_out (output_bfd
, &rel
, loc
);
3998 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
3999 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
4000 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0)
4001 sym
->st_shndx
= SHN_ABS
;
4006 /* Finish up the dynamic sections. */
4009 sh64_elf64_finish_dynamic_sections (output_bfd
, info
)
4011 struct bfd_link_info
*info
;
4017 dynobj
= elf_hash_table (info
)->dynobj
;
4019 sgot
= bfd_get_section_by_name (dynobj
, ".got.plt");
4020 BFD_ASSERT (sgot
!= NULL
);
4021 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
4023 if (elf_hash_table (info
)->dynamic_sections_created
)
4026 Elf64_External_Dyn
*dyncon
, *dynconend
;
4028 BFD_ASSERT (sdyn
!= NULL
);
4030 dyncon
= (Elf64_External_Dyn
*) sdyn
->contents
;
4031 dynconend
= (Elf64_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
4032 for (; dyncon
< dynconend
; dyncon
++)
4034 Elf_Internal_Dyn dyn
;
4037 struct elf_link_hash_entry
*h
;
4039 bfd_elf64_swap_dyn_in (dynobj
, dyncon
, &dyn
);
4047 name
= info
->init_function
;
4051 name
= info
->fini_function
;
4053 if (dyn
.d_un
.d_val
!= 0)
4055 h
= elf_link_hash_lookup (elf_hash_table (info
), name
,
4056 false, false, true);
4057 if (h
!= NULL
&& (h
->other
& STO_SH5_ISA32
))
4059 dyn
.d_un
.d_val
|= 1;
4060 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4072 s
= bfd_get_section_by_name (output_bfd
, name
);
4073 BFD_ASSERT (s
!= NULL
);
4074 dyn
.d_un
.d_ptr
= s
->vma
;
4075 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4079 s
= bfd_get_section_by_name (output_bfd
, ".rela.plt");
4080 BFD_ASSERT (s
!= NULL
);
4081 if (s
->_cooked_size
!= 0)
4082 dyn
.d_un
.d_val
= s
->_cooked_size
;
4084 dyn
.d_un
.d_val
= s
->_raw_size
;
4085 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4089 /* My reading of the SVR4 ABI indicates that the
4090 procedure linkage table relocs (DT_JMPREL) should be
4091 included in the overall relocs (DT_RELA). This is
4092 what Solaris does. However, UnixWare can not handle
4093 that case. Therefore, we override the DT_RELASZ entry
4094 here to make it not include the JMPREL relocs. Since
4095 the linker script arranges for .rela.plt to follow all
4096 other relocation sections, we don't have to worry
4097 about changing the DT_RELA entry. */
4098 s
= bfd_get_section_by_name (output_bfd
, ".rela.plt");
4101 if (s
->_cooked_size
!= 0)
4102 dyn
.d_un
.d_val
-= s
->_cooked_size
;
4104 dyn
.d_un
.d_val
-= s
->_raw_size
;
4106 bfd_elf64_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4111 /* Fill in the first entry in the procedure linkage table. */
4112 splt
= bfd_get_section_by_name (dynobj
, ".plt");
4113 if (splt
&& splt
->_raw_size
> 0)
4117 if (elf_sh64_pic_plt_entry
== NULL
)
4119 elf_sh64_pic_plt_entry
= (bfd_big_endian (output_bfd
) ?
4120 elf_sh64_pic_plt_entry_be
:
4121 elf_sh64_pic_plt_entry_le
);
4123 memcpy (splt
->contents
, elf_sh64_pic_plt_entry
,
4124 elf_sh64_sizeof_plt (info
));
4128 if (elf_sh64_plt0_entry
== NULL
)
4130 elf_sh64_plt0_entry
= (bfd_big_endian (output_bfd
) ?
4131 elf_sh64_plt0_entry_be
:
4132 elf_sh64_plt0_entry_le
);
4134 memcpy (splt
->contents
, elf_sh64_plt0_entry
, PLT_ENTRY_SIZE
);
4135 movi_3shori_putval (output_bfd
,
4136 sgot
->output_section
->vma
4137 + sgot
->output_offset
,
4139 + elf_sh64_plt0_gotplt_offset (info
));
4142 /* UnixWare sets the entsize of .plt to 8, although that doesn't
4143 really seem like the right value. */
4144 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
= 8;
4148 /* Fill in the first three entries in the global offset table. */
4149 if (sgot
->_raw_size
> 0)
4152 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
);
4154 bfd_put_64 (output_bfd
,
4155 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
4157 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 8);
4158 bfd_put_64 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ 16);
4161 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 8;
4166 #define TARGET_BIG_SYM bfd_elf64_sh64_vec
4167 #define TARGET_BIG_NAME "elf64-sh64"
4168 #define TARGET_LITTLE_SYM bfd_elf64_sh64l_vec
4169 #define TARGET_LITTLE_NAME "elf64-sh64l"
4170 #define ELF_ARCH bfd_arch_sh
4171 #define ELF_MACHINE_CODE EM_SH
4172 #define ELF_MAXPAGESIZE 128
4174 #define elf_symbol_leading_char '_'
4176 #define bfd_elf64_bfd_reloc_type_lookup sh_elf64_reloc_type_lookup
4177 #define elf_info_to_howto sh_elf64_info_to_howto
4179 /* Note: there's no relaxation at present. */
4181 #define elf_backend_relocate_section sh_elf64_relocate_section
4182 #define bfd_elf64_bfd_get_relocated_section_contents \
4183 sh_elf64_get_relocated_section_contents
4184 #define elf_backend_object_p sh_elf64_set_mach_from_flags
4185 #define bfd_elf64_bfd_set_private_flags \
4186 sh_elf64_set_private_flags
4187 #define bfd_elf64_bfd_copy_private_bfd_data \
4188 sh_elf64_copy_private_data
4189 #define bfd_elf64_bfd_merge_private_bfd_data \
4190 sh_elf64_merge_private_data
4191 #define elf_backend_fake_sections sh64_elf64_fake_sections
4193 #define elf_backend_gc_mark_hook sh_elf64_gc_mark_hook
4194 #define elf_backend_gc_sweep_hook sh_elf64_gc_sweep_hook
4195 #define elf_backend_check_relocs sh_elf64_check_relocs
4197 #define elf_backend_can_gc_sections 1
4199 #define elf_backend_get_symbol_type sh64_elf64_get_symbol_type
4201 #define elf_backend_add_symbol_hook sh64_elf64_add_symbol_hook
4203 #define elf_backend_link_output_symbol_hook \
4204 sh64_elf64_link_output_symbol_hook
4206 #define elf_backend_final_write_processing \
4207 sh64_elf64_final_write_processing
4209 #define elf_backend_create_dynamic_sections \
4210 sh64_elf64_create_dynamic_sections
4211 #define bfd_elf64_bfd_link_hash_table_create \
4212 sh64_elf64_link_hash_table_create
4213 #define elf_backend_adjust_dynamic_symbol \
4214 sh64_elf64_adjust_dynamic_symbol
4215 #define elf_backend_size_dynamic_sections \
4216 sh64_elf64_size_dynamic_sections
4217 #define elf_backend_finish_dynamic_symbol \
4218 sh64_elf64_finish_dynamic_symbol
4219 #define elf_backend_finish_dynamic_sections \
4220 sh64_elf64_finish_dynamic_sections
4222 #define elf_backend_want_got_plt 1
4223 #define elf_backend_plt_readonly 1
4224 #define elf_backend_want_plt_sym 0
4225 #define elf_backend_got_header_size 24
4226 #define elf_backend_plt_header_size PLT_ENTRY_SIZE
4228 #include "elf64-target.h"
4230 /* NetBSD support. */
4231 #undef TARGET_BIG_SYM
4232 #define TARGET_BIG_SYM bfd_elf64_sh64nbsd_vec
4233 #undef TARGET_BIG_NAME
4234 #define TARGET_BIG_NAME "elf64-sh64-nbsd"
4235 #undef TARGET_LITTLE_SYM
4236 #define TARGET_LITTLE_SYM bfd_elf64_sh64lnbsd_vec
4237 #undef TARGET_LITTLE_NAME
4238 #define TARGET_LITTLE_NAME "elf64-sh64l-nbsd"
4239 #undef ELF_MAXPAGESIZE
4240 #define ELF_MAXPAGESIZE 0x10000
4241 #undef elf_symbol_leading_char
4242 #define elf_symbol_leading_char 0
4244 #define elf64_bed elf64_sh64_nbsd_bed
4246 #include "elf64-target.h"
4248 /* Linux support. */
4249 #undef TARGET_BIG_SYM
4250 #define TARGET_BIG_SYM bfd_elf64_sh64blin_vec
4251 #undef TARGET_BIG_NAME
4252 #define TARGET_BIG_NAME "elf64-sh64big-linux"
4253 #undef TARGET_LITTLE_SYM
4254 #define TARGET_LITTLE_SYM bfd_elf64_sh64lin_vec
4255 #undef TARGET_LITTLE_NAME
4256 #define TARGET_LITTLE_NAME "elf64-sh64-linux"
4258 #define INCLUDED_TARGET_FILE
4259 #include "elf64-target.h"