DESCRIPTION

GElf is a generic, ELF class-independent API for manipulating ELF object files. GElf provides a single,
common interface for handling 32-bit and 64-bit ELF format object files. GElf is a translation layer between the application and the class-dependent parts
of the ELF library. Thus, the application can use GElf, which in turn, will call the corresponding elf32_ or elf64_ functions
on behalf of the application. The data structures returned are all large enough to hold 32-bit and 64-bit data.

GElf provides a simple, class-independent layer of indirection over the class-dependent ELF32 and ELF64API's. GElf is stateless, and may be used along side the ELF32 and ELF64API's.

GElf always returns a copy of the underlying ELF32 or ELF64 structure, and therefore the programming practice of using the address of an ELF header as the base offset for the ELF's mapping into memory should be avoided. Also, data accessed by type-casting the Elf_Data buffer to a class-dependent
type and treating it like an array, for example, a symbol table, will not work under GElf, and the gelf_get functions must be used instead. See the EXAMPLE section.

Programs that create or modify ELF files using libelf(3LIB) need to perform an extra step when using GElf. Modifications to GElf values must be explicitly flushed to the underlying ELF32
or ELF64 structures by way of the gelf_update_ interfaces. Use of elf_update or elf_flagelf and the like remains the same.

The sizes of versioning structures remain the same between ELF32 and ELF64. The GElfAPI only defines types for versioning,
rather than a functional API. The processing of versioning information will stay the same in the GElf environment as it was in the class-dependent ELF
environment.

List of Functions

gelf_checksum()
An analog to elf32_checksum(3ELF) and elf64_checksum(3ELF).

gelf_fsize()
An analog to elf32_fsize(3ELF) and elf64_fsize(3ELF).

gelf_getcap()
Retrieves the Elf32_Cap or Elf64_Cap information from the capability table at the given index. dst points to the location where the GElf_Cap capability entry is stored.

gelf_getclass()
Returns one of the constants ELFCLASS32, ELFCLASS64
or ELFCLASSNONE.

gelf_getdyn()
Retrieves the Elf32_Dyn or Elf64_Dyn information from the dynamic table at the given index. dst points to the location where the GElf_Dyn dynamic entry is stored.

gelf_getehdr()
An analog to elf32_getehdr(3ELF) and elf64_getehdr(3ELF). dst points to
the location where the GElf_Ehdr header is stored.

gelf_getmove()
Retrieves the Elf32_Move or Elf64_Move information from the move table at the given index. dst points to the location where the GElf_Move move entry is stored.

gelf_getphdr()
An analog toelf32_getphdr(3ELF) and elf64_getphdr(3ELF). dst points to
the location where the GElf_Phdr program header is stored.

gelf_getrel()
Retrieves the Elf32_Rel or Elf64_Rel information from the relocation table at the given index. dst points to the location where the GElf_Rel relocation entry is stored.

gelf_getrela()
Retrieves the Elf32_Rela or Elf64_Rela information from the relocation table at the given
index. dst points to the location where the GElf_Rela relocation entry is stored.

gelf_getshdr()
An analog to elf32_getshdr(3ELF) and elf64_getshdr(3ELF). dst points to
the location where the GElf_Shdr section header is stored.

gelf_getsym()
Retrieves the Elf32_Sym or Elf64_Sym information from the symbol table at the given index. dst points to the location where the GElf_Sym symbol entry is stored.

gelf_getsyminfo()
Retrieves the Elf32_Syminfo or Elf64_Syminfo information from the relocation
table at the given index. dst points to the location where the GElf_Syminfo symbol information entry is stored.

gelf_getsymshndx()
Provides an extension to gelf_getsym() that retrieves the Elf32_Sym or Elf64_Sym information, and the section index from the symbol table at the given index ndx.

The symbols section index is typically recorded in the st_shndx field of the symbols structure. However, a file that requires ELF Extended Sections may
record an st_shndx of SHN_XINDEX indicating that the section index must be obtained from an associated SHT_SYMTAB_SHNDX section entry. If xshndx and shndxdata are non-null, the value recorded at index ndx of the SHT_SYMTAB_SHNDX table pointed to by shndxdata is returned in xshndx. See USAGE.

gelf_newehdr()
An analog to elf32_newehdr(3ELF) and elf64_newehdr(3ELF).

gelf_newphdr()
An analog to elf32_newphdr(3ELF) and elf64_newphdr(3ELF).

gelf_update_cap()
Copies the GElf_Cap information back into the underlying Elf32_Cap or Elf64_Cap structure at the given index.

gelf_update_dyn()
Copies the GElf_Dyn information back into the underlying Elf32_Dyn or Elf64_Dyn structure at the given index.

gelf_update_ehdr()
Copies the contents of the GElf_EhdrELF header to the underlying Elf32_Ehdr or Elf64_Ehdr structure.

gelf_update_move()
Copies the GElf_Move information back into the underlying Elf32_Move or Elf64_Move structure at the given index.

gelf_update_phdr()
Copies of the contents of GElf_Phdr program header to underlying the Elf32_Phdr
or Elf64_Phdr structure.

gelf_update_rel()
Copies the GElf_Rel information back into the underlying Elf32_Rel or Elf64_Rel structure at the given index.

gelf_update_rela()
Copies the GElf_Rela information back into the underlying Elf32_Rela or Elf64_Rela structure at the given index.

gelf_update_shdr()
Copies of the contents of GElf_Shdr section header to underlying the Elf32_Shdr
or Elf64_Shdr structure.

gelf_update_sym()
Copies the GElf_Sym information back into the underlying Elf32_Sym or Elf64_Sym structure at the given index.

gelf_update_syminfo()
Copies the GElf_Syminfo information back into the underlying Elf32_Syminfo or Elf64_Syminfo structure at the given index.

gelf_update_symshndx()
Provides an extension to gelf_update_sym() that copies the GElf_Sym information
back into the Elf32_Sym or Elf64_Sym structure at the given index ndx, and copies the extended xshndx section
index into the Elf32_Word at the given index ndx in the buffer described by shndxdata. See USAGE.

gelf_xlatetof()
An analog to elf32_xlatetof(3ELF) and elf64_xlatetof(3ELF)

gelf_xlatetom()
An analog to elf32_xlatetom(3ELF) and elf64_xlatetom(3ELF)

RETURN VALUES

Upon failure, all GElf functions return 0 and set elf_errno. See elf_errno(3ELF)