1.\"	$NetBSD: elf_version.3,v 1.2 2014/03/09 16:58:04 christos Exp $
2.\"
3.\" Copyright (c) 2006,2008 Joseph Koshy.  All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" This software is provided by Joseph Koshy ``as is'' and
15.\" any express or implied warranties, including, but not limited to, the
16.\" implied warranties of merchantability and fitness for a particular purpose
17.\" are disclaimed.  in no event shall Joseph Koshy be liable
18.\" for any direct, indirect, incidental, special, exemplary, or consequential
19.\" damages (including, but not limited to, procurement of substitute goods
20.\" or services; loss of use, data, or profits; or business interruption)
21.\" however caused and on any theory of liability, whether in contract, strict
22.\" liability, or tort (including negligence or otherwise) arising in any way
23.\" out of the use of this software, even if advised of the possibility of
24.\" such damage.
25.\"
26.\" Id: elf_version.3 2123 2011-11-09 15:40:09Z jkoshy
27.\"
28.Dd November 9, 2011
29.Os
30.Dt ELF_VERSION 3
31.Sh NAME
32.Nm elf_version
33.Nd retrieve or set ELF library operating version
34.Sh LIBRARY
35.Lb libelf
36.Sh SYNOPSIS
37.In libelf.h
38.Ft unsigned int
39.Fn elf_version "unsigned int version"
40.Sh DESCRIPTION
41The
42.Fn elf_version
43function is used to query the current operating version of the ELF
44library, and to inform the ELF library about the application's desired
45operating version.
46.Pp
47If the argument
48.Ar version
49is
50.Dv EV_NONE ,
51the
52.Fn elf_version
53function returns the currently configured operating version for the
54ELF library.
55.Pp
56If the argument
57.Ar version
58is not
59.Dv EV_NONE ,
60and if argument
61.Ar version
62is supported by the ELF library, function
63.Fn elf_version
64sets the library's operating version to
65.Ar version ,
66and returns the previous value of the operating version.
67If argument
68.Ar version
69cannot be supported, then the
70.Fn elf_version
71function returns
72.Dv EV_NONE .
73.Sh RETURN VALUES
74The
75.Fn elf_version
76function returns the currently configured ELF library version, or
77.Dv EV_NONE
78if an unsupported version is requested.
79.Sh EXAMPLES
80An application program would inform the ELF library about its desired
81operating version and check for an error using the following code
82snippet:
83.Bd -literal -offset indent
84if (elf_version(EV_CURRENT) == EV_NONE)
85	err(EXIT_FAILURE, "ELF library too old");
86.Ed
87.Sh ERRORS
88Function
89.Fn elf_version
90may fail with the following error:
91.Bl -tag -width "[ELF_E_RESOURCE]"
92.It Bq Er "ELF_E_VERSION"
93An unsupported library version number was requested.
94.El
95.Sh SEE ALSO
96.Xr elf 3 ,
97.Xr gelf 3
98