[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1


elf_version Subroutine

Purpose

Coordinate ELF library and application versions

Library

cc [flag...] file... -lelf [library]...
#include <libelf.h>

Syntax


unsigned elf_version(unsigned ver);

Description

As the Introduction to ELF Subroutines explains, the program, the library, and an object file have independent notions of the latest ELF version. elf_version lets a program determine the ELF library's internal version. It further lets the program specify what memory types it uses by giving its own working version, ver, to the library. Every program that uses the ELF library must coordinate versions as described below.

The header file 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.

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.

Parameters

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.

Examples

The following excerpt from an application program protects itself from using an older library.

   if (elf_version(EV_CURRENT) == EV_NONE)
   {
   	/* library out of date */
   	/* recover from error */
   }

Related Information

The elf_begin (elf_begin Subroutine) subroutine, elf32_xlatetof (elf32_xlatetof, elf32_xlatetom, elf64_xlatetof, elf64_xlatetom Subroutine) subroutine, elf64_xlatetof (elf32_xlatetof, elf32_xlatetom, elf64_xlatetof, elf64_xlatetom Subroutine) subroutine.

Introduction to ELF Subroutines.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]