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 2006 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 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <sys/elf_SPARC.h> 37 #ifndef _ASM 38 #include <sys/types.h> 39 #include <sys/elf.h> 40 #include <sys/link.h> /* for Elf*_Dyn */ 41 #endif /* _ASM */ 42 43 /* 44 * Make machine class dependent data types transparent to the common code 45 */ 46 #if defined(_ELF64) && !defined(_ELF32_COMPAT) 47 48 #ifndef _ASM 49 typedef Elf64_Xword Xword; 50 typedef Elf64_Lword Lword; 51 typedef Elf64_Sxword Sxword; 52 typedef Elf64_Word Word; 53 typedef Elf64_Sword Sword; 54 typedef Elf64_Half Half; 55 typedef Elf64_Addr Addr; 56 typedef Elf64_Off Off; 57 typedef uchar_t Byte; 58 #endif /* _ASM */ 59 60 #if defined(_KERNEL) 61 #define ELF_R_TYPE ELF64_R_TYPE 62 #define ELF_R_SYM ELF64_R_SYM 63 #define ELF_R_TYPE_DATA ELF64_R_TYPE_DATA 64 #define ELF_R_INFO ELF64_R_INFO 65 #define ELF_ST_BIND ELF64_ST_BIND 66 #define ELF_ST_TYPE ELF64_ST_TYPE 67 #define ELF_M_SYM ELF64_M_SYM 68 #define ELF_M_SIZE ELF64_M_SIZE 69 #endif 70 71 #ifndef _ASM 72 typedef Elf64_Ehdr Ehdr; 73 typedef Elf64_Shdr Shdr; 74 typedef Elf64_Sym Sym; 75 typedef Elf64_Syminfo Syminfo; 76 typedef Elf64_Rela Rela; 77 typedef Elf64_Rel Rel; 78 typedef Elf64_Nhdr Nhdr; 79 typedef Elf64_Phdr Phdr; 80 typedef Elf64_Dyn Dyn; 81 typedef Elf64_Boot Boot; 82 typedef Elf64_Verdef Verdef; 83 typedef Elf64_Verdaux Verdaux; 84 typedef Elf64_Verneed Verneed; 85 typedef Elf64_Vernaux Vernaux; 86 typedef Elf64_Versym Versym; 87 typedef Elf64_Move Move; 88 typedef Elf64_Cap Cap; 89 #endif /* _ASM */ 90 91 #else /* _ILP32 */ 92 93 #ifndef _ASM 94 typedef Elf32_Word Xword; /* Xword/Sxword are 32-bits in Elf32 */ 95 typedef Elf32_Lword Lword; 96 typedef Elf32_Sword Sxword; 97 typedef Elf32_Word Word; 98 typedef Elf32_Sword Sword; 99 typedef Elf32_Half Half; 100 typedef Elf32_Addr Addr; 101 typedef Elf32_Off Off; 102 typedef uchar_t Byte; 103 #endif /* _ASM */ 104 105 #if defined(_KERNEL) 106 #define ELF_R_TYPE ELF32_R_TYPE 107 #define ELF_R_SYM ELF32_R_SYM 108 #define ELF_R_INFO ELF32_R_INFO 109 #define ELF_R_TYPE_DATA(x) (0) 110 #define ELF_ST_BIND ELF32_ST_BIND 111 #define ELF_ST_TYPE ELF32_ST_TYPE 112 #define ELF_M_SYM ELF32_M_SYM 113 #define ELF_M_SIZE ELF32_M_SIZE 114 #endif 115 116 #ifndef _ASM 117 typedef Elf32_Ehdr Ehdr; 118 typedef Elf32_Shdr Shdr; 119 typedef Elf32_Sym Sym; 120 typedef Elf32_Syminfo Syminfo; 121 typedef Elf32_Rela Rela; 122 typedef Elf32_Rel Rel; 123 typedef Elf32_Nhdr Nhdr; 124 typedef Elf32_Phdr Phdr; 125 typedef Elf32_Dyn Dyn; 126 typedef Elf32_Boot Boot; 127 typedef Elf32_Verdef Verdef; 128 typedef Elf32_Verdaux Verdaux; 129 typedef Elf32_Verneed Verneed; 130 typedef Elf32_Vernaux Vernaux; 131 typedef Elf32_Versym Versym; 132 typedef Elf32_Move Move; 133 typedef Elf32_Cap Cap; 134 #endif /* _ASM */ 135 136 #endif /* _ILP32 */ 137 138 /* 139 * Elf `printf' type-cast macros. These force arguments to be a fixed size 140 * so that Elf32 and Elf64 can share common format strings. 141 */ 142 #ifndef __lint 143 #define EC_ADDR(a) ((Elf64_Addr)(a)) /* "ull" */ 144 #define EC_OFF(a) ((Elf64_Off)(a)) /* "ull" */ 145 #define EC_HALF(a) ((Elf64_Half)(a)) /* "d" */ 146 #define EC_WORD(a) ((Elf64_Word)(a)) /* "u" */ 147 #define EC_SWORD(a) ((Elf64_Sword)(a)) /* "d" */ 148 #define EC_XWORD(a) ((Elf64_Xword)(a)) /* "ull" */ 149 #define EC_SXWORD(a) ((Elf64_Sxword)(a)) /* "ll" */ 150 #define EC_LWORD(a) ((Elf64_Lword)(a)) /* "ull" */ 151 152 /* 153 * A native pointer is special. Although it can be convenient to display 154 * these from a common format (ull), compilers may flag the cast of a pointer 155 * to an integer as illegal. Casting these pointers to the native pointer 156 * size, suppresses any compiler errors. 157 */ 158 #define EC_NATPTR(a) ((Elf64_Xword)(uintptr_t)(a)) /* "ull" */ 159 #else 160 #define EC_ADDR(a) ((u_longlong_t)(a)) 161 #define EC_OFF(a) ((u_longlong_t)(a)) 162 #define EC_HALF(a) ((ushort_t)(a)) 163 #define EC_WORD(a) ((uint_t)(a)) 164 #define EC_SWORD(a) ((int)(a)) 165 #define EC_XWORD(a) ((u_longlong_t)(a)) 166 #define EC_SXWORD(a) ((longlong_t)(a)) 167 #define EC_LWORD(a) ((u_longlong_t)(a)) 168 169 #define EC_NATPTR(a) ((u_longlong_t)(a)) 170 #endif 171 172 #ifndef _ASM 173 /* 174 * Structure used to build the reloc_table[] 175 */ 176 typedef struct { 177 Xword re_mask; /* mask to apply to reloc */ 178 Word re_flags; /* relocation attributes */ 179 uchar_t re_fsize; /* field size (in bytes) */ 180 uchar_t re_bshift; /* number of bits to shift */ 181 uchar_t re_sigbits; /* number of significant bits */ 182 } Rel_entry; 183 184 #endif /* _ASM */ 185 186 #ifdef __cplusplus 187 } 188 #endif 189 190 #endif /* _SYS_MACHELF_H */ 191