sparc.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /* SPARC ELF support for BFD.
  2. Copyright (C) 1996-2015 Free Software Foundation, Inc.
  3. By Doug Evans, Cygnus Support, <dje@cygnus.com>.
  4. This file is part of BFD, the Binary File Descriptor library.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. #ifndef _ELF_SPARC_H
  18. #define _ELF_SPARC_H
  19. /* Processor specific flags for the ELF header e_flags field. */
  20. /* These are defined by Sun. */
  21. #define EF_SPARC_32PLUS_MASK 0xffff00 /* bits indicating V8+ type */
  22. #define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */
  23. #define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */
  24. #define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */
  25. #define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */
  26. #define EF_SPARC_LEDATA 0x800000 /* little endian data */
  27. /* This name is used in the V9 ABI. */
  28. #define EF_SPARC_EXT_MASK 0xffff00 /* reserved for vendor extensions */
  29. /* V9 memory models */
  30. #define EF_SPARCV9_MM 0x3 /* memory model mask */
  31. #define EF_SPARCV9_TSO 0x0 /* total store ordering */
  32. #define EF_SPARCV9_PSO 0x1 /* partial store ordering */
  33. #define EF_SPARCV9_RMO 0x2 /* relaxed store ordering */
  34. /* Section indices. */
  35. #define SHN_BEFORE SHN_LORESERVE /* Used with SHF_ORDERED and... */
  36. #define SHN_AFTER (SHN_LORESERVE + 1) /* SHF_LINK_ORDER section flags. */
  37. /* Section flags. */
  38. #define SHF_ORDERED 0x40000000 /* treat sh_link,sh_info specially */
  39. /* Symbol types. */
  40. #define STT_REGISTER 13 /* global reg reserved to app. */
  41. #include "elf/reloc-macros.h"
  42. /* Relocation types. */
  43. START_RELOC_NUMBERS (elf_sparc_reloc_type)
  44. RELOC_NUMBER (R_SPARC_NONE, 0)
  45. RELOC_NUMBER (R_SPARC_8, 1)
  46. RELOC_NUMBER (R_SPARC_16, 2)
  47. RELOC_NUMBER (R_SPARC_32, 3)
  48. RELOC_NUMBER (R_SPARC_DISP8, 4)
  49. RELOC_NUMBER (R_SPARC_DISP16, 5)
  50. RELOC_NUMBER (R_SPARC_DISP32, 6)
  51. RELOC_NUMBER (R_SPARC_WDISP30, 7)
  52. RELOC_NUMBER (R_SPARC_WDISP22, 8)
  53. RELOC_NUMBER (R_SPARC_HI22, 9)
  54. RELOC_NUMBER (R_SPARC_22, 10)
  55. RELOC_NUMBER (R_SPARC_13, 11)
  56. RELOC_NUMBER (R_SPARC_LO10, 12)
  57. RELOC_NUMBER (R_SPARC_GOT10, 13)
  58. RELOC_NUMBER (R_SPARC_GOT13, 14)
  59. RELOC_NUMBER (R_SPARC_GOT22, 15)
  60. RELOC_NUMBER (R_SPARC_PC10, 16)
  61. RELOC_NUMBER (R_SPARC_PC22, 17)
  62. RELOC_NUMBER (R_SPARC_WPLT30, 18)
  63. RELOC_NUMBER (R_SPARC_COPY, 19)
  64. RELOC_NUMBER (R_SPARC_GLOB_DAT, 20)
  65. RELOC_NUMBER (R_SPARC_JMP_SLOT, 21)
  66. RELOC_NUMBER (R_SPARC_RELATIVE, 22)
  67. RELOC_NUMBER (R_SPARC_UA32, 23)
  68. /* ??? These 6 relocs are new but not currently used. For binary
  69. compatibility in the sparc64-elf toolchain, we leave them out.
  70. A non-binary upward compatible change is expected for sparc64-elf. */
  71. #ifndef SPARC64_OLD_RELOCS
  72. /* ??? New relocs on the UltraSPARC. Not sure what they're for yet. */
  73. RELOC_NUMBER (R_SPARC_PLT32, 24)
  74. RELOC_NUMBER (R_SPARC_HIPLT22, 25)
  75. RELOC_NUMBER (R_SPARC_LOPLT10, 26)
  76. RELOC_NUMBER (R_SPARC_PCPLT32, 27)
  77. RELOC_NUMBER (R_SPARC_PCPLT22, 28)
  78. RELOC_NUMBER (R_SPARC_PCPLT10, 29)
  79. #endif
  80. /* v9 relocs */
  81. RELOC_NUMBER (R_SPARC_10, 30)
  82. RELOC_NUMBER (R_SPARC_11, 31)
  83. RELOC_NUMBER (R_SPARC_64, 32)
  84. RELOC_NUMBER (R_SPARC_OLO10, 33)
  85. RELOC_NUMBER (R_SPARC_HH22, 34)
  86. RELOC_NUMBER (R_SPARC_HM10, 35)
  87. RELOC_NUMBER (R_SPARC_LM22, 36)
  88. RELOC_NUMBER (R_SPARC_PC_HH22, 37)
  89. RELOC_NUMBER (R_SPARC_PC_HM10, 38)
  90. RELOC_NUMBER (R_SPARC_PC_LM22, 39)
  91. RELOC_NUMBER (R_SPARC_WDISP16, 40)
  92. RELOC_NUMBER (R_SPARC_WDISP19, 41)
  93. RELOC_NUMBER (R_SPARC_UNUSED_42, 42)
  94. RELOC_NUMBER (R_SPARC_7, 43)
  95. RELOC_NUMBER (R_SPARC_5, 44)
  96. RELOC_NUMBER (R_SPARC_6, 45)
  97. RELOC_NUMBER (R_SPARC_DISP64, 46)
  98. RELOC_NUMBER (R_SPARC_PLT64, 47)
  99. RELOC_NUMBER (R_SPARC_HIX22, 48)
  100. RELOC_NUMBER (R_SPARC_LOX10, 49)
  101. RELOC_NUMBER (R_SPARC_H44, 50)
  102. RELOC_NUMBER (R_SPARC_M44, 51)
  103. RELOC_NUMBER (R_SPARC_L44, 52)
  104. RELOC_NUMBER (R_SPARC_REGISTER, 53)
  105. RELOC_NUMBER (R_SPARC_UA64, 54)
  106. RELOC_NUMBER (R_SPARC_UA16, 55)
  107. RELOC_NUMBER (R_SPARC_TLS_GD_HI22, 56)
  108. RELOC_NUMBER (R_SPARC_TLS_GD_LO10, 57)
  109. RELOC_NUMBER (R_SPARC_TLS_GD_ADD, 58)
  110. RELOC_NUMBER (R_SPARC_TLS_GD_CALL, 59)
  111. RELOC_NUMBER (R_SPARC_TLS_LDM_HI22, 60)
  112. RELOC_NUMBER (R_SPARC_TLS_LDM_LO10, 61)
  113. RELOC_NUMBER (R_SPARC_TLS_LDM_ADD, 62)
  114. RELOC_NUMBER (R_SPARC_TLS_LDM_CALL, 63)
  115. RELOC_NUMBER (R_SPARC_TLS_LDO_HIX22, 64)
  116. RELOC_NUMBER (R_SPARC_TLS_LDO_LOX10, 65)
  117. RELOC_NUMBER (R_SPARC_TLS_LDO_ADD, 66)
  118. RELOC_NUMBER (R_SPARC_TLS_IE_HI22, 67)
  119. RELOC_NUMBER (R_SPARC_TLS_IE_LO10, 68)
  120. RELOC_NUMBER (R_SPARC_TLS_IE_LD, 69)
  121. RELOC_NUMBER (R_SPARC_TLS_IE_LDX, 70)
  122. RELOC_NUMBER (R_SPARC_TLS_IE_ADD, 71)
  123. RELOC_NUMBER (R_SPARC_TLS_LE_HIX22, 72)
  124. RELOC_NUMBER (R_SPARC_TLS_LE_LOX10, 73)
  125. RELOC_NUMBER (R_SPARC_TLS_DTPMOD32, 74)
  126. RELOC_NUMBER (R_SPARC_TLS_DTPMOD64, 75)
  127. RELOC_NUMBER (R_SPARC_TLS_DTPOFF32, 76)
  128. RELOC_NUMBER (R_SPARC_TLS_DTPOFF64, 77)
  129. RELOC_NUMBER (R_SPARC_TLS_TPOFF32, 78)
  130. RELOC_NUMBER (R_SPARC_TLS_TPOFF64, 79)
  131. RELOC_NUMBER (R_SPARC_GOTDATA_HIX22, 80)
  132. RELOC_NUMBER (R_SPARC_GOTDATA_LOX10, 81)
  133. RELOC_NUMBER (R_SPARC_GOTDATA_OP_HIX22, 82)
  134. RELOC_NUMBER (R_SPARC_GOTDATA_OP_LOX10, 83)
  135. RELOC_NUMBER (R_SPARC_GOTDATA_OP, 84)
  136. RELOC_NUMBER (R_SPARC_H34, 85)
  137. RELOC_NUMBER (R_SPARC_SIZE32, 86)
  138. RELOC_NUMBER (R_SPARC_SIZE64, 87)
  139. RELOC_NUMBER (R_SPARC_WDISP10, 88)
  140. EMPTY_RELOC (R_SPARC_max_std)
  141. RELOC_NUMBER (R_SPARC_JMP_IREL, 248)
  142. RELOC_NUMBER (R_SPARC_IRELATIVE, 249)
  143. RELOC_NUMBER (R_SPARC_GNU_VTINHERIT, 250)
  144. RELOC_NUMBER (R_SPARC_GNU_VTENTRY, 251)
  145. RELOC_NUMBER (R_SPARC_REV32, 252)
  146. END_RELOC_NUMBERS (R_SPARC_max)
  147. /* Relocation macros. */
  148. #define ELF64_R_TYPE_DATA(info) \
  149. (((bfd_signed_vma)(ELF64_R_TYPE(info) >> 8) ^ 0x800000) - 0x800000)
  150. #define ELF64_R_TYPE_ID(info) \
  151. ((info) & 0xff)
  152. #define ELF64_R_TYPE_INFO(data, type) \
  153. (((bfd_vma) ((data) & 0xffffff) << 8) | (bfd_vma) (type))
  154. /* Values for Elf64_Dyn.d_tag. */
  155. #define DT_SPARC_REGISTER 0x70000001
  156. /* Object attribute tags. */
  157. enum
  158. {
  159. /* 0-3 are generic. */
  160. Tag_GNU_Sparc_HWCAPS = 4,
  161. Tag_GNU_Sparc_HWCAPS2 = 8
  162. };
  163. /* Generally speaking the ELF_SPARC_HWCAP_* and ELF_SPARC_HWCAP2_*
  164. values match the AV_SPARC_* and AV2_SPARC_* bits respectively.
  165. However Solaris 11 introduced a backwards-incompatible change
  166. deprecating the RANDOM, TRANS and ASI_CACHE_SPARING bits in the
  167. AT_SUNW_CAP_HW1 flags, reusing the bits for the unrelated hwcaps
  168. FJATHHPC, FJDES and FJAES respectively. In GNU/Linux we opted to
  169. keep the old hwcaps in Tag_GNU_Sparc_HWCAPS and allocate bits for
  170. FJATHHPC, FJDES and JFAES in Tag_GNU_Sparc_HWCAPS2. */
  171. #define ELF_SPARC_HWCAP_MUL32 0x00000001 /* umul/umulcc/smul/smulcc insns */
  172. #define ELF_SPARC_HWCAP_DIV32 0x00000002 /* udiv/udivcc/sdiv/sdivcc insns */
  173. #define ELF_SPARC_HWCAP_FSMULD 0x00000004 /* 'fsmuld' insn */
  174. #define ELF_SPARC_HWCAP_V8PLUS 0x00000008 /* v9 insns available to 32bit */
  175. #define ELF_SPARC_HWCAP_POPC 0x00000010 /* 'popc' insn */
  176. #define ELF_SPARC_HWCAP_VIS 0x00000020 /* VIS insns */
  177. #define ELF_SPARC_HWCAP_VIS2 0x00000040 /* VIS2 insns */
  178. #define ELF_SPARC_HWCAP_ASI_BLK_INIT \
  179. 0x00000080 /* block init ASIs */
  180. #define ELF_SPARC_HWCAP_FMAF 0x00000100 /* fused multiply-add */
  181. #define ELF_SPARC_HWCAP_VIS3 0x00000400 /* VIS3 insns */
  182. #define ELF_SPARC_HWCAP_HPC 0x00000800 /* HPC insns */
  183. #define ELF_SPARC_HWCAP_RANDOM 0x00001000 /* 'random' insn */
  184. #define ELF_SPARC_HWCAP_TRANS 0x00002000 /* transaction insns */
  185. #define ELF_SPARC_HWCAP_FJFMAU 0x00004000 /* unfused multiply-add */
  186. #define ELF_SPARC_HWCAP_IMA 0x00008000 /* integer multiply-add */
  187. #define ELF_SPARC_HWCAP_ASI_CACHE_SPARING \
  188. 0x00010000 /* cache sparing ASIs */
  189. #define ELF_SPARC_HWCAP_AES 0x00020000 /* AES crypto insns */
  190. #define ELF_SPARC_HWCAP_DES 0x00040000 /* DES crypto insns */
  191. #define ELF_SPARC_HWCAP_KASUMI 0x00080000 /* KASUMI crypto insns */
  192. #define ELF_SPARC_HWCAP_CAMELLIA \
  193. 0x00100000 /* CAMELLIA crypto insns */
  194. #define ELF_SPARC_HWCAP_MD5 0x00200000 /* MD5 hashing insns */
  195. #define ELF_SPARC_HWCAP_SHA1 0x00400000 /* SHA1 hashing insns */
  196. #define ELF_SPARC_HWCAP_SHA256 0x00800000 /* SHA256 hashing insns */
  197. #define ELF_SPARC_HWCAP_SHA512 0x01000000 /* SHA512 hashing insns */
  198. #define ELF_SPARC_HWCAP_MPMUL 0x02000000 /* Multiple Precision Multiply */
  199. #define ELF_SPARC_HWCAP_MONT 0x04000000 /* Montgomery Mult/Sqrt */
  200. #define ELF_SPARC_HWCAP_PAUSE 0x08000000 /* Pause insn */
  201. #define ELF_SPARC_HWCAP_CBCOND 0x10000000 /* Compare and Branch insns */
  202. #define ELF_SPARC_HWCAP_CRC32C 0x20000000 /* CRC32C insn */
  203. #define ELF_SPARC_HWCAP2_FJATHPLUS 0x00000001 /* Fujitsu Athena+ */
  204. #define ELF_SPARC_HWCAP2_VIS3B 0x00000002 /* Subset of VIS3 present on sparc64 X+ */
  205. #define ELF_SPARC_HWCAP2_ADP 0x00000004 /* Application Data Protection */
  206. #define ELF_SPARC_HWCAP2_SPARC5 0x00000008 /* The 29 new fp and sub instructions */
  207. #define ELF_SPARC_HWCAP2_MWAIT 0x00000010 /* mwait instruction and load/monitor ASIs */
  208. #define ELF_SPARC_HWCAP2_XMPMUL 0x00000020 /* XOR multiple precision multiply */
  209. #define ELF_SPARC_HWCAP2_XMONT 0x00000040 /* XOR Montgomery mult/sqr instructions */
  210. #define ELF_SPARC_HWCAP2_NSEC \
  211. 0x00000080 /* pause insn with support for nsec timings */
  212. #define ELF_SPARC_HWCAP2_FJATHHPC 0x00001000 /* Fujitsu HPC instrs */
  213. #define ELF_SPARC_HWCAP2_FJDES 0x00002000 /* Fujitsu DES instrs */
  214. #define ELF_SPARC_HWCAP2_FJAES 0x00010000 /* Fujitsu AES instrs */
  215. #endif /* _ELF_SPARC_H */