1elf_version(3ELF) ELF Library Functions elf_version(3ELF)
2
3
4
6 elf_version - coordinate ELF library and application versions
7
9 cc [ flag ... ] file ... -lelf [ library ... ]
10 #include <libelf.h>
11
12 unsigned elf_version(unsigned ver);
13
14
16 As elf(3ELF) explains, the program, the library, and an object file
17 have independent notions of the latest ELF version. elf_version() lets
18 a program query the ELF library's internal version. It further lets the
19 program specify what memory types it uses by giving its own working
20 version, ver, to the library. Every program that uses the ELF library
21 must coordinate versions as described below.
22
23
24 The header <libelf.h> supplies the version to the program with the
25 macro EV_CURRENT. If the library's internal version (the highest ver‐
26 sion known to the library) is lower than that known by the program
27 itself, the library may lack semantic knowledge assumed by the program.
28 Accordingly, elf_version() will not accept a working version unknown to
29 the library.
30
31
32 Passing ver equal to EV_NONE causes elf_version() to return the
33 library's internal version, without altering the working version. If
34 ver is a version known to the library, elf_version() returns the previ‐
35 ous (or initial) working version number. Otherwise, the working version
36 remains unchanged and elf_version() returns EV_NONE.
37
39 Example 1 A sample display of using the elf_version() function.
40
41
42 The following excerpt from an application program protects itself from
43 using an older library:
44
45
46 if (elf_version(EV_CURRENT) == EV_NONE) {
47 /* library out of date */
48 /* recover from error */
49 }
50
51
53 See attributes(5) for descriptions of the following attributes:
54
55
56
57
58 ┌─────────────────────────────┬─────────────────────────────┐
59 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
60 ├─────────────────────────────┼─────────────────────────────┤
61 │Interface Stability │Stable │
62 ├─────────────────────────────┼─────────────────────────────┤
63 │MT-Level │MT-Safe │
64 └─────────────────────────────┴─────────────────────────────┘
65
67 elf(3ELF), elf32_xlatetof(3ELF), elf_begin(3ELF), libelf(3LIB),
68 attributes(5)
69
71 The working version should be the same for all operations on a particu‐
72 lar ELF descriptor. Changing the version between operations on a
73 descriptor will probably not give the expected results.
74
75
76
77SunOS 5.11 11 Jul 2001 elf_version(3ELF)