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