Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-05-18 08:29:55

0001 /* This file defines generic ELF types, structures, and macros.
0002    Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2007, 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 _GELF_H
0030 #define _GELF_H 1
0031 
0032 #include <libelf.h>
0033 
0034 
0035 #ifdef __cplusplus
0036 extern "C" {
0037 #endif
0038 
0039 /* Class independent type definitions.  Correctly speaking this is not
0040    true.  We assume that 64-bit binaries are the largest class and
0041    therefore all other classes can be represented without loss.  */
0042 
0043 /* Type for a 16-bit quantity.  */
0044 typedef Elf64_Half GElf_Half;
0045 
0046 /* Types for signed and unsigned 32-bit quantities.  */
0047 typedef Elf64_Word GElf_Word;
0048 typedef Elf64_Sword GElf_Sword;
0049 
0050 /* Types for signed and unsigned 64-bit quantities.  */
0051 typedef Elf64_Xword GElf_Xword;
0052 typedef Elf64_Sxword GElf_Sxword;
0053 
0054 /* Type of addresses.  */
0055 typedef Elf64_Addr GElf_Addr;
0056 
0057 /* Type of file offsets.  */
0058 typedef Elf64_Off GElf_Off;
0059 
0060 
0061 /* The ELF file header.  This appears at the start of every ELF file.  */
0062 typedef Elf64_Ehdr GElf_Ehdr;
0063 
0064 /* Section header.  */
0065 typedef Elf64_Shdr GElf_Shdr;
0066 
0067 /* Section index.  */
0068 /* XXX This should probably be a larger type in preparation of times when
0069    regular section indices can be larger.  */
0070 typedef Elf64_Section GElf_Section;
0071 
0072 /* Symbol table entry.  */
0073 typedef Elf64_Sym GElf_Sym;
0074 
0075 /* The syminfo section if available contains additional information about
0076    every dynamic symbol.  */
0077 typedef Elf64_Syminfo GElf_Syminfo;
0078 
0079 /* Relocation table entry without addend (in section of type SHT_REL).  */
0080 typedef Elf64_Rel GElf_Rel;
0081 
0082 /* Relocation table entry with addend (in section of type SHT_RELA).  */
0083 typedef Elf64_Rela GElf_Rela;
0084 
0085 /* Program segment header.  */
0086 typedef Elf64_Phdr GElf_Phdr;
0087 
0088 /* Header of a compressed section.  */
0089 typedef Elf64_Chdr GElf_Chdr;
0090 
0091 /* Dynamic section entry.  */
0092 typedef Elf64_Dyn GElf_Dyn;
0093 
0094 
0095 /* Version definition sections.  */
0096 typedef Elf64_Verdef GElf_Verdef;
0097 
0098 /* Auxiliary version information.  */
0099 typedef Elf64_Verdaux GElf_Verdaux;
0100 
0101 /* Version dependency section.  */
0102 typedef Elf64_Verneed GElf_Verneed;
0103 
0104 /* Auxiliary needed version information.  */
0105 typedef Elf64_Vernaux GElf_Vernaux;
0106 
0107 
0108 /* Type for version symbol information.  */
0109 typedef Elf64_Versym GElf_Versym;
0110 
0111 
0112 /* Auxiliary vector.  */
0113 typedef Elf64_auxv_t GElf_auxv_t;
0114 
0115 
0116 /* Note section contents.  */
0117 typedef Elf64_Nhdr GElf_Nhdr;
0118 
0119 
0120 /* Move structure.  */
0121 typedef Elf64_Move GElf_Move;
0122 
0123 
0124 /* Library list structure.  */
0125 typedef Elf64_Lib GElf_Lib;
0126 
0127 
0128 /* How to extract and insert information held in the st_info field.  */
0129 
0130 #define GELF_ST_BIND(val)       ELF64_ST_BIND (val)
0131 #define GELF_ST_TYPE(val)       ELF64_ST_TYPE (val)
0132 #define GELF_ST_INFO(bind, type)    ELF64_ST_INFO (bind, type)
0133 
0134 /* How to extract information held in the st_other field.  */
0135 
0136 #define GELF_ST_VISIBILITY(val)     ELF64_ST_VISIBILITY (val)
0137 
0138 
0139 /* How to extract and insert information held in the r_info field.  */
0140 
0141 #define GELF_R_SYM(info)        ELF64_R_SYM (info)
0142 #define GELF_R_TYPE(info)       ELF64_R_TYPE (info)
0143 #define GELF_R_INFO(sym, type)      ELF64_R_INFO (sym, type)
0144 
0145 
0146 /* How to extract and insert information held in the m_info field.  */
0147 #define GELF_M_SYM(info)        ELF64_M_SYM (info)
0148 #define GELF_M_SIZE(info)       ELF64_M_SIZE (info)
0149 #define GELF_M_INFO(sym, size)      ELF64_M_INFO (sym, size)
0150 
0151 
0152 /* Get class of the file associated with ELF.  */
0153 extern int gelf_getclass (Elf *__elf);
0154 
0155 
0156 /* Return size of array of COUNT elements of the type denoted by TYPE
0157    in the external representation.  The binary class is taken from ELF.
0158    The result is based on version VERSION of the ELF standard.  */
0159 extern size_t gelf_fsize (Elf *__elf, Elf_Type __type, size_t __count,
0160               unsigned int __version);
0161 
0162 /* Retrieve object file header.  */
0163 extern GElf_Ehdr *gelf_getehdr (Elf *__elf, GElf_Ehdr *__dest);
0164 
0165 /* Update the ELF header.  */
0166 extern int gelf_update_ehdr (Elf *__elf, GElf_Ehdr *__src);
0167 
0168 /* Create new ELF header if none exists.  Creates an Elf32_Ehdr if CLASS
0169    is ELFCLASS32 or an Elf64_Ehdr if CLASS is ELFCLASS64.  Returns NULL
0170    on error.  */
0171 extern void *gelf_newehdr (Elf *__elf, int __class);
0172 
0173 /* Get section at OFFSET.  */
0174 extern Elf_Scn *gelf_offscn (Elf *__elf, GElf_Off __offset);
0175 
0176 /* Retrieve section header.  */
0177 extern GElf_Shdr *gelf_getshdr (Elf_Scn *__scn, GElf_Shdr *__dst);
0178 
0179 /* Update section header.  */
0180 extern int gelf_update_shdr (Elf_Scn *__scn, GElf_Shdr *__src);
0181 
0182 /* Retrieve program header table entry.  */
0183 extern GElf_Phdr *gelf_getphdr (Elf *__elf, int __ndx, GElf_Phdr *__dst);
0184 
0185 /* Update the program header.  */
0186 extern int gelf_update_phdr (Elf *__elf, int __ndx, GElf_Phdr *__src);
0187 
0188 /* Create new program header with PHNUM entries.  Creates either an
0189    Elf32_Phdr or an Elf64_Phdr depending on whether the given ELF is
0190    ELFCLASS32 or ELFCLASS64.  Returns NULL on error.  */
0191 extern void *gelf_newphdr (Elf *__elf, size_t __phnum);
0192 
0193 /* Get compression header of section if any.  Returns NULL and sets
0194    elf_errno if the section isn't compressed or an error occurred.  */
0195 extern GElf_Chdr *gelf_getchdr (Elf_Scn *__scn, GElf_Chdr *__dst);
0196 
0197 /* Convert data structure from the representation in the file represented
0198    by ELF to their memory representation.  */
0199 extern Elf_Data *gelf_xlatetom (Elf *__elf, Elf_Data *__dest,
0200                 const Elf_Data *__src, unsigned int __encode);
0201 
0202 /* Convert data structure from to the representation in memory
0203    represented by ELF file representation.  */
0204 extern Elf_Data *gelf_xlatetof (Elf *__elf, Elf_Data *__dest,
0205                 const Elf_Data *__src, unsigned int __encode);
0206 
0207 
0208 /* Retrieve REL relocation info at the given index.  */
0209 extern GElf_Rel *gelf_getrel (Elf_Data *__data, int __ndx, GElf_Rel *__dst);
0210 
0211 /* Retrieve RELA relocation info at the given index.  */
0212 extern GElf_Rela *gelf_getrela (Elf_Data *__data, int __ndx, GElf_Rela *__dst);
0213 
0214 /* Update REL relocation information at given index.  */
0215 extern int gelf_update_rel (Elf_Data *__dst, int __ndx, GElf_Rel *__src);
0216 
0217 /* Update RELA relocation information at given index.  */
0218 extern int gelf_update_rela (Elf_Data *__dst, int __ndx, GElf_Rela *__src);
0219 
0220 
0221 /* Retrieve symbol information from the symbol table at the given index.  */
0222 extern GElf_Sym *gelf_getsym (Elf_Data *__data, int __ndx, GElf_Sym *__dst);
0223 
0224 /* Update symbol information in the symbol table at the given index.  */
0225 extern int gelf_update_sym (Elf_Data *__data, int __ndx, GElf_Sym *__src);
0226 
0227 
0228 /* Retrieve symbol information and separate section index from the
0229    symbol table at the given index.  */
0230 extern GElf_Sym *gelf_getsymshndx (Elf_Data *__symdata, Elf_Data *__shndxdata,
0231                    int __ndx, GElf_Sym *__sym,
0232                    Elf32_Word *__xshndx);
0233 
0234 /* Update symbol information and separate section index in the symbol
0235    table at the given index.  */
0236 extern int gelf_update_symshndx (Elf_Data *__symdata, Elf_Data *__shndxdata,
0237                  int __ndx, GElf_Sym *__sym,
0238                  Elf32_Word __xshndx);
0239 
0240 
0241 /* Retrieve additional symbol information from the symbol table at the
0242    given index.  */
0243 extern GElf_Syminfo *gelf_getsyminfo (Elf_Data *__data, int __ndx,
0244                       GElf_Syminfo *__dst);
0245 
0246 /* Update additional symbol information in the symbol table at the
0247    given index.  */
0248 extern int gelf_update_syminfo (Elf_Data *__data, int __ndx,
0249                 GElf_Syminfo *__src);
0250 
0251 
0252 /* Get information from dynamic table at the given index.  */
0253 extern GElf_Dyn *gelf_getdyn (Elf_Data *__data, int __ndx, GElf_Dyn *__dst);
0254 
0255 /* Update information in dynamic table at the given index.  */
0256 extern int gelf_update_dyn (Elf_Data *__dst, int __ndx, GElf_Dyn *__src);
0257 
0258 
0259 /* Get move structure at the given index.  */
0260 extern GElf_Move *gelf_getmove (Elf_Data *__data, int __ndx, GElf_Move *__dst);
0261 
0262 /* Update move structure at the given index.  */
0263 extern int gelf_update_move (Elf_Data *__data, int __ndx,
0264                  GElf_Move *__src);
0265 
0266 
0267 /* Get library from table at the given index.  */
0268 extern GElf_Lib *gelf_getlib (Elf_Data *__data, int __ndx, GElf_Lib *__dst);
0269 
0270 /* Update library in table at the given index.  */
0271 extern int gelf_update_lib (Elf_Data *__data, int __ndx, GElf_Lib *__src);
0272 
0273 
0274 
0275 /* Retrieve symbol version information at given index.  */
0276 extern GElf_Versym *gelf_getversym (Elf_Data *__data, int __ndx,
0277                     GElf_Versym *__dst);
0278 
0279 /* Update symbol version information.  */
0280 extern int gelf_update_versym (Elf_Data *__data, int __ndx,
0281                    GElf_Versym *__src);
0282 
0283 
0284 /* Retrieve required symbol version information at given offset.  */
0285 extern GElf_Verneed *gelf_getverneed (Elf_Data *__data, int __offset,
0286                       GElf_Verneed *__dst);
0287 
0288 /* Update required symbol version information.  */
0289 extern int gelf_update_verneed (Elf_Data *__data, int __offset,
0290                 GElf_Verneed *__src);
0291 
0292 /* Retrieve additional required symbol version information at given offset.  */
0293 extern GElf_Vernaux *gelf_getvernaux (Elf_Data *__data, int __offset,
0294                       GElf_Vernaux *__dst);
0295 
0296 /* Update additional required symbol version information.  */
0297 extern int gelf_update_vernaux (Elf_Data *__data, int __offset,
0298                 GElf_Vernaux *__src);
0299 
0300 
0301 /* Retrieve symbol version definition information at given offset.  */
0302 extern GElf_Verdef *gelf_getverdef (Elf_Data *__data, int __offset,
0303                     GElf_Verdef *__dst);
0304 
0305 /* Update symbol version definition information.  */
0306 extern int gelf_update_verdef (Elf_Data *__data, int __offset,
0307                    GElf_Verdef *__src);
0308 
0309 /* Retrieve additional symbol version definition information at given
0310    offset.  */
0311 extern GElf_Verdaux *gelf_getverdaux (Elf_Data *__data, int __offset,
0312                       GElf_Verdaux *__dst);
0313 
0314 /* Update additional symbol version definition information.  */
0315 extern int gelf_update_verdaux (Elf_Data *__data, int __offset,
0316                 GElf_Verdaux *__src);
0317 
0318 
0319 /* Get auxv entry at the given index.  */
0320 extern GElf_auxv_t *gelf_getauxv (Elf_Data *__data, int __ndx,
0321                   GElf_auxv_t *__dst);
0322 
0323 /* Update auxv entry at the given index.  */
0324 extern int gelf_update_auxv (Elf_Data *__data, int __ndx, GElf_auxv_t *__src);
0325 
0326 
0327 /* Get note header at the given offset into the data, and the offsets of
0328    the note's name and descriptor data.  Returns the offset of the next
0329    note header, or 0 for an invalid offset or corrupt note header.  */
0330 extern size_t gelf_getnote (Elf_Data *__data, size_t __offset,
0331                 GElf_Nhdr *__result,
0332                 size_t *__name_offset, size_t *__desc_offset);
0333 
0334 
0335 /* Compute simple checksum from permanent parts of the ELF file.  */
0336 extern long int gelf_checksum (Elf *__elf);
0337 
0338 #ifdef __cplusplus
0339 }
0340 #endif
0341 
0342 #endif  /* gelf.h */