Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
laffer1 committed Nov 8, 2024
1 parent 333a399 commit 3d02141
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 211 deletions.
1 change: 0 additions & 1 deletion contrib/com_err/compile_et.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.\" Copyright (c) 1988 Massachusetts Institute of Technology,
.\" Student Information Processing Board. All rights reserved.
.\"
.\" $FreeBSD: stable/10/contrib/com_err/compile_et.1 206622 2010-04-14 19:08:06Z uqs $
.\"
.Dd November 22, 1988
.Dt COMPILE_ET 1
Expand Down
1 change: 0 additions & 1 deletion contrib/com_err/version-script.map
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# $MidnightBSD$

HEIMDAL_COM_ERR_1.0 {
global:
Expand Down
68 changes: 0 additions & 68 deletions contrib/libexecinfo/builtin.c

This file was deleted.

2 changes: 1 addition & 1 deletion contrib/libexecinfo/execinfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* $NetBSD: execinfo.h,v 1.2 2012/06/09 21:22:17 christos Exp $ */
/* $FreeBSD: stable/11/contrib/libexecinfo/execinfo.h 255177 2013-09-03 13:38:41Z emaste $ */
/* $FreeBSD$ */

/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
Expand Down
46 changes: 39 additions & 7 deletions contrib/libexecinfo/symtab.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: symtab.c,v 1.2 2013/08/29 15:01:57 christos Exp $ */
/* $NetBSD: symtab.c,v 1.5 2016/04/20 14:00:16 christos Exp $ */

/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -29,12 +29,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: symtab.c,v 1.2 2013/08/29 15:01:57 christos Exp $");
__RCSID("$NetBSD: symtab.c,v 1.5 2016/04/20 14:00:16 christos Exp $");

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <err.h>
#include <dlfcn.h>

Expand All @@ -47,7 +48,6 @@ __RCSID("$NetBSD: symtab.c,v 1.2 2013/08/29 15:01:57 christos Exp $");
#define ELF_ST_TYPE(x) (((unsigned int)x) & 0xf)
#endif


#include "symtab.h"

struct symbol {
Expand All @@ -59,6 +59,7 @@ struct symbol {
struct symtab {
size_t nsymbols;
struct symbol *symbols;
bool ispie;
};

static int
Expand Down Expand Up @@ -86,6 +87,7 @@ symtab_create(int fd, int bind, int type)
Elf *elf;
symtab_t *st;
Elf_Scn *scn = NULL;
GElf_Ehdr ehdr;

if (elf_version(EV_CURRENT) == EV_NONE) {
warnx("Elf Library is out of date.");
Expand All @@ -103,6 +105,13 @@ symtab_create(int fd, int bind, int type)
elf_end(elf);
return NULL;
}
if (gelf_getehdr(elf, &ehdr) == NULL) {
warnx("Error getting ELF Ehdr");
elf_end(elf);
return NULL;
}

st->ispie = ehdr.e_type == ET_DYN;

while ((scn = elf_nextscn(elf, scn)) != NULL) {
GElf_Shdr shdr;
Expand All @@ -127,6 +136,13 @@ symtab_create(int fd, int bind, int type)
GElf_Sym sym;
gelf_getsym(edata, (int)i, &sym);

#ifdef SYMTAB_DEBUG
fprintf(stderr, "%s: %s@%#jx=%d,%d\n", __func__,
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))
continue;
Expand Down Expand Up @@ -159,7 +175,7 @@ symtab_create(int fd, int bind, int type)
return NULL;
}


int
symtab_find(const symtab_t *st, const void *p, Dl_info *dli)
{
Expand All @@ -168,8 +184,15 @@ symtab_find(const symtab_t *st, const void *p, Dl_info *dli)
size_t hi = ns;
size_t lo = 0;
size_t mid = ns / 2;
uintptr_t dd, sd, me = (uintptr_t)p;

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;

#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
for (;;) {
if (s[mid].st_value < me)
lo = mid;
Expand All @@ -183,11 +206,20 @@ symtab_find(const symtab_t *st, const void *p, Dl_info *dli)
}
mid = (hi + lo) / 2;
}
dd = me - (uintptr_t)dli->dli_saddr;
dd = me - ad;
sd = me - s[mid].st_value;
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
}
#ifdef SYMTAB_DEBUG
else
fprintf(stderr, "%s: %#jx -> [%#jx, ***]\n", __func__,
(uintmax_t)me, (uintmax_t)sd);
#endif
return 1;
}
12 changes: 8 additions & 4 deletions contrib/libexecinfo/unwind.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: unwind.c,v 1.1 2012/05/26 22:02:29 christos Exp $ */
/* $NetBSD: unwind.c,v 1.3 2019/01/30 22:46:49 mrg Exp $ */

/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -51,8 +51,10 @@ tracer(struct _Unwind_Context *ctx, void *arg)
return 0;
}
if (t->n < t->len)
t->arr[t->n++] = _Unwind_GetIP(ctx);
return 0;
t->arr[t->n++] = (void *)_Unwind_GetIP(ctx);
else
return _URC_END_OF_STACK;
return _URC_NO_REASON;
}

size_t
Expand All @@ -65,7 +67,9 @@ backtrace(void **arr, size_t len)
ctx.n = (size_t)~0;

_Unwind_Backtrace(tracer, &ctx);
if (ctx.n != (size_t)~0 && ctx.n > 0)
if (ctx.n == (size_t)~0)
ctx.n = 0;
else if (ctx.n > 0)
ctx.arr[--ctx.n] = NULL; /* Skip frame below __start */

return ctx.n;
Expand Down
68 changes: 0 additions & 68 deletions contrib/libexecinfo/unwind.h

This file was deleted.

61 changes: 0 additions & 61 deletions contrib/libexecinfo/unwind_arm_ehabi_stub.c

This file was deleted.

0 comments on commit 3d02141

Please sign in to comment.