1214082Sdim/* SPARC ELF specific backend routines. 2214634Sdim Copyright 2005, 2007 Free Software Foundation, Inc. 3214082Sdim 4214082SdimThis file is part of BFD, the Binary File Descriptor library. 5214082Sdim 6214082SdimThis program is free software; you can redistribute it and/or modify 7214082Sdimit under the terms of the GNU General Public License as published by 8214082Sdimthe Free Software Foundation; either version 2 of the License, or 9214082Sdim(at your option) any later version. 10214082Sdim 11214082SdimThis program is distributed in the hope that it will be useful, 12214082Sdimbut WITHOUT ANY WARRANTY; without even the implied warranty of 13214082SdimMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14214082SdimGNU General Public License for more details. 15214082Sdim 16214082SdimYou should have received a copy of the GNU General Public License 17214082Sdimalong with this program; if not, write to the Free Software 18214082SdimFoundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 19214082Sdim 20214082Sdim#include "elf/common.h" 21214082Sdim#include "elf/internal.h" 22214082Sdim 23214082Sdimstruct _bfd_sparc_elf_section_data 24214082Sdim{ 25214082Sdim struct bfd_elf_section_data elf; 26214082Sdim unsigned int do_relax, reloc_count; 27214082Sdim}; 28214082Sdim 29214082Sdim#define sec_do_relax(sec) \ 30214082Sdim ((struct _bfd_sparc_elf_section_data *) elf_section_data (sec))->do_relax 31214082Sdim#define canon_reloc_count(sec) \ 32214082Sdim ((struct _bfd_sparc_elf_section_data *) elf_section_data (sec))->reloc_count 33214082Sdim 34214082Sdimstruct _bfd_sparc_elf_app_reg 35214082Sdim{ 36214082Sdim unsigned char bind; 37214082Sdim unsigned short shndx; 38214082Sdim bfd *abfd; 39214082Sdim char *name; 40214082Sdim}; 41214082Sdim 42214082Sdim/* Sparc ELF linker hash table. */ 43214082Sdim 44214082Sdimstruct _bfd_sparc_elf_link_hash_table 45214082Sdim{ 46214082Sdim struct elf_link_hash_table elf; 47214082Sdim 48214082Sdim /* Short-cuts to get to dynamic linker sections. */ 49214082Sdim asection *sgot; 50214082Sdim asection *srelgot; 51214082Sdim asection *splt; 52214082Sdim asection *srelplt; 53214082Sdim asection *sdynbss; 54214082Sdim asection *srelbss; 55214082Sdim 56214082Sdim union { 57214082Sdim bfd_signed_vma refcount; 58214082Sdim bfd_vma offset; 59214082Sdim } tls_ldm_got; 60214082Sdim 61214082Sdim /* Small local sym to section mapping cache. */ 62214082Sdim struct sym_sec_cache sym_sec; 63214082Sdim 64214082Sdim /* True if the target system is VxWorks. */ 65214082Sdim int is_vxworks; 66214082Sdim 67214082Sdim /* The (unloaded but important) .rela.plt.unloaded section, for VxWorks. */ 68214082Sdim asection *srelplt2; 69214082Sdim 70214082Sdim /* .got.plt is only used on VxWorks. */ 71214082Sdim asection *sgotplt; 72214082Sdim 73214082Sdim void (*put_word) (bfd *, bfd_vma, void *); 74214082Sdim bfd_vma (*r_info) (Elf_Internal_Rela *, bfd_vma, bfd_vma); 75214082Sdim bfd_vma (*r_symndx) (bfd_vma); 76214082Sdim int (*build_plt_entry) (bfd *, asection *, bfd_vma, bfd_vma, bfd_vma *); 77214082Sdim const char *dynamic_interpreter; 78214082Sdim int dynamic_interpreter_size; 79214082Sdim unsigned int word_align_power; 80214082Sdim unsigned int align_power_max; 81214082Sdim unsigned int plt_header_size; 82214082Sdim unsigned int plt_entry_size; 83214082Sdim int bytes_per_word; 84214082Sdim int bytes_per_rela; 85214082Sdim int dtpoff_reloc; 86214082Sdim int dtpmod_reloc; 87214082Sdim int tpoff_reloc; 88214082Sdim 89214082Sdim struct _bfd_sparc_elf_app_reg app_regs [4]; 90214082Sdim}; 91214082Sdim 92214082Sdim/* Get the SPARC ELF linker hash table from a link_info structure. */ 93214082Sdim 94214082Sdim#define _bfd_sparc_elf_hash_table(p) \ 95214082Sdim ((struct _bfd_sparc_elf_link_hash_table *) ((p)->hash)) 96214082Sdim 97214082Sdimextern reloc_howto_type *_bfd_sparc_elf_reloc_type_lookup 98214082Sdim (bfd *, bfd_reloc_code_real_type); 99214634Sdimextern reloc_howto_type *_bfd_sparc_elf_reloc_name_lookup 100214634Sdim (bfd *, const char *); 101214082Sdimextern void _bfd_sparc_elf_info_to_howto 102214082Sdim (bfd *, arelent *, Elf_Internal_Rela *); 103214082Sdimextern reloc_howto_type *_bfd_sparc_elf_info_to_howto_ptr 104214082Sdim (unsigned int); 105214082Sdimextern bfd_boolean _bfd_sparc_elf_mkobject 106214082Sdim (bfd *); 107214082Sdimextern struct bfd_link_hash_table *_bfd_sparc_elf_link_hash_table_create 108214082Sdim (bfd *); 109214082Sdimextern bfd_boolean _bfd_sparc_elf_create_dynamic_sections 110214082Sdim (bfd *, struct bfd_link_info *); 111214082Sdimextern void _bfd_sparc_elf_copy_indirect_symbol 112214082Sdim (struct bfd_link_info *, 113214082Sdim struct elf_link_hash_entry *, 114214082Sdim struct elf_link_hash_entry *); 115214082Sdimextern bfd_boolean _bfd_sparc_elf_check_relocs 116214082Sdim (bfd *, struct bfd_link_info *, 117214082Sdim asection *, const Elf_Internal_Rela *); 118214082Sdimextern asection *_bfd_sparc_elf_gc_mark_hook 119214082Sdim (asection *, struct bfd_link_info *, 120214082Sdim Elf_Internal_Rela *, struct elf_link_hash_entry *, 121214082Sdim Elf_Internal_Sym *); 122214082Sdimextern bfd_boolean _bfd_sparc_elf_gc_sweep_hook 123214082Sdim (bfd *, struct bfd_link_info *, 124214082Sdim asection *, const Elf_Internal_Rela *); 125214082Sdimextern bfd_boolean _bfd_sparc_elf_adjust_dynamic_symbol 126214082Sdim (struct bfd_link_info *, struct elf_link_hash_entry *); 127214082Sdimextern bfd_boolean _bfd_sparc_elf_omit_section_dynsym 128214082Sdim (bfd *, struct bfd_link_info *, asection *); 129214082Sdimextern bfd_boolean _bfd_sparc_elf_size_dynamic_sections 130214082Sdim (bfd *, struct bfd_link_info *); 131214082Sdimextern bfd_boolean _bfd_sparc_elf_new_section_hook 132214082Sdim (bfd *, asection *); 133214082Sdimextern bfd_boolean _bfd_sparc_elf_relax_section 134214082Sdim (bfd *, struct bfd_section *, struct bfd_link_info *, bfd_boolean *); 135214082Sdimextern bfd_boolean _bfd_sparc_elf_relocate_section 136214082Sdim (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 137214082Sdim Elf_Internal_Rela *, Elf_Internal_Sym *, asection **); 138214082Sdimextern bfd_boolean _bfd_sparc_elf_finish_dynamic_symbol 139214082Sdim (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, 140214082Sdim Elf_Internal_Sym *sym); 141214082Sdimextern bfd_boolean _bfd_sparc_elf_finish_dynamic_sections 142214082Sdim (bfd *, struct bfd_link_info *); 143214082Sdimextern bfd_boolean _bfd_sparc_elf_object_p 144214082Sdim (bfd *); 145214082Sdimextern bfd_vma _bfd_sparc_elf_plt_sym_val 146214082Sdim (bfd_vma, const asection *, const arelent *); 147