1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_MACHELF_H 28 #define _SYS_MACHELF_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #if defined(__amd64) || (defined(__i386) && defined(_ELF64)) 35 #include <sys/elf_amd64.h> 36 #elif defined(__i386) 37 #include <sys/elf_386.h> 38 #elif defined(__sparc) 39 #include <sys/elf_SPARC.h> 40 #endif 41 #ifndef _ASM 42 #include <sys/types.h> 43 #include <sys/elf.h> 44 #include <sys/link.h> /* for Elf*_Dyn */ 45 #endif /* _ASM */ 46 47 /* 48 * Make machine class dependent data types transparent to the common code 49 */ 50 #if defined(_ELF64) && !defined(_ELF32_COMPAT) 51 52 #ifndef _ASM 53 typedef Elf64_Xword Xword; 54 typedef Elf64_Lword Lword; 55 typedef Elf64_Sxword Sxword; 56 typedef Elf64_Word Word; 57 typedef Elf64_Sword Sword; 58 typedef Elf64_Half Half; 59 typedef Elf64_Addr Addr; 60 typedef Elf64_Off Off; 61 typedef uchar_t Byte; 62 #endif /* _ASM */ 63 64 #if defined(_KERNEL) 65 #define ELF_R_TYPE ELF64_R_TYPE 66 #define ELF_R_SYM ELF64_R_SYM 67 #define ELF_R_TYPE_DATA ELF64_R_TYPE_DATA 68 #define ELF_R_INFO ELF64_R_INFO 69 #define ELF_ST_BIND ELF64_ST_BIND 70 #define ELF_ST_TYPE ELF64_ST_TYPE 71 #define ELF_M_SYM ELF64_M_SYM 72 #define ELF_M_SIZE ELF64_M_SIZE 73 #endif 74 75 #ifndef _ASM 76 typedef Elf64_Ehdr Ehdr; 77 typedef Elf64_Shdr Shdr; 78 typedef Elf64_Sym Sym; 79 typedef Elf64_Syminfo Syminfo; 80 typedef Elf64_Rela Rela; 81 typedef Elf64_Rel Rel; 82 typedef Elf64_Nhdr Nhdr; 83 typedef Elf64_Phdr Phdr; 84 typedef Elf64_Dyn Dyn; 85 typedef Elf64_Boot Boot; 86 typedef Elf64_Verdef Verdef; 87 typedef Elf64_Verdaux Verdaux; 88 typedef Elf64_Verneed Verneed; 89 typedef Elf64_Vernaux Vernaux; 90 typedef Elf64_Versym Versym; 91 typedef Elf64_Move Move; 92 typedef Elf64_Cap Cap; 93 typedef Elf64_Capinfo Capinfo; 94 typedef Elf64_Capchain Capchain; 95 #endif /* _ASM */ 96 97 #else /* _ILP32 */ 98 99 #ifndef _ASM 100 typedef Elf32_Word Xword; /* Xword/Sxword are 32-bits in Elf32 */ 101 typedef Elf32_Lword Lword; 102 typedef Elf32_Sword Sxword; 103 typedef Elf32_Word Word; 104 typedef Elf32_Sword Sword; 105 typedef Elf32_Half Half; 106 typedef Elf32_Addr Addr; 107 typedef Elf32_Off Off; 108 typedef uchar_t Byte; 109 #endif /* _ASM */ 110 111 #if defined(_KERNEL) 112 #define ELF_R_TYPE ELF32_R_TYPE 113 #define ELF_R_SYM ELF32_R_SYM 114 #define ELF_R_TYPE_DATA(x) (0) 115 #define ELF_R_INFO ELF32_R_INFO 116 #define ELF_ST_BIND ELF32_ST_BIND 117 #define ELF_ST_TYPE ELF32_ST_TYPE 118 #define ELF_M_SYM ELF32_M_SYM 119 #define ELF_M_SIZE ELF32_M_SIZE 120 #endif 121 122 #ifndef _ASM 123 typedef Elf32_Ehdr Ehdr; 124 typedef Elf32_Shdr Shdr; 125 typedef Elf32_Sym Sym; 126 typedef Elf32_Syminfo Syminfo; 127 typedef Elf32_Rela Rela; 128 typedef Elf32_Rel Rel; 129 typedef Elf32_Nhdr Nhdr; 130 typedef Elf32_Phdr Phdr; 131 typedef Elf32_Dyn Dyn; 132 typedef Elf32_Boot Boot; 133 typedef Elf32_Verdef Verdef; 134 typedef Elf32_Verdaux Verdaux; 135 typedef Elf32_Verneed Verneed; 136 typedef Elf32_Vernaux Vernaux; 137 typedef Elf32_Versym Versym; 138 typedef Elf32_Move Move; 139 typedef Elf32_Cap Cap; 140 typedef Elf32_Capinfo Capinfo; 141 typedef Elf32_Capchain Capchain; 142 #endif /* _ASM */ 143 144 #endif /* _ILP32 */ 145 146 /* 147 * Elf `printf' type-cast macros. These force arguments to be a fixed size 148 * so that Elf32 and Elf64 can share common format strings. 149 */ 150 #ifndef __lint 151 #define EC_ADDR(a) ((Elf64_Addr)(a)) /* "ull" */ 152 #define EC_OFF(a) ((Elf64_Off)(a)) /* "ull" */ 153 #define EC_HALF(a) ((Elf64_Half)(a)) /* "d" */ 154 #define EC_WORD(a) ((Elf64_Word)(a)) /* "u" */ 155 #define EC_SWORD(a) ((Elf64_Sword)(a)) /* "d" */ 156 #define EC_XWORD(a) ((Elf64_Xword)(a)) /* "ull" */ 157 #define EC_SXWORD(a) ((Elf64_Sxword)(a)) /* "ll" */ 158 #define EC_LWORD(a) ((Elf64_Lword)(a)) /* "ull" */ 159 160 /* 161 * A native pointer is special. Although it can be convenient to display 162 * these from a common format (ull), compilers may flag the cast of a pointer 163 * to an integer as illegal. Casting these pointers to the native pointer 164 * size, suppresses any compiler errors. 165 */ 166 #define EC_NATPTR(a) ((Elf64_Xword)(uintptr_t)(a)) /* "ull" */ 167 #else 168 #define EC_ADDR(a) ((u_longlong_t)(a)) 169 #define EC_OFF(a) ((u_longlong_t)(a)) 170 #define EC_HALF(a) ((ushort_t)(a)) 171 #define EC_WORD(a) ((uint_t)(a)) 172 #define EC_SWORD(a) ((int)(a)) 173 #define EC_XWORD(a) ((u_longlong_t)(a)) 174 #define EC_SXWORD(a) ((longlong_t)(a)) 175 #define EC_LWORD(a) ((u_longlong_t)(a)) 176 177 #define EC_NATPTR(a) ((u_longlong_t)(a)) 178 #endif 179 180 #ifdef __cplusplus 181 } 182 #endif 183 184 #endif /* _SYS_MACHELF_H */ 185