gelf.h revision 164190
1164190Sjkoshy/*- 2164190Sjkoshy * Copyright (c) 2006 Joseph Koshy 3164190Sjkoshy * All rights reserved. 4164190Sjkoshy * 5164190Sjkoshy * Redistribution and use in source and binary forms, with or without 6164190Sjkoshy * modification, are permitted provided that the following conditions 7164190Sjkoshy * are met: 8164190Sjkoshy * 1. Redistributions of source code must retain the above copyright 9164190Sjkoshy * notice, this list of conditions and the following disclaimer. 10164190Sjkoshy * 2. Redistributions in binary form must reproduce the above copyright 11164190Sjkoshy * notice, this list of conditions and the following disclaimer in the 12164190Sjkoshy * documentation and/or other materials provided with the distribution. 13164190Sjkoshy * 14164190Sjkoshy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15164190Sjkoshy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16164190Sjkoshy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17164190Sjkoshy * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18164190Sjkoshy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19164190Sjkoshy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20164190Sjkoshy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21164190Sjkoshy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22164190Sjkoshy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23164190Sjkoshy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24164190Sjkoshy * SUCH DAMAGE. 25164190Sjkoshy * 26164190Sjkoshy * $FreeBSD: head/lib/libelf/gelf.h 164190 2006-11-11 17:16:35Z jkoshy $ 27164190Sjkoshy */ 28164190Sjkoshy 29164190Sjkoshy#ifndef _GELF_H_ 30164190Sjkoshy#define _GELF_H_ 31164190Sjkoshy 32164190Sjkoshy#include <sys/cdefs.h> 33164190Sjkoshy 34164190Sjkoshy#include <libelf.h> 35164190Sjkoshy#include <osreldate.h> 36164190Sjkoshy 37164190Sjkoshytypedef Elf64_Addr GElf_Addr; /* Addresses */ 38164190Sjkoshytypedef Elf64_Half GElf_Half; /* Half words (16 bit) */ 39164190Sjkoshytypedef Elf64_Off GElf_Off; /* Offsets */ 40164190Sjkoshytypedef Elf64_Sword GElf_Sword; /* Signed words (32 bit) */ 41164190Sjkoshytypedef Elf64_Sxword GElf_Sxword; /* Signed long words (64 bit) */ 42164190Sjkoshytypedef Elf64_Word GElf_Word; /* Unsigned words (32 bit) */ 43164190Sjkoshytypedef Elf64_Xword GElf_Xword; /* Unsigned long words (64 bit) */ 44164190Sjkoshy 45164190Sjkoshytypedef Elf64_Dyn GElf_Dyn; /* ".dynamic" section entries */ 46164190Sjkoshytypedef Elf64_Ehdr GElf_Ehdr; /* ELF header */ 47164190Sjkoshytypedef Elf64_Phdr GElf_Phdr; /* Program header */ 48164190Sjkoshytypedef Elf64_Shdr GElf_Shdr; /* Section header */ 49164190Sjkoshytypedef Elf64_Sym GElf_Sym; /* Symbol table entries */ 50164190Sjkoshytypedef Elf64_Rel GElf_Rel; /* Relocation entries */ 51164190Sjkoshytypedef Elf64_Rela GElf_Rela; /* Relocation entries with addend */ 52164190Sjkoshy 53164190Sjkoshy#if __FreeBSD_version > 700009 54164190Sjkoshytypedef Elf64_Cap GElf_Cap; /* SW/HW capabilities */ 55164190Sjkoshytypedef Elf64_Move GElf_Move; /* Move entries */ 56164190Sjkoshytypedef Elf64_Syminfo GElf_Syminfo; /* Symbol information */ 57164190Sjkoshy#endif 58164190Sjkoshy 59164190Sjkoshy__BEGIN_DECLS 60164190Sjkoshylong gelf_checksum(Elf *_elf); 61164190Sjkoshysize_t gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count, 62164190Sjkoshy unsigned int _version); 63164190Sjkoshyint gelf_getclass(Elf *_elf); 64164190SjkoshyGElf_Dyn *gelf_getdyn(Elf_Data *_data, int _index, GElf_Dyn *_dst); 65164190SjkoshyGElf_Ehdr *gelf_getehdr(Elf *_elf, GElf_Ehdr *_dst); 66164190SjkoshyGElf_Phdr *gelf_getphdr(Elf *_elf, int _index, GElf_Phdr *_dst); 67164190SjkoshyGElf_Rel *gelf_getrel(Elf_Data *_src, int _index, GElf_Rel *_dst); 68164190SjkoshyGElf_Rela *gelf_getrela(Elf_Data *_src, int _index, GElf_Rela *_dst); 69164190SjkoshyGElf_Shdr *gelf_getshdr(Elf_Scn *_scn, GElf_Shdr *_dst); 70164190SjkoshyGElf_Sym *gelf_getsym(Elf_Data *_src, int _index, GElf_Sym *_dst); 71164190SjkoshyGElf_Sym *gelf_getsymshndx(Elf_Data *_src, Elf_Data *_shindexsrc, 72164190Sjkoshy int _index, GElf_Sym *_dst, Elf32_Word *_shindexdst); 73164190Sjkoshyvoid * gelf_newehdr(Elf *_elf, int _class); 74164190Sjkoshyvoid * gelf_newphdr(Elf *_elf, size_t _phnum); 75164190Sjkoshyint gelf_update_dyn(Elf_Data *_dst, int _index, GElf_Dyn *_src); 76164190Sjkoshyint gelf_update_ehdr(Elf *_elf, GElf_Ehdr *_src); 77164190Sjkoshyint gelf_update_phdr(Elf *_elf, int _index, GElf_Phdr *_src); 78164190Sjkoshyint gelf_update_rel(Elf_Data *_dst, int _index, GElf_Rel *_src); 79164190Sjkoshyint gelf_update_rela(Elf_Data *_dst, int _index, GElf_Rela *_src); 80164190Sjkoshyint gelf_update_shdr(Elf_Scn *_dst, GElf_Shdr *_src); 81164190Sjkoshyint gelf_update_sym(Elf_Data *_dst, int _index, GElf_Sym *_src); 82164190Sjkoshyint gelf_update_symshndx(Elf_Data *_symdst, Elf_Data *_shindexdst, 83164190Sjkoshy int _index, GElf_Sym *_symsrc, Elf32_Word _shindexsrc); 84164190SjkoshyElf_Data *gelf_xlatetof(Elf *_elf, Elf_Data *_dst, const Elf_Data *_src, unsigned int _encode); 85164190SjkoshyElf_Data *gelf_xlatetom(Elf *_elf, Elf_Data *_dst, const Elf_Data *_src, unsigned int _encode); 86164190Sjkoshy 87164190Sjkoshy#if __FreeBSD_version > 700009 88164190SjkoshyGElf_Cap *gelf_getcap(Elf_Data *_data, int _index, GElf_Cap *_cap); 89164190SjkoshyGElf_Move *gelf_getmove(Elf_Data *_src, int _index, GElf_Move *_dst); 90164190SjkoshyGElf_Syminfo *gelf_getsyminfo(Elf_Data *_src, int _index, GElf_Syminfo *_dst); 91164190Sjkoshyint gelf_update_cap(Elf_Data *_dst, int _index, GElf_Cap *_src); 92164190Sjkoshyint gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src); 93164190Sjkoshyint gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src); 94164190Sjkoshy#endif 95164190Sjkoshy__END_DECLS 96164190Sjkoshy 97164190Sjkoshy#endif /* _GELF_H_ */ 98