diff options
Diffstat (limited to 'lib/libproc/proc_sym.c')
-rw-r--r-- | lib/libproc/proc_sym.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c index ad6673f9f9ba..be932b12a24f 100644 --- a/lib/libproc/proc_sym.c +++ b/lib/libproc/proc_sym.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2016-2017 Mark Johnston <markj@FreeBSD.org> * Copyright (c) 2010 The FreeBSD Foundation @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #ifndef NO_CTF #include <sys/ctf.h> @@ -54,7 +51,7 @@ __FBSDID("$FreeBSD$"); #endif #include <libutil.h> -#include "crc32.h" +#include <zlib.h> #include "_libproc.h" #define PATH_DEBUG_DIR "/usr/lib/debug" @@ -70,17 +67,14 @@ extern char *__cxa_demangle(const char *, char *, size_t *, int *); static int crc32_file(int fd, uint32_t *crc) { - uint8_t buf[PAGE_SIZE], *p; - size_t n; + char buf[MAXPHYS]; + ssize_t nr; - *crc = ~0; - while ((n = read(fd, buf, sizeof(buf))) > 0) { - p = &buf[0]; - while (n-- > 0) - *crc = crc32_tab[(*crc ^ *p++) & 0xff] ^ (*crc >> 8); + *crc = crc32(0L, Z_NULL, 0); + while ((nr = read(fd, buf, sizeof(buf))) > 0) { + *crc = crc32(*crc, (char *)buf, nr); } - *crc = ~*crc; - return (n); + return (!!nr); } static void @@ -108,7 +102,7 @@ struct symsort_thunk { }; static int -symvalcmp(void *_thunk, const void *a1, const void *a2) +symvalcmp(const void *a1, const void *a2, void *_thunk) { GElf_Sym sym1, sym2; struct symsort_thunk *thunk; @@ -195,7 +189,7 @@ load_symtab(Elf *e, struct symtab *symtab, u_long sh_type) thunk.e = e; thunk.symtab = symtab; - qsort_r(symtab->index, nsyms, sizeof(u_int), &thunk, symvalcmp); + qsort_r(symtab->index, nsyms, sizeof(u_int), symvalcmp, &thunk); return (0); } |