Home | History | Annotate | Download | only in libebl
      1 /* SH specific relocation handling.
      2    Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
      3    Written by Ulrich Drepper <drepper (at) redhat.com>, 2000.
      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_sh.h>
     23 
     24 
     25 /* Return of the backend.  */
     26 const char *
     27 sh_backend_name (void)
     28 {
     29   return "sh";
     30 }
     31 
     32 
     33 /* Determine relocation type string for SH.  */
     34 const char *
     35 sh_reloc_type_name (int type, char *buf, size_t len)
     36 {
     37   static const char *map_table1[] =
     38   {
     39     [R_SH_NONE] = "R_SH_NONE",
     40     [R_SH_DIR32] = "R_SH_DIR32",
     41     [R_SH_REL32] = "R_SH_REL32",
     42     [R_SH_DIR8WPN] = "R_SH_DIR8WPN",
     43     [R_SH_IND12W] = "R_SH_IND12W",
     44     [R_SH_DIR8WPL] = "R_SH_DIR8WPL",
     45     [R_SH_DIR8WPZ] = "R_SH_DIR8WPZ",
     46     [R_SH_DIR8BP] = "R_SH_DIR8BP",
     47     [R_SH_DIR8W] = "R_SH_DIR8W",
     48     [R_SH_DIR8L] = "R_SH_DIR8L",
     49     [R_SH_SWITCH16] = "R_SH_SWITCH16",
     50     [R_SH_SWITCH32] = "R_SH_SWITCH32",
     51     [R_SH_USES] = "R_SH_USES",
     52     [R_SH_COUNT] = "R_SH_COUNT",
     53     [R_SH_ALIGN] = "R_SH_ALIGN",
     54     [R_SH_CODE] = "R_SH_CODE",
     55     [R_SH_DATA] = "R_SH_DATA",
     56     [R_SH_LABEL] = "R_SH_LABEL",
     57     [R_SH_SWITCH8] = "R_SH_SWITCH8",
     58     [R_SH_GNU_VTINHERIT] ="R_SH_GNU_VTINHERIT",
     59     [R_SH_GNU_VTENTRY] = "R_SH_GNU_VTENTRY"
     60   };
     61   static const char *map_table2[] =
     62   {
     63     [R_SH_TLS_GD_32] = "R_SH_TLS_GD_32",
     64     [R_SH_TLS_LD_32] = "R_SH_TLS_LD_32",
     65     [R_SH_TLS_LDO_32] = "R_SH_TLS_LDO_32",
     66     [R_SH_TLS_IE_32] = "R_SH_TLS_IE_32",
     67     [R_SH_TLS_LE_32] = "R_SH_TLS_LE_32",
     68     [R_SH_TLS_DTPMOD32] = "R_SH_TLS_DTPMOD32",
     69     [R_SH_TLS_DTPOFF32] = "R_SH_TLS_DTPOFF32",
     70     [R_SH_TLS_TPOFF32] = "R_SH_TLS_TPOFF32",
     71     [R_SH_GOT32 - R_SH_GOT32] = "R_SH_GOT32",
     72     [R_SH_PLT32 - R_SH_GOT32] = "R_SH_PLT32",
     73     [R_SH_COPY - R_SH_GOT32] = "R_SH_COPY",
     74     [R_SH_GLOB_DAT - R_SH_GOT32] = "R_SH_GLOB_DAT",
     75     [R_SH_JMP_SLOT - R_SH_GOT32] = "R_SH_JMP_SLOT",
     76     [R_SH_RELATIVE - R_SH_GOT32] = "R_SH_RELATIVE",
     77     [R_SH_GOTOFF - R_SH_GOT32] = "R_SH_GOTOFF",
     78     [R_SH_GOTPC - R_SH_GOT32] = "R_SH_GOTPC"
     79   };
     80 
     81   if (type >= 0
     82       && (size_t) type < sizeof (map_table1) / sizeof (map_table1[0]))
     83     return map_table1[type];
     84 
     85   if ((type - R_SH_TLS_GD_32) >= 0
     86       && ((size_t) (type - R_SH_TLS_GD_32)
     87 	  < sizeof (map_table2) / sizeof (map_table2[0])))
     88     return map_table2[type - R_SH_TLS_GD_32];
     89 
     90   return NULL;
     91 }
     92