Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:47

0001 /* Interface for libelf.
0002    Copyright (C) 1998-2010, 2015 Red Hat, Inc.
0003    This file is part of elfutils.
0004 
0005    This file is free software; you can redistribute it and/or modify
0006    it under the terms of either
0007 
0008      * the GNU Lesser General Public License as published by the Free
0009        Software Foundation; either version 3 of the License, or (at
0010        your option) any later version
0011 
0012    or
0013 
0014      * the GNU General Public License as published by the Free
0015        Software Foundation; either version 2 of the License, or (at
0016        your option) any later version
0017 
0018    or both in parallel, as here.
0019 
0020    elfutils is distributed in the hope that it will be useful, but
0021    WITHOUT ANY WARRANTY; without even the implied warranty of
0022    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0023    General Public License for more details.
0024 
0025    You should have received copies of the GNU General Public License and
0026    the GNU Lesser General Public License along with this program.  If
0027    not, see <http://www.gnu.org/licenses/>.  */
0028 
0029 #ifndef _LIBELF_H
0030 #define _LIBELF_H 1
0031 
0032 #include <stdint.h>
0033 #include <sys/types.h>
0034 
0035 /* Get the ELF types.  */
0036 #include <elf.h>
0037 
0038 #ifndef SHF_COMPRESSED
0039  /* Older glibc elf.h might not yet define the ELF compression types.  */
0040  #define SHF_COMPRESSED      (1 << 11)  /* Section with compressed data. */
0041 
0042  /* Section compression header.  Used when SHF_COMPRESSED is set.  */
0043 
0044  typedef struct
0045  {
0046    Elf32_Word   ch_type;        /* Compression format.  */
0047    Elf32_Word   ch_size;        /* Uncompressed data size.  */
0048    Elf32_Word   ch_addralign;   /* Uncompressed data alignment.  */
0049  } Elf32_Chdr;
0050 
0051  typedef struct
0052  {
0053    Elf64_Word   ch_type;        /* Compression format.  */
0054    Elf64_Word   ch_reserved;
0055    Elf64_Xword  ch_size;        /* Uncompressed data size.  */
0056    Elf64_Xword  ch_addralign;   /* Uncompressed data alignment.  */
0057  } Elf64_Chdr;
0058 
0059  /* Legal values for ch_type (compression algorithm).  */
0060  #define ELFCOMPRESS_ZLIB       1          /* ZLIB/DEFLATE algorithm.  */
0061  #define ELFCOMPRESS_LOOS       0x60000000 /* Start of OS-specific.  */
0062  #define ELFCOMPRESS_HIOS       0x6fffffff /* End of OS-specific.  */
0063  #define ELFCOMPRESS_LOPROC     0x70000000 /* Start of processor-specific.  */
0064  #define ELFCOMPRESS_HIPROC     0x7fffffff /* End of processor-specific.  */
0065 #endif
0066 
0067 #ifndef ELFCOMPRESS_ZSTD
0068  /* So ZSTD compression can be used even with an old system elf.h.  */
0069  #define ELFCOMPRESS_ZSTD       2          /* Zstandard algorithm.  */
0070 #endif
0071 
0072 #ifndef SHT_RELR
0073  /* So RELR defines/typedefs can be used even with an old system elf.h.  */
0074  #define SHT_RELR       19      /* RELR relative relocations */
0075 
0076  /* RELR relocation table entry */
0077  typedef Elf32_Word     Elf32_Relr;
0078  typedef Elf64_Xword    Elf64_Relr;
0079 
0080  #define DT_RELRSZ      35      /* Total size of RELR relative relocations */
0081  #define DT_RELR        36      /* Address of RELR relative relocations */
0082  #define DT_RELRENT     37      /* Size of one RELR relative relocaction */
0083 #endif
0084 
0085 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
0086 # define __nonnull_attribute__(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))
0087 # define __deprecated_attribute__ __attribute__ ((__deprecated__))
0088 # define __pure_attribute__ __attribute__ ((__pure__))
0089 # define __const_attribute__ __attribute__ ((__const__))
0090 #else
0091 # define __nonnull_attribute__(...)
0092 # define __deprecated_attribute__
0093 # define __pure_attribute__
0094 # define __const_attribute__
0095 #endif
0096 
0097 #if __GNUC__ < 4
0098 #define __noreturn_attribute__
0099 #else
0100 #define __noreturn_attribute__ __attribute__ ((noreturn))
0101 #endif
0102 
0103 #ifdef __GNUC_STDC_INLINE__
0104 # define __libdw_extern_inline extern __inline __attribute__ ((__gnu_inline__))
0105 #else
0106 # define __libdw_extern_inline extern __inline
0107 #endif
0108 
0109 /* Known translation types.  */
0110 typedef enum
0111 {
0112   ELF_T_BYTE,                   /* unsigned char */
0113   ELF_T_ADDR,                   /* Elf32_Addr, Elf64_Addr, ... */
0114   ELF_T_DYN,                    /* Dynamic section record.  */
0115   ELF_T_EHDR,                   /* ELF header.  */
0116   ELF_T_HALF,                   /* Elf32_Half, Elf64_Half, ... */
0117   ELF_T_OFF,                    /* Elf32_Off, Elf64_Off, ... */
0118   ELF_T_PHDR,                   /* Program header.  */
0119   ELF_T_RELA,                   /* Relocation entry with addend.  */
0120   ELF_T_REL,                    /* Relocation entry.  */
0121   ELF_T_SHDR,                   /* Section header.  */
0122   ELF_T_SWORD,                  /* Elf32_Sword, Elf64_Sword, ... */
0123   ELF_T_SYM,                    /* Symbol record.  */
0124   ELF_T_WORD,                   /* Elf32_Word, Elf64_Word, ... */
0125   ELF_T_XWORD,                  /* Elf32_Xword, Elf64_Xword, ... */
0126   ELF_T_SXWORD,                 /* Elf32_Sxword, Elf64_Sxword, ... */
0127   ELF_T_VDEF,                   /* Elf32_Verdef, Elf64_Verdef, ... */
0128   ELF_T_VDAUX,                  /* Elf32_Verdaux, Elf64_Verdaux, ... */
0129   ELF_T_VNEED,                  /* Elf32_Verneed, Elf64_Verneed, ... */
0130   ELF_T_VNAUX,                  /* Elf32_Vernaux, Elf64_Vernaux, ... */
0131   ELF_T_NHDR,                   /* Elf32_Nhdr, Elf64_Nhdr, ... */
0132   ELF_T_SYMINFO,        /* Elf32_Syminfo, Elf64_Syminfo, ... */
0133   ELF_T_MOVE,           /* Elf32_Move, Elf64_Move, ... */
0134   ELF_T_LIB,            /* Elf32_Lib, Elf64_Lib, ... */
0135   ELF_T_GNUHASH,        /* GNU-style hash section.  */
0136   ELF_T_AUXV,           /* Elf32_auxv_t, Elf64_auxv_t, ... */
0137   ELF_T_CHDR,           /* Compressed, Elf32_Chdr, Elf64_Chdr, ... */
0138   ELF_T_NHDR8,          /* Special GNU Properties note.  Same as Nhdr,
0139                    except padding.  */
0140   ELF_T_RELR,           /* Relative relocation entry.  */
0141   /* Keep this the last entry.  */
0142   ELF_T_NUM
0143 } Elf_Type;
0144 
0145 /* Descriptor for data to be converted to or from memory format.  */
0146 typedef struct
0147 {
0148   void *d_buf;          /* Pointer to the actual data.  */
0149   Elf_Type d_type;      /* Type of this piece of data.  */
0150   unsigned int d_version;   /* ELF version.  */
0151   size_t d_size;        /* Size in bytes.  */
0152   int64_t d_off;        /* Offset into section.  */
0153   size_t d_align;       /* Alignment in section.  */
0154 } Elf_Data;
0155 
0156 
0157 /* Commands for `...'.  */
0158 typedef enum
0159 {
0160   ELF_C_NULL,           /* Nothing, terminate, or compute only.  */
0161   ELF_C_READ,           /* Read .. */
0162   ELF_C_RDWR,           /* Read and write .. */
0163   ELF_C_WRITE,          /* Write .. */
0164   ELF_C_CLR,            /* Clear flag.  */
0165   ELF_C_SET,            /* Set flag.  */
0166   ELF_C_FDDONE,         /* Signal that file descriptor will not be
0167                    used anymore.  */
0168   ELF_C_FDREAD,         /* Read rest of data so that file descriptor
0169                    is not used anymore.  */
0170   /* The following are extensions.  */
0171   ELF_C_READ_MMAP,      /* Read, but mmap the file if possible.  */
0172   ELF_C_RDWR_MMAP,      /* Read and write, with mmap.  */
0173   ELF_C_WRITE_MMAP,     /* Write, with mmap.  */
0174   ELF_C_READ_MMAP_PRIVATE,  /* Read, but memory is writable, results are
0175                    not written to the file.  */
0176   ELF_C_EMPTY,          /* Copy basic file data but not the content. */
0177   /* Keep this the last entry.  */
0178   ELF_C_NUM
0179 } Elf_Cmd;
0180 
0181 
0182 /* Flags for the ELF structures.  */
0183 enum
0184 {
0185   ELF_F_DIRTY = 0x1,
0186 #define ELF_F_DIRTY     ELF_F_DIRTY
0187   ELF_F_LAYOUT = 0x4,
0188 #define ELF_F_LAYOUT        ELF_F_LAYOUT
0189   ELF_F_PERMISSIVE = 0x8
0190 #define ELF_F_PERMISSIVE    ELF_F_PERMISSIVE
0191 };
0192 
0193 /* Flags for elf_compress[_gnu].  */
0194 enum
0195 {
0196   ELF_CHF_FORCE = 0x1
0197 #define ELF_CHF_FORCE ELF_CHF_FORCE
0198 };
0199 
0200 /* Identification values for recognized object files.  */
0201 typedef enum
0202 {
0203   ELF_K_NONE,           /* Unknown.  */
0204   ELF_K_AR,         /* Archive.  */
0205   ELF_K_COFF,           /* Stupid old COFF.  */
0206   ELF_K_ELF,            /* ELF file.  */
0207   /* Keep this the last entry.  */
0208   ELF_K_NUM
0209 } Elf_Kind;
0210 
0211 
0212 /* Archive member header.  */
0213 typedef struct
0214 {
0215   char *ar_name;        /* Name of archive member.  */
0216   time_t ar_date;       /* File date.  */
0217   uid_t ar_uid;         /* User ID.  */
0218   gid_t ar_gid;         /* Group ID.  */
0219   mode_t ar_mode;       /* File mode.  */
0220   int64_t ar_size;      /* File size.  */
0221   char *ar_rawname;     /* Original name of archive member.  */
0222 } Elf_Arhdr;
0223 
0224 
0225 /* Archive symbol table entry.  */
0226 typedef struct
0227 {
0228   char *as_name;        /* Symbol name.  */
0229   size_t as_off;        /* Offset for this file in the archive.  */
0230   unsigned long int as_hash;    /* Hash value of the name.  */
0231 } Elf_Arsym;
0232 
0233 
0234 /* Descriptor for the ELF file.  */
0235 typedef struct Elf Elf;
0236 
0237 /* Descriptor for ELF file section.  */
0238 typedef struct Elf_Scn Elf_Scn;
0239 
0240 
0241 #ifdef __cplusplus
0242 extern "C" {
0243 #endif
0244 
0245 /* Return descriptor for ELF file to work according to CMD.  */
0246 extern Elf *elf_begin (int __fildes, Elf_Cmd __cmd, Elf *__ref);
0247 
0248 /* Create a clone of an existing ELF descriptor.  */
0249   extern Elf *elf_clone (Elf *__elf, Elf_Cmd __cmd);
0250 
0251 /* Create descriptor for memory region.  */
0252 extern Elf *elf_memory (char *__image, size_t __size);
0253 
0254 /* Advance archive descriptor to next element.  */
0255 extern Elf_Cmd elf_next (Elf *__elf);
0256 
0257 /* Free resources allocated for ELF.  */
0258 extern int elf_end (Elf *__elf);
0259 
0260 /* Update ELF descriptor and write file to disk.  */
0261 extern int64_t elf_update (Elf *__elf, Elf_Cmd __cmd);
0262 
0263 /* Determine what kind of file is associated with ELF.  */
0264 extern Elf_Kind elf_kind (Elf *__elf) __pure_attribute__;
0265 
0266 /* Get the base offset for an object file.  */
0267 extern int64_t elf_getbase (Elf *__elf);
0268 
0269 
0270 /* Retrieve file identification data.  */
0271 extern char *elf_getident (Elf *__elf, size_t *__nbytes);
0272 
0273 /* Retrieve class-dependent object file header.  */
0274 extern Elf32_Ehdr *elf32_getehdr (Elf *__elf);
0275 /* Similar but this time the binary calls is ELFCLASS64.  */
0276 extern Elf64_Ehdr *elf64_getehdr (Elf *__elf);
0277 
0278 /* Create ELF header if none exists.  */
0279 extern Elf32_Ehdr *elf32_newehdr (Elf *__elf);
0280 /* Similar but this time the binary calls is ELFCLASS64.  */
0281 extern Elf64_Ehdr *elf64_newehdr (Elf *__elf);
0282 
0283 /* Get the number of program headers in the ELF file.  If the file uses
0284    more headers than can be represented in the e_phnum field of the ELF
0285    header the information from the sh_info field in the zeroth section
0286    header is used.  */
0287 extern int elf_getphdrnum (Elf *__elf, size_t *__dst);
0288 
0289 /* Retrieve class-dependent program header table.  */
0290 extern Elf32_Phdr *elf32_getphdr (Elf *__elf);
0291 /* Similar but this time the binary calls is ELFCLASS64.  */
0292 extern Elf64_Phdr *elf64_getphdr (Elf *__elf);
0293 
0294 /* Create ELF program header.  */
0295 extern Elf32_Phdr *elf32_newphdr (Elf *__elf, size_t __cnt);
0296 /* Similar but this time the binary calls is ELFCLASS64.  */
0297 extern Elf64_Phdr *elf64_newphdr (Elf *__elf, size_t __cnt);
0298 
0299 
0300 /* Get section at INDEX.  */
0301 extern Elf_Scn *elf_getscn (Elf *__elf, size_t __index);
0302 
0303 /* Get section at OFFSET.  */
0304 extern Elf_Scn *elf32_offscn (Elf *__elf, Elf32_Off __offset);
0305 /* Similar but this time the binary calls is ELFCLASS64.  */
0306 extern Elf_Scn *elf64_offscn (Elf *__elf, Elf64_Off __offset);
0307 
0308 /* Get index of section.  */
0309 extern size_t elf_ndxscn (Elf_Scn *__scn);
0310 
0311 /* Get section with next section index.  */
0312 extern Elf_Scn *elf_nextscn (Elf *__elf, Elf_Scn *__scn);
0313 
0314 /* Create a new section and append it at the end of the table.  */
0315 extern Elf_Scn *elf_newscn (Elf *__elf);
0316 
0317 /* Get the section index of the extended section index table for the
0318    given symbol table.  */
0319 extern int elf_scnshndx (Elf_Scn *__scn);
0320 
0321 /* Get the number of sections in the ELF file.  If the file uses more
0322    sections than can be represented in the e_shnum field of the ELF
0323    header the information from the sh_size field in the zeroth section
0324    header is used.  */
0325 extern int elf_getshdrnum (Elf *__elf, size_t *__dst);
0326 /* Sun messed up the implementation of 'elf_getshnum' in their implementation.
0327    It was agreed to make the same functionality available under a different
0328    name and obsolete the old name.  */
0329 extern int elf_getshnum (Elf *__elf, size_t *__dst)
0330      __deprecated_attribute__;
0331 
0332 
0333 /* Get the section index of the section header string table in the ELF
0334    file.  If the index cannot be represented in the e_shstrndx field of
0335    the ELF header the information from the sh_link field in the zeroth
0336    section header is used.  */
0337 extern int elf_getshdrstrndx (Elf *__elf, size_t *__dst);
0338 /* Sun messed up the implementation of 'elf_getshstrndx' in their
0339    implementation.  It was agreed to make the same functionality available
0340    under a different name and obsolete the old name.  */
0341 extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
0342      __deprecated_attribute__;
0343 
0344 
0345 /* Retrieve section header of ELFCLASS32 binary.  */
0346 extern Elf32_Shdr *elf32_getshdr (Elf_Scn *__scn);
0347 /* Similar for ELFCLASS64.  */
0348 extern Elf64_Shdr *elf64_getshdr (Elf_Scn *__scn);
0349 
0350 /* Returns compression header for a section if section data is
0351    compressed.  Returns NULL and sets elf_errno if the section isn't
0352    compressed or an error occurred.  */
0353 extern Elf32_Chdr *elf32_getchdr (Elf_Scn *__scn);
0354 extern Elf64_Chdr *elf64_getchdr (Elf_Scn *__scn);
0355 
0356 /* Compress or decompress the data of a section and adjust the section
0357    header.
0358 
0359    elf_compress works by setting or clearing the SHF_COMPRESS flag
0360    from the section Shdr and will encode or decode a Elf32_Chdr or
0361    Elf64_Chdr at the start of the section data.  elf_compress_gnu will
0362    encode or decode any section, but is traditionally only used for
0363    sections that have a name starting with ".debug" when
0364    uncompressed or ".zdebug" when compressed and stores just the
0365    uncompressed size.  The GNU compression method is deprecated and
0366    should only be used for legacy support.
0367 
0368    elf_compress takes a compression type that should be either zero to
0369    decompress or an ELFCOMPRESS algorithm to use for compression.
0370    Currently ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD are supported.
0371    elf_compress_gnu will compress in the traditional GNU compression
0372    format when compress is one and decompress the section data when
0373    compress is zero.
0374 
0375    The FLAGS argument can be zero or ELF_CHF_FORCE.  If FLAGS contains
0376    ELF_CHF_FORCE then it will always compress the section, even if
0377    that would not reduce the size of the data section (including the
0378    header).  Otherwise elf_compress and elf_compress_gnu will compress
0379    the section only if the total data size is reduced.
0380 
0381    On successful compression or decompression the function returns
0382    one.  If (not forced) compression is requested and the data section
0383    would not actually reduce in size, the section is not actually
0384    compressed and zero is returned.  Otherwise -1 is returned and
0385    elf_errno is set.
0386 
0387    It is an error to request compression for a section that already
0388    has SHF_COMPRESSED set, or (for elf_compress) to request
0389    decompression for an section that doesn't have SHF_COMPRESSED set.
0390    If a section has SHF_COMPRESSED set then calling elf_compress_gnu
0391    will result in an error.  The section has to be decompressed first
0392    using elf_compress.  Calling elf_compress on a section compressed
0393    with elf_compress_gnu is fine, but probably useless.
0394 
0395    It is always an error to call these functions on SHT_NOBITS
0396    sections or if the section has the SHF_ALLOC flag set.
0397    elf_compress_gnu will not check whether the section name starts
0398    with ".debug" or .zdebug".  It is the responsibility of the caller
0399    to make sure the deprecated GNU compression method is only called
0400    on correctly named sections (and to change the name of the section
0401    when using elf_compress_gnu).
0402 
0403    All previous returned Shdrs and Elf_Data buffers are invalidated by
0404    this call and should no longer be accessed.
0405 
0406    Note that although this changes the header and data returned it
0407    doesn't mark the section as dirty.  To keep the changes when
0408    calling elf_update the section has to be flagged ELF_F_DIRTY.  */
0409 extern int elf_compress (Elf_Scn *scn, int type, unsigned int flags);
0410 extern int elf_compress_gnu (Elf_Scn *scn, int compress, unsigned int flags);
0411 
0412 /* Set or clear flags for ELF file.  */
0413 extern unsigned int elf_flagelf (Elf *__elf, Elf_Cmd __cmd,
0414                  unsigned int __flags);
0415 /* Similarly for the ELF header.  */
0416 extern unsigned int elf_flagehdr (Elf *__elf, Elf_Cmd __cmd,
0417                   unsigned int __flags);
0418 /* Similarly for the ELF program header.  */
0419 extern unsigned int elf_flagphdr (Elf *__elf, Elf_Cmd __cmd,
0420                   unsigned int __flags);
0421 /* Similarly for the given ELF section.  */
0422 extern unsigned int elf_flagscn (Elf_Scn *__scn, Elf_Cmd __cmd,
0423                  unsigned int __flags);
0424 /* Similarly for the given ELF data.  */
0425 extern unsigned int elf_flagdata (Elf_Data *__data, Elf_Cmd __cmd,
0426                   unsigned int __flags);
0427 /* Similarly for the given ELF section header.  */
0428 extern unsigned int elf_flagshdr (Elf_Scn *__scn, Elf_Cmd __cmd,
0429                   unsigned int __flags);
0430 
0431 
0432 /* Get data from section while translating from file representation to
0433    memory representation.  The Elf_Data d_type is set based on the
0434    section type if known.  Otherwise d_type is set to ELF_T_BYTE.  If
0435    the section contains compressed data then d_type is always set to
0436    ELF_T_CHDR.  */
0437 extern Elf_Data *elf_getdata (Elf_Scn *__scn, Elf_Data *__data);
0438 
0439 /* Get uninterpreted section content.  */
0440 extern Elf_Data *elf_rawdata (Elf_Scn *__scn, Elf_Data *__data);
0441 
0442 /* Create new data descriptor for section SCN.  */
0443 extern Elf_Data *elf_newdata (Elf_Scn *__scn);
0444 
0445 /* Get data translated from a chunk of the file contents as section data
0446    would be for TYPE.  The resulting Elf_Data pointer is valid until
0447    elf_end (ELF) is called.  */
0448 extern Elf_Data *elf_getdata_rawchunk (Elf *__elf,
0449                        int64_t __offset, size_t __size,
0450                        Elf_Type __type);
0451 
0452 
0453 /* Return pointer to string at OFFSET in section INDEX.  */
0454 extern char *elf_strptr (Elf *__elf, size_t __index, size_t __offset);
0455 
0456 
0457 /* Return header of archive.  */
0458 extern Elf_Arhdr *elf_getarhdr (Elf *__elf);
0459 
0460 /* Return offset in archive for current file ELF.  */
0461 extern int64_t elf_getaroff (Elf *__elf);
0462 
0463 /* Select archive element at OFFSET.  */
0464 extern size_t elf_rand (Elf *__elf, size_t __offset);
0465 
0466 /* Get symbol table of archive.  */
0467 extern Elf_Arsym *elf_getarsym (Elf *__elf, size_t *__narsyms);
0468 
0469 
0470 /* Control ELF descriptor.  */
0471 extern int elf_cntl (Elf *__elf, Elf_Cmd __cmd);
0472 
0473 /* Retrieve uninterpreted file contents.  */
0474 extern char *elf_rawfile (Elf *__elf, size_t *__nbytes);
0475 
0476 
0477 /* Return size of array of COUNT elements of the type denoted by TYPE
0478    in the external representation.  The binary class is taken from ELF.
0479    The result is based on version VERSION of the ELF standard.  */
0480 extern size_t elf32_fsize (Elf_Type __type, size_t __count,
0481                unsigned int __version)
0482        __const_attribute__;
0483 /* Similar but this time the binary calls is ELFCLASS64.  */
0484 extern size_t elf64_fsize (Elf_Type __type, size_t __count,
0485                unsigned int __version)
0486        __const_attribute__;
0487 
0488 
0489 /* Convert data structure from the representation in the file represented
0490    by ELF to their memory representation.  */
0491 extern Elf_Data *elf32_xlatetom (Elf_Data *__dest, const Elf_Data *__src,
0492                  unsigned int __encode);
0493 /* Same for 64 bit class.  */
0494 extern Elf_Data *elf64_xlatetom (Elf_Data *__dest, const Elf_Data *__src,
0495                  unsigned int __encode);
0496 
0497 /* Convert data structure from to the representation in memory
0498    represented by ELF file representation.  */
0499 extern Elf_Data *elf32_xlatetof (Elf_Data *__dest, const Elf_Data *__src,
0500                  unsigned int __encode);
0501 /* Same for 64 bit class.  */
0502 extern Elf_Data *elf64_xlatetof (Elf_Data *__dest, const Elf_Data *__src,
0503                  unsigned int __encode);
0504 
0505 
0506 /* Return error code of last failing function call.  This value is kept
0507    separately for each thread.  */
0508 extern int elf_errno (void);
0509 
0510 /* Return error string for ERROR.  If ERROR is zero, return error string
0511    for most recent error or NULL is none occurred.  If ERROR is -1 the
0512    behaviour is similar to the last case except that not NULL but a legal
0513    string is returned.  */
0514 extern const char *elf_errmsg (int __error);
0515 
0516 
0517 /* Coordinate ELF library and application versions.  */
0518 extern unsigned int elf_version (unsigned int __version);
0519 
0520 /* Set fill bytes used to fill holes in data structures.  */
0521 extern void elf_fill (int __fill);
0522 
0523 /* Compute hash value.  */
0524 extern unsigned long int elf_hash (const char *__string)
0525        __pure_attribute__;
0526 
0527 /* Compute hash value using the GNU-specific hash function.  */
0528 extern unsigned long int elf_gnu_hash (const char *__string)
0529        __pure_attribute__;
0530 
0531 
0532 /* Compute simple checksum from permanent parts of the ELF file.  */
0533 extern long int elf32_checksum (Elf *__elf);
0534 /* Similar but this time the binary calls is ELFCLASS64.  */
0535 extern long int elf64_checksum (Elf *__elf);
0536 
0537 #ifdef __cplusplus
0538 }
0539 #endif
0540 
0541 #endif  /* libelf.h */