Visit Our UNIX and Linux User Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #512
Difficulty: Medium
PHP requires that all variables begin with a dollar sign, for example $flag.
True or False?
Linux & Unix Commands - Search Man Pages

elf_getident(3elf) [opensolaris man page]

elf_getident(3ELF)					       ELF Library Functions						elf_getident(3ELF)

NAME
elf_getident, elf_getphnum, elf_getshnum, elf_getshstrndx - retrieve ELF header data SYNOPSIS
cc [ flag ... ] file ... -lelf [ library ... ] #include <libelf.h> char * elf_getident(Elf *elf, size_t *dst); int elf_getphnum(Elf *elf, size_t *dst); int elf_getshnum(Elf *elf, size_t *dst); int elf_getshstrndx(Elf *elf, size_t *dst); DESCRIPTION
As elf(3ELF) explains, ELF provides a framework for various classes of files, where basic objects might have 32 or 64 bits. To accommodate these differences, without forcing the larger sizes on smaller machines, the initial bytes in an ELF file hold identification information common to all file classes. The e_ident of every ELF header has EI_NIDENT bytes with interpretations described in the following table. e_ident Index Value Purpose EI_MAG0 ELFMAG0 File identification EI_MAG1 ELFMAG1 EI_MAG2 ELFMAG2 EI_MAG3 ELFMAG3 EI_CLASS ELFCLASSNONE File class ELFCLASS32 ELFCLASS64 EI_DATA ELFDATANONE Data encoding ELFDATA2LSB ELFDATA2MSB EI_VERSION EV_CURRENT File version 7-15 0 Unused, set to zero Other kinds of files might have identification data, though they would not conform to e_ident. See elf_kind(3ELF) for information on other kinds of files. The elf_getident() function returns a pointer to the initial bytes of the file. If the library recognizes the file, a conversion from the file image to the memory image can occur. The identification bytes are guaranteed to be unmodified, though the size of the unmodified area depends on the file type. If the dst argument is non-null, the library stores the number of identification bytes in the location to which dst points. If no data are present, elf is NULL, or an error occurs, the return value is a null pointer, with 0 stored through dst, if dst is non-null. The elf_getphnum() function obtains the number of program headers recorded in the ELF file. The number of sections in a file is typically recorded in the e_phnum field of the ELF header. A file that requires the ELF extended program header records the value PN_XNUM in the e_phnum field and records the number of sections in the sh_info field of section header 0. See USAGE. The dst argument points to the loca- tion where the number of sections is stored. If elf is NULL or an error occurs, elf_getphnum() returns 0. The elf_getshnum() function obtains the number of sections recorded in the ELF file. The number of sections in a file is typically recorded in the e_shnum field of the ELF header. A file that requires ELF extended section records the value 0 in the e_shnum field and records the number of sections in the sh_size field of section header 0. See USAGE. The dst argument points to the location where the number of sec- tions is stored. If a call to elf_newscn(3ELF) that uses the same elf descriptor is performed, the value obtained by elf_getshnum() is valid only after a successful call to elf_update(3ELF). If elf is NULL or an error occurs, elf_getshnum() returns 0. The elf_getshstrndx() function obtains the section index of the string table associated with the section headers in the ELF file. The sec- tion header string table index is typically recorded in the e_shstrndx field of the ELF header. A file that requires ELF extended section records the value SHN_XINDEX in the e_shstrndx field and records the string table index in the sh_link field of section header 0. See USAGE. The dst argument points to the location where the section header string table index is stored. If elf is NULL or an error occurs, elf_getshstrndx() returns 0. USAGE
ELF extended sections allow an ELF file to contain more than 0xff00 (SHN_LORESERVE) section. ELF extended program headers allow an ELF file to contain 0xffff (PN_XNUM) or more program headers. See the Linker and Libraries Guide for more information. RETURN VALUES
Upon successful completion, elf_getident(), elf_getphnum(), elf_getshnum(), and elf_getshstrndx() functions return 1. Otherwise, they return 0. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Stable | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
elf(3ELF), elf32_getehdr(3ELF), elf_begin(3ELF), elf_kind(3ELF), elf_newscn(3ELF), elf_rawfile(3ELF), elf_update(3ELF), libelf(3LIB), attributes(5) Linker and Libraries Guide SunOS 5.11 15 Nov 2005 elf_getident(3ELF)

Featured Tech Videos