arm.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. // arm.h -- ELF definitions specific to EM_ARM -*- C++ -*-
  2. // Copyright (C) 2009-2022 Free Software Foundation, Inc.
  3. // Written by Doug Kwan <dougkwan@google.com>.
  4. // This file is part of elfcpp.
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU Library General Public License
  7. // as published by the Free Software Foundation; either version 2, or
  8. // (at your option) any later version.
  9. // In addition to the permissions in the GNU Library General Public
  10. // License, the Free Software Foundation gives you unlimited
  11. // permission to link the compiled version of this file into
  12. // combinations with other programs, and to distribute those
  13. // combinations without any restriction coming from the use of this
  14. // file. (The Library Public License restrictions do apply in other
  15. // respects; for example, they cover modification of the file, and
  16. // distribution when not linked into a combined executable.)
  17. // This program is distributed in the hope that it will be useful, but
  18. // WITHOUT ANY WARRANTY; without even the implied warranty of
  19. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. // Library General Public License for more details.
  21. // You should have received a copy of the GNU Library General Public
  22. // License along with this program; if not, write to the Free Software
  23. // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
  24. // 02110-1301, USA.
  25. #ifndef ELFCPP_ARM_H
  26. #define ELFCPP_ARM_H
  27. // The relocation type information is taken from:
  28. //
  29. // ELF for the ARM Architecture
  30. // Document number: ARM IHI 0044C, current through ABI release 2.07
  31. // Date of Issue: 10th October, 2008
  32. //
  33. namespace elfcpp
  34. {
  35. //
  36. // ARM Relocations Codes
  37. //
  38. // Operation notes:
  39. // S: Address of the symbol.
  40. // A: Addend for relocation.
  41. // P: Address of the place being relocated.
  42. // Pa: Adjusted address of the place being relocated (P & 0xfffffffc)
  43. // T: is 1 if S has type STT_FUNC and the symbol addresses a Thumb
  44. // instruction.Thumb-bit; it is 0 otherwise.
  45. // B(S): Addressing origin of the output segment defining S.
  46. // GOT_ORG: Addressing origin of the Global Offset Table.
  47. // GOT(S): Address of the GOT entry for S.
  48. //
  49. enum
  50. {
  51. // Type Class Operation
  52. // ------------------------------
  53. R_ARM_NONE = 0, // Static Misc
  54. R_ARM_PC24 = 1, // Deprecated ARM ((S + A) | T) - P
  55. R_ARM_ABS32 = 2, // Static Data (S + A) | T
  56. R_ARM_REL32 = 3, // Static Data ((S + A) | T) - P
  57. R_ARM_LDR_PC_G0 = 4, // Static ARM S + A - P
  58. R_ARM_ABS16 = 5, // Static Data S + A
  59. R_ARM_ABS12 = 6, // Static ARM S + A
  60. R_ARM_THM_ABS5 = 7, // Static Thumb16 S + A
  61. R_ARM_ABS8 = 8, // Static Data S + A
  62. R_ARM_SBREL32 = 9, // Static Data ((S + A) | T) - B(S)
  63. R_ARM_THM_CALL = 10, // Static Thumb32 ((S + A) | T) - P
  64. R_ARM_THM_PC8 = 11, // Static Thumb16
  65. R_ARM_BREL_ADJ = 12, // Dynamic Data DeltaB(S) + A
  66. R_ARM_TLS_DESC = 13, // Dynamic Data
  67. R_ARM_THM_SWI8 = 14, // Obsolete
  68. R_ARM_XPC25 = 15, // Obsolete
  69. R_ARM_THM_XPC22 = 16, // Obsolete
  70. R_ARM_TLS_DTPMOD32 = 17, // Dynamic Data Module(S)
  71. R_ARM_TLS_DTPOFF32 = 18, // Dynamic Data S + A - TLS
  72. R_ARM_TLS_TPOFF32 = 19, // Dynamic Data S + A - tp
  73. R_ARM_COPY = 20, // Dynamic Misc
  74. R_ARM_GLOB_DAT = 21, // Dynamic Data (S + A) | T
  75. R_ARM_JUMP_SLOT = 22, // Dynamic Data (S + A) | T
  76. R_ARM_RELATIVE = 23, // Dynamic Data B(S) + A
  77. R_ARM_GOTOFF32 = 24, // Static Data (((S + A) | T) - GOT_ORG
  78. R_ARM_BASE_PREL = 25, // Static Data B(S) + A - P
  79. R_ARM_GOT_BREL = 26, // Static Data GOT(S) + A - GOT_ORG
  80. R_ARM_PLT32 = 27, // Deprecated ARM ((S + A) | T) - P
  81. R_ARM_CALL = 28, // Static ARM ((S + A) | T) - P
  82. R_ARM_JUMP24 = 29, // Static ARM ((S + A) | T) - P
  83. R_ARM_THM_JUMP24 = 30, // Static Thumb32 ((S + A) | T) - P
  84. R_ARM_BASE_ABS = 31, // Static Data B(S) + A
  85. R_ARM_ALU_PCREL_7_0 = 32, // Obsolete
  86. R_ARM_ALU_PCREL_15_8 = 33, // Obsolete
  87. R_ARM_ALU_PCREL_23_15 = 34, // Obsolete
  88. R_ARM_LDR_SBREL_11_0_NC = 35, // Deprecated ARM S + A - B(S)
  89. R_ARM_ALU_SBREL_19_12_NC = 36,// Deprecated ARM S + A - B(S)
  90. R_ARM_ALU_SBREL_27_20_CK = 37,// Deprecated ARM S + A - B(S)
  91. R_ARM_TARGET1 = 38, // Data Misc (S + A) | T or
  92. // ((S + A) | T) - P
  93. R_ARM_SBREL31 = 39, // Deprecated Data ((S + A) | T) - B(S)
  94. R_ARM_V4BX = 40, // Static Misc
  95. R_ARM_TARGET2 = 41, // Static Misc
  96. R_ARM_PREL31 = 42, // Static Data ((S + A) | T) - P
  97. R_ARM_MOVW_ABS_NC = 43, // Static ARM (S + A) | T
  98. R_ARM_MOVT_ABS = 44, // Static ARM S + A
  99. R_ARM_MOVW_PREL_NC = 45, // Static ARM ((S + A) | T) - P
  100. R_ARM_MOVT_PREL = 46, // Static ARM S + A - P
  101. R_ARM_THM_MOVW_ABS_NC = 47, // Static Thumb32 (S + A) | T
  102. R_ARM_THM_MOVT_ABS = 48, // Static Thumb32 S + A - P
  103. R_ARM_THM_MOVW_PREL_NC = 49, // Static Thumb32 ((S + A) | T) - P
  104. R_ARM_THM_MOVT_PREL = 50, // Static Thumb32 S + A - P
  105. R_ARM_THM_JUMP19 = 51, // Static Thumb32 ((S + A) | T) - P
  106. R_ARM_THM_JUMP6 = 52, // Static Thumb16 S + A - P
  107. R_ARM_THM_ALU_PREL_11_0 = 53, // Static Thumb32 ((S + A) | T) - Pa
  108. R_ARM_THM_PC12 = 54, // Static Thumb32 S + A - Pa
  109. R_ARM_ABS32_NOI = 55, // Static Data S + A
  110. R_ARM_REL32_NOI = 56, // Static Data S + A - P
  111. R_ARM_ALU_PC_G0_NC = 57, // Static ARM ((S + A) | T) - P
  112. R_ARM_ALU_PC_G0 = 58, // Static ARM ((S + A) | T) - P
  113. R_ARM_ALU_PC_G1_NC = 59, // Static ARM ((S + A) | T) - P
  114. R_ARM_ALU_PC_G1 = 60, // Static ARM ((S + A) | T) - P
  115. R_ARM_ALU_PC_G2 = 61, // Static ARM ((S + A) | T) - P
  116. R_ARM_LDR_PC_G1 = 62, // Static ARM S + A - P
  117. R_ARM_LDR_PC_G2 = 63, // Static ARM S + A - P
  118. R_ARM_LDRS_PC_G0 = 64, // Static ARM S + A - P
  119. R_ARM_LDRS_PC_G1 = 65, // Static ARM S + A - P
  120. R_ARM_LDRS_PC_G2 = 66, // Static ARM S + A - P
  121. R_ARM_LDC_PC_G0 = 67, // Static ARM S + A - P
  122. R_ARM_LDC_PC_G1 = 68, // Static ARM S + A - P
  123. R_ARM_LDC_PC_G2 = 69, // Static ARM S + A - P
  124. R_ARM_ALU_SB_G0_NC = 70, // Static ARM ((S + A) | T) - B(S)
  125. R_ARM_ALU_SB_G0 = 71, // Static ARM ((S + A) | T) - B(S)
  126. R_ARM_ALU_SB_G1_NC = 72, // Static ARM ((S + A) | T) - B(S)
  127. R_ARM_ALU_SB_G1 = 73, // Static ARM ((S + A) | T) - B(S)
  128. R_ARM_ALU_SB_G2 = 74, // Static ARM ((S + A) | T) - B(S)
  129. R_ARM_LDR_SB_G0 = 75, // Static ARM S + A - B(S)
  130. R_ARM_LDR_SB_G1 = 76, // Static ARM S + A - B(S)
  131. R_ARM_LDR_SB_G2 = 77, // Static ARM S + A - B(S)
  132. R_ARM_LDRS_SB_G0 = 78, // Static ARM S + A - B(S)
  133. R_ARM_LDRS_SB_G1 = 79, // Static ARM S + A - B(S)
  134. R_ARM_LDRS_SB_G2 = 80, // Static ARM S + A - B(S)
  135. R_ARM_LDC_SB_G0 = 81, // Static ARM S + A - B(S)
  136. R_ARM_LDC_SB_G1 = 82, // Static ARM S + A - B(S)
  137. R_ARM_LDC_SB_G2 = 83, // Static ARM S + A - B(S)
  138. R_ARM_MOVW_BREL_NC = 84, // Static ARM ((S + A) | T) - B(S)
  139. R_ARM_MOVT_BREL = 85, // Static ARM S + A - B(S)
  140. R_ARM_MOVW_BREL = 86, // Static ARM ((S + A) | T) - B(S)
  141. R_ARM_THM_MOVW_BREL_NC = 87, // Static Thumb32 ((S + A) | T) - B(S)
  142. R_ARM_THM_MOVT_BREL = 88, // Static Thumb32 S + A - B(S)
  143. R_ARM_THM_MOVW_BREL = 89, // Static Thumb32 ((S + A) | T) - B(S)
  144. R_ARM_TLS_GOTDESC = 90, // Static Data
  145. R_ARM_TLS_CALL = 91, // Static ARM
  146. R_ARM_TLS_DESCSEQ = 92, // Static ARM TLS relaxation
  147. R_ARM_THM_TLS_CALL = 93, // Static Thumb32
  148. R_ARM_PLT32_ABS = 94, // Static Data PLT(S) + A
  149. R_ARM_GOT_ABS = 95, // Static Data GOT(S) + A
  150. R_ARM_GOT_PREL = 96, // Static Data GOT(S) + A - P
  151. R_ARM_GOT_BREL12 = 97, // Static ARM GOT(S) + A - GOT_ORG
  152. R_ARM_GOTOFF12 = 98, // Static ARM S + A - GOT_ROG
  153. R_ARM_GOTRELAX = 99, // Static Misc
  154. R_ARM_GNU_VTENTRY = 100, // Deprecated Data
  155. R_ARM_GNU_VTINHERIT = 101, // Deprecated Data
  156. R_ARM_THM_JUMP11 = 102, // Static Thumb16 S + A - P
  157. R_ARM_THM_JUMP8 = 103, // Static Thumb16 S + A - P
  158. R_ARM_TLS_GD32 = 104, // Static Data GOT(S) + A - P
  159. R_ARM_TLS_LDM32 = 105, // Static Data GOT(S) + A - P
  160. R_ARM_TLS_LDO32 = 106, // Static Data S + A - TLS
  161. R_ARM_TLS_IE32 = 107, // Static Data GOT(S) + A - P
  162. R_ARM_TLS_LE32 = 108, // Static Data S + A - tp
  163. R_ARM_TLS_LDO12 = 109, // Static ARM S + A - TLS
  164. R_ARM_TLS_LE12 = 110, // Static ARM S + A - tp
  165. R_ARM_TLS_IE12GP = 111, // Static ARM GOT(S) + A - GOT_ORG
  166. R_ARM_PRIVATE_0 = 112, // Private (n = 0, 1, ... 15)
  167. R_ARM_PRIVATE_1 = 113,
  168. R_ARM_PRIVATE_2 = 114,
  169. R_ARM_PRIVATE_3 = 115,
  170. R_ARM_PRIVATE_4 = 116,
  171. R_ARM_PRIVATE_5 = 117,
  172. R_ARM_PRIVATE_6 = 118,
  173. R_ARM_PRIVATE_7 = 119,
  174. R_ARM_PRIVATE_8 = 120,
  175. R_ARM_PRIVATE_9 = 121,
  176. R_ARM_PRIVATE_10 = 122,
  177. R_ARM_PRIVATE_11 = 123,
  178. R_ARM_PRIVATE_12 = 124,
  179. R_ARM_PRIVATE_13 = 125,
  180. R_ARM_PRIVATE_14 = 126,
  181. R_ARM_PRIVATE_15 = 127,
  182. R_ARM_ME_TOO = 128, // Obsolete
  183. R_ARM_THM_TLS_DESCSEQ16 = 129,// Static Thumb16
  184. R_ARM_THM_TLS_DESCSEQ32 = 130,// Static Thumb32
  185. // 131 - 135 Unallocated
  186. // Relocations for Armv8.1-M Mainline (BF/BFL)
  187. R_ARM_THM_BF16 = 136, // Static Thumb32 ((S + A) | T) – P
  188. R_ARM_THM_BF12 = 137, // Static Thumb32 ((S + A) | T) – P
  189. R_ARM_THM_BF18 = 138, // Static Thumb32 ((S + A) | T) – P
  190. // 139 Unallocated
  191. // 140 - 159 Dynamic Reserved for future allocation
  192. R_ARM_IRELATIVE = 160, // Dynamic
  193. // 161 - 255 Unallocated
  194. };
  195. // e_flags values used for ARM. We only support flags defined in AAELF.
  196. enum
  197. {
  198. EF_ARM_BE8 = 0x00800000,
  199. // Mask to extract EABI version, not really a flag value.
  200. EF_ARM_EABIMASK = 0xFF000000,
  201. EF_ARM_EABI_UNKNOWN = 0x00000000,
  202. EF_ARM_EABI_VER1 = 0x01000000,
  203. EF_ARM_EABI_VER2 = 0x02000000,
  204. EF_ARM_EABI_VER3 = 0x03000000,
  205. EF_ARM_EABI_VER4 = 0x04000000,
  206. EF_ARM_EABI_VER5 = 0x05000000,
  207. };
  208. // Extract EABI version from flags.
  209. inline Elf_Word
  210. arm_eabi_version(Elf_Word flags)
  211. { return flags & EF_ARM_EABIMASK; }
  212. // EABI_VER5 e_flags values for identifying soft- and hard-float ABI
  213. // choice.
  214. enum
  215. {
  216. EF_ARM_ABI_FLOAT_SOFT = 0x200,
  217. EF_ARM_ABI_FLOAT_HARD = 0x400,
  218. };
  219. // Values for the Tag_CPU_arch EABI attribute.
  220. enum
  221. {
  222. TAG_CPU_ARCH_PRE_V4,
  223. TAG_CPU_ARCH_V4,
  224. TAG_CPU_ARCH_V4T,
  225. TAG_CPU_ARCH_V5T,
  226. TAG_CPU_ARCH_V5TE,
  227. TAG_CPU_ARCH_V5TEJ,
  228. TAG_CPU_ARCH_V6,
  229. TAG_CPU_ARCH_V6KZ,
  230. TAG_CPU_ARCH_V6T2,
  231. TAG_CPU_ARCH_V6K,
  232. TAG_CPU_ARCH_V7,
  233. TAG_CPU_ARCH_V6_M,
  234. TAG_CPU_ARCH_V6S_M,
  235. TAG_CPU_ARCH_V7E_M,
  236. TAG_CPU_ARCH_V8,
  237. TAG_CPU_ARCH_V8R,
  238. TAG_CPU_ARCH_V8M_BASE,
  239. TAG_CPU_ARCH_V8M_MAIN,
  240. TAG_CPU_ARCH_8_1A,
  241. TAG_CPU_ARCH_8_2A,
  242. TAG_CPU_ARCH_8_3A,
  243. TAG_CPU_ARCH_V8_1M_MAIN,
  244. TAG_CPU_ARCH_V9,
  245. MAX_TAG_CPU_ARCH = TAG_CPU_ARCH_V9,
  246. // Pseudo-architecture to allow objects to be compatible with the subset of
  247. // armv4t and armv6-m. This value should never be stored in object files.
  248. TAG_CPU_ARCH_V4T_PLUS_V6_M = (MAX_TAG_CPU_ARCH + 1)
  249. };
  250. // EABI object attributes.
  251. enum
  252. {
  253. // 0-3 are generic.
  254. Tag_CPU_raw_name = 4,
  255. Tag_CPU_name = 5,
  256. Tag_CPU_arch = 6,
  257. Tag_CPU_arch_profile = 7,
  258. Tag_ARM_ISA_use = 8,
  259. Tag_THUMB_ISA_use = 9,
  260. Tag_FP_arch = 10,
  261. Tag_WMMX_arch = 11,
  262. Tag_Advanced_SIMD_arch = 12,
  263. Tag_PCS_config = 13,
  264. Tag_ABI_PCS_R9_use = 14,
  265. Tag_ABI_PCS_RW_data = 15,
  266. Tag_ABI_PCS_RO_data = 16,
  267. Tag_ABI_PCS_GOT_use = 17,
  268. Tag_ABI_PCS_wchar_t = 18,
  269. Tag_ABI_FP_rounding = 19,
  270. Tag_ABI_FP_denormal = 20,
  271. Tag_ABI_FP_exceptions = 21,
  272. Tag_ABI_FP_user_exceptions = 22,
  273. Tag_ABI_FP_number_model = 23,
  274. Tag_ABI_align_needed = 24,
  275. Tag_ABI_align_preserved = 25,
  276. Tag_ABI_enum_size = 26,
  277. Tag_ABI_HardFP_use = 27,
  278. Tag_ABI_VFP_args = 28,
  279. Tag_ABI_WMMX_args = 29,
  280. Tag_ABI_optimization_goals = 30,
  281. Tag_ABI_FP_optimization_goals = 31,
  282. // 32 is generic (Tag_compatibility).
  283. Tag_undefined33 = 33,
  284. Tag_CPU_unaligned_access = 34,
  285. Tag_undefined35 = 35,
  286. Tag_FP_HP_extension = 36,
  287. Tag_undefined37 = 37,
  288. Tag_ABI_FP_16bit_format = 38,
  289. Tag_undefined39 = 39,
  290. Tag_undefined40 = 40,
  291. Tag_undefined41 = 41,
  292. Tag_MPextension_use = 42,
  293. Tag_undefined43 = 43,
  294. Tag_DIV_use = 44,
  295. Tag_MVE_arch = 48,
  296. Tag_PAC_extension = 50,
  297. Tag_BTI_extension = 52,
  298. Tag_BTI_use = 74,
  299. Tag_PACRET_use = 76,
  300. Tag_nodefaults = 64,
  301. Tag_also_compatible_with = 65,
  302. Tag_T2EE_use = 66,
  303. Tag_conformance = 67,
  304. Tag_Virtualization_use = 68,
  305. Tag_undefined69 = 69,
  306. Tag_MPextension_use_legacy = 70,
  307. // The following tags are legacy names for other tags.
  308. Tag_VFP_arch = Tag_FP_arch,
  309. Tag_ABI_align8_needed = Tag_ABI_align_needed,
  310. Tag_ABI_align8_preserved = Tag_ABI_align_preserved,
  311. Tag_VFP_HP_extension = Tag_FP_HP_extension
  312. };
  313. // Values for Tag_ABI_PCS_R9_use.
  314. enum
  315. {
  316. AEABI_R9_V6 = 0,
  317. AEABI_R9_SB = 1,
  318. AEABI_R9_TLS = 2,
  319. AEABI_R9_unused = 3
  320. };
  321. // Values for Tag_ABI_PCS_RW_data.
  322. enum
  323. {
  324. AEABI_PCS_RW_data_absolute = 0,
  325. AEABI_PCS_RW_data_PCrel = 1,
  326. AEABI_PCS_RW_data_SBrel = 2,
  327. AEABI_PCS_RW_data_unused = 3
  328. };
  329. // Values for Tag_ABI_enum_size.
  330. enum
  331. {
  332. AEABI_enum_unused = 0,
  333. AEABI_enum_short = 1,
  334. AEABI_enum_wide = 2,
  335. AEABI_enum_forced_wide = 3
  336. };
  337. // Values for Tag_ABI_FP_number_model.
  338. enum
  339. {
  340. AEABI_FP_number_model_none = 0,
  341. AEABI_FP_number_model_ieee754_number = 1,
  342. AEABI_FP_number_model_rtabi = 2,
  343. AEABI_FP_number_model_ieee754_all = 3
  344. };
  345. // Values for Tag_ABI_VFP_args.
  346. enum
  347. {
  348. AEABI_VFP_args_base = 0,
  349. AEABI_VFP_args_vfp = 1,
  350. AEABI_VFP_args_toolchain = 2,
  351. AEABI_VFP_args_compatible = 3
  352. };
  353. // For Exception Index Table. (Exception handling ABI for the ARM
  354. // architectue, Section 5)
  355. enum
  356. {
  357. EXIDX_CANTUNWIND = 1,
  358. };
  359. } // End namespace elfcpp.
  360. #endif // !defined(ELFCPP_ARM_H)