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