Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

elf(3E)

elf32_getehdr(3E)

elf_begin(3E)

elf_flagdata(3E)

elf32_getphdr(3E)

NAME

elf32_getphdr, elf32_newphdr − retrieve class-dependent program header table

SYNOPSIS

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

#include <libelf.h>

Elf32_Phdr ∗elf32_getphdr(Elf ∗elf);

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

MT-LEVEL

Unsafe

DESCRIPTION

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

elf32_newphdr() 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_flagdata(3E)).  Specifying a zero count deletes an existing table.  Note this behavior differs from that of elf32_newehdr() (see elf32_getehdr(3E)), allowing a program to replace or delete the program header table, changing its size if necessary. 

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

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

Elf32_Wordp_type;
Elf32_Offp_offset;
Elf32_Addrp_vaddr;
Elf32_Addrp_paddr;
Elf32_Wordp_filesz;
Elf32_Wordp_memsz;
Elf32_Wordp_flags;
Elf32_Wordp_align;

The ELF header’s e_phnum member tells how many entries the program header table has (see elf32_getehdr(3E)).  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. 

SEE ALSO

elf(3E), elf32_getehdr(3E), elf_begin(3E), elf_flagdata(3E)

Sun Microsystems  —  Last change: 22 Jan 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026