summaryrefslogtreecommitdiffstats
path: root/lib/libelf/elf_phnum.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libelf/elf_phnum.c')
-rw-r--r--lib/libelf/elf_phnum.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/libelf/elf_phnum.c b/lib/libelf/elf_phnum.c
index ff10c7e..4ec108e 100644
--- a/lib/libelf/elf_phnum.c
+++ b/lib/libelf/elf_phnum.c
@@ -32,8 +32,8 @@ __FBSDID("$FreeBSD$");
#include "_libelf.h"
-int
-elf_getphnum(Elf *e, size_t *phnum)
+static int
+_libelf_getphdrnum(Elf *e, size_t *phnum)
{
void *eh;
int ec;
@@ -41,13 +41,26 @@ elf_getphnum(Elf *e, size_t *phnum)
if (e == NULL || e->e_kind != ELF_K_ELF ||
((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64)) {
LIBELF_SET_ERROR(ARGUMENT, 0);
- return (0);
+ return (-1);
}
if ((eh = _libelf_ehdr(e, ec, 0)) == NULL)
- return (0);
+ return (-1);
*phnum = e->e_u.e_elf.e_nphdr;
- return (1);
+ return (0);
+}
+
+int
+elf_getphdrnum(Elf *e, size_t *phnum)
+{
+ return (_libelf_getphdrnum(e, phnum));
+}
+
+/* Deprecated API */
+int
+elf_getphnum(Elf *e, size_t *phnum)
+{
+ return (_libelf_getphdrnum(e, phnum) >= 0);
}
OpenPOWER on IntegriCloud