Back to home page

EIC code displayed by LXR

 
 

    


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

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 /* Relative relocation entry (in section of type SHT_RELR).  */
0086 typedef Elf64_Relr GElf_Relr;
0087 
0088 /* Program segment header.  */
0089 typedef Elf64_Phdr GElf_Phdr;
0090 
0091 /* Header of a compressed section.  */
0092 typedef Elf64_Chdr GElf_Chdr;
0093 
0094 /* Dynamic section entry.  */
0095 typedef Elf64_Dyn GElf_Dyn;
0096 
0097 
0098 /* Version definition sections.  */
0099 typedef Elf64_Verdef GElf_Verdef;
0100 
0101 /* Auxiliary version information.  */
0102 typedef Elf64_Verdaux GElf_Verdaux;
0103 
0104 /* Version dependency section.  */
0105 typedef Elf64_Verneed GElf_Verneed;
0106 
0107 /* Auxiliary needed version information.  */
0108 typedef Elf64_Vernaux GElf_Vernaux;
0109 
0110 
0111 /* Type for version symbol information.  */
0112 typedef Elf64_Versym GElf_Versym;
0113 
0114 
0115 /* Auxiliary vector.  */
0116 typedef Elf64_auxv_t GElf_auxv_t;
0117 
0118 
0119 /* Note section contents.  */
0120 typedef Elf64_Nhdr GElf_Nhdr;
0121 
0122 
0123 /* Move structure.  */
0124 typedef Elf64_Move GElf_Move;
0125 
0126 
0127 /* Library list structure.  */
0128 typedef Elf64_Lib GElf_Lib;
0129 
0130 
0131 /* How to extract and insert information held in the st_info field.  */
0132 
0133 #define GELF_ST_BIND(val)       ELF64_ST_BIND (val)
0134 #define GELF_ST_TYPE(val)       ELF64_ST_TYPE (val)
0135 #define GELF_ST_INFO(bind, type)    ELF64_ST_INFO (bind, type)
0136 
0137 /* How to extract information held in the st_other field.  */
0138 
0139 #define GELF_ST_VISIBILITY(val)     ELF64_ST_VISIBILITY (val)
0140 
0141 
0142 /* How to extract and insert information held in the r_info field.  */
0143 
0144 #define GELF_R_SYM(info)        ELF64_R_SYM (info)
0145 #define GELF_R_TYPE(info)       ELF64_R_TYPE (info)
0146 #define GELF_R_INFO(sym, type)      ELF64_R_INFO (sym, type)
0147 
0148 
0149 /* How to extract and insert information held in the m_info field.  */
0150 #define GELF_M_SYM(info)        ELF64_M_SYM (info)
0151 #define GELF_M_SIZE(info)       ELF64_M_SIZE (info)
0152 #define GELF_M_INFO(sym, size)      ELF64_M_INFO (sym, size)
0153 
0154 
0155 /* Get class of the file associated with ELF.  */
0156 extern int gelf_getclass (Elf *__elf);
0157 
0158 
0159 /* Return size of array of COUNT elements of the type denoted by TYPE
0160    in the external representation.  The binary class is taken from ELF.
0161    The result is based on version VERSION of the ELF standard.  */
0162 extern size_t gelf_fsize (Elf *__elf, Elf_Type __type, size_t __count,
0163               unsigned int __version);
0164 
0165 /* Retrieve object file header.  */
0166 extern GElf_Ehdr *gelf_getehdr (Elf *__elf, GElf_Ehdr *__dest);
0167 
0168 /* Update the ELF header.  */
0169 extern int gelf_update_ehdr (Elf *__elf, GElf_Ehdr *__src);
0170 
0171 /* Create new ELF header if none exists.  Creates an Elf32_Ehdr if CLASS
0172    is ELFCLASS32 or an Elf64_Ehdr if CLASS is ELFCLASS64.  Returns NULL
0173    on error.  */
0174 extern void *gelf_newehdr (Elf *__elf, int __class);
0175 
0176 /* Get section at OFFSET.  */
0177 extern Elf_Scn *gelf_offscn (Elf *__elf, GElf_Off __offset);
0178 
0179 /* Retrieve section header.  */
0180 extern GElf_Shdr *gelf_getshdr (Elf_Scn *__scn, GElf_Shdr *__dst);
0181 
0182 /* Update section header.  */
0183 extern int gelf_update_shdr (Elf_Scn *__scn, GElf_Shdr *__src);
0184 
0185 /* Retrieve program header table entry.  */
0186 extern GElf_Phdr *gelf_getphdr (Elf *__elf, int __ndx, GElf_Phdr *__dst);
0187 
0188 /* Update the program header.  */
0189 extern int gelf_update_phdr (Elf *__elf, int __ndx, GElf_Phdr *__src);
0190 
0191 /* Create new program header with PHNUM entries.  Creates either an
0192    Elf32_Phdr or an Elf64_Phdr depending on whether the given ELF is
0193    ELFCLASS32 or ELFCLASS64.  Returns NULL on error.  */
0194 extern void *gelf_newphdr (Elf *__elf, size_t __phnum);
0195 
0196 /* Get compression header of section if any.  Returns NULL and sets
0197    elf_errno if the section isn't compressed or an error occurred.  */
0198 extern GElf_Chdr *gelf_getchdr (Elf_Scn *__scn, GElf_Chdr *__dst);
0199 
0200 /* Convert data structure from the representation in the file represented
0201    by ELF to their memory representation.  */
0202 extern Elf_Data *gelf_xlatetom (Elf *__elf, Elf_Data *__dest,
0203                 const Elf_Data *__src, unsigned int __encode);
0204 
0205 /* Convert data structure from to the representation in memory
0206    represented by ELF file representation.  */
0207 extern Elf_Data *gelf_xlatetof (Elf *__elf, Elf_Data *__dest,
0208                 const Elf_Data *__src, unsigned int __encode);
0209 
0210 
0211 /* Retrieve REL relocation info at the given index.  */
0212 extern GElf_Rel *gelf_getrel (Elf_Data *__data, int __ndx, GElf_Rel *__dst);
0213 
0214 /* Retrieve RELA relocation info at the given index.  */
0215 extern GElf_Rela *gelf_getrela (Elf_Data *__data, int __ndx, GElf_Rela *__dst);
0216 
0217 /* Update REL relocation information at given index.  */
0218 extern int gelf_update_rel (Elf_Data *__dst, int __ndx, GElf_Rel *__src);
0219 
0220 /* Update RELA relocation information at given index.  */
0221 extern int gelf_update_rela (Elf_Data *__dst, int __ndx, GElf_Rela *__src);
0222 
0223 
0224 /* Retrieve symbol information from the symbol table at the given index.  */
0225 extern GElf_Sym *gelf_getsym (Elf_Data *__data, int __ndx, GElf_Sym *__dst);
0226 
0227 /* Update symbol information in the symbol table at the given index.  */
0228 extern int gelf_update_sym (Elf_Data *__data, int __ndx, GElf_Sym *__src);
0229 
0230 
0231 /* Retrieve symbol information and separate section index from the
0232    symbol table at the given index.  */
0233 extern GElf_Sym *gelf_getsymshndx (Elf_Data *__symdata, Elf_Data *__shndxdata,
0234                    int __ndx, GElf_Sym *__sym,
0235                    Elf32_Word *__xshndx);
0236 
0237 /* Update symbol information and separate section index in the symbol
0238    table at the given index.  */
0239 extern int gelf_update_symshndx (Elf_Data *__symdata, Elf_Data *__shndxdata,
0240                  int __ndx, GElf_Sym *__sym,
0241                  Elf32_Word __xshndx);
0242 
0243 
0244 /* Retrieve additional symbol information from the symbol table at the
0245    given index.  */
0246 extern GElf_Syminfo *gelf_getsyminfo (Elf_Data *__data, int __ndx,
0247                       GElf_Syminfo *__dst);
0248 
0249 /* Update additional symbol information in the symbol table at the
0250    given index.  */
0251 extern int gelf_update_syminfo (Elf_Data *__data, int __ndx,
0252                 GElf_Syminfo *__src);
0253 
0254 
0255 /* Get information from dynamic table at the given index.  */
0256 extern GElf_Dyn *gelf_getdyn (Elf_Data *__data, int __ndx, GElf_Dyn *__dst);
0257 
0258 /* Update information in dynamic table at the given index.  */
0259 extern int gelf_update_dyn (Elf_Data *__dst, int __ndx, GElf_Dyn *__src);
0260 
0261 
0262 /* Get move structure at the given index.  */
0263 extern GElf_Move *gelf_getmove (Elf_Data *__data, int __ndx, GElf_Move *__dst);
0264 
0265 /* Update move structure at the given index.  */
0266 extern int gelf_update_move (Elf_Data *__data, int __ndx,
0267                  GElf_Move *__src);
0268 
0269 
0270 /* Get library from table at the given index.  */
0271 extern GElf_Lib *gelf_getlib (Elf_Data *__data, int __ndx, GElf_Lib *__dst);
0272 
0273 /* Update library in table at the given index.  */
0274 extern int gelf_update_lib (Elf_Data *__data, int __ndx, GElf_Lib *__src);
0275 
0276 
0277 
0278 /* Retrieve symbol version information at given index.  */
0279 extern GElf_Versym *gelf_getversym (Elf_Data *__data, int __ndx,
0280                     GElf_Versym *__dst);
0281 
0282 /* Update symbol version information.  */
0283 extern int gelf_update_versym (Elf_Data *__data, int __ndx,
0284                    GElf_Versym *__src);
0285 
0286 
0287 /* Retrieve required symbol version information at given offset.  */
0288 extern GElf_Verneed *gelf_getverneed (Elf_Data *__data, int __offset,
0289                       GElf_Verneed *__dst);
0290 
0291 /* Update required symbol version information.  */
0292 extern int gelf_update_verneed (Elf_Data *__data, int __offset,
0293                 GElf_Verneed *__src);
0294 
0295 /* Retrieve additional required symbol version information at given offset.  */
0296 extern GElf_Vernaux *gelf_getvernaux (Elf_Data *__data, int __offset,
0297                       GElf_Vernaux *__dst);
0298 
0299 /* Update additional required symbol version information.  */
0300 extern int gelf_update_vernaux (Elf_Data *__data, int __offset,
0301                 GElf_Vernaux *__src);
0302 
0303 
0304 /* Retrieve symbol version definition information at given offset.  */
0305 extern GElf_Verdef *gelf_getverdef (Elf_Data *__data, int __offset,
0306                     GElf_Verdef *__dst);
0307 
0308 /* Update symbol version definition information.  */
0309 extern int gelf_update_verdef (Elf_Data *__data, int __offset,
0310                    GElf_Verdef *__src);
0311 
0312 /* Retrieve additional symbol version definition information at given
0313    offset.  */
0314 extern GElf_Verdaux *gelf_getverdaux (Elf_Data *__data, int __offset,
0315                       GElf_Verdaux *__dst);
0316 
0317 /* Update additional symbol version definition information.  */
0318 extern int gelf_update_verdaux (Elf_Data *__data, int __offset,
0319                 GElf_Verdaux *__src);
0320 
0321 
0322 /* Get auxv entry at the given index.  */
0323 extern GElf_auxv_t *gelf_getauxv (Elf_Data *__data, int __ndx,
0324                   GElf_auxv_t *__dst);
0325 
0326 /* Update auxv entry at the given index.  */
0327 extern int gelf_update_auxv (Elf_Data *__data, int __ndx, GElf_auxv_t *__src);
0328 
0329 
0330 /* Get note header at the given offset into the data, and the offsets of
0331    the note's name and descriptor data.  Returns the offset of the next
0332    note header, or 0 for an invalid offset or corrupt note header.  */
0333 extern size_t gelf_getnote (Elf_Data *__data, size_t __offset,
0334                 GElf_Nhdr *__result,
0335                 size_t *__name_offset, size_t *__desc_offset);
0336 
0337 
0338 /* Compute simple checksum from permanent parts of the ELF file.  */
0339 extern long int gelf_checksum (Elf *__elf);
0340 
0341 #ifdef __cplusplus
0342 }
0343 #endif
0344 
0345 #endif  /* gelf.h */