1*3d8817e4Smiod /* SPARC ELF specific backend routines. 2*3d8817e4Smiod Copyright 2005 Free Software Foundation, Inc. 3*3d8817e4Smiod 4*3d8817e4Smiod This file is part of BFD, the Binary File Descriptor library. 5*3d8817e4Smiod 6*3d8817e4Smiod This program is free software; you can redistribute it and/or modify 7*3d8817e4Smiod it under the terms of the GNU General Public License as published by 8*3d8817e4Smiod the Free Software Foundation; either version 2 of the License, or 9*3d8817e4Smiod (at your option) any later version. 10*3d8817e4Smiod 11*3d8817e4Smiod This program is distributed in the hope that it will be useful, 12*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of 13*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*3d8817e4Smiod GNU General Public License for more details. 15*3d8817e4Smiod 16*3d8817e4Smiod You should have received a copy of the GNU General Public License 17*3d8817e4Smiod along with this program; if not, write to the Free Software 18*3d8817e4Smiod Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 19*3d8817e4Smiod 20*3d8817e4Smiod #include "elf/common.h" 21*3d8817e4Smiod #include "elf/internal.h" 22*3d8817e4Smiod 23*3d8817e4Smiod struct _bfd_sparc_elf_section_data 24*3d8817e4Smiod { 25*3d8817e4Smiod struct bfd_elf_section_data elf; 26*3d8817e4Smiod unsigned int do_relax, reloc_count; 27*3d8817e4Smiod }; 28*3d8817e4Smiod 29*3d8817e4Smiod #define sec_do_relax(sec) \ 30*3d8817e4Smiod ((struct _bfd_sparc_elf_section_data *) elf_section_data (sec))->do_relax 31*3d8817e4Smiod #define canon_reloc_count(sec) \ 32*3d8817e4Smiod ((struct _bfd_sparc_elf_section_data *) elf_section_data (sec))->reloc_count 33*3d8817e4Smiod 34*3d8817e4Smiod struct _bfd_sparc_elf_app_reg 35*3d8817e4Smiod { 36*3d8817e4Smiod unsigned char bind; 37*3d8817e4Smiod unsigned short shndx; 38*3d8817e4Smiod bfd *abfd; 39*3d8817e4Smiod char *name; 40*3d8817e4Smiod }; 41*3d8817e4Smiod 42*3d8817e4Smiod /* Sparc ELF linker hash table. */ 43*3d8817e4Smiod 44*3d8817e4Smiod struct _bfd_sparc_elf_link_hash_table 45*3d8817e4Smiod { 46*3d8817e4Smiod struct elf_link_hash_table elf; 47*3d8817e4Smiod 48*3d8817e4Smiod /* Short-cuts to get to dynamic linker sections. */ 49*3d8817e4Smiod asection *sgot; 50*3d8817e4Smiod asection *srelgot; 51*3d8817e4Smiod asection *splt; 52*3d8817e4Smiod asection *srelplt; 53*3d8817e4Smiod asection *sdynbss; 54*3d8817e4Smiod asection *srelbss; 55*3d8817e4Smiod 56*3d8817e4Smiod union { 57*3d8817e4Smiod bfd_signed_vma refcount; 58*3d8817e4Smiod bfd_vma offset; 59*3d8817e4Smiod } tls_ldm_got; 60*3d8817e4Smiod 61*3d8817e4Smiod /* Small local sym to section mapping cache. */ 62*3d8817e4Smiod struct sym_sec_cache sym_sec; 63*3d8817e4Smiod 64*3d8817e4Smiod /* True if the target system is VxWorks. */ 65*3d8817e4Smiod int is_vxworks; 66*3d8817e4Smiod 67*3d8817e4Smiod /* The (unloaded but important) .rela.plt.unloaded section, for VxWorks. */ 68*3d8817e4Smiod asection *srelplt2; 69*3d8817e4Smiod 70*3d8817e4Smiod /* .got.plt is only used on VxWorks. */ 71*3d8817e4Smiod asection *sgotplt; 72*3d8817e4Smiod 73*3d8817e4Smiod void (*put_word) (bfd *, bfd_vma, void *); 74*3d8817e4Smiod bfd_vma (*r_info) (Elf_Internal_Rela *, bfd_vma, bfd_vma); 75*3d8817e4Smiod bfd_vma (*r_symndx) (bfd_vma); 76*3d8817e4Smiod int (*build_plt_entry) (bfd *, asection *, bfd_vma, bfd_vma, bfd_vma *); 77*3d8817e4Smiod const char *dynamic_interpreter; 78*3d8817e4Smiod int dynamic_interpreter_size; 79*3d8817e4Smiod unsigned int word_align_power; 80*3d8817e4Smiod unsigned int align_power_max; 81*3d8817e4Smiod unsigned int plt_header_size; 82*3d8817e4Smiod unsigned int plt_entry_size; 83*3d8817e4Smiod int bytes_per_word; 84*3d8817e4Smiod int bytes_per_rela; 85*3d8817e4Smiod int dtpoff_reloc; 86*3d8817e4Smiod int dtpmod_reloc; 87*3d8817e4Smiod int tpoff_reloc; 88*3d8817e4Smiod 89*3d8817e4Smiod struct _bfd_sparc_elf_app_reg app_regs [4]; 90*3d8817e4Smiod }; 91*3d8817e4Smiod 92*3d8817e4Smiod /* Get the SPARC ELF linker hash table from a link_info structure. */ 93*3d8817e4Smiod 94*3d8817e4Smiod #define _bfd_sparc_elf_hash_table(p) \ 95*3d8817e4Smiod ((struct _bfd_sparc_elf_link_hash_table *) ((p)->hash)) 96*3d8817e4Smiod 97*3d8817e4Smiod extern reloc_howto_type *_bfd_sparc_elf_reloc_type_lookup 98*3d8817e4Smiod (bfd *, bfd_reloc_code_real_type); 99*3d8817e4Smiod extern void _bfd_sparc_elf_info_to_howto 100*3d8817e4Smiod (bfd *, arelent *, Elf_Internal_Rela *); 101*3d8817e4Smiod extern reloc_howto_type *_bfd_sparc_elf_info_to_howto_ptr 102*3d8817e4Smiod (unsigned int); 103*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_mkobject 104*3d8817e4Smiod (bfd *); 105*3d8817e4Smiod extern struct bfd_link_hash_table *_bfd_sparc_elf_link_hash_table_create 106*3d8817e4Smiod (bfd *); 107*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_create_dynamic_sections 108*3d8817e4Smiod (bfd *, struct bfd_link_info *); 109*3d8817e4Smiod extern void _bfd_sparc_elf_copy_indirect_symbol 110*3d8817e4Smiod (struct bfd_link_info *, 111*3d8817e4Smiod struct elf_link_hash_entry *, 112*3d8817e4Smiod struct elf_link_hash_entry *); 113*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_check_relocs 114*3d8817e4Smiod (bfd *, struct bfd_link_info *, 115*3d8817e4Smiod asection *, const Elf_Internal_Rela *); 116*3d8817e4Smiod extern asection *_bfd_sparc_elf_gc_mark_hook 117*3d8817e4Smiod (asection *, struct bfd_link_info *, 118*3d8817e4Smiod Elf_Internal_Rela *, struct elf_link_hash_entry *, 119*3d8817e4Smiod Elf_Internal_Sym *); 120*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_gc_sweep_hook 121*3d8817e4Smiod (bfd *, struct bfd_link_info *, 122*3d8817e4Smiod asection *, const Elf_Internal_Rela *); 123*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_adjust_dynamic_symbol 124*3d8817e4Smiod (struct bfd_link_info *, struct elf_link_hash_entry *); 125*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_omit_section_dynsym 126*3d8817e4Smiod (bfd *, struct bfd_link_info *, asection *); 127*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_size_dynamic_sections 128*3d8817e4Smiod (bfd *, struct bfd_link_info *); 129*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_new_section_hook 130*3d8817e4Smiod (bfd *, asection *); 131*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_relax_section 132*3d8817e4Smiod (bfd *, struct bfd_section *, struct bfd_link_info *, bfd_boolean *); 133*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_relocate_section 134*3d8817e4Smiod (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 135*3d8817e4Smiod Elf_Internal_Rela *, Elf_Internal_Sym *, asection **); 136*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_finish_dynamic_symbol 137*3d8817e4Smiod (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, 138*3d8817e4Smiod Elf_Internal_Sym *sym); 139*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_finish_dynamic_sections 140*3d8817e4Smiod (bfd *, struct bfd_link_info *); 141*3d8817e4Smiod extern bfd_boolean _bfd_sparc_elf_object_p 142*3d8817e4Smiod (bfd *); 143*3d8817e4Smiod extern bfd_vma _bfd_sparc_elf_plt_sym_val 144*3d8817e4Smiod (bfd_vma, const asection *, const arelent *); 145