1*4639c15bSchristos /* $NetBSD: elf_getversion.c,v 1.1.1.1 2024/03/03 14:41:47 christos Exp $ */
2*4639c15bSchristos
3*4639c15bSchristos /*-
4*4639c15bSchristos * Copyright (c) 2021 Joseph Koshy
5*4639c15bSchristos * All rights reserved.
6*4639c15bSchristos *
7*4639c15bSchristos * Redistribution and use in source and binary forms, with or without
8*4639c15bSchristos * modification, are permitted provided that the following conditions
9*4639c15bSchristos * are met:
10*4639c15bSchristos * 1. Redistributions of source code must retain the above copyright
11*4639c15bSchristos * notice, this list of conditions and the following disclaimer.
12*4639c15bSchristos * 2. Redistributions in binary form must reproduce the above copyright
13*4639c15bSchristos * notice, this list of conditions and the following disclaimer in the
14*4639c15bSchristos * documentation and/or other materials provided with the distribution.
15*4639c15bSchristos *
16*4639c15bSchristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
17*4639c15bSchristos * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18*4639c15bSchristos * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19*4639c15bSchristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
20*4639c15bSchristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21*4639c15bSchristos * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22*4639c15bSchristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23*4639c15bSchristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24*4639c15bSchristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25*4639c15bSchristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26*4639c15bSchristos * THE POSSIBILITY OF SUCH DAMAGE.
27*4639c15bSchristos */
28*4639c15bSchristos
29*4639c15bSchristos #include <sys/cdefs.h>
30*4639c15bSchristos
31*4639c15bSchristos #include <libelf.h>
32*4639c15bSchristos
33*4639c15bSchristos #include "_libelf.h"
34*4639c15bSchristos
35*4639c15bSchristos ELFTC_VCSID("Id: elf_getversion.c 3977 2022-05-01 06:45:34Z jkoshy");
36*4639c15bSchristos
37*4639c15bSchristos __RCSID("$NetBSD: elf_getversion.c,v 1.1.1.1 2024/03/03 14:41:47 christos Exp $");
38*4639c15bSchristos
39*4639c15bSchristos unsigned int
elf_getversion(Elf * e)40*4639c15bSchristos elf_getversion(Elf *e)
41*4639c15bSchristos {
42*4639c15bSchristos if (e == NULL || e->e_kind != ELF_K_ELF) {
43*4639c15bSchristos LIBELF_SET_ERROR(ARGUMENT, 0);
44*4639c15bSchristos return (EV_NONE);
45*4639c15bSchristos }
46*4639c15bSchristos
47*4639c15bSchristos return (e->e_version);
48*4639c15bSchristos }
49