CVS commit: src/lib/libexecinfo
Module Name:src Committed By: rin Date: Wed Aug 23 12:24:59 UTC 2023 Modified Files: src/lib/libexecinfo: execinfo.h symtab.c unwind_arm_ehabi_stub.c Log Message: libexecinfo: whitespace, missing RCSID, no binary changes To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/execinfo.h cvs rdiff -u -r1.9 -r1.10 src/lib/libexecinfo/symtab.c cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/unwind_arm_ehabi_stub.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libexecinfo/execinfo.h diff -u src/lib/libexecinfo/execinfo.h:1.3 src/lib/libexecinfo/execinfo.h:1.4 --- src/lib/libexecinfo/execinfo.h:1.3 Fri Jun 30 21:39:43 2017 +++ src/lib/libexecinfo/execinfo.h Wed Aug 23 12:24:59 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: execinfo.h,v 1.3 2017/06/30 21:39:43 christos Exp $ */ +/* $NetBSD: execinfo.h,v 1.4 2023/08/23 12:24:59 rin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include #include #include - + #ifdef _BSD_SIZE_T_ typedef _BSD_SIZE_T_size_t; #undef _BSD_SIZE_T_ Index: src/lib/libexecinfo/symtab.c diff -u src/lib/libexecinfo/symtab.c:1.9 src/lib/libexecinfo/symtab.c:1.10 --- src/lib/libexecinfo/symtab.c:1.9 Sat Jun 25 06:51:37 2022 +++ src/lib/libexecinfo/symtab.c Wed Aug 23 12:24:59 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: symtab.c,v 1.9 2022/06/25 06:51:37 skrll Exp $ */ +/* $NetBSD: symtab.c,v 1.10 2023/08/23 12:24:59 rin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: symtab.c,v 1.9 2022/06/25 06:51:37 skrll Exp $"); +__RCSID("$NetBSD: symtab.c,v 1.10 2023/08/23 12:24:59 rin Exp $"); #include #include @@ -141,7 +141,7 @@ symtab_create(int fd, int bind, int type for (size_t i = 0; i < ns; i++) { GElf_Sym sym; -gelf_getsym(edata, (int)i, ); + gelf_getsym(edata, (int)i, ); DPRINTF("%s@%#jx=%d,%d", elf_strptr(elf, shdr.sh_link, sym.st_name), @@ -165,7 +165,7 @@ symtab_create(int fd, int bind, int type goto out; } s++; -} + } st->nsymbols = s - st->symbols; if (st->nsymbols == 0) { warnx("No symbols found"); @@ -196,9 +196,9 @@ symtab_find(const symtab_t *st, const vo uintptr_t sa = SYMBOL_CANONICALIZE(dli->dli_saddr); uintptr_t ad = sa - fbase; - DPRINTF("[fbase=%#jx, saddr=%p, sa=%#jx, me=%#jx ad=%#jx]", + DPRINTF("[fbase=%#jx, saddr=%p, sa=%#jx, me=%#jx ad=%#jx]", (uintmax_t)fbase, dli->dli_saddr, (uintmax_t)sa, - (uintmax_t)me, (uintmax_t)ad); + (uintmax_t)me, (uintmax_t)ad); for (;;) { if (s[mid].st_value < me) Index: src/lib/libexecinfo/unwind_arm_ehabi_stub.c diff -u src/lib/libexecinfo/unwind_arm_ehabi_stub.c:1.2 src/lib/libexecinfo/unwind_arm_ehabi_stub.c:1.3 --- src/lib/libexecinfo/unwind_arm_ehabi_stub.c:1.2 Tue May 6 16:02:10 2014 +++ src/lib/libexecinfo/unwind_arm_ehabi_stub.c Wed Aug 23 12:24:59 2023 @@ -1,3 +1,5 @@ +/* $NetBSD: unwind_arm_ehabi_stub.c,v 1.3 2023/08/23 12:24:59 rin Exp $ */ + /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. * All rights reserved.
CVS commit: src/lib/libexecinfo
Module Name:src Committed By: rin Date: Wed Aug 23 12:24:59 UTC 2023 Modified Files: src/lib/libexecinfo: execinfo.h symtab.c unwind_arm_ehabi_stub.c Log Message: libexecinfo: whitespace, missing RCSID, no binary changes To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/execinfo.h cvs rdiff -u -r1.9 -r1.10 src/lib/libexecinfo/symtab.c cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/unwind_arm_ehabi_stub.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libexecinfo
Module Name:src Committed By: skrll Date: Sat Jun 25 06:51:37 UTC 2022 Modified Files: src/lib/libexecinfo: Makefile backtrace.c symtab.c Added Files: src/lib/libexecinfo: symbol.h symbol_hppa.c Log Message: Decode function descriptors (aka plabels) on hppa to fix backtrace. PR/56881: hppa: backtrace_symbols() delivers bogus results for some dynloaded functions To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libexecinfo/Makefile cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/backtrace.c cvs rdiff -u -r0 -r1.1 src/lib/libexecinfo/symbol.h \ src/lib/libexecinfo/symbol_hppa.c cvs rdiff -u -r1.8 -r1.9 src/lib/libexecinfo/symtab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libexecinfo
Module Name:src Committed By: skrll Date: Sat Jun 25 06:51:37 UTC 2022 Modified Files: src/lib/libexecinfo: Makefile backtrace.c symtab.c Added Files: src/lib/libexecinfo: symbol.h symbol_hppa.c Log Message: Decode function descriptors (aka plabels) on hppa to fix backtrace. PR/56881: hppa: backtrace_symbols() delivers bogus results for some dynloaded functions To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libexecinfo/Makefile cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/backtrace.c cvs rdiff -u -r0 -r1.1 src/lib/libexecinfo/symbol.h \ src/lib/libexecinfo/symbol_hppa.c cvs rdiff -u -r1.8 -r1.9 src/lib/libexecinfo/symtab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libexecinfo/Makefile diff -u src/lib/libexecinfo/Makefile:1.9 src/lib/libexecinfo/Makefile:1.10 --- src/lib/libexecinfo/Makefile:1.9 Wed Jan 22 15:10:32 2020 +++ src/lib/libexecinfo/Makefile Sat Jun 25 06:51:37 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.9 2020/01/22 15:10:32 mgorny Exp $ +# $NetBSD: Makefile,v 1.10 2022/06/25 06:51:37 skrll Exp $ .include @@ -27,6 +27,10 @@ SRCS+=unwind_arm_ehabi_stub.c SRCS+=builtin.c .endif +.if exists(${.CURDIR}/symbol_${LIBEXECINFO_MACHINE_ARCH}.c) +SRCS+=symbol_${LIBEXECINFO_MACHINE_ARCH}.c +.endif + MLINKS+= backtrace.3 backtrace_symbols.3 MLINKS+= backtrace.3 backtrace_symbols_fmt.3 MLINKS+= backtrace.3 backtrace_symbols_fd.3 Index: src/lib/libexecinfo/backtrace.c diff -u src/lib/libexecinfo/backtrace.c:1.7 src/lib/libexecinfo/backtrace.c:1.8 --- src/lib/libexecinfo/backtrace.c:1.7 Thu Jun 23 09:48:00 2022 +++ src/lib/libexecinfo/backtrace.c Sat Jun 25 06:51:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: backtrace.c,v 1.7 2022/06/23 09:48:00 skrll Exp $ */ +/* $NetBSD: backtrace.c,v 1.8 2022/06/25 06:51:37 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: backtrace.c,v 1.7 2022/06/23 09:48:00 skrll Exp $"); +__RCSID("$NetBSD: backtrace.c,v 1.8 2022/06/25 06:51:37 skrll Exp $"); #include #include @@ -45,6 +45,7 @@ __RCSID("$NetBSD: backtrace.c,v 1.7 2022 #include #include "execinfo.h" +#include "symbol.h" #include "symtab.h" #ifdef __linux__ @@ -114,7 +115,8 @@ static ssize_t format_string(char **buf, size_t *bufsiz, size_t offs, const char *fmt, Dl_info *dli, const void *addr) { - ptrdiff_t diff = (const char *)addr - (const char *)dli->dli_saddr; + const uintptr_t symaddr = SYMBOL_CANONICALIZE(dli->dli_saddr); + ptrdiff_t diff = (const char *)addr - (const char *)symaddr; size_t o = offs; int len; Index: src/lib/libexecinfo/symtab.c diff -u src/lib/libexecinfo/symtab.c:1.8 src/lib/libexecinfo/symtab.c:1.9 --- src/lib/libexecinfo/symtab.c:1.8 Thu Jun 23 09:58:25 2022 +++ src/lib/libexecinfo/symtab.c Sat Jun 25 06:51:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: symtab.c,v 1.8 2022/06/23 09:58:25 skrll Exp $ */ +/* $NetBSD: symtab.c,v 1.9 2022/06/25 06:51:37 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: symtab.c,v 1.8 2022/06/23 09:58:25 skrll Exp $"); +__RCSID("$NetBSD: symtab.c,v 1.9 2022/06/25 06:51:37 skrll Exp $"); #include #include @@ -48,6 +48,7 @@ __RCSID("$NetBSD: symtab.c,v 1.8 2022/06 #define ELF_ST_TYPE(x) (((unsigned int)x) & 0xf) #endif +#include "symbol.h" #include "symtab.h" #ifdef SYMTAB_DEBUG @@ -192,11 +193,12 @@ symtab_find(const symtab_t *st, const vo size_t mid = ns / 2; uintptr_t fbase = st->ispie ? (uintptr_t)dli->dli_fbase : 0; uintptr_t dd, sd, me = (uintptr_t)p - fbase; - uintptr_t ad = (uintptr_t)dli->dli_saddr - fbase; + uintptr_t sa = SYMBOL_CANONICALIZE(dli->dli_saddr); + uintptr_t ad = sa - fbase; - DPRINTF("[fbase=%#jx, saddr=%p, me=%#jx ad=%#jx]", - (uintmax_t)fbase, dli->dli_saddr, - (uintmax_t)me, (uintmax_t)ad); + DPRINTF("[fbase=%#jx, saddr=%p, sa=%#jx, me=%#jx ad=%#jx]", + (uintmax_t)fbase, dli->dli_saddr, (uintmax_t)sa, + (uintmax_t)me, (uintmax_t)ad); for (;;) { if (s[mid].st_value < me) Added files: Index: src/lib/libexecinfo/symbol.h diff -u /dev/null src/lib/libexecinfo/symbol.h:1.1 --- /dev/null Sat Jun 25 06:51:37 2022 +++ src/lib/libexecinfo/symbol.h Sat Jun 25 06:51:37 2022 @@ -0,0 +1,49 @@ +/* $NetBSD: symbol.h,v 1.1 2022/06/25 06:51:37 skrll Exp $ */ + +/*- + * Copyright (c) 2022 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nick Hudson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions
CVS commit: src/lib/libexecinfo
Module Name:src Committed By: skrll Date: Thu Jun 23 09:58:26 UTC 2022 Modified Files: src/lib/libexecinfo: symtab.c Log Message: Oops... fix SYMTAB_DEBUG build To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/symtab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libexecinfo/symtab.c diff -u src/lib/libexecinfo/symtab.c:1.7 src/lib/libexecinfo/symtab.c:1.8 --- src/lib/libexecinfo/symtab.c:1.7 Thu Jun 23 09:53:49 2022 +++ src/lib/libexecinfo/symtab.c Thu Jun 23 09:58:25 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: symtab.c,v 1.7 2022/06/23 09:53:49 skrll Exp $ */ +/* $NetBSD: symtab.c,v 1.8 2022/06/23 09:58:25 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: symtab.c,v 1.7 2022/06/23 09:53:49 skrll Exp $"); +__RCSID("$NetBSD: symtab.c,v 1.8 2022/06/23 09:58:25 skrll Exp $"); #include #include @@ -194,7 +194,7 @@ symtab_find(const symtab_t *st, const vo uintptr_t dd, sd, me = (uintptr_t)p - fbase; uintptr_t ad = (uintptr_t)dli->dli_saddr - fbase; - DPRINTF("[fbase=%#jx, saddr=%p, sa=%#jx, me=%#jx ad=%#jx]", + DPRINTF("[fbase=%#jx, saddr=%p, me=%#jx ad=%#jx]", (uintmax_t)fbase, dli->dli_saddr, (uintmax_t)me, (uintmax_t)ad);
CVS commit: src/lib/libexecinfo
Module Name:src Committed By: skrll Date: Thu Jun 23 09:58:26 UTC 2022 Modified Files: src/lib/libexecinfo: symtab.c Log Message: Oops... fix SYMTAB_DEBUG build To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/symtab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libexecinfo
Module Name:src Committed By: skrll Date: Thu Jun 23 09:53:49 UTC 2022 Modified Files: src/lib/libexecinfo: symtab.c Log Message: Define and use a DPRINTF macro To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/symtab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libexecinfo/symtab.c diff -u src/lib/libexecinfo/symtab.c:1.6 src/lib/libexecinfo/symtab.c:1.7 --- src/lib/libexecinfo/symtab.c:1.6 Thu Jun 23 09:48:00 2022 +++ src/lib/libexecinfo/symtab.c Thu Jun 23 09:53:49 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: symtab.c,v 1.6 2022/06/23 09:48:00 skrll Exp $ */ +/* $NetBSD: symtab.c,v 1.7 2022/06/23 09:53:49 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: symtab.c,v 1.6 2022/06/23 09:48:00 skrll Exp $"); +__RCSID("$NetBSD: symtab.c,v 1.7 2022/06/23 09:53:49 skrll Exp $"); #include #include @@ -50,6 +50,12 @@ __RCSID("$NetBSD: symtab.c,v 1.6 2022/06 #include "symtab.h" +#ifdef SYMTAB_DEBUG +#define DPRINTF(fmt, ...) fprintf(stderr, "%s: " fmt "\n", __func__, __VA_ARGS__) +#else +#define DPRINTF(fmt, ...) +#endif + struct symbol { char *st_name; uintptr_t st_value; @@ -136,12 +142,10 @@ symtab_create(int fd, int bind, int type GElf_Sym sym; gelf_getsym(edata, (int)i, ); -#ifdef SYMTAB_DEBUG - fprintf(stderr, "%s: %s@%#jx=%d,%d\n", __func__, + DPRINTF("%s@%#jx=%d,%d", elf_strptr(elf, shdr.sh_link, sym.st_name), (uintmax_t)sym.st_value, ELF_ST_BIND(sym.st_info), ELF_ST_TYPE(sym.st_info)); -#endif if (bind != -1 && (unsigned)bind != ELF_ST_BIND(sym.st_info)) @@ -190,11 +194,10 @@ symtab_find(const symtab_t *st, const vo uintptr_t dd, sd, me = (uintptr_t)p - fbase; uintptr_t ad = (uintptr_t)dli->dli_saddr - fbase; -#ifdef SYMTAB_DEBUG - fprintf(stderr, "%s: [fbase=%#jx, saddr=%p, me=%#jx ad=%#jx]\n", - __func__, (uintmax_t)fbase, dli->dli_saddr, (uintmax_t)me, - (uintmax_t)ad); -#endif + DPRINTF("[fbase=%#jx, saddr=%p, sa=%#jx, me=%#jx ad=%#jx]", + (uintmax_t)fbase, dli->dli_saddr, + (uintmax_t)me, (uintmax_t)ad); + for (;;) { if (s[mid].st_value < me) lo = mid; @@ -213,15 +216,11 @@ symtab_find(const symtab_t *st, const vo if (dd > sd) { dli->dli_saddr = (void *)s[mid].st_value; dli->dli_sname = s[mid].st_name; -#ifdef SYMTAB_DEBUG - fprintf(stderr, "%s: me=%#jx -> [%#jx, %s]\n", __func__, - (uintmax_t)me, (uintmax_t)sd, dli->dli_sname); -#endif + DPRINTF("me=%#jx -> [%#jx, %s]", (uintmax_t)me, (uintmax_t)sd, + dli->dli_sname); + } else { + DPRINTF("%#jx -> [%#jx, ***]", (uintmax_t)me, (uintmax_t)sd); } -#ifdef SYMTAB_DEBUG - else - fprintf(stderr, "%s: %#jx -> [%#jx, ***]\n", __func__, - (uintmax_t)me, (uintmax_t)sd); -#endif + return 1; }
CVS commit: src/lib/libexecinfo
Module Name:src Committed By: skrll Date: Thu Jun 23 09:53:49 UTC 2022 Modified Files: src/lib/libexecinfo: symtab.c Log Message: Define and use a DPRINTF macro To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/symtab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libexecinfo
Module Name:src Committed By: skrll Date: Thu Jun 23 09:48:00 UTC 2022 Modified Files: src/lib/libexecinfo: backtrace.c symtab.c Log Message: Trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/backtrace.c cvs rdiff -u -r1.5 -r1.6 src/lib/libexecinfo/symtab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libexecinfo/backtrace.c diff -u src/lib/libexecinfo/backtrace.c:1.6 src/lib/libexecinfo/backtrace.c:1.7 --- src/lib/libexecinfo/backtrace.c:1.6 Fri Sep 25 19:27:31 2015 +++ src/lib/libexecinfo/backtrace.c Thu Jun 23 09:48:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: backtrace.c,v 1.6 2015/09/25 19:27:31 christos Exp $ */ +/* $NetBSD: backtrace.c,v 1.7 2022/06/23 09:48:00 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: backtrace.c,v 1.6 2015/09/25 19:27:31 christos Exp $"); +__RCSID("$NetBSD: backtrace.c,v 1.7 2022/06/23 09:48:00 skrll Exp $"); #include #include @@ -93,7 +93,7 @@ rasprintf(char **buf, size_t *bufsiz, si nbufsiz = MAX(*bufsiz + 512, (size_t)len + 1); } else nbufsiz = MAX(offs, *bufsiz) + 512; - + nbuf = realloc(*buf, nbufsiz); if (nbuf == NULL) return -1; Index: src/lib/libexecinfo/symtab.c diff -u src/lib/libexecinfo/symtab.c:1.5 src/lib/libexecinfo/symtab.c:1.6 --- src/lib/libexecinfo/symtab.c:1.5 Wed Apr 20 14:00:16 2016 +++ src/lib/libexecinfo/symtab.c Thu Jun 23 09:48:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: symtab.c,v 1.5 2016/04/20 14:00:16 christos Exp $ */ +/* $NetBSD: symtab.c,v 1.6 2022/06/23 09:48:00 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: symtab.c,v 1.5 2016/04/20 14:00:16 christos Exp $"); +__RCSID("$NetBSD: symtab.c,v 1.6 2022/06/23 09:48:00 skrll Exp $"); #include #include @@ -142,7 +142,7 @@ symtab_create(int fd, int bind, int type (uintmax_t)sym.st_value, ELF_ST_BIND(sym.st_info), ELF_ST_TYPE(sym.st_info)); #endif - + if (bind != -1 && (unsigned)bind != ELF_ST_BIND(sym.st_info)) continue; @@ -177,7 +177,7 @@ out: return NULL; } - + int symtab_find(const symtab_t *st, const void *p, Dl_info *dli) {
CVS commit: src/lib/libexecinfo
Module Name:src Committed By: skrll Date: Thu Jun 23 09:48:00 UTC 2022 Modified Files: src/lib/libexecinfo: backtrace.c symtab.c Log Message: Trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/backtrace.c cvs rdiff -u -r1.5 -r1.6 src/lib/libexecinfo/symtab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/lib/libexecinfo
On Wed, Apr 20, 2016 at 10:00:16AM -0400, Christos Zoulas wrote: > Module Name: src > Committed By: christos > Date: Wed Apr 20 14:00:16 UTC 2016 > > Modified Files: > src/lib/libexecinfo: symtab.c > > Log Message: > Don't subtract base if not pie. Can we please stop making this even more complicated and go back to the original version and *then* analyse what went wrong? Joerg