Blame libelf/libelf.h

Packit 032894
/* Interface for libelf.
Packit 032894
   Copyright (C) 1998-2010, 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 _LIBELF_H
Packit 032894
#define _LIBELF_H 1
Packit 032894
Packit 032894
#include <stdint.h>
Packit 032894
#include <sys/types.h>
Packit 032894
Packit 032894
/* Get the ELF types.  */
Packit 032894
#include <elf.h>
Packit 032894
Packit 032894
#ifndef SHF_COMPRESSED
Packit 032894
 /* Older glibc elf.h might not yet define the ELF compression types.  */
Packit 032894
 #define SHF_COMPRESSED      (1 << 11)  /* Section with compressed data. */
Packit 032894
Packit 032894
 /* Section compression header.  Used when SHF_COMPRESSED is set.  */
Packit 032894
Packit 032894
 typedef struct
Packit 032894
 {
Packit 032894
   Elf32_Word   ch_type;        /* Compression format.  */
Packit 032894
   Elf32_Word   ch_size;        /* Uncompressed data size.  */
Packit 032894
   Elf32_Word   ch_addralign;   /* Uncompressed data alignment.  */
Packit 032894
 } Elf32_Chdr;
Packit 032894
Packit 032894
 typedef struct
Packit 032894
 {
Packit 032894
   Elf64_Word   ch_type;        /* Compression format.  */
Packit 032894
   Elf64_Word   ch_reserved;
Packit 032894
   Elf64_Xword  ch_size;        /* Uncompressed data size.  */
Packit 032894
   Elf64_Xword  ch_addralign;   /* Uncompressed data alignment.  */
Packit 032894
 } Elf64_Chdr;
Packit 032894
Packit 032894
 /* Legal values for ch_type (compression algorithm).  */
Packit 032894
 #define ELFCOMPRESS_ZLIB       1          /* ZLIB/DEFLATE algorithm.  */
Packit 032894
 #define ELFCOMPRESS_LOOS       0x60000000 /* Start of OS-specific.  */
Packit 032894
 #define ELFCOMPRESS_HIOS       0x6fffffff /* End of OS-specific.  */
Packit 032894
 #define ELFCOMPRESS_LOPROC     0x70000000 /* Start of processor-specific.  */
Packit 032894
 #define ELFCOMPRESS_HIPROC     0x7fffffff /* End of processor-specific.  */
