Home | History | Annotate | Download | only in libebl
      1 /* SPARC specific symbolic name handling.
      2    Copyright (C) 2002, 2003 Red Hat, Inc.
      3    Written by Jakub Jelinek <jakub (at) redhat.com>, 2002.
      4 
      5    This program is Open Source software; you can redistribute it and/or
      6    modify it under the terms of the Open Software License version 1.0 as
      7    published by the Open Source Initiative.
      8 
      9    You should have received a copy of the Open Software License along
     10    with this program; if not, you may obtain a copy of the Open Software
     11    License version 1.0 from http://www.opensource.org/licenses/osl.php or
     12    by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
     13    3001 King Ranch Road, Ukiah, CA 95482.   */
     14 
     15 #ifdef HAVE_CONFIG_H
     16 # include <config.h>
     17 #endif
     18 
     19 #include <elf.h>
     20 #include <stddef.h>
     21 
     22 #include <libebl_sparc.h>
     23 
     24 
     25 /* Return of the backend.  */
     26 const char *
     27 sparc_backend_name (void)
     28 {
     29   return "sparc";
     30 }
     31 
     32 
     33 /* Relocation mapping table.  */
     34 static const char *reloc_map_table[] =
     35   {
     36     [R_SPARC_NONE] = "R_SPARC_NONE",
     37     [R_SPARC_8] = "R_SPARC_8",
     38     [R_SPARC_16] = "R_SPARC_16",
     39     [R_SPARC_32] = "R_SPARC_32",
     40     [R_SPARC_DISP8] = "R_SPARC_DISP8",
     41     [R_SPARC_DISP16] = "R_SPARC_DISP16",
     42     [R_SPARC_DISP32] = "R_SPARC_DISP32",
     43     [R_SPARC_WDISP30] = "R_SPARC_WDISP30",
     44     [R_SPARC_WDISP22] = "R_SPARC_WDISP22",
     45     [R_SPARC_HI22] = "R_SPARC_HI22",
     46     [R_SPARC_22] = "R_SPARC_22",
     47     [R_SPARC_13] = "R_SPARC_13",
     48     [R_SPARC_LO10] = "R_SPARC_LO10",
     49     [R_SPARC_GOT10] = "R_SPARC_GOT10",
     50     [R_SPARC_GOT13] = "R_SPARC_GOT13",
     51     [R_SPARC_GOT22] = "R_SPARC_GOT22",
     52     [R_SPARC_PC10] = "R_SPARC_PC10",
     53     [R_SPARC_PC22] = "R_SPARC_PC22",
     54     [R_SPARC_WPLT30] = "R_SPARC_WPLT30",
     55     [R_SPARC_COPY] = "R_SPARC_COPY",
     56     [R_SPARC_GLOB_DAT] = "R_SPARC_GLOB_DAT",
     57     [R_SPARC_JMP_SLOT] = "R_SPARC_JMP_SLOT",
     58     [R_SPARC_RELATIVE] = "R_SPARC_RELATIVE",
     59     [R_SPARC_UA32] = "R_SPARC_UA32",
     60     [R_SPARC_PLT32] = "R_SPARC_PLT32",
     61     [R_SPARC_HIPLT22] = "R_SPARC_HIPLT22",
     62     [R_SPARC_LOPLT10] = "R_SPARC_LOPLT10",
     63     [R_SPARC_PCPLT32] = "R_SPARC_PCPLT32",
     64     [R_SPARC_PCPLT22] = "R_SPARC_PCPLT22",
     65     [R_SPARC_PCPLT10] = "R_SPARC_PCPLT10",
     66     [R_SPARC_10] = "R_SPARC_10",
     67     [R_SPARC_11] = "R_SPARC_11",
     68     [R_SPARC_64] = "R_SPARC_64",
     69     [R_SPARC_OLO10] = "R_SPARC_OLO10",
     70     [R_SPARC_HH22] = "R_SPARC_HH22",
     71     [R_SPARC_HM10] = "R_SPARC_HM10",
     72     [R_SPARC_LM22] = "R_SPARC_LM22",
     73     [R_SPARC_PC_HH22] = "R_SPARC_PC_HH22",
     74     [R_SPARC_PC_HM10] = "R_SPARC_PC_HM10",
     75     [R_SPARC_PC_LM22] = "R_SPARC_PC_LM22",
     76     [R_SPARC_WDISP16] = "R_SPARC_WDISP16",
     77     [R_SPARC_WDISP19] = "R_SPARC_WDISP19",
     78     [R_SPARC_7] = "R_SPARC_7",
     79     [R_SPARC_5] = "R_SPARC_5",
     80     [R_SPARC_6] = "R_SPARC_6",
     81     [R_SPARC_DISP64] = "R_SPARC_DISP64",
     82     [R_SPARC_PLT64] = "R_SPARC_PLT64",
     83     [R_SPARC_HIX22] = "R_SPARC_HIX22",
     84     [R_SPARC_LOX10] = "R_SPARC_LOX10",
     85     [R_SPARC_H44] = "R_SPARC_H44",
     86     [R_SPARC_M44] = "R_SPARC_M44",
     87     [R_SPARC_L44] = "R_SPARC_L44",
     88     [R_SPARC_REGISTER] = "R_SPARC_REGISTER",
     89     [R_SPARC_UA64] = "R_SPARC_UA64",
     90     [R_SPARC_UA16] = "R_SPARC_UA16",
     91     [R_SPARC_TLS_GD_HI22] = "R_SPARC_TLS_GD_HI22",
     92     [R_SPARC_TLS_GD_LO10] = "R_SPARC_TLS_GD_LO10",
     93     [R_SPARC_TLS_GD_ADD] = "R_SPARC_TLS_GD_ADD",
     94     [R_SPARC_TLS_GD_CALL] = "R_SPARC_TLS_GD_CALL",
     95     [R_SPARC_TLS_LDM_HI22] = "R_SPARC_TLS_LDM_HI22",
     96     [R_SPARC_TLS_LDM_LO10] = "R_SPARC_TLS_LDM_LO10",
     97     [R_SPARC_TLS_LDM_ADD] = "R_SPARC_TLS_LDM_ADD",
     98     [R_SPARC_TLS_LDM_CALL] = "R_SPARC_TLS_LDM_CALL",
     99     [R_SPARC_TLS_LDO_HIX22] = "R_SPARC_TLS_LDO_HIX22",
    100     [R_SPARC_TLS_LDO_LOX10] = "R_SPARC_TLS_LDO_LOX10",
    101     [R_SPARC_TLS_LDO_ADD] = "R_SPARC_TLS_LDO_ADD",
    102     [R_SPARC_TLS_IE_HI22] = "R_SPARC_TLS_IE_HI22",
    103     [R_SPARC_TLS_IE_LO10] = "R_SPARC_TLS_IE_LO10",
    104     [R_SPARC_TLS_IE_LD] = "R_SPARC_TLS_IE_LD",
    105     [R_SPARC_TLS_IE_LDX] = "R_SPARC_TLS_IE_LDX",
    106     [R_SPARC_TLS_IE_ADD] = "R_SPARC_TLS_IE_ADD",
    107     [R_SPARC_TLS_LE_HIX22] = "R_SPARC_TLS_LE_HIX22",
    108     [R_SPARC_TLS_LE_LOX10] = "R_SPARC_TLS_LE_LOX10",
    109     [R_SPARC_TLS_DTPMOD32] = "R_SPARC_TLS_DTPMOD32",
    110     [R_SPARC_TLS_DTPMOD64] = "R_SPARC_TLS_DTPMOD64",
    111     [R_SPARC_TLS_DTPOFF32] = "R_SPARC_TLS_DTPOFF32",
    112     [R_SPARC_TLS_DTPOFF64] = "R_SPARC_TLS_DTPOFF64",
    113     [R_SPARC_TLS_TPOFF32] = "R_SPARC_TLS_TPOFF32",
    114     [R_SPARC_TLS_TPOFF64] = "R_SPARC_TLS_TPOFF64"
    115   };
    116 
    117 
    118 /* Determine relocation type string for sparc.  */
    119 const char *
    120 sparc_reloc_type_name (int type, char *buf, size_t len)
    121 {
    122   /* High 24 bits of r_type are used for second addend in R_SPARC_OLO10.  */
    123   if ((type & 0xff) == R_SPARC_OLO10)
    124     return reloc_map_table[type & 0xff];
    125 
    126   if (type < 0 || type >= R_SPARC_NUM)
    127     return NULL;
    128 
    129   return reloc_map_table[type];
    130 }
    131 
    132 
    133 /* Check for correct relocation type.  */
    134 bool
    135 sparc_reloc_type_check (int type)
    136 {
    137   if ((type & 0xff) == R_SPARC_OLO10)
    138     return true;
    139   return (type >= R_SPARC_NONE && type < R_SPARC_NUM
    140 	  && reloc_map_table[type] != NULL) ? true : false;
    141 }
    142