xref: /netbsd-src/external/gpl3/gdb/dist/include/elf/aarch64.h (revision bfcefd56cfc74946ba0f251734a8426a0b91e115)
1 /* AArch64 ELF support for BFD.
2 
3    Copyright 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
4    Contributed by ARM Ltd.
5 
6    This file is part of GNU Binutils.
7 
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the license, or
11    (at your option) any later version.
12 
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program; see the file COPYING3. If not,
20    see <http://www.gnu.org/licenses/>.  */
21 
22 #ifndef _ELF_AARCH64_H
23 #define _ELF_AARCH64_H
24 
25 #include "elf/reloc-macros.h"
26 
27 /* Processor specific program header types.  */
28 #define PT_AARCH64_ARCHEXT	(PT_LOPROC + 0)
29 
30 /* Additional section types.  */
31 #define SHT_AARCH64_ATTRIBUTES	0x70000003  /* Section holds attributes.  */
32 
33 /* AArch64-specific values for sh_flags.  */
34 #define SHF_ENTRYSECT		0x10000000   /* Section contains an
35 						entry point.  */
36 #define SHF_COMDEF		0x80000000   /* Section may be multiply defined
37 						in the input to a link step.  */
38 
39 /* Relocation types.  */
40 
41 START_RELOC_NUMBERS (elf_aarch64_reloc_type)
42 
43 /* Null relocations.  */
44 RELOC_NUMBER (R_AARCH64_NONE, 0) /* No reloc */
45 
46 FAKE_RELOC (R_AARCH64_static_min, 256)
47 
48 RELOC_NUMBER (R_AARCH64_NULL, 256) /* No reloc */
49 
50 /* Basic data relocations.  */
51 
52 /* .xword: (S+A) */
53 RELOC_NUMBER (R_AARCH64_ABS64, 257)
54 
55 /* .word:  (S+A) */
56 RELOC_NUMBER (R_AARCH64_ABS32, 258)
57 
58 /* .half: (S+A) */
59 RELOC_NUMBER (R_AARCH64_ABS16, 259)
60 
61 /* .xword: (S+A-P) */
62 RELOC_NUMBER (R_AARCH64_PREL64, 260)
63 
64 /* .word: (S+A-P) */
65 RELOC_NUMBER (R_AARCH64_PREL32, 261)
66 
67 /* .half:  (S+A-P) */
68 RELOC_NUMBER (R_AARCH64_PREL16, 262)
69 
70 /* Group relocations to create a 16, 32, 48 or 64 bit
71    unsigned data or abs address inline.  */
72 
73 /* MOV[ZK]:   ((S+A) >>  0) & 0xffff */
74 RELOC_NUMBER (R_AARCH64_MOVW_UABS_G0,		263)
75 
76 /* MOV[ZK]:   ((S+A) >>  0) & 0xffff */
77 RELOC_NUMBER (R_AARCH64_MOVW_UABS_G0_NC, 264)
78 
79 /* MOV[ZK]:   ((S+A) >> 16) & 0xffff */
80 RELOC_NUMBER (R_AARCH64_MOVW_UABS_G1, 265)
81 
82 /* MOV[ZK]:   ((S+A) >> 16) & 0xffff */
83 RELOC_NUMBER (R_AARCH64_MOVW_UABS_G1_NC, 266)
84 
85 /* MOV[ZK]:   ((S+A) >> 32) & 0xffff */
86 RELOC_NUMBER (R_AARCH64_MOVW_UABS_G2, 267)
87 
88 /* MOV[ZK]:   ((S+A) >> 32) & 0xffff */
89 RELOC_NUMBER (R_AARCH64_MOVW_UABS_G2_NC, 268)
90 
91 /* MOV[ZK]:   ((S+A) >> 48) & 0xffff */
92 RELOC_NUMBER (R_AARCH64_MOVW_UABS_G3, 269)
93 
94 /* Group relocations to create high part of a 16, 32, 48 or 64 bit
95    signed data or abs address inline. Will change instruction
96    to MOVN or MOVZ depending on sign of calculated value.  */
97 
98 /* MOV[ZN]:   ((S+A) >>  0) & 0xffff */
99 RELOC_NUMBER (R_AARCH64_MOVW_SABS_G0, 270)
100 
101 /* MOV[ZN]:   ((S+A) >> 16) & 0xffff */
102 RELOC_NUMBER (R_AARCH64_MOVW_SABS_G1, 271)
103 
104 /* MOV[ZN]:   ((S+A) >> 32) & 0xffff */
105 RELOC_NUMBER (R_AARCH64_MOVW_SABS_G2, 272)
106 
107 /* Relocations to generate 19, 21 and 33 bit PC-relative load/store
108    addresses: PG(x) is (x & ~0xfff).  */
109 
110 /* LD-lit: ((S+A-P) >> 2) & 0x7ffff */
111 RELOC_NUMBER (R_AARCH64_LD_PREL_LO19, 273)
112 
113 /* ADR:    (S+A-P) & 0x1fffff */
114 RELOC_NUMBER (R_AARCH64_ADR_PREL_LO21, 274)
115 
116 /* ADRH:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
117 RELOC_NUMBER (R_AARCH64_ADR_PREL_PG_HI21, 275)
118 
119 /* ADRH:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
120 RELOC_NUMBER (R_AARCH64_ADR_PREL_PG_HI21_NC, 276)
121 
122 /* ADD:    (S+A) & 0xfff */
123 RELOC_NUMBER (R_AARCH64_ADD_ABS_LO12_NC, 277)
124 
125 /* LD/ST8: (S+A) & 0xfff */
126 RELOC_NUMBER (R_AARCH64_LDST8_ABS_LO12_NC, 278)
127 
128 /* Relocations for control-flow instructions.  */
129 
130 /* TBZ/NZ: ((S+A-P) >> 2) & 0x3fff.  */
131 RELOC_NUMBER (R_AARCH64_TSTBR14, 279)
132 
133 /* B.cond: ((S+A-P) >> 2) & 0x7ffff.  */
134 RELOC_NUMBER (R_AARCH64_CONDBR19, 280)
135 
136 /* 281 unused */
137 
138 /* B:      ((S+A-P) >> 2) & 0x3ffffff.  */
139 RELOC_NUMBER (R_AARCH64_JUMP26, 282)
140 
141 /* BL:     ((S+A-P) >> 2) & 0x3ffffff.  */
142 RELOC_NUMBER (R_AARCH64_CALL26, 283)
143 
144 /* LD/ST16: (S+A) & 0xffe */
145 RELOC_NUMBER (R_AARCH64_LDST16_ABS_LO12_NC, 284)
146 
147 /* LD/ST32: (S+A) & 0xffc */
148 RELOC_NUMBER (R_AARCH64_LDST32_ABS_LO12_NC, 285)
149 
150 /* LD/ST64: (S+A) & 0xff8 */
151 RELOC_NUMBER (R_AARCH64_LDST64_ABS_LO12_NC, 286)
152 
153 /* LD/ST128: (S+A) & 0xff0 */
154 RELOC_NUMBER (R_AARCH64_LDST128_ABS_LO12_NC, 299)
155 
156 RELOC_NUMBER (R_AARCH64_GOT_LD_PREL19, 309)
157 RELOC_NUMBER (R_AARCH64_ADR_GOT_PAGE, 311)
158 RELOC_NUMBER (R_AARCH64_LD64_GOT_LO12_NC, 312)
159 
160 FAKE_RELOC (R_AARCH64_static_max, 313)
161 
162 FAKE_RELOC (R_AARCH64_tls_min, 512)
163 RELOC_NUMBER (R_AARCH64_TLSGD_ADR_PAGE21, 513)
164 RELOC_NUMBER (R_AARCH64_TLSGD_ADD_LO12_NC, 514)
165 RELOC_NUMBER (R_AARCH64_TLSIE_MOVW_GOTTPREL_G1, 539)
166 RELOC_NUMBER (R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC, 540)
167 RELOC_NUMBER (R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21, 541)
168 RELOC_NUMBER (R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC, 542)
169 RELOC_NUMBER (R_AARCH64_TLSIE_LD_GOTTPREL_PREL19, 543)
170 RELOC_NUMBER (R_AARCH64_TLSLE_MOVW_TPREL_G2, 544)
171 RELOC_NUMBER (R_AARCH64_TLSLE_MOVW_TPREL_G1, 545)
172 RELOC_NUMBER (R_AARCH64_TLSLE_MOVW_TPREL_G1_NC, 546)
173 RELOC_NUMBER (R_AARCH64_TLSLE_MOVW_TPREL_G0, 547)
174 RELOC_NUMBER (R_AARCH64_TLSLE_MOVW_TPREL_G0_NC, 548)
175 RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_HI12, 549)
176 RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_LO12, 550)
177 RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, 551)
178 FAKE_RELOC (R_AARCH64_tls_max, 552)
179 
180 FAKE_RELOC (R_AARCH64_tlsdesc_min, 560)
181 RELOC_NUMBER (R_AARCH64_TLSDESC_LD64_PREL19, 560)
182 RELOC_NUMBER (R_AARCH64_TLSDESC_ADR_PREL21, 561)
183 RELOC_NUMBER (R_AARCH64_TLSDESC_ADR_PAGE, 562)
184 RELOC_NUMBER (R_AARCH64_TLSDESC_LD64_LO12_NC, 563)
185 RELOC_NUMBER (R_AARCH64_TLSDESC_ADD_LO12_NC, 564)
186 RELOC_NUMBER (R_AARCH64_TLSDESC_OFF_G1, 565)
187 RELOC_NUMBER (R_AARCH64_TLSDESC_OFF_G0_NC, 566)
188 RELOC_NUMBER (R_AARCH64_TLSDESC_LDR, 567)
189 RELOC_NUMBER (R_AARCH64_TLSDESC_ADD, 568)
190 RELOC_NUMBER (R_AARCH64_TLSDESC_CALL, 569)
191 FAKE_RELOC (R_AARCH64_tlsdesc_max, 570)
192 
193 /* Dynamic relocations */
194 FAKE_RELOC (R_AARCH64_dyn_min, 1024)
195 
196 /* Copy symbol at runtime.  */
197 RELOC_NUMBER (R_AARCH64_COPY, 1024)
198 
199 /* Create GOT entry.  */
200 RELOC_NUMBER (R_AARCH64_GLOB_DAT, 1025)
201 
202  /* Create PLT entry.  */
203 RELOC_NUMBER (R_AARCH64_JUMP_SLOT, 1026)
204 
205 /* Adjust by program base.  */
206 RELOC_NUMBER (R_AARCH64_RELATIVE, 1027)
207 RELOC_NUMBER (R_AARCH64_TLS_DTPMOD64, 1028)
208 RELOC_NUMBER (R_AARCH64_TLS_DTPREL64, 1029)
209 RELOC_NUMBER (R_AARCH64_TLS_TPREL64, 1030)
210 RELOC_NUMBER (R_AARCH64_TLSDESC, 1031)
211 FAKE_RELOC (R_AARCH64_dyn_max, 1032)
212 
213 END_RELOC_NUMBERS (R_AARCH64_end)
214 
215 #endif /* _ELF_AARCH64_H */
216