Back to index

cell-binutils  2.17cvs20070401
cr16c.h
Go to the documentation of this file.
00001 /* CR16C ELF support for BFD.
00002    Copyright 2004 Free Software Foundation, Inc.
00003 
00004    This file is part of BFD, the Binary File Descriptor library.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software Foundation,
00018    Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00019 
00020 #ifndef _ELF_CR16C_H
00021 #define _ELF_CR16C_H
00022 
00023 #include "bfd.h"
00024 #include "elf/reloc-macros.h"
00025 
00026 /* Creating indices for reloc_map_index array.  */
00027 START_RELOC_NUMBERS (elf_cr16c_reloc_type)
00028      RELOC_NUMBER (RINDEX_16C_NUM08,             0)
00029      RELOC_NUMBER (RINDEX_16C_NUM08_C,           1)
00030      RELOC_NUMBER (RINDEX_16C_NUM16,             2)
00031      RELOC_NUMBER (RINDEX_16C_NUM16_C,           3)
00032      RELOC_NUMBER (RINDEX_16C_NUM32,             4)
00033      RELOC_NUMBER (RINDEX_16C_NUM32_C,           5)
00034      RELOC_NUMBER (RINDEX_16C_DISP04,            6)
00035      RELOC_NUMBER (RINDEX_16C_DISP04_C,          7)
00036      RELOC_NUMBER (RINDEX_16C_DISP08,            8)
00037      RELOC_NUMBER (RINDEX_16C_DISP08_C,          9)
00038      RELOC_NUMBER (RINDEX_16C_DISP16,            10)
00039      RELOC_NUMBER (RINDEX_16C_DISP16_C,          11)
00040      RELOC_NUMBER (RINDEX_16C_DISP24,            12)
00041      RELOC_NUMBER (RINDEX_16C_DISP24_C,          13)
00042      RELOC_NUMBER (RINDEX_16C_DISP24a,           14)
00043      RELOC_NUMBER (RINDEX_16C_DISP24a_C,  15)
00044      RELOC_NUMBER (RINDEX_16C_REG04,             16)
00045      RELOC_NUMBER (RINDEX_16C_REG04_C,           17)
00046      RELOC_NUMBER (RINDEX_16C_REG04a,            18)
00047      RELOC_NUMBER (RINDEX_16C_REG04a_C,          19)
00048      RELOC_NUMBER (RINDEX_16C_REG14,             20)
00049      RELOC_NUMBER (RINDEX_16C_REG14_C,           21)
00050      RELOC_NUMBER (RINDEX_16C_REG16,             22)
00051      RELOC_NUMBER (RINDEX_16C_REG16_C,           23)
00052      RELOC_NUMBER (RINDEX_16C_REG20,             24)
00053      RELOC_NUMBER (RINDEX_16C_REG20_C,           25)
00054      RELOC_NUMBER (RINDEX_16C_ABS20,             26)
00055      RELOC_NUMBER (RINDEX_16C_ABS20_C,           27)
00056      RELOC_NUMBER (RINDEX_16C_ABS24,             28)
00057      RELOC_NUMBER (RINDEX_16C_ABS24_C,           29)
00058      RELOC_NUMBER (RINDEX_16C_IMM04,             30)
00059      RELOC_NUMBER (RINDEX_16C_IMM04_C,           31)
00060      RELOC_NUMBER (RINDEX_16C_IMM16,             32)
00061      RELOC_NUMBER (RINDEX_16C_IMM16_C,           33)
00062      RELOC_NUMBER (RINDEX_16C_IMM20,             34)
00063      RELOC_NUMBER (RINDEX_16C_IMM20_C,           35)
00064      RELOC_NUMBER (RINDEX_16C_IMM24,             36)
00065      RELOC_NUMBER (RINDEX_16C_IMM24_C,           37)
00066      RELOC_NUMBER (RINDEX_16C_IMM32,             38)
00067      RELOC_NUMBER (RINDEX_16C_IMM32_C,           39)
00068 END_RELOC_NUMBERS (RINDEX_16C_MAX)
00069 
00070 /* CR16C Relocation Types ('cr_reloc_type' entry in the reloc_map structure).
00071    The relocation constant name is determined as follows :
00072 
00073    R_16C_<format><size>[_C]
00074 
00075    Where :
00076 
00077      <format> is one of the following:
00078        NUM  - R_NUMBER mnemonic,
00079        DISP - R_16C_DISPL mnemonic,
00080        REG  - R_16C_REGREL mnemonic,
00081        ABS  - R_16C_ABS mnemonic,
00082        IMM  - R_16C_IMMED mnemonic,
00083      <size> stands for R_S_16C_<size> 
00084      _C means 'code label' and is only added when R_ADDRTYPE subfield 
00085      is of type R_CODE_ADDR.  */
00086    
00087 /* The table below shows what the hex digits in the definition of the
00088    relocation type constants correspond to.
00089    ------------------------------------------------------------------
00090        R_SIZESP      R_FORMAT      R_RELTO             R_ADDRTYPE
00091    ------------------------------------------------------------------  */
00092 /*     R_S_16C_08    R_NUMBER      R_ABS        R_ADDRESS */
00093 #define R_16C_NUM08  0X0001
00094 
00095 /*     R_S_16C_08    R_NUMBER      R_ABS        R_CODE_ADDR */
00096 #define R_16C_NUM08_C       0X0006
00097 
00098 /*     R_S_16C_16    R_NUMBER      R_ABS        R_ADDRESS */
00099 #define R_16C_NUM16  0X1001
00100 
00101 /*     R_S_16C_16    R_NUMBER      R_ABS        R_CODE_ADDR */
00102 #define R_16C_NUM16_C       0X1006
00103 
00104 /*      R_S_16C_32      R_NUMBER   R_ABS        R_ADDRESS */
00105 #define R_16C_NUM32     0X2001
00106 
00107 /*      R_S_16C_32      R_NUMBER   R_ABS        R_CODE_ADDR */
00108 #define R_16C_NUM32_C   0X2006
00109 
00110 /*     R_S_16C_04    R_16C_DISPL   R_PCREL             R_ADDRESS */
00111 #define R_16C_DISP04 0X5411
00112 
00113 /*     R_S_16C_04    R_16C_DISPL   R_PCREL             R_CODE_ADDR */
00114 #define R_16C_DISP04_C      0X5416
00115 
00116 /*     R_S_16C_08    R_16C_DISPL   R_PCREL             R_ADDRESS */
00117 #define R_16C_DISP08 0X0411
00118 
00119 /*     R_S_16C_08    R_16C_DISPL   R_PCREL             R_CODE_ADDR */
00120 #define R_16C_DISP08_C      0X0416
00121 
00122 /*     R_S_16C_16    R_16C_DISPL   R_PCREL             R_ADDRESS */
00123 #define R_16C_DISP16 0X1411
00124 
00125 /*     R_S_16C_16    R_16C_DISPL   R_PCREL             R_CODE_ADDR */
00126 #define R_16C_DISP16_C      0X1416
00127 
00128 /*     R_S_16C_24    R_16C_DISPL   R_PCREL             R_ADDRESS */
00129 #define R_16C_DISP24 0X7411
00130 
00131 /*     R_S_16C_24    R_16C_DISPL   R_PCREL             R_CODE_ADDR */
00132 #define R_16C_DISP24_C      0X7416
00133 
00134 /*     R_S_16C_24a   R_16C_DISPL   R_PCREL             R_ADDRESS */
00135 #define R_16C_DISP24a       0X6411
00136 
00137 /*     R_S_16C_24a   R_16C_DISPL   R_PCREL             R_CODE_ADDR */
00138 #define R_16C_DISP24a_C     0X6416
00139 
00140 /*     R_S_16C_04    R_16C_REGREL  R_ABS        R_ADDRESS */
00141 #define R_16C_REG04  0X5201
00142 
00143 /*     R_S_16C_04    R_16C_REGREL  R_ABS        R_CODE_ADDR */
00144 #define R_16C_REG04_C       0X5206
00145 
00146 /*     R_S_16C_04_a  R_16C_REGREL  R_ABS        R_ADDRESS */
00147 #define R_16C_REG04a 0X4201
00148 
00149 /*     R_S_16C_04_a  R_16C_REGREL  R_ABS        R_CODE_ADDR */
00150 #define R_16C_REG04a_C      0X4206
00151 
00152 /*     R_S_16C_14    R_16C_REGREL  R_ABS        R_ADDRESS */
00153 #define R_16C_REG14  0X3201
00154 
00155 /*     R_S_16C_14    R_16C_REGREL  R_ABS        R_CODE_ADDR */
00156 #define R_16C_REG14_C       0X3206
00157 
00158 /*     R_S_16C_16    R_16C_REGREL  R_ABS        R_ADDRESS */
00159 #define R_16C_REG16  0X1201
00160 
00161 /*     R_S_16C_16    R_16C_REGREL  R_ABS        R_CODE_ADDR */
00162 #define R_16C_REG16_C       0X1206
00163 
00164 /*     R_S_16C_20    R_16C_REGREL  R_ABS        R_ADDRESS */
00165 #define R_16C_REG20  0X8201
00166 
00167 /*     R_S_16C_20    R_16C_REGREL  R_ABS        R_CODE_ADDR */
00168 #define R_16C_REG20_C       0X8206
00169 
00170 /*      R_S_16C_20      R_16C_ABS  R_ABS        R_ADDRESS */
00171 #define R_16C_ABS20     0X8101
00172 
00173 /*      R_S_16C_20      R_16C_ABS  R_ABS        R_CODE_ADDR */
00174 #define R_16C_ABS20_C   0X8106
00175 
00176 /*      R_S_16C_24      R_16C_ABS  R_ABS        R_ADDRESS */
00177 #define R_16C_ABS24     0X7101
00178 
00179 /*      R_S_16C_24      R_16C_ABS  R_ABS        R_CODE_ADDR */
00180 #define R_16C_ABS24_C   0X7106
00181 
00182 /*      R_S_16C_04      R_16C_IMMED       R_ABS        R_ADDRESS */
00183 #define R_16C_IMM04     0X5301
00184 
00185 /*      R_S_16C_04      R_16C_IMMED       R_ABS        R_CODE_ADDR */
00186 #define R_16C_IMM04_C   0X5306
00187 
00188 /*      R_S_16C_16      R_16C_IMMED       R_ABS        R_ADDRESS */
00189 #define R_16C_IMM16     0X1301
00190 
00191 /*      R_S_16C_16      R_16C_IMMED       R_ABS        R_CODE_ADDR */
00192 #define R_16C_IMM16_C   0X1306
00193 
00194 /*      R_S_16C_20      R_16C_IMMED       R_ABS        R_ADDRESS */
00195 #define R_16C_IMM20     0X8301
00196 
00197 /*      R_S_16C_20      R_16C_IMMED       R_ABS        R_CODE_ADDR */
00198 #define R_16C_IMM20_C   0X8306
00199 
00200 /*      R_S_16C_24      R_16C_IMMED       R_ABS        R_ADDRESS */
00201 #define R_16C_IMM24     0X7301
00202 
00203 /*      R_S_16C_24      R_16C_IMMED       R_ABS        R_CODE_ADDR */
00204 #define R_16C_IMM24_C   0X7306
00205 
00206 /*      R_S_16C_32      R_16C_IMMED       R_ABS        R_ADDRESS */
00207 #define R_16C_IMM32     0X2301
00208 
00209 /*      R_S_16C_32      R_16C_IMMED       R_ABS        R_CODE_ADDR */
00210 #define R_16C_IMM32_C   0X2306
00211 
00212 
00213 /* Relocation item type.  */
00214 #define   R_ADDRTYPE  0x000f
00215 #define   R_ADDRESS      0x0001    /* Take address of symbol.  */
00216 #define   R_CODE_ADDR    0x0006    /* Take address of symbol divided by 2.  */
00217 
00218 /* Relocation action.  */
00219 #define   R_RELTO        0x00f0
00220 #define   R_ABS          0x0000    /* Keep symbol's address as such.  */
00221 #define   R_PCREL        0x0010    /* Subtract the pc address of hole.  */
00222 
00223 /* Relocation item data format.  */
00224 #define   R_FORMAT       0x0f00
00225 #define   R_NUMBER       0x0000    /* Retain as two's complement value.  */
00226 #define   R_16C_DISPL    0x0400    /* CR16C displacement type.  */
00227 #define   R_16C_ABS      0x0100    /* CR16C absolute type.  */
00228 #define   R_16C_REGREL   0x0200    /* CR16C register-relative type.  */
00229 #define   R_16C_IMMED    0x0300    /* CR16C immediate type.  */
00230 
00231 /* Relocation item size. */
00232 #define   R_SIZESP       0xf000
00233 #define   R_S_16C_04     0x5000
00234 #define   R_S_16C_04_a   0x4000
00235 #define   R_S_16C_08  0x0000
00236 #define   R_S_16C_14     0x3000
00237 #define   R_S_16C_16  0x1000
00238 #define   R_S_16C_20     0x8000
00239 #define   R_S_16C_24_a   0x6000
00240 #define   R_S_16C_24  0x7000
00241 #define   R_S_16C_32     0x2000
00242 
00243 
00244 /* Processor specific section indices.  These sections do not actually
00245    exist.  Symbols with a st_shndx field corresponding to one of these
00246    values have a special meaning.  */
00247 
00248 /* Far common symbol.  */
00249 #define SHN_CR16C_FCOMMON   0xff00
00250 #define SHN_CR16C_NCOMMON   0xff01
00251 
00252 typedef struct reloc_map
00253 {
00254   unsigned short            cr_reloc_type;  /* CR relocation type.  */
00255   bfd_reloc_code_real_type  bfd_reloc_enum; /* BFD relocation enum.  */
00256 } RELOC_MAP;
00257 
00258 #endif /* _ELF_CR16C_H */