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