HP-UX Reference (11i v2 07/12) - 3 Library Functions A-M (vol 6)

e
elf_update(3E) elf_update(3E)
NAME
elf_update - update an ELF descriptor
SYNOPSIS
cc [flag... ] file...
-lelf [library] ...
#include <libelf.h>
off_t elf_update(Elf *elf, Elf_Cmd cmd);
DESCRIPTION
elf_update causes the library to examine the information associated with an ELF descriptor, elf, and to
recalculate the structural data needed to generate the file’s image.
cmd may have the following values.
ELF_C_NULL This value tells elf_update to recalculate various values, updating only the ELF
descriptor’s memory structures. Any modified structures are flagged with the
ELF_F_DIRTY bit. A program thus can update the structural information and then
reexamine them without changing the le associated with the ELF descriptor. Because
this does not change the file, the ELF descriptor may allow reading, writing, or both
reading and writing (see elf_begin(3E)).
ELF_C_WRITE If cmd has this value, elf_update duplicates its ELF_C_NULL actions and also
writes any ‘‘dirty’’ information associated with the ELF descriptor to the file. That is,
when a program has used elf_getdata or the elf_flag facilities to supply new
(or update existing) information for an ELF descriptor, those data will be examined,
coordinated, translated if necessary (see elf_xlate(3E)), and written to the file. When
portions of the file are written, any ELF_F_DIRTY bits are reset, indicating those
items no longer need to be written to the file (see elf_flag(3E)). The sections data is
written in the order of their section header entries, and the section header table is writ-
ten to the end of the file.
When the ELF descriptor was created with
elf_begin, it must have allowed writing
the file. That is, the elf_begin command must have been either ELF_C_RDWR or
ELF_C_WRITE .
If elf_update succeeds, it returns the total size of the file image (not the memory image), in bytes. Oth-
erwise an error occurred, and the function returns -1.
When updating the internal structures, elf_update sets some members itself. Members listed below
are the application’s responsibility and retain the values given by the program.
Member Notes
e_ident[EI_DATA] Library controls other
e_ident values
e_type
e_machine
e_version
ELF Header e_entry
e_phoff Only when ELF_F_LAYOUT
asserted
e_shoff Only when ELF_F_LAYOUT
asserted
e_flags
e_shstrndx
Member Notes
p_type The application controls all
p_offset program header entries
p_vaddr
p_paddr
Program Header p_filesz
370 Hewlett-Packard Company 1 HP-UX 11i Version 2: December 2007 Update