diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-03-15 17:49:52 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-03-15 17:49:52 +0000 |
commit | 51c05938a19431dac43eee9d33a9eaeb0d38c5b5 (patch) | |
tree | 156fdf05e9a83b02329197200116d23f3ba98a22 /usr.bin/pmdb | |
parent | e2b43d09082dffa4ad720fe2b237c1bc33bcd098 (diff) |
Move the linking offset from the symbol format dependent structs
to struct sym_table.
Allow callers to specify linking offset to st_open.
Diffstat (limited to 'usr.bin/pmdb')
-rw-r--r-- | usr.bin/pmdb/aout_syms.c | 16 | ||||
-rw-r--r-- | usr.bin/pmdb/elf_syms.c | 16 | ||||
-rw-r--r-- | usr.bin/pmdb/symbol.c | 11 | ||||
-rw-r--r-- | usr.bin/pmdb/symbol.h | 5 |
4 files changed, 20 insertions, 28 deletions
diff --git a/usr.bin/pmdb/aout_syms.c b/usr.bin/pmdb/aout_syms.c index db9c558a90a..6ef5fd89981 100644 --- a/usr.bin/pmdb/aout_syms.c +++ b/usr.bin/pmdb/aout_syms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aout_syms.c,v 1.2 2002/03/15 16:41:06 jason Exp $ */ +/* $OpenBSD: aout_syms.c,v 1.3 2002/03/15 17:49:51 art Exp $ */ /* * Copyright (c) 2002 Federico Schwindt <fgsch@openbsd.org> * All rights reserved. @@ -54,7 +54,6 @@ struct aout_symbol_handle { u_int32_t ash_strsize; struct nlist *ash_symtab; int ash_symsize; - int ash_offs; }; #define ASH_TO_ST(ash) (&(ash)->ash_st) @@ -184,7 +183,7 @@ aout_name_and_off(struct sym_table *st, reg pc, reg *offs) int nsyms, i; char *symn; -#define SYMVAL(S) (unsigned long)((S)->n_value + ash->ash_offs) +#define SYMVAL(S) (unsigned long)((S)->n_value + st->st_offs) nsyms = ash->ash_symsize / sizeof(struct nlist); @@ -262,7 +261,7 @@ restart: return (-1); } - *res = s->n_value + ST_TO_ASH(st)->ash_offs; + *res = s->n_value + st->st_offs; return (0); } @@ -285,7 +284,7 @@ aout_update(struct pstate *ps) warnx("Can't find __DYNAMIC"); return; } - addr = s->n_value + ST_TO_ASH(ps->ps_sym_exe)->ash_offs; + addr = s->n_value + ps->ps_sym_exe->st_offs; if (read_from_pid(pid, addr, &dyn, sizeof(dyn)) < 0) { warn("Can't read __DYNAMIC"); @@ -314,7 +313,6 @@ aout_update(struct pstate *ps) somp = (off_t)(reg)sdt.sdt_loaded; while (somp) { - struct sym_table *st; char fname[MAXPATHLEN]; int i; @@ -338,11 +336,7 @@ aout_update(struct pstate *ps) continue; } - st = st_open(ps, fname); - if (st == NULL) { + if (st_open(ps, fname, (reg)som.som_addr) == NULL) warn("symbol loading failed"); - continue; - } - ST_TO_ASH(st)->ash_offs = (int)som.som_addr; } } diff --git a/usr.bin/pmdb/elf_syms.c b/usr.bin/pmdb/elf_syms.c index 0df200acc7b..f566a930b6c 100644 --- a/usr.bin/pmdb/elf_syms.c +++ b/usr.bin/pmdb/elf_syms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elf_syms.c,v 1.2 2002/03/15 16:41:06 jason Exp $ */ +/* $OpenBSD: elf_syms.c,v 1.3 2002/03/15 17:49:51 art Exp $ */ /* * Copyright (c) 2002 Artur Grabowski <art@openbsd.org> * All rights reserved. @@ -56,7 +56,6 @@ struct elf_symbol_handle { Elf_Word esh_strsize; Elf_Sym *esh_symtab; Elf_Word esh_symsize; - Elf_Addr esh_offs; }; #define ESH_TO_ST(esh) (&(esh)->esh_st) @@ -203,7 +202,7 @@ elf_name_and_off(struct sym_table *st, reg pc, reg *offs) int nsyms, i; char *symn; -#define SYMVAL(S) (unsigned long)((S)->st_value + esh->esh_offs) +#define SYMVAL(S) (unsigned long)((S)->st_value + st->st_offs) nsyms = esh->esh_symsize / sizeof(Elf_Sym); @@ -266,7 +265,7 @@ elf_lookup(struct pstate *ps, const char *name, reg *res) } if (s != NULL) { - *res = s->st_value + ST_TO_ESH(st)->esh_offs; + *res = s->st_value + st->st_offs; return (0); } @@ -319,7 +318,6 @@ elf_update(struct pstate *ps) #ifndef __NetBSD__ pid_t pid = ps->ps_pid; struct elf_object_v1 eobj; - struct sym_table *st; struct r_debug rdeb; reg addr; Elf_Dyn dyn; @@ -330,7 +328,7 @@ elf_update(struct pstate *ps) warnx("Can't find _DYNAMIC"); return; } - addr = s->st_value + ST_TO_ESH(ps->ps_sym_exe)->esh_offs; + addr = s->st_value + ps->ps_sym_exe->st_offs; do { if (read_from_pid(pid, addr, &dyn, sizeof(dyn)) < 0) { @@ -392,12 +390,8 @@ elf_update(struct pstate *ps) if (i == MAXPATHLEN) continue; - st = st_open(ps, fname); - if (st == NULL) { + if (st_open(ps, fname, eobj.load_offs) == NULL) warn("symbol loading failed"); - continue; - } - ST_TO_ESH(st)->esh_offs = eobj.load_offs; } #endif } diff --git a/usr.bin/pmdb/symbol.c b/usr.bin/pmdb/symbol.c index d4d9bd3e280..43937d60bfa 100644 --- a/usr.bin/pmdb/symbol.c +++ b/usr.bin/pmdb/symbol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: symbol.c,v 1.2 2002/03/15 16:41:06 jason Exp $ */ +/* $OpenBSD: symbol.c,v 1.3 2002/03/15 17:49:51 art Exp $ */ /* * Copyright (c) 2002 Artur Grabowski <art@openbsd.org> * All rights reserved. @@ -51,7 +51,8 @@ sym_init_exec(struct pstate *ps, const char *name) warnx("sym_init_exec: %s is not a supported file format", name); if (ps->ps_sops) { - ps->ps_sym_exe = st_open(ps, name); + /* XXX - this 0 doesn't have to be correct.. */ + ps->ps_sym_exe = st_open(ps, name, 0); if (ps->ps_sym_exe) ps->ps_sym_exe->st_flags |= ST_EXEC; } @@ -139,12 +140,12 @@ sym_print(struct pstate *ps, reg pc, char *buf, size_t buflen) * it's already there. */ struct sym_table * -st_open(struct pstate *ps, const char *name) +st_open(struct pstate *ps, const char *name, reg offs) { struct sym_table *st; TAILQ_FOREACH(st, &ps->ps_syms, st_list) { - if (!strcmp(name, st->st_fname)) + if (!strcmp(name, st->st_fname) && (st->st_offs == offs)) return (st); } @@ -155,6 +156,8 @@ st_open(struct pstate *ps, const char *name) strlcpy(st->st_fname, name, sizeof(st->st_fname)); } + st->st_offs = offs; + return (st); } diff --git a/usr.bin/pmdb/symbol.h b/usr.bin/pmdb/symbol.h index 5a7d28b98b7..192f2e81e9c 100644 --- a/usr.bin/pmdb/symbol.h +++ b/usr.bin/pmdb/symbol.h @@ -1,4 +1,4 @@ -/* $OpenBSD: symbol.h,v 1.2 2002/03/15 16:41:06 jason Exp $ */ +/* $OpenBSD: symbol.h,v 1.3 2002/03/15 17:49:51 art Exp $ */ /* * Copyright (c) 2002 Artur Grabowski <art@openbsd.org> * All rights reserved. @@ -30,6 +30,7 @@ struct sym_table { TAILQ_ENTRY(sym_table) st_list; char st_fname[MAXPATHLEN]; int st_flags; + reg st_offs; }; /* Flags in st_flags */ @@ -51,7 +52,7 @@ int sym_lookup(struct pstate *, const char *, reg *); char *sym_print(struct pstate *, reg, char *, size_t); /* Internal for symbol handlers only. */ -struct sym_table *st_open(struct pstate *, const char *); +struct sym_table *st_open(struct pstate *, const char *, reg); #ifdef PMDB_ELF int sym_check_elf(const char *, struct pstate *); |