Packit 032894
#endif
Packit 032894
Packit 032894
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
Packit 032894
# define __nonnull_attribute__(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))
Packit 032894
# define __deprecated_attribute__ __attribute__ ((__deprecated__))
Packit 032894
# define __pure_attribute__ __attribute__ ((__pure__))
Packit 032894
# define __const_attribute__ __attribute__ ((__const__))
Packit 032894
#else
Packit 032894
# define __nonnull_attribute__(...)
Packit 032894
# define __deprecated_attribute__
Packit 032894
# define __pure_attribute__
Packit 032894
# define __const_attribute__
Packit 032894
#endif
Packit 032894
Packit 032894
#if __GNUC__ < 4
Packit 032894
#define __noreturn_attribute__
Packit 032894
#else
Packit 032894
#define __noreturn_attribute__ __attribute__ ((noreturn))
Packit 032894
#endif
Packit 032894
Packit 032894
#ifdef __GNUC_STDC_INLINE__
Packit 032894
# define __libdw_extern_inline extern __inline __attribute__ ((__gnu_inline__))
Packit 032894
#else
Packit 032894
# define __libdw_extern_inline extern __inline
Packit 032894
#endif
Packit 032894
Packit 032894
/* Known translation types.  */
Packit 032894
typedef enum
Packit 032894
{
Packit 032894
  ELF_T_BYTE,                   /* unsigned char */
Packit 032894
  ELF_T_ADDR,                   /* Elf32_Addr, Elf64_Addr, ... */
Packit 032894
  ELF_T_DYN,                    /* Dynamic section record.  */
Packit 032894
  ELF_T_EHDR,                   /* ELF header.  */
Packit 032894
  ELF_T_HALF,                   /* Elf32_Half, Elf64_Half, ... */
Packit 032894
  ELF_T_OFF,                    /* Elf32_Off, Elf64_Off, ... */
Packit 032894
  ELF_T_PHDR,                   /* Program header.  */
Packit 032894
  ELF_T_RELA,                   /* Relocation entry with addend.  */
Packit 032894
  ELF_T_REL,                    /* Relocation entry.  */
Packit 032894
  ELF_T_SHDR,                   /* Section header.  */
Packit 032894
  ELF_T_SWORD,                  /* Elf32_Sword, Elf64_Sword, ... */
Packit 032894
  ELF_T_SYM,                    /* Symbol record.  */
Packit 032894
  ELF_T_WORD,                   /* Elf32_Word, Elf64_Word, ... */
Packit 032894
  ELF_T_XWORD,                  /* Elf32_Xword, Elf64_Xword, ... */
Packit 032894
  ELF_T_SXWORD,                 /* Elf32_Sxword, Elf64_Sxword, ... */
Packit 032894
  ELF_T_VDEF,                   /* Elf32_Verdef, Elf64_Verdef, ... */
Packit 032894
  ELF_T_VDAUX,                  /* Elf32_Verdaux, Elf64_Verdaux, ... */
Packit 032894
  ELF_T_VNEED,                  /* Elf32_Verneed, Elf64_Verneed, ... */
Packit 032894
  ELF_T_VNAUX,                  /* Elf32_Vernaux, Elf64_Vernaux, ... */
Packit 032894
  ELF_T_NHDR,                   /* Elf32_Nhdr, Elf64_Nhdr, ... */
Packit 032894
  ELF_T_SYMINFO,		/* Elf32_Syminfo, Elf64_Syminfo, ... */
Packit 032894
  ELF_T_MOVE,			/* Elf32_Move, Elf64_Move, ... */
Packit 032894
  ELF_T_LIB,			/* Elf32_Lib, Elf64_Lib, ... */
Packit 032894
  ELF_T_GNUHASH,		/* GNU-style hash section.  */
Packit 032894
  ELF_T_AUXV,			/* Elf32_auxv_t, Elf64_auxv_t, ... */
Packit 032894
  ELF_T_CHDR,			/* Compressed, Elf32_Chdr, Elf64_Chdr, ... */
Packit 032894
  ELF_T_NHDR8,			/* Special GNU Properties note.  Same as Nhdr,
Packit 032894
				   except padding.  */
Packit 032894
  /* Keep this the last entry.  */
Packit 032894
  ELF_T_NUM
Packit 032894
} Elf_Type;
Packit 032894
Packit 032894
/* Descriptor for data to be converted to or from memory format.  */
Packit 032894
typedef struct
Packit 032894
{
Packit 032894
  void *d_buf;			/* Pointer to the actual data.  */
Packit 032894
  Elf_Type d_type;		/* Type of this piece of data.  */
Packit 032894
  unsigned int d_version;	/* ELF version.  */
Packit 032894
  size_t d_size;		/* Size in bytes.  */
Packit 032894
  int64_t d_off;		/* Offset into section.  */
Packit 032894
  size_t d_align;		/* Alignment in section.  */
Packit 032894
} Elf_Data;
Packit 032894
Packit 032894
Packit 032894
/* Commands for `...'.  */
Packit 032894
typedef enum
Packit 032894
{
Packit 032894
  ELF_C_NULL,			/* Nothing, terminate, or compute only.  */
Packit 032894
  ELF_C_READ,			/* Read .. */
Packit 032894
  ELF_C_RDWR,			/* Read and write .. */
Packit 032894
  ELF_C_WRITE,			/* Write .. */
Packit 032894
  ELF_C_CLR,			/* Clear flag.  */
Packit 032894
  ELF_C_SET,			/* Set flag.  */
Packit 032894
  ELF_C_FDDONE,			/* Signal that file descriptor will not be
Packit 032894
				   used anymore.  */
Packit 032894
  ELF_C_FDREAD,			/* Read rest of data so that file descriptor
Packit 032894
				   is not used anymore.  */
Packit 032894
  /* The following are extensions.  */
Packit 032894
  ELF_C_READ_MMAP,		/* Read, but mmap the file if possible.  */
Packit 032894
  ELF_C_RDWR_MMAP,		/* Read and write, with mmap.  */
Packit 032894
  ELF_C_WRITE_MMAP,		/* Write, with mmap.  */
Packit 032894
  ELF_C_READ_MMAP_PRIVATE,	/* Read, but memory is writable, results are
Packit 032894
				   not written to the file.  */
Packit 032894
  ELF_C_EMPTY,			/* Copy basic file data but not the content. */
Packit 032894
  /* Keep this the last entry.  */
Packit 032894
  ELF_C_NUM
Packit 032894
} Elf_Cmd;
Packit 032894
Packit 032894
Packit 032894
/* Flags for the ELF structures.  */
Packit 032894
enum
Packit 032894
{
Packit 032894
  ELF_F_DIRTY = 0x1,
Packit 032894
#define ELF_F_DIRTY		ELF_F_DIRTY
Packit 032894
  ELF_F_LAYOUT = 0x4,
Packit 032894
#define ELF_F_LAYOUT		ELF_F_LAYOUT
Packit 032894
  ELF_F_PERMISSIVE = 0x8
Packit 032894
#define ELF_F_PERMISSIVE	ELF_F_PERMISSIVE
Packit 032894
};
Packit 032894
Packit 032894
/* Flags for elf_compress[_gnu].  */
Packit 032894
enum
Packit 032894
{
Packit 032894
  ELF_CHF_FORCE = 0x1
Packit 032894
#define ELF_CHF_FORCE ELF_CHF_FORCE
Packit 032894
};
Packit 032894
Packit 032894
/* Identification values for recognized object files.  */
Packit 032894
typedef enum
Packit 032894
{
Packit 032894
  ELF_K_NONE,			/* Unknown.  */
Packit 032894
  ELF_K_AR,			/* Archive.  */
Packit 032894
  ELF_K_COFF,			/* Stupid old COFF.  */
Packit 032894
  ELF_K_ELF,			/* ELF file.  */
Packit 032894
  /* Keep this the last entry.  */
Packit 032894
  ELF_K_NUM
Packit 032894
} Elf_Kind;
Packit 032894
Packit 032894
Packit 032894
/* Archive member header.  */
Packit 032894
typedef struct
Packit 032894
{
Packit 032894
  char *ar_name;		/* Name of archive member.  */
Packit 032894
  time_t ar_date;		/* File date.  */
Packit 032894
  uid_t ar_uid;			/* User ID.  */
Packit 032894
  gid_t ar_gid;			/* Group ID.  */
Packit 032894
  mode_t ar_mode;		/* File mode.  */
Packit 032894
  int64_t ar_size;		/* File size.  */
Packit 032894
  char *ar_rawname;		/* Original name of archive member.  */
Packit 032894
} Elf_Arhdr;
Packit 032894
Packit 032894
Packit 032894
/* Archive symbol table entry.  */
Packit 032894
typedef struct
Packit 032894
{
Packit 032894
  char *as_name;		/* Symbol name.  */
Packit 032894
  size_t as_off;		/* Offset for this file in the archive.  */
Packit 032894
  unsigned long int as_hash;	/* Hash value of the name.  */
Packit 032894
} Elf_Arsym;
Packit 032894
Packit 032894
Packit 032894
/* Descriptor for the ELF file.  */
Packit 032894
typedef struct Elf Elf;
Packit 032894
Packit 032894
/* Descriptor for ELF file section.  */
Packit 032894
typedef struct Elf_Scn Elf_Scn;
Packit 032894
Packit 032894
Packit 032894
#ifdef __cplusplus
Packit 032894
extern "C" {
Packit 032894
#endif
Packit 032894
Packit 032894
/* Return descriptor for ELF file to work according to CMD.  */
Packit 032894
extern Elf *elf_begin (int __fildes, Elf_Cmd __cmd, Elf *__ref);
Packit 032894
Packit 032894
/* Create a clone of an existing ELF descriptor.  */
Packit 032894
  extern Elf *elf_clone (Elf *__elf, Elf_Cmd __cmd);
Packit 032894
Packit 032894
/* Create descriptor for memory region.  */
Packit 032894
extern Elf *elf_memory (char *__image, size_t __size);
Packit 032894
Packit 032894
/* Advance archive descriptor to next element.  */
Packit 032894
extern Elf_Cmd elf_next (Elf *__elf);
Packit 032894
Packit 032894
/* Free resources allocated for ELF.  */
Packit 032894
extern int elf_end (Elf *__elf);
Packit 032894
Packit 032894
/* Update ELF descriptor and write file to disk.  */
Packit 032894
extern int64_t elf_update (Elf *__elf, Elf_Cmd __cmd);
Packit 032894
Packit 032894
/* Determine what kind of file is associated with ELF.  */
Packit 032894
extern Elf_Kind elf_kind (Elf *__elf) __pure_attribute__;
Packit 032894
Packit 032894
/* Get the base offset for an object file.  */
Packit 032894
extern int64_t elf_getbase (Elf *__elf);
Packit 032894
Packit 032894
Packit 032894
/* Retrieve file identification data.  */
Packit 032894
extern char *elf_getident (Elf *__elf, size_t *__nbytes);
Packit 032894
Packit 032894
/* Retrieve class-dependent object file header.  */
Packit 032894
extern Elf32_Ehdr *elf32_getehdr (Elf *__elf);
Packit 032894
/* Similar but this time the binary calls is ELFCLASS64.  */
Packit 032894
extern Elf64_Ehdr *elf64_getehdr (Elf *__elf);
Packit 032894
Packit 032894
/* Create ELF header if none exists.  */
Packit 032894
extern Elf32_Ehdr *elf32_newehdr (Elf *__elf);
Packit 032894
/* Similar but this time the binary calls is ELFCLASS64.  */
Packit 032894
extern Elf64_Ehdr *elf64_newehdr (Elf *__elf);
Packit 032894
Packit 032894
/* Get the number of program headers in the ELF file.  If the file uses
Packit 032894
   more headers than can be represented in the e_phnum field of the ELF
Packit 032894
   header the information from the sh_info field in the zeroth section
Packit 032894
   header is used.  */
Packit 032894
extern int elf_getphdrnum (Elf *__elf, size_t *__dst);
Packit 032894
Packit 032894
/* Retrieve class-dependent program header table.  */
Packit 032894
extern Elf32_Phdr *elf32_getphdr (Elf *__elf);
Packit 032894
/* Similar but this time the binary calls is ELFCLASS64.  */
Packit 032894
extern Elf64_Phdr *elf64_getphdr (Elf *__elf);
Packit 032894
Packit 032894
/* Create ELF program header.  */
Packit 032894
extern Elf32_Phdr *elf32_newphdr (Elf *__elf, size_t __cnt);
Packit 032894
/* Similar but this time the binary calls is ELFCLASS64.  */
Packit 032894
extern Elf64_Phdr *elf64_newphdr (Elf *__elf, size_t __cnt);
Packit 032894
Packit 032894
Packit 032894
/* Get section at INDEX.  */
Packit 032894
extern Elf_Scn *elf_getscn (Elf *__elf, size_t __index);
Packit 032894
Packit 032894
/* Get section at OFFSET.  */
Packit 032894
extern Elf_Scn *elf32_offscn (Elf *__elf, Elf32_Off __offset);
Packit 032894
/* Similar bug this time the binary calls is ELFCLASS64.  */
Packit 032894
extern Elf_Scn *elf64_offscn (Elf *__elf, Elf64_Off __offset);
Packit 032894
Packit 032894
/* Get index of section.  */
Packit 032894
extern size_t elf_ndxscn (Elf_Scn *__scn);
Packit 032894
Packit 032894
/* Get section with next section index.  */
Packit 032894
extern Elf_Scn *elf_nextscn (Elf *__elf, Elf_Scn *__scn);
Packit 032894
Packit 032894
/* Create a new section and append it at the end of the table.  */
Packit 032894
extern Elf_Scn *elf_newscn (Elf *__elf);
Packit 032894
Packit 032894
/* Get the section index of the extended section index table for the
Packit 032894
   given symbol table.  */
Packit 032894
extern int elf_scnshndx (Elf_Scn *__scn);
Packit 032894
Packit 032894
/* Get the number of sections in the ELF file.  If the file uses more
Packit 032894
   sections than can be represented in the e_shnum field of the ELF
Packit 032894
   header the information from the sh_size field in the zeroth section
Packit 032894
   header is used.  */
Packit 032894
extern int elf_getshdrnum (Elf *__elf, size_t *__dst);
Packit 032894
/* Sun messed up the implementation of 'elf_getshnum' in their implementation.
Packit 032894
   It was agreed to make the same functionality available under a different
Packit 032894
   name and obsolete the old name.  */
Packit 032894
extern int elf_getshnum (Elf *__elf, size_t *__dst)
Packit 032894
     __deprecated_attribute__;
Packit 032894
Packit 032894
Packit 032894
/* Get the section index of the section header string table in the ELF
Packit 032894
   file.  If the index cannot be represented in the e_shstrndx field of
Packit 032894
   the ELF header the information from the sh_link field in the zeroth
Packit 032894
   section header is used.  */
Packit 032894
extern int elf_getshdrstrndx (Elf *__elf, size_t *__dst);
Packit 032894
/* Sun messed up the implementation of 'elf_getshstrndx' in their
Packit 032894
   implementation.  It was agreed to make the same functionality available
Packit 032894
   under a different name and obsolete the old name.  */
Packit 032894
extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
Packit 032894
     __deprecated_attribute__;
Packit 032894
Packit 032894
Packit 032894
/* Retrieve section header of ELFCLASS32 binary.  */
Packit 032894
extern Elf32_Shdr *elf32_getshdr (Elf_Scn *__scn);
Packit 032894
/* Similar for ELFCLASS64.  */
Packit 032894
extern Elf64_Shdr *elf64_getshdr (Elf_Scn *__scn);
Packit 032894
Packit 032894
/* Returns compression header for a section if section data is
Packit 032894
   compressed.  Returns NULL and sets elf_errno if the section isn't
Packit 032894
   compressed or an error occurred.  */
Packit 032894
extern Elf32_Chdr *elf32_getchdr (Elf_Scn *__scn);
Packit 032894
extern Elf64_Chdr *elf64_getchdr (Elf_Scn *__scn);
Packit 032894
Packit 032894
/* Compress or decompress the data of a section and adjust the section
Packit 032894
   header.
Packit 032894
Packit 032894
   elf_compress works by setting or clearing the SHF_COMPRESS flag
Packit 032894
   from the section Shdr and will encode or decode a Elf32_Chdr or
Packit 032894
   Elf64_Chdr at the start of the section data.  elf_compress_gnu will
Packit 032894
   encode or decode any section, but is traditionally only used for
Packit 032894
   sections that have a name starting with ".debug" when
Packit 032894
   uncompressed or ".zdebug" when compressed and stores just the
Packit 032894
   uncompressed size.  The GNU compression method is deprecated and
Packit 032894
   should only be used for legacy support.
Packit 032894
Packit 032894
   elf_compress takes a compression type that should be either zero to
Packit 032894
   decompress or an ELFCOMPRESS algorithm to use for compression.
Packit 032894
   Currently only ELFCOMPRESS_ZLIB is supported.  elf_compress_gnu
Packit 032894
   will compress in the traditional GNU compression format when
Packit 032894
   compress is one and decompress the section data when compress is
Packit 032894
   zero.
Packit 032894
Packit 032894
   The FLAGS argument can be zero or ELF_CHF_FORCE.  If FLAGS contains
Packit 032894
   ELF_CHF_FORCE then it will always compress the section, even if
Packit 032894
   that would not reduce the size of the data section (including the
Packit 032894
   header).  Otherwise elf_compress and elf_compress_gnu will compress
Packit 032894
   the section only if the total data size is reduced.
Packit 032894
Packit 032894
   On successful compression or decompression the function returns
Packit 032894
   one.  If (not forced) compression is requested and the data section
Packit 032894
   would not actually reduce in size, the section is not actually
Packit 032894
   compressed and zero is returned.  Otherwise -1 is returned and
Packit 032894
   elf_errno is set.
Packit 032894
Packit 032894
   It is an error to request compression for a section that already
Packit 032894
   has SHF_COMPRESSED set, or (for elf_compress) to request
Packit 032894
   decompression for an section that doesn't have SHF_COMPRESSED set.
Packit 032894
   If a section has SHF_COMPRESSED set then calling elf_compress_gnu
Packit 032894
   will result in an error.  The section has to be decompressed first
Packit 032894
   using elf_compress.  Calling elf_compress on a section compressed
Packit 032894
   with elf_compress_gnu is fine, but probably useless.
Packit 032894
Packit 032894
   It is always an error to call these functions on SHT_NOBITS
Packit 032894
   sections or if the section has the SHF_ALLOC flag set.
Packit 032894
   elf_compress_gnu will not check whether the section name starts
Packit 032894
   with ".debug" or .zdebug".  It is the responsibilty of the caller
Packit 032894
   to make sure the deprecated GNU compression method is only called
Packit 032894
   on correctly named sections (and to change the name of the section
Packit 032894
   when using elf_compress_gnu).
Packit 032894
Packit 032894
   All previous returned Shdrs and Elf_Data buffers are invalidated by
Packit 032894
   this call and should no longer be accessed.
Packit 032894
Packit 032894
   Note that although this changes the header and data returned it
Packit 032894
   doesn't mark the section as dirty.  To keep the changes when
Packit 032894
   calling elf_update the section has to be flagged ELF_F_DIRTY.  */
Packit 032894
extern int elf_compress (Elf_Scn *scn, int type, unsigned int flags);
Packit 032894
extern int elf_compress_gnu (Elf_Scn *scn, int compress, unsigned int flags);
Packit 032894
Packit 032894
/* Set or clear flags for ELF file.  */
Packit 032894
extern unsigned int elf_flagelf (Elf *__elf, Elf_Cmd __cmd,
Packit 032894
				 unsigned int __flags);
Packit 032894
/* Similarly for the ELF header.  */
Packit 032894
extern unsigned int elf_flagehdr (Elf *__elf, Elf_Cmd __cmd,
Packit 032894
				  unsigned int __flags);
Packit 032894
/* Similarly for the ELF program header.  */
Packit 032894
extern unsigned int elf_flagphdr (Elf *__elf, Elf_Cmd __cmd,
Packit 032894
				  unsigned int __flags);
Packit 032894
/* Similarly for the given ELF section.  */
Packit 032894
extern unsigned int elf_flagscn (Elf_Scn *__scn, Elf_Cmd __cmd,
Packit 032894
				 unsigned int __flags);
Packit 032894
/* Similarly for the given ELF data.  */
Packit 032894
extern unsigned int elf_flagdata (Elf_Data *__data, Elf_Cmd __cmd,
Packit 032894
				  unsigned int __flags);
Packit 032894
/* Similarly for the given ELF section header.  */
Packit 032894
extern unsigned int elf_flagshdr (Elf_Scn *__scn, Elf_Cmd __cmd,
Packit 032894
				  unsigned int __flags);
Packit 032894
Packit 032894
Packit 032894
/* Get data from section while translating from file representation to
Packit 032894
   memory representation.  The Elf_Data d_type is set based on the
Packit 032894
   section type if known.  Otherwise d_type is set to ELF_T_BYTE.  If
Packit 032894
   the section contains compressed data then d_type is always set to
Packit 032894
   ELF_T_CHDR.  */
Packit 032894
extern Elf_Data *elf_getdata (Elf_Scn *__scn, Elf_Data *__data);
Packit 032894
Packit 032894
/* Get uninterpreted section content.  */
Packit 032894
extern Elf_Data *elf_rawdata (Elf_Scn *__scn, Elf_Data *__data);
Packit 032894
Packit 032894
/* Create new data descriptor for section SCN.  */
Packit 032894
extern Elf_Data *elf_newdata (Elf_Scn *__scn);
Packit 032894
Packit 032894
/* Get data translated from a chunk of the file contents as section data
Packit 032894
   would be for TYPE.  The resulting Elf_Data pointer is valid until
Packit 032894
   elf_end (ELF) is called.  */
Packit 032894
extern Elf_Data *elf_getdata_rawchunk (Elf *__elf,
Packit 032894
				       int64_t __offset, size_t __size,
Packit 032894
				       Elf_Type __type);
Packit 032894
Packit 032894
Packit 032894
/* Return pointer to string at OFFSET in section INDEX.  */
Packit 032894
extern char *elf_strptr (Elf *__elf, size_t __index, size_t __offset);
Packit 032894
Packit 032894
Packit 032894
/* Return header of archive.  */
Packit 032894
extern Elf_Arhdr *elf_getarhdr (Elf *__elf);
Packit 032894
Packit 032894
/* Return offset in archive for current file ELF.  */
Packit 032894
extern int64_t elf_getaroff (Elf *__elf);
Packit 032894
Packit 032894
/* Select archive element at OFFSET.  */
Packit 032894
extern size_t elf_rand (Elf *__elf, size_t __offset);
Packit 032894
Packit 032894
/* Get symbol table of archive.  */
Packit 032894
extern Elf_Arsym *elf_getarsym (Elf *__elf, size_t *__narsyms);
Packit 032894
Packit 032894
Packit 032894
/* Control ELF descriptor.  */
Packit 032894
extern int elf_cntl (Elf *__elf, Elf_Cmd __cmd);
Packit 032894
Packit 032894
/* Retrieve uninterpreted file contents.  */
Packit 032894
extern char *elf_rawfile (Elf *__elf, size_t *__nbytes);
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 elf32_fsize (Elf_Type __type, size_t __count,
Packit 032894
			   unsigned int __version)
Packit 032894
       __const_attribute__;
Packit 032894
/* Similar but this time the binary calls is ELFCLASS64.  */
Packit 032894
extern size_t elf64_fsize (Elf_Type __type, size_t __count,
Packit 032894
			   unsigned int __version)
Packit 032894
       __const_attribute__;
Packit 032894
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 *elf32_xlatetom (Elf_Data *__dest, const Elf_Data *__src,
Packit 032894
				 unsigned int __encode);
Packit 032894
/* Same for 64 bit class.  */
Packit 032894
extern Elf_Data *elf64_xlatetom (Elf_Data *__dest, const Elf_Data *__src,
Packit 032894
				 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 *elf32_xlatetof (Elf_Data *__dest, const Elf_Data *__src,
Packit 032894
				 unsigned int __encode);
Packit 032894
/* Same for 64 bit class.  */
Packit 032894
extern Elf_Data *elf64_xlatetof (Elf_Data *__dest, const Elf_Data *__src,
Packit 032894
				 unsigned int __encode);
Packit 032894
Packit 032894
Packit 032894
/* Return error code of last failing function call.  This value is kept
Packit 032894
   separately for each thread.  */
Packit 032894
extern int elf_errno (void);
Packit 032894
Packit 032894
/* Return error string for ERROR.  If ERROR is zero, return error string
Packit 032894
   for most recent error or NULL is none occurred.  If ERROR is -1 the
Packit 032894
   behaviour is similar to the last case except that not NULL but a legal
Packit 032894
   string is returned.  */
Packit 032894
extern const char *elf_errmsg (int __error);
Packit 032894
Packit 032894
Packit 032894
/* Coordinate ELF library and application versions.  */
Packit 032894
extern unsigned int elf_version (unsigned int __version);
Packit 032894
Packit 032894
/* Set fill bytes used to fill holes in data structures.  */
Packit 032894
extern void elf_fill (int __fill);
Packit 032894
Packit 032894
/* Compute hash value.  */
Packit 032894
extern unsigned long int elf_hash (const char *__string)
Packit 032894
       __pure_attribute__;
Packit 032894
Packit 032894
/* Compute hash value using the GNU-specific hash function.  */
Packit 032894
extern unsigned long int elf_gnu_hash (const char *__string)
Packit 032894
       __pure_attribute__;
Packit 032894
Packit 032894
Packit 032894
/* Compute simple checksum from permanent parts of the ELF file.  */
Packit 032894
extern long int elf32_checksum (Elf *__elf);
Packit 032894
/* Similar but this time the binary calls is ELFCLASS64.  */
Packit 032894
extern long int elf64_checksum (Elf *__elf);
Packit 032894
Packit 032894
#ifdef __cplusplus
Packit 032894
}
Packit 032894
#endif
Packit 032894
Packit 032894
#endif  /* libelf.h */