xref: /onnv-gate/usr/src/uts/common/sys/machelf.h (revision 11827:d7ef53deac3f)
16206Sab196087 /*
26206Sab196087  * CDDL HEADER START
36206Sab196087  *
46206Sab196087  * The contents of this file are subject to the terms of the
56206Sab196087  * Common Development and Distribution License (the "License").
66206Sab196087  * You may not use this file except in compliance with the License.
76206Sab196087  *
86206Sab196087  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96206Sab196087  * or http://www.opensolaris.org/os/licensing.
106206Sab196087  * See the License for the specific language governing permissions
116206Sab196087  * and limitations under the License.
126206Sab196087  *
136206Sab196087  * When distributing Covered Code, include this CDDL HEADER in each
146206Sab196087  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156206Sab196087  * If applicable, add the following below this CDDL HEADER, with the
166206Sab196087  * fields enclosed by brackets "[]" replaced with your own identifying
176206Sab196087  * information: Portions Copyright [yyyy] [name of copyright owner]
186206Sab196087  *
196206Sab196087  * CDDL HEADER END
206206Sab196087  */
216206Sab196087 
226206Sab196087 /*
23*11827SRod.Evans@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
246206Sab196087  * Use is subject to license terms.
256206Sab196087  */
266206Sab196087 
276206Sab196087 #ifndef	_SYS_MACHELF_H
286206Sab196087 #define	_SYS_MACHELF_H
296206Sab196087 
306206Sab196087 #ifdef	__cplusplus
316206Sab196087 extern "C" {
326206Sab196087 #endif
336206Sab196087 
3410201SEdward.Pilatowicz@Sun.COM #if defined(__amd64) || (defined(__i386) && defined(_ELF64))
356206Sab196087 #include <sys/elf_amd64.h>
366206Sab196087 #elif defined(__i386)
376206Sab196087 #include <sys/elf_386.h>
386206Sab196087 #elif defined(__sparc)
396206Sab196087 #include <sys/elf_SPARC.h>
406206Sab196087 #endif
416206Sab196087 #ifndef	_ASM
426206Sab196087 #include <sys/types.h>
436206Sab196087 #include <sys/elf.h>
446206Sab196087 #include <sys/link.h>	/* for Elf*_Dyn */
456206Sab196087 #endif	/* _ASM */
466206Sab196087 
476206Sab196087 /*
486206Sab196087  * Make machine class dependent data types transparent to the common code
496206Sab196087  */
506206Sab196087 #if defined(_ELF64) && !defined(_ELF32_COMPAT)
516206Sab196087 
526206Sab196087 #ifndef	_ASM
536206Sab196087 typedef	Elf64_Xword	Xword;
546206Sab196087 typedef	Elf64_Lword	Lword;
556206Sab196087 typedef	Elf64_Sxword	Sxword;
566206Sab196087 typedef	Elf64_Word	Word;
576206Sab196087 typedef	Elf64_Sword	Sword;
586206Sab196087 typedef	Elf64_Half	Half;
596206Sab196087 typedef	Elf64_Addr	Addr;
606206Sab196087 typedef	Elf64_Off	Off;
616206Sab196087 typedef	uchar_t		Byte;
626206Sab196087 #endif	/* _ASM */
636206Sab196087 
646206Sab196087 #if defined(_KERNEL)
656206Sab196087 #define	ELF_R_TYPE	ELF64_R_TYPE
666206Sab196087 #define	ELF_R_SYM	ELF64_R_SYM
676206Sab196087 #define	ELF_R_TYPE_DATA ELF64_R_TYPE_DATA
686206Sab196087 #define	ELF_R_INFO	ELF64_R_INFO
696206Sab196087 #define	ELF_ST_BIND	ELF64_ST_BIND
706206Sab196087 #define	ELF_ST_TYPE	ELF64_ST_TYPE
716206Sab196087 #define	ELF_M_SYM	ELF64_M_SYM
726206Sab196087 #define	ELF_M_SIZE	ELF64_M_SIZE
736206Sab196087 #endif
746206Sab196087 
756206Sab196087 #ifndef	_ASM
766206Sab196087 typedef	Elf64_Ehdr	Ehdr;
776206Sab196087 typedef	Elf64_Shdr	Shdr;
786206Sab196087 typedef	Elf64_Sym	Sym;
796206Sab196087 typedef	Elf64_Syminfo	Syminfo;
806206Sab196087 typedef	Elf64_Rela	Rela;
816206Sab196087 typedef	Elf64_Rel	Rel;
826206Sab196087 typedef	Elf64_Nhdr	Nhdr;
836206Sab196087 typedef	Elf64_Phdr	Phdr;
846206Sab196087 typedef	Elf64_Dyn	Dyn;
856206Sab196087 typedef	Elf64_Boot	Boot;
866206Sab196087 typedef	Elf64_Verdef	Verdef;
876206Sab196087 typedef	Elf64_Verdaux	Verdaux;
886206Sab196087 typedef	Elf64_Verneed	Verneed;
896206Sab196087 typedef	Elf64_Vernaux	Vernaux;
906206Sab196087 typedef	Elf64_Versym	Versym;
916206Sab196087 typedef	Elf64_Move	Move;
926206Sab196087 typedef	Elf64_Cap	Cap;
93*11827SRod.Evans@Sun.COM typedef	Elf64_Capinfo	Capinfo;
94*11827SRod.Evans@Sun.COM typedef	Elf64_Capchain	Capchain;
956206Sab196087 #endif	/* _ASM */
966206Sab196087 
976206Sab196087 #else	/* _ILP32 */
986206Sab196087 
996206Sab196087 #ifndef	_ASM
1006206Sab196087 typedef	Elf32_Word	Xword;	/* Xword/Sxword are 32-bits in Elf32 */
1016206Sab196087 typedef	Elf32_Lword	Lword;
1026206Sab196087 typedef	Elf32_Sword	Sxword;
1036206Sab196087 typedef	Elf32_Word	Word;
1046206Sab196087 typedef	Elf32_Sword	Sword;
1056206Sab196087 typedef	Elf32_Half	Half;
1066206Sab196087 typedef	Elf32_Addr	Addr;
1076206Sab196087 typedef	Elf32_Off	Off;
1086206Sab196087 typedef	uchar_t		Byte;
1096206Sab196087 #endif	/* _ASM */
1106206Sab196087 
1116206Sab196087 #if defined(_KERNEL)
1126206Sab196087 #define	ELF_R_TYPE	ELF32_R_TYPE
1136206Sab196087 #define	ELF_R_SYM	ELF32_R_SYM
1146206Sab196087 #define	ELF_R_TYPE_DATA(x)	(0)
1156206Sab196087 #define	ELF_R_INFO	ELF32_R_INFO
1166206Sab196087 #define	ELF_ST_BIND	ELF32_ST_BIND
1176206Sab196087 #define	ELF_ST_TYPE	ELF32_ST_TYPE
1186206Sab196087 #define	ELF_M_SYM	ELF32_M_SYM
1196206Sab196087 #define	ELF_M_SIZE	ELF32_M_SIZE
1206206Sab196087 #endif
1216206Sab196087 
1226206Sab196087 #ifndef	_ASM
1236206Sab196087 typedef	Elf32_Ehdr	Ehdr;
1246206Sab196087 typedef	Elf32_Shdr	Shdr;
1256206Sab196087 typedef	Elf32_Sym	Sym;
1266206Sab196087 typedef	Elf32_Syminfo	Syminfo;
1276206Sab196087 typedef	Elf32_Rela	Rela;
1286206Sab196087 typedef	Elf32_Rel	Rel;
1296206Sab196087 typedef	Elf32_Nhdr	Nhdr;
1306206Sab196087 typedef	Elf32_Phdr	Phdr;
1316206Sab196087 typedef	Elf32_Dyn	Dyn;
1326206Sab196087 typedef	Elf32_Boot	Boot;
1336206Sab196087 typedef	Elf32_Verdef	Verdef;
1346206Sab196087 typedef	Elf32_Verdaux	Verdaux;
1356206Sab196087 typedef	Elf32_Verneed	Verneed;
1366206Sab196087 typedef	Elf32_Vernaux	Vernaux;
1376206Sab196087 typedef	Elf32_Versym	Versym;
1386206Sab196087 typedef	Elf32_Move	Move;
1396206Sab196087 typedef	Elf32_Cap	Cap;
140*11827SRod.Evans@Sun.COM typedef	Elf32_Capinfo	Capinfo;
141*11827SRod.Evans@Sun.COM typedef	Elf32_Capchain	Capchain;
1426206Sab196087 #endif	/* _ASM */
1436206Sab196087 
1446206Sab196087 #endif	/* _ILP32 */
1456206Sab196087 
1466206Sab196087 /*
1476206Sab196087  * Elf `printf' type-cast macros.  These force arguments to be a fixed size
1486206Sab196087  * so that Elf32 and Elf64 can share common format strings.
1496206Sab196087  */
1506206Sab196087 #ifndef	__lint
1516206Sab196087 #define	EC_ADDR(a)	((Elf64_Addr)(a))		/* "ull" */
1526206Sab196087 #define	EC_OFF(a)	((Elf64_Off)(a))		/* "ull"  */
1536206Sab196087 #define	EC_HALF(a)	((Elf64_Half)(a))		/* "d"   */
1546206Sab196087 #define	EC_WORD(a)	((Elf64_Word)(a))		/* "u"   */
1556206Sab196087 #define	EC_SWORD(a)	((Elf64_Sword)(a))		/* "d"   */
1566206Sab196087 #define	EC_XWORD(a)	((Elf64_Xword)(a))		/* "ull" */
1576206Sab196087 #define	EC_SXWORD(a)	((Elf64_Sxword)(a))		/* "ll"  */
1586206Sab196087 #define	EC_LWORD(a)	((Elf64_Lword)(a))		/* "ull" */
1596206Sab196087 
1606206Sab196087 /*
1616206Sab196087  * A native pointer is special.  Although it can be convenient to display
1626206Sab196087  * these from a common format (ull), compilers may flag the cast of a pointer
1636206Sab196087  * to an integer as illegal.  Casting these pointers to the native pointer
1646206Sab196087  * size, suppresses any compiler errors.
1656206Sab196087  */
1666206Sab196087 #define	EC_NATPTR(a)	((Elf64_Xword)(uintptr_t)(a))	/* "ull" */
1676206Sab196087 #else
1686206Sab196087 #define	EC_ADDR(a)	((u_longlong_t)(a))
1696206Sab196087 #define	EC_OFF(a)	((u_longlong_t)(a))
1706206Sab196087 #define	EC_HALF(a)	((ushort_t)(a))
1716206Sab196087 #define	EC_WORD(a)	((uint_t)(a))
1726206Sab196087 #define	EC_SWORD(a)	((int)(a))
1736206Sab196087 #define	EC_XWORD(a)	((u_longlong_t)(a))
1746206Sab196087 #define	EC_SXWORD(a)	((longlong_t)(a))
1756206Sab196087 #define	EC_LWORD(a)	((u_longlong_t)(a))
1766206Sab196087 
1776206Sab196087 #define	EC_NATPTR(a)	((u_longlong_t)(a))
1786206Sab196087 #endif
1796206Sab196087 
1806206Sab196087 #ifdef	__cplusplus
1816206Sab196087 }
1826206Sab196087 #endif
1836206Sab196087 
1846206Sab196087 #endif	/* _SYS_MACHELF_H */
185