home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / bfd / elf64-sparc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-04  |  17.0 KB  |  419 lines

  1. /* SPARC-specific support for 64-bit ELF
  2.    Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
  3.  
  4. This file is part of BFD, the Binary File Descriptor library.
  5.  
  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.
  10.  
  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.
  15.  
  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.  */
  19.  
  20. /* We need a published ABI spec for this.  Until one comes out, don't
  21.    assume this'll remain unchanged forever.  */
  22.  
  23. #include "bfd.h"
  24. #include "sysdep.h"
  25. #include "libbfd.h"
  26. #include "elf-bfd.h"
  27.  
  28. #define SPARC64_OLD_RELOCS
  29. #include "elf/sparc.h"
  30.  
  31. static reloc_howto_type *sparc64_elf_reloc_type_lookup
  32.   PARAMS ((bfd *, bfd_reloc_code_real_type));
  33. static void sparc64_elf_info_to_howto
  34.   PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
  35.  
  36. static boolean sparc64_elf_relocate_section
  37.   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
  38.        Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
  39. static boolean sparc64_elf_object_p PARAMS ((bfd *));
  40.  
  41. /* The howto table and associated functions.
  42.    ??? Some of the relocation values have changed.  Until we're ready
  43.    to upgrade, we have our own copy.  At some point a non upward compatible
  44.    change will be made at which point this table can be deleted and we'll
  45.    use the one in elf32-sparc.c.  */
  46.  
  47. static bfd_reloc_status_type sparc_elf_wdisp16_reloc
  48.   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
  49.  
  50. static reloc_howto_type sparc64_elf_howto_table[] = 
  51. {
  52.   HOWTO(R_SPARC_NONE,      0,0, 0,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_NONE",    false,0,0x00000000,true),
  53.   HOWTO(R_SPARC_8,         0,0, 8,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_8",       false,0,0x000000ff,true),
  54.   HOWTO(R_SPARC_16,        0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_16",      false,0,0x0000ffff,true),
  55.   HOWTO(R_SPARC_32,        0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_32",      false,0,0xffffffff,true),
  56.   HOWTO(R_SPARC_DISP8,     0,0, 8,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP8",   false,0,0x000000ff,true),
  57.   HOWTO(R_SPARC_DISP16,    0,1,16,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP16",  false,0,0x0000ffff,true),
  58.   HOWTO(R_SPARC_DISP32,    0,2,32,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP32",  false,0,0x00ffffff,true),
  59.   HOWTO(R_SPARC_WDISP30,   2,2,30,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WDISP30", false,0,0x3fffffff,true),
  60.   HOWTO(R_SPARC_WDISP22,   2,2,22,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WDISP22", false,0,0x003fffff,true),
  61.   HOWTO(R_SPARC_HI22,     10,2,22,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_HI22",    false,0,0x003fffff,true),
  62.   HOWTO(R_SPARC_22,        0,2,22,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_22",      false,0,0x003fffff,true),
  63.   HOWTO(R_SPARC_13,        0,2,13,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_13",      false,0,0x00001fff,true),
  64.   HOWTO(R_SPARC_LO10,      0,2,10,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_LO10",    false,0,0x000003ff,true),
  65.   HOWTO(R_SPARC_GOT10,     0,2,10,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_GOT10",   false,0,0x000003ff,true),
  66.   HOWTO(R_SPARC_GOT13,     0,2,13,false,0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_GOT13",   false,0,0x00001fff,true),
  67.   HOWTO(R_SPARC_GOT22,    10,2,22,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_GOT22",   false,0,0x003fffff,true),
  68.   HOWTO(R_SPARC_PC10,      0,2,10,true, 0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_PC10",    false,0,0x000003ff,true),
  69.   HOWTO(R_SPARC_PC22,     10,2,22,true, 0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_PC22",    false,0,0x003fffff,true),
  70.   HOWTO(R_SPARC_WPLT30,    2,2,30,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WPLT30",  false,0,0x3fffffff,true),
  71.   HOWTO(R_SPARC_COPY,      0,0,00,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_COPY",    false,0,0x00000000,true),
  72.   HOWTO(R_SPARC_GLOB_DAT,  0,0,00,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
  73.   HOWTO(R_SPARC_JMP_SLOT,  0,0,00,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_JMP_SLOT",false,0,0x00000000,true),
  74.   HOWTO(R_SPARC_RELATIVE,  0,0,00,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_RELATIVE",false,0,0x00000000,true),
  75.   HOWTO(R_SPARC_UA32,      0,0,00,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_UA32",    false,0,0x00000000,true),
  76. #if 0 /* not used yet */
  77.   HOWTO(R_SPARC_PLT32,     0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsupported_reloc,  "R_SPARC_PLT32",    false,0,0x00000000,true),
  78.   HOWTO(R_SPARC_HIPLT22,   0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsupported_reloc,  "R_SPARC_HIPLT22",  false,0,0x00000000,true),
  79.   HOWTO(R_SPARC_LOPLT10,   0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsupported_reloc,  "R_SPARC_LOPLT10",  false,0,0x00000000,true),
  80.   HOWTO(R_SPARC_PCPLT32,   0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsupported_reloc,  "R_SPARC_PCPLT32",  false,0,0x00000000,true),
  81.   HOWTO(R_SPARC_PCPLT22,   0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsupported_reloc,  "R_SPARC_PCPLT22",  false,0,0x00000000,true),
  82.   HOWTO(R_SPARC_PCPLT10,   0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsupported_reloc,  "R_SPARC_PCPLT10",  false,0,0x00000000,true),
  83. #endif
  84.   HOWTO(R_SPARC_10,        0,2,10,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_10",      false,0,0x000003ff,true),
  85.   HOWTO(R_SPARC_11,        0,2,11,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_11",      false,0,0x000007ff,true),
  86.   HOWTO(R_SPARC_64,        0,4,00,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_64",      false,0,~ (bfd_vma) 0, true),
  87.   HOWTO(R_SPARC_OLO10,     0,2,10,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_OLO10",   false,0,0x000003ff,true),
  88.   HOWTO(R_SPARC_HH22,     42,2,22,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_HH22",    false,0,0x003fffff,true),
  89.   HOWTO(R_SPARC_HM10,     32,2,10,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_HM10",    false,0,0x000003ff,true),
  90.   HOWTO(R_SPARC_LM22,     10,2,22,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_LM22",    false,0,0x003fffff,true),
  91.   HOWTO(R_SPARC_PC_HH22,  42,2,22,true, 0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_HH22",    false,0,0x003fffff,true),
  92.   HOWTO(R_SPARC_PC_HM10,  32,2,10,true, 0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_HM10",    false,0,0x000003ff,true),
  93.   HOWTO(R_SPARC_PC_LM22,  10,2,22,true, 0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_LM22",    false,0,0x003fffff,true),
  94.   HOWTO(R_SPARC_WDISP16,   2,2,16,true, 0,complain_overflow_signed,  sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", false,0,0x00000000,true),
  95.   HOWTO(R_SPARC_WDISP19,   2,2,22,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WDISP19", false,0,0x0007ffff,true),
  96.   HOWTO(R_SPARC_GLOB_JMP,  0,0,00,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_GLOB_JMP",false,0,0x00000000,true),
  97.   HOWTO(R_SPARC_7,         0,2, 7,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_7",       false,0,0x0000007f,true),
  98.   HOWTO(R_SPARC_5,         0,2, 5,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_5",       false,0,0x0000001f,true),
  99.   HOWTO(R_SPARC_6,         0,2, 6,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_6",       false,0,0x0000003f,true),
  100. };
  101.  
  102. struct elf_reloc_map {
  103.   unsigned char bfd_reloc_val;
  104.   unsigned char elf_reloc_val;
  105. };
  106.  
  107. static CONST struct elf_reloc_map sparc_reloc_map[] =
  108. {
  109.   { BFD_RELOC_NONE, R_SPARC_NONE, },
  110.   { BFD_RELOC_16, R_SPARC_16, },
  111.   { BFD_RELOC_8, R_SPARC_8 },
  112.   { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
  113.   /* ??? This might cause us to need separate functions in elf{32,64}-sparc.c
  114.      (we could still have just one table), but is this reloc ever used?  */
  115.   { BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits.  */
  116.   { BFD_RELOC_32, R_SPARC_32 },
  117.   { BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
  118.   { BFD_RELOC_HI22, R_SPARC_HI22 },
  119.   { BFD_RELOC_LO10, R_SPARC_LO10, },
  120.   { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
  121.   { BFD_RELOC_SPARC22, R_SPARC_22 },
  122.   { BFD_RELOC_SPARC13, R_SPARC_13 },
  123.   { BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
  124.   { BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
  125.   { BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
  126.   { BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
  127.   { BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
  128.   { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
  129.   { BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
  130.   { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
  131.   { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
  132.   { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
  133.   { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
  134.   /* ??? Doesn't dwarf use this?  */
  135. /*{ BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
  136.   {BFD_RELOC_SPARC_10, R_SPARC_10},
  137.   {BFD_RELOC_SPARC_11, R_SPARC_11},
  138.   {BFD_RELOC_SPARC_64, R_SPARC_64},
  139.   {BFD_RELOC_SPARC_OLO10, R_SPARC_OLO10},
  140.   {BFD_RELOC_SPARC_HH22, R_SPARC_HH22},
  141.   {BFD_RELOC_SPARC_HM10, R_SPARC_HM10},
  142.   {BFD_RELOC_SPARC_LM22, R_SPARC_LM22},
  143.   {BFD_RELOC_SPARC_PC_HH22, R_SPARC_PC_HH22},
  144.   {BFD_RELOC_SPARC_PC_HM10, R_SPARC_PC_HM10},
  145.   {BFD_RELOC_SPARC_PC_LM22, R_SPARC_PC_LM22},
  146.   {BFD_RELOC_SPARC_WDISP16, R_SPARC_WDISP16},
  147.   {BFD_RELOC_SPARC_WDISP19, R_SPARC_WDISP19},
  148.   {BFD_RELOC_SPARC_GLOB_JMP, R_SPARC_GLOB_JMP},
  149.   {BFD_RELOC_SPARC_7, R_SPARC_7},
  150.   {BFD_RELOC_SPARC_5, R_SPARC_5},
  151.   {BFD_RELOC_SPARC_6, R_SPARC_6},
  152. };
  153.  
  154. static reloc_howto_type *
  155. sparc64_elf_reloc_type_lookup (abfd, code)
  156.      bfd *abfd;
  157.      bfd_reloc_code_real_type code;
  158. {
  159.   unsigned int i;
  160.   for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++)
  161.     {
  162.       if (sparc_reloc_map[i].bfd_reloc_val == code)
  163.     return &sparc64_elf_howto_table[(int) sparc_reloc_map[i].elf_reloc_val];
  164.     }
  165.   return 0;
  166. }
  167.  
  168. static void
  169. sparc64_elf_info_to_howto (abfd, cache_ptr, dst)
  170.      bfd *abfd;
  171.      arelent *cache_ptr;
  172.      Elf64_Internal_Rela *dst;
  173. {
  174.   BFD_ASSERT (ELF64_R_TYPE (dst->r_info) < (unsigned int) R_SPARC_max);
  175.   cache_ptr->howto = &sparc64_elf_howto_table[ELF64_R_TYPE (dst->r_info)];
  176. }
  177.  
  178. /* Handle the WDISP16 reloc.  */
  179.  
  180. static bfd_reloc_status_type
  181. sparc_elf_wdisp16_reloc (abfd,
  182.              reloc_entry,
  183.              symbol,
  184.              data,
  185.              input_section,
  186.              output_bfd,
  187.              error_message)
  188.      bfd *abfd;
  189.      arelent *reloc_entry;
  190.      asymbol *symbol;
  191.      PTR data;
  192.      asection *input_section;
  193.      bfd *output_bfd;
  194.      char **error_message;
  195. {
  196.   bfd_vma relocation;
  197.   bfd_vma x;
  198.  
  199.   if (output_bfd != (bfd *) NULL
  200.       && (symbol->flags & BSF_SECTION_SYM) == 0
  201.       && (! reloc_entry->howto->partial_inplace
  202.       || reloc_entry->addend == 0))
  203.     {
  204.       reloc_entry->address += input_section->output_offset;
  205.       return bfd_reloc_ok;
  206.     }
  207.  
  208.   if (output_bfd != NULL)
  209.     return bfd_reloc_continue;
  210.  
  211.   if (reloc_entry->address > input_section->_cooked_size)
  212.     return bfd_reloc_outofrange;
  213.  
  214.   relocation = (symbol->value
  215.         + symbol->section->output_section->vma
  216.         + symbol->section->output_offset);
  217.   relocation += reloc_entry->addend;
  218.   relocation -=    (input_section->output_section->vma
  219.          + input_section->output_offset);
  220.   relocation -= reloc_entry->address;
  221.  
  222.   x = bfd_get_32 (abfd, (char *) data + reloc_entry->address);
  223.   x |= ((((relocation >> 2) & 0xc000) << 6)
  224.     | ((relocation >> 2) & 0x3fff));
  225.   bfd_put_32 (abfd, x, (char *) data + reloc_entry->address);
  226.  
  227.   if ((bfd_signed_vma) relocation < - 0x40000
  228.       || (bfd_signed_vma) relocation > 0x3ffff)
  229.     return bfd_reloc_overflow;
  230.   else
  231.     return bfd_reloc_ok;
  232. }
  233.  
  234. /* Relocate a SPARC64 ELF section.  */
  235.  
  236. static boolean
  237. sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
  238.                   contents, relocs, local_syms, local_sections)
  239.      bfd *output_bfd;
  240.      struct bfd_link_info *info;
  241.      bfd *input_bfd;
  242.      asection *input_section;
  243.      bfd_byte *contents;
  244.      Elf_Internal_Rela *relocs;
  245.      Elf_Internal_Sym *local_syms;
  246.      asection **local_sections;
  247. {
  248.   Elf_Internal_Shdr *symtab_hdr;
  249.   struct elf_link_hash_entry **sym_hashes;
  250.   Elf_Internal_Rela *rel;
  251.   Elf_Internal_Rela *relend;
  252.  
  253.   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
  254.   sym_hashes = elf_sym_hashes (input_bfd);
  255.  
  256.   rel = relocs;
  257.   relend = relocs + input_section->reloc_count;
  258.   for (; rel < relend; rel++)
  259.     {
  260.       int r_type;
  261.       reloc_howto_type *howto;
  262.       long r_symndx;
  263.       struct elf_link_hash_entry *h;
  264.       Elf_Internal_Sym *sym;
  265.       asection *sec;
  266.       bfd_vma relocation;
  267.       bfd_reloc_status_type r;
  268.  
  269.       r_type = ELF64_R_TYPE (rel->r_info);
  270.       if (r_type < 0 || r_type >= (int) R_SPARC_max)
  271.     {
  272.       bfd_set_error (bfd_error_bad_value);
  273.       return false;
  274.     }
  275.       howto = sparc64_elf_howto_table + r_type;
  276.  
  277.       r_symndx = ELF64_R_SYM (rel->r_info);
  278.  
  279.       if (info->relocateable)
  280.     {
  281.       /* This is a relocateable link.  We don't have to change
  282.          anything, unless the reloc is against a section symbol,
  283.          in which case we have to adjust according to where the
  284.          section symbol winds up in the output section.  */
  285.       if (r_symndx < symtab_hdr->sh_info)
  286.         {
  287.           sym = local_syms + r_symndx;
  288.           if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
  289.         {
  290.           sec = local_sections[r_symndx];
  291.           rel->r_addend += sec->output_offset + sym->st_value;
  292.         }
  293.         }
  294.  
  295.       continue;
  296.     }
  297.  
  298.       /* This is a final link.  */
  299.       h = NULL;
  300.       sym = NULL;
  301.       sec = NULL;
  302.       if (r_symndx < symtab_hdr->sh_info)
  303.     {
  304.       sym = local_syms + r_symndx;
  305.       sec = local_sections[r_symndx];
  306.       relocation = (sec->output_section->vma
  307.             + sec->output_offset
  308.             + sym->st_value);
  309.     }
  310.       else
  311.     {
  312.       h = sym_hashes[r_symndx - symtab_hdr->sh_info];
  313.       while (h->root.type == bfd_link_hash_indirect
  314.          || h->root.type == bfd_link_hash_warning)
  315.         h = (struct elf_link_hash_entry *) h->root.u.i.link;
  316.       if (h->root.type == bfd_link_hash_defined
  317.           || h->root.type == bfd_link_hash_defweak)
  318.         {
  319.           sec = h->root.u.def.section;
  320.           relocation = (h->root.u.def.value
  321.                 + sec->output_section->vma
  322.                 + sec->output_offset);
  323.         }
  324.       else if (h->root.type == bfd_link_hash_undefweak)
  325.         relocation = 0;
  326.       else
  327.         {
  328.           if (! ((*info->callbacks->undefined_symbol)
  329.              (info, h->root.root.string, input_bfd,
  330.               input_section, rel->r_offset)))
  331.         return false;
  332.           relocation = 0;
  333.         }
  334.     }
  335.  
  336.       if (r_type != R_SPARC_WDISP16)
  337.     r = _bfd_final_link_relocate (howto, input_bfd, input_section,
  338.                       contents, rel->r_offset,
  339.                       relocation, rel->r_addend);
  340.       else
  341.     {
  342.       bfd_vma x;
  343.  
  344.       relocation += rel->r_addend;
  345.       relocation -= (input_section->output_section->vma
  346.              + input_section->output_offset);
  347.       relocation -= rel->r_offset;
  348.  
  349.       x = bfd_get_32 (input_bfd, contents + rel->r_offset);
  350.       x |= ((((relocation >> 2) & 0xc000) << 6)
  351.         | ((relocation >> 2) & 0x3fff));
  352.       bfd_put_32 (input_bfd, x, contents + rel->r_offset);
  353.  
  354.       if ((bfd_signed_vma) relocation < - 0x40000
  355.           || (bfd_signed_vma) relocation > 0x3ffff)
  356.         r = bfd_reloc_overflow;
  357.       else
  358.         r = bfd_reloc_ok;
  359.     }
  360.  
  361.       if (r != bfd_reloc_ok)
  362.     {
  363.       switch (r)
  364.         {
  365.         default:
  366.         case bfd_reloc_outofrange:
  367.           abort ();
  368.         case bfd_reloc_overflow:
  369.           {
  370.         const char *name;
  371.  
  372.         if (h != NULL)
  373.           name = h->root.root.string;
  374.         else
  375.           {
  376.             name = (bfd_elf_string_from_elf_section
  377.                 (input_bfd,
  378.                  symtab_hdr->sh_link,
  379.                  sym->st_name));
  380.             if (name == NULL)
  381.               return false;
  382.             if (*name == '\0')
  383.               name = bfd_section_name (input_bfd, sec);
  384.           }
  385.         if (! ((*info->callbacks->reloc_overflow)
  386.                (info, name, howto->name, (bfd_vma) 0,
  387.             input_bfd, input_section, rel->r_offset)))
  388.           return false;
  389.           }
  390.           break;
  391.         }
  392.     }
  393.     }
  394.  
  395.   return true;
  396. }
  397.  
  398. /* Set the right machine number for a SPARC64 ELF file.  */
  399.  
  400. static boolean
  401. sparc64_elf_object_p (abfd)
  402.      bfd *abfd;
  403. {
  404.   return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc_v9);
  405. }
  406.  
  407. #define TARGET_BIG_SYM    bfd_elf64_sparc_vec
  408. #define TARGET_BIG_NAME    "elf64-sparc"
  409. #define ELF_ARCH    bfd_arch_sparc
  410. #define ELF_MACHINE_CODE EM_SPARC64
  411. #define ELF_MAXPAGESIZE 0x100000
  412.  
  413. #define elf_info_to_howto        sparc64_elf_info_to_howto
  414. #define bfd_elf64_bfd_reloc_type_lookup    sparc64_elf_reloc_type_lookup
  415. #define elf_backend_relocate_section    sparc64_elf_relocate_section
  416. #define elf_backend_object_p        sparc64_elf_object_p
  417.  
  418. #include "elf64-target.h"
  419.