elf_getident(3E) elf_getident(3E)
NAME
elfgetident - retrieve file identification data
SYNOPSIS
cc [flag ...] file ... -lelf [library ...]
#include <libelf.h>
char *elfgetident(Elf *elf, sizet *ptr);
DESCRIPTION
As elf(3E) explains, ELF provides a framework for various classes of
files, where basic objects may have 32 bits, 64 bits, etc. To accommo-
date these differences, without forcing the larger sizes on smaller
machines, the initial bytes in an ELF file hold identification infor-
mation common to all file classes. Every ELF header's eident has
EINIDENT bytes with the following interpretation.
______________________________________________________________________
| eident Index | Value | Purpose |
|_______________|_______________|_____________________________________|
| EIMAG0 | ELFMAG0 | File identification |
| EIMAG1 | ELFMAG1 | |
| EIMAG2 | ELFMAG2 | |
| EIMAG3 | ELFMAG3 | |
|_______________|_______________|_____________________________________|
| EICLASS | ELFCLASSNONE | File class |
| | ELFCLASS32 | |
| | ELFClASS64 | |
|_______________|_______________|_____________________________________|
| EIDATA | ELFDATANONE | Data encoding |
| | ELFDATA2LSB | |
| | ELFDATA2MSB | |
|_______________|_______________|_____________________________________|
| EIVERSION | EVCURRENT | File version |
|_______________|_______________|_____________________________________|
| 7-15 | 0 | Unused, set to zero |
|_______________|_______________|_____________________________________|
Other kinds of files [see elfkind(3E)] also may have identification
data, though they would not conform to eident.
elfgetident() returns a pointer to the file's "initial bytes". If the
library recognizes the file, a conversion from the file image to the
memory image may occur. In any case, the identification bytes are
guaranteed not to have been modified, though the size of the unmodi-
fied area depends on the file type. If ptr is non-null, the library
stores the number of identification bytes in the location to which ptr
points. If no data is present, elf is null, or an error occurs, the
return value is a null pointer, with zero optionally stored through
ptr.
Page 1 Reliant UNIX 5.44 Printed 11/98
elf_getident(3E) elf_getident(3E)
SEE ALSO
elf(3E), elfbegin(3E), elfgetehdr(3E), elfkind(3E),
elfrawfile(3E).
Page 2 Reliant UNIX 5.44 Printed 11/98