ELF Library Functions elfcntl(3ELF)
NAME
elfcntl - control an elf file descriptor
SYNOPSIS
cc [ flag ... ] file ... -lelf [ library ... ]
#include
int elfcntl(Elf *elf, ElfCmd cmd);
DESCRIPTION
elfcntl() instructs the library to modify its behavior with
respect to an ELF descriptor, elf. As elfbegin(3ELF)
describes, an ELF descriptor can have multiple activations,
and multiple ELF descriptors may share a single file
descriptor. Generally, elfcntl() commands apply to all
activations of elf. Moreover, if the ELF descriptor is asso-
ciated with an archive file, descriptors for members within
the archive will also be affected as described below. Unless
stated otherwise, operations on archive members do not
affect the descriptor for the containing archive.
The cmd argument tells what actions to take and may have the
following values:
ELFCFDONE This value tells the library not to use the
file descriptor associated with elf. A pro-
gram 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
elfgetdata() for a section, will fail if
the data are not in memory already.
ELFCFDREAD This command is similar to ELFCFDONE,
except it forces the library to read the
rest of the file. A program should use this
command when it must close the file descrip-
tor but has not yet read everything it needs
from the file. After elfcntl() completes
the ELFCFDREAD command, future operations,
such as elfgetdata(), will use the memory
version of the file without needing to use
the file descriptor.
SunOS 5.11 Last change: 11 Jul 2001 1
ELF Library Functions elfcntl(3ELF)
If elfcntl() succeeds, it returns 0. Otherwise elf was NUL
or an error occurred, and the function returns -1.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Stable
MT-Level MT-Safe
SEE ALSO
elf(3ELF), elfbegin(3ELF), elfgetdata(3ELF),
elfrawfile(3ELF), libelf(3LIB), attributes(5)
NOTES
If the program wishes to use the ``raw'' operations (see
elfrawdata(), which elfgetdata(3ELF) describes, and
elfrawfile(3ELF)) after disabling the file descriptor with
ELFCFDONE or ELFCFDREAD, it must execute the raw opera-
tions explicitly beforehand. Otherwise, the raw file opera-
tions will fail. Calling elfrawfile() makes the entire
image available, thus supporting subsequent elfrawdata()
calls.
SunOS 5.11 Last change: 11 Jul 2001 2
|