1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _GELF_H 28*7c478bd9Sstevel@tonic-gate #define _GELF_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #include <libelf.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/link.h> 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 38*7c478bd9Sstevel@tonic-gate extern "C" { 39*7c478bd9Sstevel@tonic-gate #endif 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #if !defined(_INT64_TYPE) 43*7c478bd9Sstevel@tonic-gate #error "64-bit integer types are required by gelf." 44*7c478bd9Sstevel@tonic-gate #endif 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate /* 47*7c478bd9Sstevel@tonic-gate * Class-independent ELF API for Elf utilities. This is 48*7c478bd9Sstevel@tonic-gate * for manipulating Elf32 and Elf64 specific information 49*7c478bd9Sstevel@tonic-gate * in a format common to both classes. 50*7c478bd9Sstevel@tonic-gate */ 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate typedef Elf64_Addr GElf_Addr; 53*7c478bd9Sstevel@tonic-gate typedef Elf64_Half GElf_Half; 54*7c478bd9Sstevel@tonic-gate typedef Elf64_Off GElf_Off; 55*7c478bd9Sstevel@tonic-gate typedef Elf64_Sword GElf_Sword; 56*7c478bd9Sstevel@tonic-gate typedef Elf64_Sxword GElf_Sxword; 57*7c478bd9Sstevel@tonic-gate typedef Elf64_Word GElf_Word; 58*7c478bd9Sstevel@tonic-gate typedef Elf64_Xword GElf_Xword; 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate typedef Elf64_Ehdr GElf_Ehdr; 61*7c478bd9Sstevel@tonic-gate typedef Elf64_Move GElf_Move; 62*7c478bd9Sstevel@tonic-gate typedef Elf64_Phdr GElf_Phdr; 63*7c478bd9Sstevel@tonic-gate typedef Elf64_Shdr GElf_Shdr; 64*7c478bd9Sstevel@tonic-gate typedef Elf64_Sym GElf_Sym; 65*7c478bd9Sstevel@tonic-gate typedef Elf64_Syminfo GElf_Syminfo; 66*7c478bd9Sstevel@tonic-gate typedef Elf64_Rela GElf_Rela; 67*7c478bd9Sstevel@tonic-gate typedef Elf64_Rel GElf_Rel; 68*7c478bd9Sstevel@tonic-gate typedef Elf64_Dyn GElf_Dyn; 69*7c478bd9Sstevel@tonic-gate typedef Elf64_Cap GElf_Cap; 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate /* 72*7c478bd9Sstevel@tonic-gate * The processing of versioning information can stay the 73*7c478bd9Sstevel@tonic-gate * same because both the Elf32 and Elf64 structures are 74*7c478bd9Sstevel@tonic-gate * of equal sizes. 75*7c478bd9Sstevel@tonic-gate */ 76*7c478bd9Sstevel@tonic-gate typedef Elf64_Verdef GElf_Verdef; 77*7c478bd9Sstevel@tonic-gate typedef Elf64_Verdaux GElf_Verdaux; 78*7c478bd9Sstevel@tonic-gate typedef Elf64_Verneed GElf_Verneed; 79*7c478bd9Sstevel@tonic-gate typedef Elf64_Vernaux GElf_Vernaux; 80*7c478bd9Sstevel@tonic-gate typedef Elf64_Versym GElf_Versym; 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate /* 83*7c478bd9Sstevel@tonic-gate * move.m_info is encoded using the 64bit fields in Gelf. 84*7c478bd9Sstevel@tonic-gate */ 85*7c478bd9Sstevel@tonic-gate #define GELF_M_SYM ELF64_M_SYM 86*7c478bd9Sstevel@tonic-gate #define GELF_M_SIZE ELF64_M_SIZE 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate /* 89*7c478bd9Sstevel@tonic-gate * sym.st_info field is same size for Elf32 and Elf64. 90*7c478bd9Sstevel@tonic-gate */ 91*7c478bd9Sstevel@tonic-gate #define GELF_ST_BIND ELF64_ST_BIND 92*7c478bd9Sstevel@tonic-gate #define GELF_ST_TYPE ELF64_ST_TYPE 93*7c478bd9Sstevel@tonic-gate #define GELF_ST_INFO ELF64_ST_INFO 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate /* 97*7c478bd9Sstevel@tonic-gate * Elf64 r_info may have data field in type id's word, 98*7c478bd9Sstevel@tonic-gate * so GELF_R_TYPE is defined as ELF64_R_TYPE_ID in order 99*7c478bd9Sstevel@tonic-gate * to isolate the proper bits for the true type id. 100*7c478bd9Sstevel@tonic-gate */ 101*7c478bd9Sstevel@tonic-gate #define GELF_R_TYPE ELF64_R_TYPE_ID 102*7c478bd9Sstevel@tonic-gate #define GELF_R_SYM ELF64_R_SYM 103*7c478bd9Sstevel@tonic-gate #define GELF_R_INFO ELF64_R_INFO 104*7c478bd9Sstevel@tonic-gate #define GELF_R_TYPE_DATA ELF64_R_TYPE_DATA 105*7c478bd9Sstevel@tonic-gate #define GELF_R_TYPE_ID ELF64_R_TYPE_ID 106*7c478bd9Sstevel@tonic-gate #define GELF_R_TYPE_INFO ELF64_R_TYPE_INFO 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate int gelf_getclass(Elf*); 111*7c478bd9Sstevel@tonic-gate size_t gelf_fsize(Elf *, Elf_Type, size_t, uint_t); 112*7c478bd9Sstevel@tonic-gate GElf_Ehdr * gelf_getehdr(Elf *, GElf_Ehdr *); 113*7c478bd9Sstevel@tonic-gate int gelf_update_ehdr(Elf *, GElf_Ehdr *); 114*7c478bd9Sstevel@tonic-gate unsigned long gelf_newehdr(Elf *, int); 115*7c478bd9Sstevel@tonic-gate GElf_Phdr * gelf_getphdr(Elf *, int, GElf_Phdr *); 116*7c478bd9Sstevel@tonic-gate int gelf_update_phdr(Elf *, int, GElf_Phdr *); 117*7c478bd9Sstevel@tonic-gate unsigned long gelf_newphdr(Elf *, size_t); 118*7c478bd9Sstevel@tonic-gate GElf_Shdr * gelf_getshdr(Elf_Scn *, GElf_Shdr *); 119*7c478bd9Sstevel@tonic-gate int gelf_update_shdr(Elf_Scn *, GElf_Shdr *); 120*7c478bd9Sstevel@tonic-gate Elf_Data * gelf_xlatetof(Elf *, Elf_Data *, const Elf_Data *, uint_t); 121*7c478bd9Sstevel@tonic-gate Elf_Data * gelf_xlatetom(Elf *, Elf_Data *, const Elf_Data *, uint_t); 122*7c478bd9Sstevel@tonic-gate GElf_Sym * gelf_getsym(Elf_Data *, int, GElf_Sym *); 123*7c478bd9Sstevel@tonic-gate int gelf_update_sym(Elf_Data *, int, GElf_Sym *); 124*7c478bd9Sstevel@tonic-gate GElf_Sym * gelf_getsymshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *, 125*7c478bd9Sstevel@tonic-gate Elf32_Word *); 126*7c478bd9Sstevel@tonic-gate int gelf_update_symshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *, 127*7c478bd9Sstevel@tonic-gate Elf32_Word); 128*7c478bd9Sstevel@tonic-gate GElf_Syminfo * gelf_getsyminfo(Elf_Data *, int, GElf_Syminfo *); 129*7c478bd9Sstevel@tonic-gate int gelf_update_syminfo(Elf_Data *, int, GElf_Syminfo *); 130*7c478bd9Sstevel@tonic-gate GElf_Move * gelf_getmove(Elf_Data *, int, GElf_Move *); 131*7c478bd9Sstevel@tonic-gate int gelf_update_move(Elf_Data *, int, GElf_Move *); 132*7c478bd9Sstevel@tonic-gate GElf_Dyn * gelf_getdyn(Elf_Data *, int, GElf_Dyn *); 133*7c478bd9Sstevel@tonic-gate int gelf_update_dyn(Elf_Data *, int, GElf_Dyn *); 134*7c478bd9Sstevel@tonic-gate GElf_Rela * gelf_getrela(Elf_Data *, int, GElf_Rela *); 135*7c478bd9Sstevel@tonic-gate int gelf_update_rela(Elf_Data *, int, GElf_Rela *); 136*7c478bd9Sstevel@tonic-gate GElf_Rel * gelf_getrel(Elf_Data *, int, GElf_Rel *); 137*7c478bd9Sstevel@tonic-gate int gelf_update_rel(Elf_Data *, int, GElf_Rel *); 138*7c478bd9Sstevel@tonic-gate long gelf_checksum(Elf *); 139*7c478bd9Sstevel@tonic-gate GElf_Cap * gelf_getcap(Elf_Data *, int, GElf_Cap *); 140*7c478bd9Sstevel@tonic-gate int gelf_update_cap(Elf_Data *, int, GElf_Cap *); 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 144*7c478bd9Sstevel@tonic-gate } 145*7c478bd9Sstevel@tonic-gate #endif 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate #endif /* _GELF_H */ 148