Blame libelf/gelf.h

Packit 032894
/* This file defines generic ELF types, structures, and macros.
Packit 032894
   Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2015 Red Hat, Inc.
Packit 032894
   This file is part of elfutils.
Packit 032894
Packit 032894
   This file is free software; you can redistribute it and/or modify
Packit 032894
   it under the terms of either
Packit 032894
Packit 032894
     * the GNU Lesser General Public License as published by the Free
Packit 032894
       Software Foundation; either version 3 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or
Packit 032894
Packit 032894
     * the GNU General Public License as published by the Free
Packit 032894
       Software Foundation; either version 2 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or both in parallel, as here.
Packit 032894
Packit 032894
   elfutils is distributed in the hope that it will be useful, but
Packit 032894
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 032894
   General Public License for more details.
Packit 032894
Packit 032894
   You should have received copies of the GNU General Public License and
Packit 032894
   the GNU Lesser General Public License along with this program.  If
Packit 032894
   not, see <http://www.gnu.org/licenses/>.  */
Packit 032894
Packit 032894
#ifndef _GELF_H
Packit 032894
#define	_GELF_H 1
Packit 032894
Packit 032894
#include <libelf.h>
Packit 032894
Packit 032894
Packit 032894
#ifdef __cplusplus
Packit 032894
extern "C" {
Packit 032894
#endif
Packit 032894
Packit 032894
/* Class independent type definitions.  Correctly speaking this is not
Packit 032894
   true.  We assume that 64-bit binaries are the largest class and
Packit 032894
   therefore all other classes can be represented without loss.  */
Packit 032894
Packit 032894
/* Type for a 16-bit quantity.  */
Packit 032894
typedef Elf64_Half GElf_Half;
Packit 032894
Packit 032894
/* Types for signed and unsigned 32-bit quantities.  */
Packit 032894
typedef Elf64_Word GElf_Word;
Packit 032894
typedef	Elf64_Sword GElf_Sword;
Packit 032894
Packit 032894
/* Types for signed and unsigned 64-bit quantities.  */
Packit 032894
typedef Elf64_Xword GElf_Xword;
Packit 032894
typedef	Elf64_Sxword GElf_Sxword;
Packit 032894
Packit 032894
/* Type of addresses.  */
Packit 032894
typedef Elf64_Addr GElf_Addr;
Packit 032894
Packit 032894
/* Type of file offsets.  */
Packit 032894
typedef Elf64_Off GElf_Off;
Packit 032894
Packit 032894
Packit 032894
/* The ELF file header.  This appears at the start of every ELF file.  */
Packit 032894
typedef Elf64_Ehdr GElf_Ehdr;
Packit 032894
Packit 032894
/* Section header.  */
Packit 032894
typedef Elf64_Shdr GElf_Shdr;
Packit 032894
Packit 032894
/* Section index.  */
Packit 032894
/* XXX This should probably be a larger type in preparation of times when
Packit 032894
   regular section indices can be larger.  */
Packit 032894
typedef Elf64_Section GElf_Section;
Packit 032894
Packit 032894
/* Symbol table entry.  */
Packit 032894
typedef Elf64_Sym GElf_Sym;
Packit 032894
Packit 032894
/* The syminfo section if available contains additional information about
Packit 032894
   every dynamic symbol.  */
Packit 032894
typedef Elf64_Syminfo GElf_Syminfo;
Packit 032894
Packit 032894
/* Relocation table entry without addend (in section of type SHT_REL).  */
Packit 032894
typedef Elf64_Rel GElf_Rel;
Packit 032894
Packit 032894
/* Relocation table entry with addend (in section of type SHT_RELA).  */
Packit 032894
typedef Elf64_Rela GElf_Rela;
Packit 032894
Packit 032894
/* Program segment header.  */
Packit 032894
typedef Elf64_Phdr GElf_Phdr;
Packit 032894
Packit 032894
/* Header of a compressed section.  */
Packit 032894
typedef Elf64_Chdr GElf_Chdr;
Packit 032894
Packit 032894
/* Dynamic section entry.  */
Packit 032894
typedef Elf64_Dyn GElf_Dyn;
Packit 032894
Packit 032894
Packit 032894
/* Version definition sections.  */
Packit 032894
typedef Elf64_Verdef GElf_Verdef;
Packit 032894
Packit 032894
/* Auxialiary version information.  */
Packit 032894
typedef Elf64_Verdaux GElf_Verdaux;
Packit 032894
Packit 032894
/* Version dependency section.  */
Packit 032894
typedef Elf64_Verneed GElf_Verneed;
Packit 032894
Packit 032894
/* Auxiliary needed version information.  */
Packit 032894
typedef Elf64_Vernaux GElf_Vernaux;
Packit 032894
Packit 032894
Packit 032894
/* Type for version symbol information.  */
Packit 032894
typedef Elf64_Versym GElf_Versym;
Packit 032894
Packit 032894
Packit 032894
/* Auxiliary vector.  */
Packit 032894
typedef Elf64_auxv_t GElf_auxv_t;
Packit 032894
Packit 032894
Packit 032894
/* Note section contents.  */
Packit 032894
typedef Elf64_Nhdr GElf_Nhdr;
Packit 032894
Packit 032894
Packit 032894
/* Move structure.  */
Packit 032894
typedef Elf64_Move GElf_Move;
Packit 032894
Packit 032894
Packit 032894
/* Library list structure.  */
Packit 032894
typedef Elf64_Lib GElf_Lib;
Packit 032894
Packit 032894
Packit 032894
/* How to extract and insert information held in the st_info field.  */
Packit 032894
Packit 032894
#define GELF_ST_BIND(val)		ELF64_ST_BIND (val)
Packit 032894
#define GELF_ST_TYPE(val)		ELF64_ST_TYPE (val)
Packit 032894
#define GELF_ST_INFO(bind, type)	ELF64_ST_INFO (bind, type)
Packit 032894
Packit 032894
/* How to extract information held in the st_other field.  */
Packit 032894
Packit 032894
#define GELF_ST_VISIBILITY(val)		ELF64_ST_VISIBILITY (val)
Packit 032894
Packit 032894
Packit 032894
/* How to extract and insert information held in the r_info field.  */
Packit 032894
Packit 032894
#define GELF_R_SYM(info)		ELF64_R_SYM (info)
Packit 032894
#define GELF_R_TYPE(info)		ELF64_R_TYPE (info)
Packit 032894
#define GELF_R_INFO(sym, type)		ELF64_R_INFO (sym, type)
Packit 032894
Packit 032894
Packit 032894
/* How to extract and insert information held in the m_info field.  */
Packit 032894
#define GELF_M_SYM(info)		ELF64_M_SYM (info)
Packit 032894
#define GELF_M_SIZE(info)		ELF64_M_SIZE (info)
Packit 032894
#define GELF_M_INFO(sym, size)		ELF64_M_INFO (sym, size)
Packit 032894
Packit 032894
Packit 032894
/* Get class of the file associated with ELF.  */
Packit 032894
extern int gelf_getclass (Elf *__elf);
Packit 032894
Packit 032894
Packit 032894
/* Return size of array of COUNT elements of the type denoted by TYPE
Packit 032894
   in the external representation.  The binary class is taken from ELF.
Packit 032894
   The result is based on version VERSION of the ELF standard.  */
Packit 032894
extern size_t gelf_fsize (Elf *__elf, Elf_Type __type, size_t __count,
Packit 032894
			  unsigned int __version);
Packit 032894
Packit 032894
/* Retrieve object file header.  */
Packit 032894
extern GElf_Ehdr *gelf_getehdr (Elf *__elf, GElf_Ehdr *__dest);
Packit 032894
Packit 032894
/* Update the ELF header.  */
Packit 032894
extern int gelf_update_ehdr (Elf *__elf, GElf_Ehdr *__src);
Packit 032894
Packit 032894
/* Create new ELF header if none exists.  Creates an Elf32_Ehdr if CLASS
Packit 032894
   is ELFCLASS32 or an Elf64_Ehdr if CLASS is ELFCLASS64.  Returns NULL
Packit 032894
   on error.  */
Packit 032894
extern void *gelf_newehdr (Elf *__elf, int __class);
Packit 032894
Packit 032894
/* Get section at OFFSET.  */
Packit 032894
extern Elf_Scn *gelf_offscn (Elf *__elf, GElf_Off __offset);
Packit 032894
Packit 032894
/* Retrieve section header.  */
Packit 032894
extern GElf_Shdr *gelf_getshdr (Elf_Scn *__scn, GElf_Shdr *__dst);
Packit 032894
Packit 032894
/* Update section header.  */
Packit 032894
extern int gelf_update_shdr (Elf_Scn *__scn, GElf_Shdr *__src);
Packit 032894
Packit 032894
/* Retrieve program header table entry.  */
Packit 032894
extern GElf_Phdr *gelf_getphdr (Elf *__elf, int __ndx, GElf_Phdr *__dst);
Packit 032894
Packit 032894
/* Update the program header.  */
Packit 032894
extern int gelf_update_phdr (Elf *__elf, int __ndx, GElf_Phdr *__src);
Packit 032894
Packit 032894
/* Create new program header with PHNUM entries.  Creates either an
Packit 032894
   Elf32_Phdr or an Elf64_Phdr depending on whether the given ELF is
Packit 032894
   ELFCLASS32 or ELFCLASS64.  Returns NULL on error.  */
Packit 032894
extern void *gelf_newphdr (Elf *__elf, size_t __phnum);
Packit 032894
Packit 032894
/* Get compression header of section if any.  Returns NULL and sets
Packit 032894
   elf_errno if the section isn't compressed or an error occurred.  */
Packit 032894
extern GElf_Chdr *gelf_getchdr (Elf_Scn *__scn, GElf_Chdr *__dst);
Packit 032894
Packit 032894
/* Convert data structure from the representation in the file represented
Packit 032894
   by ELF to their memory representation.  */
Packit 032894
extern Elf_Data *gelf_xlatetom (Elf *__elf, Elf_Data *__dest,
Packit 032894
				const Elf_Data *__src, unsigned int __encode);
Packit 032894
Packit 032894
/* Convert data structure from to the representation in memory
Packit 032894
   represented by ELF file representation.  */
Packit 032894
extern Elf_Data *gelf_xlatetof (Elf *__elf, Elf_Data *__dest,
Packit 032894
				const Elf_Data *__src, unsigned int __encode);
Packit 032894
Packit 032894
Packit 032894
/* Retrieve REL relocation info at the given index.  */
Packit 032894
extern GElf_Rel *gelf_getrel (Elf_Data *__data, int __ndx, GElf_Rel *__dst);
Packit 032894
Packit 032894
/* Retrieve RELA relocation info at the given index.  */
Packit 032894
extern GElf_Rela *gelf_getrela (Elf_Data *__data, int __ndx, GElf_Rela *__dst);
Packit 032894
Packit 032894
/* Update REL relocation information at given index.  */
Packit 032894
extern int gelf_update_rel (Elf_Data *__dst, int __ndx, GElf_Rel *__src);
Packit 032894
Packit 032894
/* Update RELA relocation information at given index.  */
Packit 032894
extern int gelf_update_rela (Elf_Data *__dst, int __ndx, GElf_Rela *__src);
Packit 032894
Packit 032894
Packit 032894
/* Retrieve symbol information from the symbol table at the given index.  */
Packit 032894
extern GElf_Sym *gelf_getsym (Elf_Data *__data, int __ndx, GElf_Sym *__dst);
Packit 032894
Packit 032894
/* Update symbol information in the symbol table at the given index.  */
Packit 032894
extern int gelf_update_sym (Elf_Data *__data, int __ndx, GElf_Sym *__src);
Packit 032894
Packit 032894
Packit 032894
/* Retrieve symbol information and separate section index from the
Packit 032894
   symbol table at the given index.  */
Packit 032894
extern GElf_Sym *gelf_getsymshndx (Elf_Data *__symdata, Elf_Data *__shndxdata,
Packit 032894
				   int __ndx, GElf_Sym *__sym,
Packit 032894
				   Elf32_Word *__xshndx);
Packit 032894
Packit 032894
/* Update symbol information and separate section index in the symbol
Packit 032894
   table at the given index.  */
Packit 032894
extern int gelf_update_symshndx (Elf_Data *__symdata, Elf_Data *__shndxdata,
Packit 032894
				 int __ndx, GElf_Sym *__sym,
Packit 032894
				 Elf32_Word __xshndx);
Packit 032894
Packit 032894
Packit 032894
/* Retrieve additional symbol information from the symbol table at the
Packit 032894
   given index.  */
Packit 032894
extern GElf_Syminfo *gelf_getsyminfo (Elf_Data *__data, int __ndx,
Packit 032894
				      GElf_Syminfo *__dst);
Packit 032894
Packit 032894
/* Update additional symbol information in the symbol table at the
Packit 032894
   given index.  */
Packit 032894
extern int gelf_update_syminfo (Elf_Data *__data, int __ndx,
Packit 032894
				GElf_Syminfo *__src);
Packit 032894
Packit 032894
Packit 032894
/* Get information from dynamic table at the given index.  */
Packit 032894
extern GElf_Dyn *gelf_getdyn (Elf_Data *__data, int __ndx, GElf_Dyn *__dst);
Packit 032894
Packit 032894
/* Update information in dynamic table at the given index.  */
Packit 032894
extern int gelf_update_dyn (Elf_Data *__dst, int __ndx, GElf_Dyn *__src);
Packit 032894
Packit 032894
Packit 032894
/* Get move structure at the given index.  */
Packit 032894
extern GElf_Move *gelf_getmove (Elf_Data *__data, int __ndx, GElf_Move *__dst);
Packit 032894
Packit 032894
/* Update move structure at the given index.  */
Packit 032894
extern int gelf_update_move (Elf_Data *__data, int __ndx,
Packit 032894
			     GElf_Move *__src);
Packit 032894
Packit 032894
Packit 032894
/* Get library from table at the given index.  */
Packit 032894
extern GElf_Lib *gelf_getlib (Elf_Data *__data, int __ndx, GElf_Lib *__dst);
Packit 032894
Packit 032894
/* Update library in table at the given index.  */
Packit 032894
extern int gelf_update_lib (Elf_Data *__data, int __ndx, GElf_Lib *__src);
Packit 032894
Packit 032894
Packit 032894
Packit 032894
/* Retrieve symbol version information at given index.  */
Packit 032894
extern GElf_Versym *gelf_getversym (Elf_Data *__data, int __ndx,
Packit 032894
				    GElf_Versym *__dst);
Packit 032894
Packit 032894
/* Update symbol version information.  */
Packit 032894
extern int gelf_update_versym (Elf_Data *__data, int __ndx,
Packit 032894
			       GElf_Versym *__src);
Packit 032894
Packit 032894
Packit 032894
/* Retrieve required symbol version information at given offset.  */
Packit 032894
extern GElf_Verneed *gelf_getverneed (Elf_Data *__data, int __offset,
Packit 032894
				      GElf_Verneed *__dst);
Packit 032894
Packit 032894
/* Update required symbol version information.  */
Packit 032894
extern int gelf_update_verneed (Elf_Data *__data, int __offset,
Packit 032894
				GElf_Verneed *__src);
Packit 032894
Packit 032894
/* Retrieve additional required symbol version information at given offset.  */
Packit 032894
extern GElf_Vernaux *gelf_getvernaux (Elf_Data *__data, int __offset,
Packit 032894
				      GElf_Vernaux *__dst);
Packit 032894
Packit 032894
/* Update additional required symbol version information.  */
Packit 032894
extern int gelf_update_vernaux (Elf_Data *__data, int __offset,
Packit 032894
				GElf_Vernaux *__src);
Packit 032894
Packit 032894
Packit 032894
/* Retrieve symbol version definition information at given offset.  */
Packit 032894
extern GElf_Verdef *gelf_getverdef (Elf_Data *__data, int __offset,
Packit 032894
				    GElf_Verdef *__dst);
Packit 032894
Packit 032894
/* Update symbol version definition information.  */
Packit 032894
extern int gelf_update_verdef (Elf_Data *__data, int __offset,
Packit 032894
			       GElf_Verdef *__src);
Packit 032894
Packit 032894
/* Retrieve additional symbol version definition information at given
Packit 032894
   offset.  */
Packit 032894
extern GElf_Verdaux *gelf_getverdaux (Elf_Data *__data, int __offset,
Packit 032894
				      GElf_Verdaux *__dst);
Packit 032894
Packit 032894
/* Update additional symbol version definition information.  */
Packit 032894
extern int gelf_update_verdaux (Elf_Data *__data, int __offset,
Packit 032894
				GElf_Verdaux *__src);
Packit 032894
Packit 032894
Packit 032894
/* Get auxv entry at the given index.  */
Packit 032894
extern GElf_auxv_t *gelf_getauxv (Elf_Data *__data, int __ndx,
Packit 032894
				  GElf_auxv_t *__dst);
Packit 032894
Packit 032894
/* Update auxv entry at the given index.  */
Packit 032894
extern int gelf_update_auxv (Elf_Data *__data, int __ndx, GElf_auxv_t *__src);
Packit 032894
Packit 032894
Packit 032894
/* Get note header at the given offset into the data, and the offsets of
Packit 032894
   the note's name and descriptor data.  Returns the offset of the next
Packit 032894
   note header, or 0 for an invalid offset or corrupt note header.  */
Packit 032894
extern size_t gelf_getnote (Elf_Data *__data, size_t __offset,
Packit 032894
			    GElf_Nhdr *__result,
Packit 032894
			    size_t *__name_offset, size_t *__desc_offset);
Packit 032894
Packit 032894
Packit 032894
/* Compute simple checksum from permanent parts of the ELF file.  */
Packit 032894
extern long int gelf_checksum (Elf *__elf);
Packit 032894
Packit 032894
#ifdef __cplusplus
Packit 032894
}
Packit 032894
#endif
Packit 032894
Packit 032894
#endif	/* gelf.h */