home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / src / binutils.2 / bfd / elf32-sp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-30  |  6.1 KB  |  151 lines

  1. /* SPARC-specific support for 32-bit ELF
  2.    Copyright 1993 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include "bfd.h"
  21. #include "sysdep.h"
  22. #include "libbfd.h"
  23. #include "libelf.h"
  24.  
  25. enum reloc_type
  26.   {
  27.     R_SPARC_NONE = 0,
  28.     R_SPARC_8,        R_SPARC_16,        R_SPARC_32, 
  29.     R_SPARC_DISP8,    R_SPARC_DISP16,        R_SPARC_DISP32, 
  30.     R_SPARC_WDISP30,    R_SPARC_WDISP22,
  31.     R_SPARC_HI22,    R_SPARC_22,
  32.     R_SPARC_13,        R_SPARC_LO10,
  33.     R_SPARC_GOT10,    R_SPARC_GOT13,        R_SPARC_GOT22,
  34.     R_SPARC_PC10,    R_SPARC_PC22,
  35.     R_SPARC_WPLT30,
  36.     R_SPARC_COPY,
  37.     R_SPARC_GLOB_DAT,    R_SPARC_JMP_SLOT,
  38.     R_SPARC_RELATIVE,
  39.     R_SPARC_UA32,
  40.     R_SPARC_max
  41.   };
  42.  
  43. #if 0
  44. static CONST char *CONST reloc_type_names[] =
  45. {
  46.   "R_SPARC_NONE",
  47.   "R_SPARC_8",        "R_SPARC_16",        "R_SPARC_32",
  48.   "R_SPARC_DISP8",    "R_SPARC_DISP16",    "R_SPARC_DISP32",
  49.   "R_SPARC_WDISP30",    "R_SPARC_WDISP22",
  50.   "R_SPARC_HI22",    "R_SPARC_22",
  51.   "R_SPARC_13",        "R_SPARC_LO10",
  52.   "R_SPARC_GOT10",    "R_SPARC_GOT13",    "R_SPARC_GOT22",
  53.   "R_SPARC_PC10",    "R_SPARC_PC22",
  54.   "R_SPARC_WPLT30",
  55.   "R_SPARC_COPY",
  56.   "R_SPARC_GLOB_DAT",    "R_SPARC_JMP_SLOT",
  57.   "R_SPARC_RELATIVE",
  58.   "R_SPARC_UA32",
  59. };
  60. #endif
  61.  
  62. static reloc_howto_type elf_sparc_howto_table[] = 
  63. {
  64.   HOWTO(R_SPARC_NONE,   0,0, 0,false,0,false,false, 0,"R_SPARC_NONE",   false,0,0x00000000,false),
  65.   HOWTO(R_SPARC_8,      0,0, 8,false,0,true,  true, 0,"R_SPARC_8",      false,0,0x000000ff,false),
  66.   HOWTO(R_SPARC_16,     0,1,16,false,0,true,  true, 0,"R_SPARC_16",     false,0,0x0000ffff,false),
  67.   HOWTO(R_SPARC_32,     0,2,32,false,0,true,  true, 0,"R_SPARC_32",     false,0,0xffffffff,false),
  68.   HOWTO(R_SPARC_DISP8,  0,0, 8,true, 0,false, true, 0,"R_SPARC_DISP8",  false,0,0x000000ff,false),
  69.   HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,false, true, 0,"R_SPARC_DISP16", false,0,0x0000ffff,false),
  70.   HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,false, true, 0,"R_SPARC_DISP32", false,0,0x00ffffff,false),
  71.   HOWTO(R_SPARC_WDISP30,2,2,30,true, 0,false, true, 0,"R_SPARC_WDISP30",false,0,0x3fffffff,false),
  72.   HOWTO(R_SPARC_WDISP22,2,2,22,true, 0,false, true, 0,"R_SPARC_WDISP22",false,0,0x003fffff,false),
  73.   HOWTO(R_SPARC_HI22,  10,2,22,false,0,true, false, 0,"R_SPARC_HI22",   false,0,0x003fffff,false),
  74.   HOWTO(R_SPARC_22,     0,2,22,false,0,true,  true, 0,"R_SPARC_22",     false,0,0x003fffff,false),
  75.   HOWTO(R_SPARC_13,     0,1,13,false,0,true,  true, 0,"R_SPARC_13",     false,0,0x00001fff,false),
  76.   HOWTO(R_SPARC_LO10,   0,1,10,false,0,true, false, 0,"R_SPARC_LO10",   false,0,0x000003ff,false),
  77.   HOWTO(R_SPARC_GOT10,  0,1,10,false,0,false, true, 0,"R_SPARC_GOT10",  false,0,0x000003ff,false),
  78.   HOWTO(R_SPARC_GOT13,  0,1,13,false,0,false, true, 0,"R_SPARC_GOT13",  false,0,0x00001fff,false),
  79.   HOWTO(R_SPARC_GOT22, 10,2,22,false,0,false, true, 0,"R_SPARC_GOT22",  false,0,0x003fffff,false),
  80.   HOWTO(R_SPARC_PC10,   0,1,10,false,0,true,  true, 0,"R_SPARC_PC10",   false,0,0x000003ff,false),
  81.   HOWTO(R_SPARC_PC22,   0,2,22,false,0,true,  true, 0,"R_SPARC_PC22",   false,0,0x003fffff,false),
  82.   HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,false,false, 0,"R_SPARC_WPLT30", false,0,0x00000000,false),
  83.   HOWTO(R_SPARC_COPY,   0,0,00,false,0,false,false, 0,"R_SPARC_COPY",   false,0,0x00000000,false),
  84.   HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,false,false,0,"R_SPARC_GLOB_DAT",false,0,0x00000000,false),
  85.   HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,false,false,0,"R_SPARC_JMP_SLOT",false,0,0x00000000,false),
  86.   HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,false,false,0,"R_SPARC_RELATIVE",false,0,0x00000000,false),
  87.   HOWTO(R_SPARC_UA32,    0,0,00,false,0,false,false,0,"R_SPARC_UA32",    false,0,0x00000000,false),
  88. };
  89.  
  90. struct elf_reloc_map {
  91.   unsigned char bfd_reloc_val;
  92.   unsigned char elf_reloc_val;
  93. };
  94.  
  95. static CONST struct elf_reloc_map sparc_reloc_map[] =
  96. {
  97.   { BFD_RELOC_NONE, R_SPARC_NONE, },
  98.   { BFD_RELOC_16, R_SPARC_16, },
  99.   { BFD_RELOC_8, R_SPARC_8 },
  100.   { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
  101.   { BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits.  */
  102.   { BFD_RELOC_32, R_SPARC_32 },
  103.   { BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
  104.   { BFD_RELOC_HI22, R_SPARC_HI22 },
  105.   { BFD_RELOC_LO10, R_SPARC_LO10, },
  106.   { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
  107.   { BFD_RELOC_SPARC22, R_SPARC_22 },
  108.   { BFD_RELOC_SPARC13, R_SPARC_13 },
  109.   { BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
  110.   { BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
  111.   { BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
  112.   { BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
  113.   { BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
  114.   { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
  115.   { BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
  116.   { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
  117.   { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
  118.   { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
  119.   /*  { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
  120. };
  121.  
  122. static CONST struct reloc_howto_struct *
  123. DEFUN (elf_bfd_reloc_type_lookup, (abfd, code),
  124.        bfd *abfd AND
  125.        bfd_reloc_code_real_type code)
  126. {
  127.   int i;
  128.   for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++)
  129.     {
  130.       if (sparc_reloc_map[i].bfd_reloc_val == code)
  131.     return &elf_sparc_howto_table[(int) sparc_reloc_map[i].elf_reloc_val];
  132.     }
  133.   return 0;
  134. }
  135.  
  136. static void
  137. DEFUN (elf_info_to_howto, (abfd, cache_ptr, dst),
  138.        bfd *abfd AND
  139.        arelent *cache_ptr AND
  140.        Elf_Internal_Rela *dst)
  141. {
  142.   BFD_ASSERT (ELF_R_TYPE(dst->r_info) < (unsigned int) R_SPARC_max);
  143.   cache_ptr->howto = &elf_sparc_howto_table[ELF_R_TYPE(dst->r_info)];
  144. }
  145.  
  146. #define TARGET_BIG_SYM    elf32_sparc_vec
  147. #define TARGET_BIG_NAME    "elf32-sparc"
  148. #define ELF_ARCH    bfd_arch_sparc
  149.  
  150. #include "elf32-target.h"
  151.