elf_getehdr(3E) elf_getehdr(3E)
NAME
elfgetehdr - retrieve class-dependent object file header
SYNOPSIS
cc [flag ...] file ... -lelf [library ...]
#include <libelf.h>
Elf32Ehdr *elf32getehdr(Elf *elf);
Elf32Ehdr *elf32newehdr(Elf *elf);
DESCRIPTION
For a 32-bit class file, elf32getehdr() returns a pointer to an ELF
header, if one is available for the ELF descriptor elf. If no header
exists for the descriptor, elf32newehdr() allocates a "clean" one,
but it otherwise behaves the same as elf32getehdr(). It does not
allocate a new header if one exists already. If no header exists (for
elfgetehdr), one cannot be created (for elfnewehdr), a system error
occurs, the file is not a 32-bit class file, or elf is null, both
functions return a null pointer.
The header includes the following members.
unsigned char eident[EINIDENT];
Elf32Half etype;
Elf32Half emachine;
Elf32Word eversion;
Elf32Addr eentry;
Elf32Off ephoff;
Elf32Off eshoff;
Elf32Word eflags;
Elf32Half eehsize;
Elf32Half ephentsize;
Elf32Half ephnum;
Elf32Half eshentsize;
Elf32Half eshnum;
Elf32Half eshstrndx;
elf32newehdr() automatically sets the ELFFDIRTY bit [see
elfflag(3E)]. A program may use elfgetident() to inspect the iden-
tification bytes from a file.
SEE ALSO
elf(3E), elfbegin(3E), elfflag(3E), elfgetident(3E).
Page 1 Reliant UNIX 5.44 Printed 11/98