xref: /titanic_51/usr/src/uts/common/sys/elf_SPARC.h (revision d9452f237f843c1321abb5810d2f9ee6cbeae43c)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52926dd2eSrie  * Common Development and Distribution License (the "License").
62926dd2eSrie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
212926dd2eSrie 
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  *	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
247c478bd9Sstevel@tonic-gate  *	  All Rights Reserved
257c478bd9Sstevel@tonic-gate  *
26*d9452f23SEdward Pilatowicz  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
277c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef _SYS_ELF_SPARC_H
317c478bd9Sstevel@tonic-gate #define	_SYS_ELF_SPARC_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #define	EF_SPARC_32PLUS_MASK	0xffff00	/* bits indicating V8+ type */
387c478bd9Sstevel@tonic-gate #define	EF_SPARC_32PLUS		0x000100	/* generic V8+ features */
397c478bd9Sstevel@tonic-gate #define	EF_SPARC_EXT_MASK	0xffff00	/* bits for vendor extensions */
407c478bd9Sstevel@tonic-gate #define	EF_SPARC_SUN_US1	0x000200	/* Sun UltraSPARC1 extensions */
417c478bd9Sstevel@tonic-gate #define	EF_SPARC_HAL_R1		0x000400	/* HAL R1 extensions */
427c478bd9Sstevel@tonic-gate #define	EF_SPARC_SUN_US3	0x000800	/* Sun UltraSPARC3 extensions */
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #define	EF_SPARCV9_MM		0x3		/* mask for memory model */
457c478bd9Sstevel@tonic-gate #define	EF_SPARCV9_TSO		0x0		/* total store ordering */
467c478bd9Sstevel@tonic-gate #define	EF_SPARCV9_PSO		0x1		/* partial store ordering */
477c478bd9Sstevel@tonic-gate #define	EF_SPARCV9_RMO		0x2		/* relaxed memory ordering */
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #define	R_SPARC_NONE		0		/* relocation type */
507c478bd9Sstevel@tonic-gate #define	R_SPARC_8		1
517c478bd9Sstevel@tonic-gate #define	R_SPARC_16		2
527c478bd9Sstevel@tonic-gate #define	R_SPARC_32		3
537c478bd9Sstevel@tonic-gate #define	R_SPARC_DISP8		4
547c478bd9Sstevel@tonic-gate #define	R_SPARC_DISP16		5
557c478bd9Sstevel@tonic-gate #define	R_SPARC_DISP32		6
567c478bd9Sstevel@tonic-gate #define	R_SPARC_WDISP30		7
577c478bd9Sstevel@tonic-gate #define	R_SPARC_WDISP22		8
587c478bd9Sstevel@tonic-gate #define	R_SPARC_HI22		9
597c478bd9Sstevel@tonic-gate #define	R_SPARC_22		10
607c478bd9Sstevel@tonic-gate #define	R_SPARC_13		11
617c478bd9Sstevel@tonic-gate #define	R_SPARC_LO10		12
627c478bd9Sstevel@tonic-gate #define	R_SPARC_GOT10		13
637c478bd9Sstevel@tonic-gate #define	R_SPARC_GOT13		14
647c478bd9Sstevel@tonic-gate #define	R_SPARC_GOT22		15
657c478bd9Sstevel@tonic-gate #define	R_SPARC_PC10		16
667c478bd9Sstevel@tonic-gate #define	R_SPARC_PC22		17
677c478bd9Sstevel@tonic-gate #define	R_SPARC_WPLT30		18
687c478bd9Sstevel@tonic-gate #define	R_SPARC_COPY		19
697c478bd9Sstevel@tonic-gate #define	R_SPARC_GLOB_DAT	20
707c478bd9Sstevel@tonic-gate #define	R_SPARC_JMP_SLOT	21
717c478bd9Sstevel@tonic-gate #define	R_SPARC_RELATIVE	22
727c478bd9Sstevel@tonic-gate #define	R_SPARC_UA32		23
737c478bd9Sstevel@tonic-gate #define	R_SPARC_PLT32		24
747c478bd9Sstevel@tonic-gate #define	R_SPARC_HIPLT22		25
757c478bd9Sstevel@tonic-gate #define	R_SPARC_LOPLT10		26
767c478bd9Sstevel@tonic-gate #define	R_SPARC_PCPLT32		27
777c478bd9Sstevel@tonic-gate #define	R_SPARC_PCPLT22		28
787c478bd9Sstevel@tonic-gate #define	R_SPARC_PCPLT10		29
797c478bd9Sstevel@tonic-gate #define	R_SPARC_10		30
807c478bd9Sstevel@tonic-gate #define	R_SPARC_11		31
817c478bd9Sstevel@tonic-gate #define	R_SPARC_64		32
827c478bd9Sstevel@tonic-gate #define	R_SPARC_OLO10		33
837c478bd9Sstevel@tonic-gate #define	R_SPARC_HH22		34
847c478bd9Sstevel@tonic-gate #define	R_SPARC_HM10		35
857c478bd9Sstevel@tonic-gate #define	R_SPARC_LM22		36
867c478bd9Sstevel@tonic-gate #define	R_SPARC_PC_HH22		37
877c478bd9Sstevel@tonic-gate #define	R_SPARC_PC_HM10		38
887c478bd9Sstevel@tonic-gate #define	R_SPARC_PC_LM22		39
897c478bd9Sstevel@tonic-gate #define	R_SPARC_WDISP16		40
907c478bd9Sstevel@tonic-gate #define	R_SPARC_WDISP19		41
917c478bd9Sstevel@tonic-gate #define	R_SPARC_GLOB_JMP	42
927c478bd9Sstevel@tonic-gate #define	R_SPARC_7		43
937c478bd9Sstevel@tonic-gate #define	R_SPARC_5		44
947c478bd9Sstevel@tonic-gate #define	R_SPARC_6		45
957c478bd9Sstevel@tonic-gate #define	R_SPARC_DISP64		46
967c478bd9Sstevel@tonic-gate #define	R_SPARC_PLT64		47
977c478bd9Sstevel@tonic-gate #define	R_SPARC_HIX22		48
987c478bd9Sstevel@tonic-gate #define	R_SPARC_LOX10		49
997c478bd9Sstevel@tonic-gate #define	R_SPARC_H44		50
1007c478bd9Sstevel@tonic-gate #define	R_SPARC_M44		51
1017c478bd9Sstevel@tonic-gate #define	R_SPARC_L44		52
1027c478bd9Sstevel@tonic-gate #define	R_SPARC_REGISTER	53
1037c478bd9Sstevel@tonic-gate #define	R_SPARC_UA64		54
1047c478bd9Sstevel@tonic-gate #define	R_SPARC_UA16		55
1057c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_GD_HI22	56
1067c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_GD_LO10	57
1077c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_GD_ADD	58
1087c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_GD_CALL	59
1097c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_LDM_HI22	60
1107c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_LDM_LO10	61
1117c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_LDM_ADD	62
1127c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_LDM_CALL	63
1137c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_LDO_HIX22	64
1147c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_LDO_LOX10	65
1157c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_LDO_ADD	66
1167c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_IE_HI22	67
1177c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_IE_LO10	68
1187c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_IE_LD	69
1197c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_IE_LDX	70
1207c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_IE_ADD	71
1217c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_LE_HIX22	72
1227c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_LE_LOX10	73
1237c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_DTPMOD32	74
1247c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_DTPMOD64	75
1257c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_DTPOFF32	76
1267c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_DTPOFF64	77
1277c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_TPOFF32	78
1287c478bd9Sstevel@tonic-gate #define	R_SPARC_TLS_TPOFF64	79
1297c478bd9Sstevel@tonic-gate #define	R_SPARC_GOTDATA_HIX22	80
1307c478bd9Sstevel@tonic-gate #define	R_SPARC_GOTDATA_LOX10	81
1317c478bd9Sstevel@tonic-gate #define	R_SPARC_GOTDATA_OP_HIX22	82
1327c478bd9Sstevel@tonic-gate #define	R_SPARC_GOTDATA_OP_LOX10	83
1337c478bd9Sstevel@tonic-gate #define	R_SPARC_GOTDATA_OP	84
1347c478bd9Sstevel@tonic-gate #define	R_SPARC_H34		85
1352926dd2eSrie #define	R_SPARC_SIZE32		86
1362926dd2eSrie #define	R_SPARC_SIZE64		87
1372926dd2eSrie #define	R_SPARC_NUM		88
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate /*
1407c478bd9Sstevel@tonic-gate  * Relocation aliases
1417c478bd9Sstevel@tonic-gate  */
1427c478bd9Sstevel@tonic-gate #define	R_SPARC_L34	R_SPARC_L44	/* associated with R_SPARC_H34 */
1437c478bd9Sstevel@tonic-gate 					/*   same calc as R_SPARC_L44 */
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate #define	ELF_SPARC_MAXPGSZ	0x10000		/* maximum page size */
1467c478bd9Sstevel@tonic-gate #define	ELF_SPARCV9_MAXPGSZ	0x100000
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate /*
1497c478bd9Sstevel@tonic-gate  * Processor specific section types
1507c478bd9Sstevel@tonic-gate  */
1517c478bd9Sstevel@tonic-gate #define	SHT_SPARC_GOTDATA	0x70000000
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate #define	SHF_ORDERED		0x40000000
1547c478bd9Sstevel@tonic-gate #define	SHF_EXCLUDE		0x80000000
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate #define	SHN_BEFORE		0xff00
1577c478bd9Sstevel@tonic-gate #define	SHN_AFTER		0xff01
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate #define	STT_SPARC_REGISTER	13		/* register symbol type */
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #define	DT_SPARC_REGISTER	0x70000001	/* identifies register */
1627c478bd9Sstevel@tonic-gate 						/*	symbols */
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate /*
1667c478bd9Sstevel@tonic-gate  * Register symbol numbers - to be used in the st_value field
1677c478bd9Sstevel@tonic-gate  * of register symbols.
1687c478bd9Sstevel@tonic-gate  */
1697c478bd9Sstevel@tonic-gate #define	STO_SPARC_REGISTER_G1	0x1		/* register %g1 */
1707c478bd9Sstevel@tonic-gate #define	STO_SPARC_REGISTER_G2	0x2		/* register %g2 */
1717c478bd9Sstevel@tonic-gate #define	STO_SPARC_REGISTER_G3	0x3		/* register %g3 */
1727c478bd9Sstevel@tonic-gate #define	STO_SPARC_REGISTER_G4	0x4		/* register %g4 */
1737c478bd9Sstevel@tonic-gate #define	STO_SPARC_REGISTER_G5	0x5		/* register %g5 */
1747c478bd9Sstevel@tonic-gate #define	STO_SPARC_REGISTER_G6	0x6		/* register %g6 */
1757c478bd9Sstevel@tonic-gate #define	STO_SPARC_REGISTER_G7	0x7		/* register %g7 */
1767c478bd9Sstevel@tonic-gate 
177*d9452f23SEdward Pilatowicz /*
178*d9452f23SEdward Pilatowicz  * There are consumers of this file that want to include elf defines for
179*d9452f23SEdward Pilatowicz  * all architectures.  This is a problem for the defines below, because
180*d9452f23SEdward Pilatowicz  * while they are architecture specific they have common names.  Hence to
181*d9452f23SEdward Pilatowicz  * prevent attempts to redefine these variables we'll check if any of
182*d9452f23SEdward Pilatowicz  * the other elf architecture header files have been included.  If
183*d9452f23SEdward Pilatowicz  * they have then we'll just stick with the existing definitions.
184*d9452f23SEdward Pilatowicz  */
185*d9452f23SEdward Pilatowicz #if !defined(_SYS_ELF_MACH_COMMON)
186*d9452f23SEdward Pilatowicz #define	_SYS_ELF_MACH_COMMON
187*d9452f23SEdward Pilatowicz 
188*d9452f23SEdward Pilatowicz /*
189*d9452f23SEdward Pilatowicz  * Plt and Got information; the first few .got and .plt entries are reserved
190*d9452f23SEdward Pilatowicz  *	PLT[0]	jump to dynamic linker
191*d9452f23SEdward Pilatowicz  *	GOT[0]	address of _DYNAMIC
192*d9452f23SEdward Pilatowicz  */
193*d9452f23SEdward Pilatowicz #define	M_PLT_INSSIZE		4	/* single plt instruction size */
194*d9452f23SEdward Pilatowicz #define	M_PLT_XNumber		4	/* reserved no. of plt entries */
195*d9452f23SEdward Pilatowicz #define	M_GOT_XDYNAMIC		0	/* got index for _DYNAMIC */
196*d9452f23SEdward Pilatowicz #define	M_GOT_XNumber		1	/* reserved no. of got entries */
197*d9452f23SEdward Pilatowicz 
198*d9452f23SEdward Pilatowicz /*
199*d9452f23SEdward Pilatowicz  * ELF32 bit PLT constants
200*d9452f23SEdward Pilatowicz  */
201*d9452f23SEdward Pilatowicz #define	M32_WORD_ALIGN		4
202*d9452f23SEdward Pilatowicz #define	M32_PLT_ENTSIZE		12	/* plt entry size in bytes */
203*d9452f23SEdward Pilatowicz #define	M32_PLT_ALIGN		M_WORD_ALIGN /* alignment of .plt section */
204*d9452f23SEdward Pilatowicz #define	M32_GOT_ENTSIZE		4	/* got entry size in bytes */
205*d9452f23SEdward Pilatowicz #define	M32_GOT_MAXSMALL	2048	/* maximum no. of small gots */
206*d9452f23SEdward Pilatowicz #define	M32_PLT_RESERVSZ	(M_PLT_XNumber * \
207*d9452f23SEdward Pilatowicz 				M32_PLT_ENTSIZE) /* first 4 plt's reserved */
208*d9452f23SEdward Pilatowicz 
209*d9452f23SEdward Pilatowicz /*
210*d9452f23SEdward Pilatowicz  * ELF64 bit PLT constants
211*d9452f23SEdward Pilatowicz  */
212*d9452f23SEdward Pilatowicz #define	M64_WORD_ALIGN		8
213*d9452f23SEdward Pilatowicz #define	M64_PLT_ENTSIZE		32	/* plt entry size in bytes */
214*d9452f23SEdward Pilatowicz #define	M64_PLT_ALIGN		256	/* alignment of .plt section */
215*d9452f23SEdward Pilatowicz #define	M64_GOT_ENTSIZE		8	/* got entry size in bytes */
216*d9452f23SEdward Pilatowicz #define	M64_GOT_MAXSMALL	1024	/* maximum no. of small gots */
217*d9452f23SEdward Pilatowicz #define	M64_PLT_RESERVSZ	(M_PLT_XNumber * \
218*d9452f23SEdward Pilatowicz 				M64_PLT_ENTSIZE) /* first 4 plt's reserved */
219*d9452f23SEdward Pilatowicz 
220*d9452f23SEdward Pilatowicz #define	M64_PLT_NEARPLTS	0x8000	/* # of NEAR PLTS we can have */
221*d9452f23SEdward Pilatowicz #define	M64_PLT_FENTSIZE	24	/* size of far plt is 6 instructions */
222*d9452f23SEdward Pilatowicz 					/*	x 4bytes */
223*d9452f23SEdward Pilatowicz #define	M64_PLT_PSIZE		8		/* size of PLTP pointer */
224*d9452f23SEdward Pilatowicz #define	M64_PLT_FBLKCNTS	160	/* # of plts in far PLT blocks */
225*d9452f23SEdward Pilatowicz #define	M64_PLT_FBLOCKSZ	(M64_PLT_FBLKCNTS *\
226*d9452f23SEdward Pilatowicz 				M64_PLT_ENTSIZE) /* size of far PLT block */
227*d9452f23SEdward Pilatowicz 
228*d9452f23SEdward Pilatowicz 
229*d9452f23SEdward Pilatowicz /*
230*d9452f23SEdward Pilatowicz  * Make common alias for the 32/64 bit specific defines based on _ELF64
231*d9452f23SEdward Pilatowicz  */
232*d9452f23SEdward Pilatowicz #ifdef _ELF64
233*d9452f23SEdward Pilatowicz /* architecture common defines */
234*d9452f23SEdward Pilatowicz #define	M_WORD_ALIGN		M64_WORD_ALIGN
235*d9452f23SEdward Pilatowicz #define	M_PLT_ENTSIZE		M64_PLT_ENTSIZE
236*d9452f23SEdward Pilatowicz #define	M_PLT_ALIGN		M64_PLT_ALIGN
237*d9452f23SEdward Pilatowicz #define	M_PLT_RESERVSZ		M64_PLT_RESERVSZ
238*d9452f23SEdward Pilatowicz #define	M_GOT_ENTSIZE		M64_GOT_ENTSIZE
239*d9452f23SEdward Pilatowicz /* sparc specific defines */
240*d9452f23SEdward Pilatowicz #define	M_GOT_MAXSMALL		M64_GOT_MAXSMALL
241*d9452f23SEdward Pilatowicz #else /* !_ELF64 */
242*d9452f23SEdward Pilatowicz /* architecture common defines */
243*d9452f23SEdward Pilatowicz #define	M_WORD_ALIGN		M32_WORD_ALIGN
244*d9452f23SEdward Pilatowicz #define	M_PLT_ENTSIZE		M32_PLT_ENTSIZE
245*d9452f23SEdward Pilatowicz #define	M_PLT_ALIGN		M32_PLT_ALIGN
246*d9452f23SEdward Pilatowicz #define	M_PLT_RESERVSZ		M32_PLT_RESERVSZ
247*d9452f23SEdward Pilatowicz #define	M_GOT_ENTSIZE		M32_GOT_ENTSIZE
248*d9452f23SEdward Pilatowicz /* sparc specific defines */
249*d9452f23SEdward Pilatowicz #define	M_GOT_MAXSMALL		M32_GOT_MAXSMALL
250*d9452f23SEdward Pilatowicz #endif /* !_ELF64 */
251*d9452f23SEdward Pilatowicz 
252*d9452f23SEdward Pilatowicz #endif /* !_SYS_ELF_MACH_COMMON */
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2557c478bd9Sstevel@tonic-gate }
2567c478bd9Sstevel@tonic-gate #endif
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate #endif	/* _SYS_ELF_SPARC_H */
259