cr16c.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /* CR16C ELF support for BFD.
  2. Copyright (C) 2004-2015 Free Software Foundation, Inc.
  3. This file is part of BFD, the Binary File Descriptor library.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
  15. #ifndef _ELF_CR16C_H
  16. #define _ELF_CR16C_H
  17. #include "bfd.h"
  18. #include "elf/reloc-macros.h"
  19. /* Creating indices for reloc_map_index array. */
  20. START_RELOC_NUMBERS (elf_cr16c_reloc_type)
  21. RELOC_NUMBER (RINDEX_16C_NUM08, 0)
  22. RELOC_NUMBER (RINDEX_16C_NUM08_C, 1)
  23. RELOC_NUMBER (RINDEX_16C_NUM16, 2)
  24. RELOC_NUMBER (RINDEX_16C_NUM16_C, 3)
  25. RELOC_NUMBER (RINDEX_16C_NUM32, 4)
  26. RELOC_NUMBER (RINDEX_16C_NUM32_C, 5)
  27. RELOC_NUMBER (RINDEX_16C_DISP04, 6)
  28. RELOC_NUMBER (RINDEX_16C_DISP04_C, 7)
  29. RELOC_NUMBER (RINDEX_16C_DISP08, 8)
  30. RELOC_NUMBER (RINDEX_16C_DISP08_C, 9)
  31. RELOC_NUMBER (RINDEX_16C_DISP16, 10)
  32. RELOC_NUMBER (RINDEX_16C_DISP16_C, 11)
  33. RELOC_NUMBER (RINDEX_16C_DISP24, 12)
  34. RELOC_NUMBER (RINDEX_16C_DISP24_C, 13)
  35. RELOC_NUMBER (RINDEX_16C_DISP24a, 14)
  36. RELOC_NUMBER (RINDEX_16C_DISP24a_C, 15)
  37. RELOC_NUMBER (RINDEX_16C_REG04, 16)
  38. RELOC_NUMBER (RINDEX_16C_REG04_C, 17)
  39. RELOC_NUMBER (RINDEX_16C_REG04a, 18)
  40. RELOC_NUMBER (RINDEX_16C_REG04a_C, 19)
  41. RELOC_NUMBER (RINDEX_16C_REG14, 20)
  42. RELOC_NUMBER (RINDEX_16C_REG14_C, 21)
  43. RELOC_NUMBER (RINDEX_16C_REG16, 22)
  44. RELOC_NUMBER (RINDEX_16C_REG16_C, 23)
  45. RELOC_NUMBER (RINDEX_16C_REG20, 24)
  46. RELOC_NUMBER (RINDEX_16C_REG20_C, 25)
  47. RELOC_NUMBER (RINDEX_16C_ABS20, 26)
  48. RELOC_NUMBER (RINDEX_16C_ABS20_C, 27)
  49. RELOC_NUMBER (RINDEX_16C_ABS24, 28)
  50. RELOC_NUMBER (RINDEX_16C_ABS24_C, 29)
  51. RELOC_NUMBER (RINDEX_16C_IMM04, 30)
  52. RELOC_NUMBER (RINDEX_16C_IMM04_C, 31)
  53. RELOC_NUMBER (RINDEX_16C_IMM16, 32)
  54. RELOC_NUMBER (RINDEX_16C_IMM16_C, 33)
  55. RELOC_NUMBER (RINDEX_16C_IMM20, 34)
  56. RELOC_NUMBER (RINDEX_16C_IMM20_C, 35)
  57. RELOC_NUMBER (RINDEX_16C_IMM24, 36)
  58. RELOC_NUMBER (RINDEX_16C_IMM24_C, 37)
  59. RELOC_NUMBER (RINDEX_16C_IMM32, 38)
  60. RELOC_NUMBER (RINDEX_16C_IMM32_C, 39)
  61. END_RELOC_NUMBERS (RINDEX_16C_MAX)
  62. /* CR16C Relocation Types ('cr_reloc_type' entry in the reloc_map structure).
  63. The relocation constant name is determined as follows :
  64. R_16C_<format><size>[_C]
  65. Where :
  66. <format> is one of the following:
  67. NUM - R_NUMBER mnemonic,
  68. DISP - R_16C_DISPL mnemonic,
  69. REG - R_16C_REGREL mnemonic,
  70. ABS - R_16C_ABS mnemonic,
  71. IMM - R_16C_IMMED mnemonic,
  72. <size> stands for R_S_16C_<size>
  73. _C means 'code label' and is only added when R_ADDRTYPE subfield
  74. is of type R_CODE_ADDR. */
  75. /* The table below shows what the hex digits in the definition of the
  76. relocation type constants correspond to.
  77. ------------------------------------------------------------------
  78. R_SIZESP R_FORMAT R_RELTO R_ADDRTYPE
  79. ------------------------------------------------------------------ */
  80. /* R_S_16C_08 R_NUMBER R_ABS R_ADDRESS */
  81. #define R_16C_NUM08 0X0001
  82. /* R_S_16C_08 R_NUMBER R_ABS R_CODE_ADDR */
  83. #define R_16C_NUM08_C 0X0006
  84. /* R_S_16C_16 R_NUMBER R_ABS R_ADDRESS */
  85. #define R_16C_NUM16 0X1001
  86. /* R_S_16C_16 R_NUMBER R_ABS R_CODE_ADDR */
  87. #define R_16C_NUM16_C 0X1006
  88. /* R_S_16C_32 R_NUMBER R_ABS R_ADDRESS */
  89. #define R_16C_NUM32 0X2001
  90. /* R_S_16C_32 R_NUMBER R_ABS R_CODE_ADDR */
  91. #define R_16C_NUM32_C 0X2006
  92. /* R_S_16C_04 R_16C_DISPL R_PCREL R_ADDRESS */
  93. #define R_16C_DISP04 0X5411
  94. /* R_S_16C_04 R_16C_DISPL R_PCREL R_CODE_ADDR */
  95. #define R_16C_DISP04_C 0X5416
  96. /* R_S_16C_08 R_16C_DISPL R_PCREL R_ADDRESS */
  97. #define R_16C_DISP08 0X0411
  98. /* R_S_16C_08 R_16C_DISPL R_PCREL R_CODE_ADDR */
  99. #define R_16C_DISP08_C 0X0416
  100. /* R_S_16C_16 R_16C_DISPL R_PCREL R_ADDRESS */
  101. #define R_16C_DISP16 0X1411
  102. /* R_S_16C_16 R_16C_DISPL R_PCREL R_CODE_ADDR */
  103. #define R_16C_DISP16_C 0X1416
  104. /* R_S_16C_24 R_16C_DISPL R_PCREL R_ADDRESS */
  105. #define R_16C_DISP24 0X7411
  106. /* R_S_16C_24 R_16C_DISPL R_PCREL R_CODE_ADDR */
  107. #define R_16C_DISP24_C 0X7416
  108. /* R_S_16C_24a R_16C_DISPL R_PCREL R_ADDRESS */
  109. #define R_16C_DISP24a 0X6411
  110. /* R_S_16C_24a R_16C_DISPL R_PCREL R_CODE_ADDR */
  111. #define R_16C_DISP24a_C 0X6416
  112. /* R_S_16C_04 R_16C_REGREL R_ABS R_ADDRESS */
  113. #define R_16C_REG04 0X5201
  114. /* R_S_16C_04 R_16C_REGREL R_ABS R_CODE_ADDR */
  115. #define R_16C_REG04_C 0X5206
  116. /* R_S_16C_04_a R_16C_REGREL R_ABS R_ADDRESS */
  117. #define R_16C_REG04a 0X4201
  118. /* R_S_16C_04_a R_16C_REGREL R_ABS R_CODE_ADDR */
  119. #define R_16C_REG04a_C 0X4206
  120. /* R_S_16C_14 R_16C_REGREL R_ABS R_ADDRESS */
  121. #define R_16C_REG14 0X3201
  122. /* R_S_16C_14 R_16C_REGREL R_ABS R_CODE_ADDR */
  123. #define R_16C_REG14_C 0X3206
  124. /* R_S_16C_16 R_16C_REGREL R_ABS R_ADDRESS */
  125. #define R_16C_REG16 0X1201
  126. /* R_S_16C_16 R_16C_REGREL R_ABS R_CODE_ADDR */
  127. #define R_16C_REG16_C 0X1206
  128. /* R_S_16C_20 R_16C_REGREL R_ABS R_ADDRESS */
  129. #define R_16C_REG20 0X8201
  130. /* R_S_16C_20 R_16C_REGREL R_ABS R_CODE_ADDR */
  131. #define R_16C_REG20_C 0X8206
  132. /* R_S_16C_20 R_16C_ABS R_ABS R_ADDRESS */
  133. #define R_16C_ABS20 0X8101
  134. /* R_S_16C_20 R_16C_ABS R_ABS R_CODE_ADDR */
  135. #define R_16C_ABS20_C 0X8106
  136. /* R_S_16C_24 R_16C_ABS R_ABS R_ADDRESS */
  137. #define R_16C_ABS24 0X7101
  138. /* R_S_16C_24 R_16C_ABS R_ABS R_CODE_ADDR */
  139. #define R_16C_ABS24_C 0X7106
  140. /* R_S_16C_04 R_16C_IMMED R_ABS R_ADDRESS */
  141. #define R_16C_IMM04 0X5301
  142. /* R_S_16C_04 R_16C_IMMED R_ABS R_CODE_ADDR */
  143. #define R_16C_IMM04_C 0X5306
  144. /* R_S_16C_16 R_16C_IMMED R_ABS R_ADDRESS */
  145. #define R_16C_IMM16 0X1301
  146. /* R_S_16C_16 R_16C_IMMED R_ABS R_CODE_ADDR */
  147. #define R_16C_IMM16_C 0X1306
  148. /* R_S_16C_20 R_16C_IMMED R_ABS R_ADDRESS */
  149. #define R_16C_IMM20 0X8301
  150. /* R_S_16C_20 R_16C_IMMED R_ABS R_CODE_ADDR */
  151. #define R_16C_IMM20_C 0X8306
  152. /* R_S_16C_24 R_16C_IMMED R_ABS R_ADDRESS */
  153. #define R_16C_IMM24 0X7301
  154. /* R_S_16C_24 R_16C_IMMED R_ABS R_CODE_ADDR */
  155. #define R_16C_IMM24_C 0X7306
  156. /* R_S_16C_32 R_16C_IMMED R_ABS R_ADDRESS */
  157. #define R_16C_IMM32 0X2301
  158. /* R_S_16C_32 R_16C_IMMED R_ABS R_CODE_ADDR */
  159. #define R_16C_IMM32_C 0X2306
  160. /* Relocation item type. */
  161. #define R_ADDRTYPE 0x000f
  162. #define R_ADDRESS 0x0001 /* Take address of symbol. */
  163. #define R_CODE_ADDR 0x0006 /* Take address of symbol divided by 2. */
  164. /* Relocation action. */
  165. #define R_RELTO 0x00f0
  166. #define R_ABS 0x0000 /* Keep symbol's address as such. */
  167. #define R_PCREL 0x0010 /* Subtract the pc address of hole. */
  168. /* Relocation item data format. */
  169. #define R_FORMAT 0x0f00
  170. #define R_NUMBER 0x0000 /* Retain as two's complement value. */
  171. #define R_16C_DISPL 0x0400 /* CR16C displacement type. */
  172. #define R_16C_ABS 0x0100 /* CR16C absolute type. */
  173. #define R_16C_REGREL 0x0200 /* CR16C register-relative type. */
  174. #define R_16C_IMMED 0x0300 /* CR16C immediate type. */
  175. /* Relocation item size. */
  176. #define R_SIZESP 0xf000
  177. #define R_S_16C_04 0x5000
  178. #define R_S_16C_04_a 0x4000
  179. #define R_S_16C_08 0x0000
  180. #define R_S_16C_14 0x3000
  181. #define R_S_16C_16 0x1000
  182. #define R_S_16C_20 0x8000
  183. #define R_S_16C_24_a 0x6000
  184. #define R_S_16C_24 0x7000
  185. #define R_S_16C_32 0x2000
  186. /* Processor specific section indices. These sections do not actually
  187. exist. Symbols with a st_shndx field corresponding to one of these
  188. values have a special meaning. */
  189. /* Far common symbol. */
  190. #define SHN_CR16C_FCOMMON SHN_LORESERVE
  191. #define SHN_CR16C_NCOMMON (SHN_LORESERVE + 1)
  192. typedef struct reloc_map
  193. {
  194. unsigned short cr_reloc_type; /* CR relocation type. */
  195. bfd_reloc_code_real_type bfd_reloc_enum; /* BFD relocation enum. */
  196. } RELOC_MAP;
  197. #endif /* _ELF_CR16C_H */