DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

elf_getphdr(S-osr5)


elf_getphdr: elf32_getphdr, elf32_newphdr -- retrieve class-dependent program header table

Syntax

cc [flag . . . ] file . . . -lelf [library] . . .

#include <libelf.h>

Elf32_Phdr *elf32_getphdr(Elf *elf);

Elf32_Phdr *elf32_newphdr(Elf *elf, size_t count);

Description

elf32_getphdr- get pointer to program header table

elf32_newphdr- allocate new program header table


For a 32-bit class file, elf32_getphdr(S-osr5) returns a pointer to the program execution header table, if one is available for the ELF descriptor elf.

elf32_newphdr(S-osr5) allocates a new table with count entries, regardless of whether one existed previously, and sets the ELF_F_DIRTY bit for the table (see elf_flag(S-osr5)). Specifying a zero count deletes an existing table. Note this behavior differs from that of elf32_newehdr(S-osr5) (see elf32_getehdr(S-osr5)), allowing a program to replace or delete the program header table, and change its size if necessary.

The table is an array of Elf32_Phdr structures, each of which includes the following members.

   	Elf32_Word	p_type;
   	Elf32_Off	p_offset;
   	Elf32_Addr	p_vaddr;
   	Elf32_Addr	p_paddr;
   	Elf32_Word	p_filesz;
   	Elf32_Word	p_memsz;
   	Elf32_Word	p_flags;
   	Elf32_Word	p_align;

The ELF header's e_phnum member tells how many entries the program header table has (see elf32_getehdr( )), A program may inspect this value to determine the size of an existing table; elf32_newphdr( ) automatically sets the member's value to count. If the program is building a new file, it is responsible for creating the file's ELF header before creating the program header table.

Return values

This returns a pointer to a program header table or NULL. Both functions return a null pointer if there is no program header table, the file is not a 32-bit class file, an error occurs, or elf is null. Additionally, elf32_newphdr( ) returns a null pointer if count is zero.

Diagnostics

Error conditions are identified through the routine elf_error(S-osr5).

See also

elf(S-osr5), elf_begin(S-osr5), elf_flag(S-osr5), elf_getehdr(S-osr5)

Standards conformance

elf32_getphdr(S-osr5) and elf32_newphdr(S-osr5) are not part of any currently supported standard; they were developed by UNIX System Laboratories, Inc. and are maintained by The SCO Group.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005