DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

elf_cntl(S)


elf_cntl -- control a file descriptor

Syntax

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

#include <libelf.h>

int elf_cntl(Elf *elf, Elf_Cmd cmd);

Description

elf_cntl(S) instructs the library to modify its behavior with respect to an ELF descriptor, elf.

As elf_begin(S) describes, an ELF descriptor can have multiple activations. Also, multiple ELF descriptors may share a single file descriptor. Generally, elf_cntl( ) commands apply to all activations of elf. Moreover, if the ELF descriptor is associated with an archive file, descriptors for members within the archive are also affected as described below. Unless stated otherwise, operations on archive members do not affect the descriptor for the containing archive.

The argument cmd tells what actions to take and may have the following values.


ELF_C_FDDONE
This value tells the library not to use the file descriptor associated with elf. A program should use this command when it has requested all the information it cares to use and wishes to avoid the overhead of reading the rest of the file. The memory for all completed operations remains valid, but later file operations, such as the initial elf_getdata(S) for a section, will fail if the data is not in memory already.

ELF_C_FDREAD
This command is similar to ELF_C_FDDONE, except it forces the library to read the rest of the file. A program should use this command when it must close the file descriptor but has not yet read everything it needs from the file. After elf_cntl( ) completes the ELF_C_FDREAD command, future operations, such as elf_getdata( ), will use the memory version of the file without needing to use the file descriptor.

Return values

If elf_cntl( ) succeeds, it returns zero. Otherwise elf was null or an error occurred, and the function returns -1.

Diagnostics

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

Warning

If the program wishes to use the ``raw'' operations (see elf_rawdata(S) under elf_getdata( ) and elf_rawfile(S)), it must disable the file descriptor with ELF_C_FDDONE or ELF_C_FDREAD, and must execute the raw operations explicitly beforehand. Otherwise, the raw file operations will fail. Calling elf_rawfile( ) makes the entire image available, thus supporting subsequent calls to elf_rawdata(S).

See also

elf(S), elf_begin(S), elf_getdata(S), elf_rawdata(S), elf_rawfile(S)

Standards conformance

elf_cntl(S) is not part of any currently supported standard; it was developed by UNIX System Laboratories, Inc. and is maintained by The SCO Group.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003