1elf_cntl(3ELF) ELF Library Functions elf_cntl(3ELF)
2
3
4
6 elf_cntl - control an elf file descriptor
7
9 cc [ flag ... ] file ... -lelf [ library ... ]
10 #include <libelf.h>
11
12 int elf_cntl(Elf *elf, Elf_Cmd cmd);
13
14
16 elf_cntl() instructs the library to modify its behavior with respect to
17 an ELF descriptor, elf. As elf_begin(3ELF) describes, an ELF descriptor
18 can have multiple activations, and multiple ELF descriptors may share a
19 single file descriptor. Generally, elf_cntl() commands apply to all
20 activations of elf. Moreover, if the ELF descriptor is associated with
21 an archive file, descriptors for members within the archive will also
22 be affected as described below. Unless stated otherwise, operations on
23 archive members do not affect the descriptor for the containing ar‐
24 chive.
25
26
27 The cmd argument tells what actions to take and may have the following
28 values:
29
30 ELF_C_FDDONE This value tells the library not to use the file
31 descriptor associated with elf. A program should use
32 this command when it has requested all the information
33 it cares to use and wishes to avoid the overhead of
34 reading the rest of the file. The memory for all com‐
35 pleted operations remains valid, but later file opera‐
36 tions, such as the initial elf_getdata() for a section,
37 will fail if the data are not in memory already.
38
39
40 ELF_C_FDREAD This command is similar to ELF_C_FDDONE, except it
41 forces the library to read the rest of the file. A pro‐
42 gram should use this command when it must close the
43 file descriptor but has not yet read everything it
44 needs from the file. After elf_cntl() completes the
45 ELF_C_FDREAD command, future operations, such as
46 elf_getdata(), will use the memory version of the file
47 without needing to use the file descriptor.
48
49
50
51 If elf_cntl() succeeds, it returns 0. Otherwise elf was NULL or an
52 error occurred, and the function returns −1.
53
55 See attributes(5) for descriptions of the following attributes:
56
57
58
59
60 ┌─────────────────────────────┬─────────────────────────────┐
61 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
62 ├─────────────────────────────┼─────────────────────────────┤
63 │Interface Stability │Stable │
64 ├─────────────────────────────┼─────────────────────────────┤
65 │MT-Level │MT-Safe │
66 └─────────────────────────────┴─────────────────────────────┘
67
69 elf(3ELF), elf_begin(3ELF), elf_getdata(3ELF), elf_rawfile(3ELF),
70 libelf(3LIB), attributes(5)
71
73 If the program wishes to use the ``raw'' operations (see elf_rawdata(),
74 which elf_getdata(3ELF) describes, and elf_rawfile(3ELF)) after dis‐
75 abling the file descriptor with ELF_C_FDDONE or ELF_C_FDREAD, it must
76 execute the raw operations explicitly beforehand. Otherwise, the raw
77 file operations will fail. Calling elf_rawfile() makes the entire image
78 available, thus supporting subsequent elf_rawdata() calls.
79
80
81
82SunOS 5.11 11 Jul 2001 elf_cntl(3ELF)