cc [ flag ... ] file ... -lelf [ library ... ]
#include <libelf.h>
unsigned elf_version(unsigned ver);
Unsafe
The header <libelf.h> supplies the version to the program with the macro EV_CURRENT . If the library’s internal version (the highest version known to the library) is lower than that known by the program itself, the library may lack semantic knowledge assumed by the program. Accordingly, elf_version() will not accept a working version unknown to the library.
Passing ver equal to EV_NONE causes elf_version() to return the library’s internal version, without altering the working version. If ver is a version known to the library, elf_version() returns the previous (or initial) working version number. Otherwise, the working version remains unchanged and elf_version() returns EV_NONE .
if (elf_version(EV_CURRENT) == EV_NONE) { /* library out of date */ /* recover from error */ }
The working version should be the same for all operations on a particular elf descriptor. Changing the version between operations on a descriptor will probably not give the expected results.