Fix ksyms_getname() broken in previous.

This commit is contained in:
ad 2008-11-16 15:28:15 +00:00
parent 42cab0447c
commit b766740610
2 changed files with 12 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ksyms.c,v 1.43 2008/11/16 15:13:35 ad Exp $ */
/* $NetBSD: kern_ksyms.c,v 1.44 2008/11/16 15:28:15 ad Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.43 2008/11/16 15:13:35 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.44 2008/11/16 15:28:15 ad Exp $");
#ifdef _KERNEL
#include "opt_ddb.h"
@ -264,8 +264,8 @@ addsymtab(const char *name, void *symstart, size_t symsize,
tab->sd_strstart = strstart;
tab->sd_strsize = strsize;
tab->sd_name = name;
tab->sd_minsym = NULL;
tab->sd_maxsym = NULL;
tab->sd_minsym = UINTPTR_MAX;
tab->sd_maxsym = 0;
tab->sd_usroffset = 0;
tab->sd_gone = false;
#ifdef KSYMS_DEBUG
@ -307,13 +307,11 @@ addsymtab(const char *name, void *symstart, size_t symsize,
nglob += (ELF_ST_BIND(nsym[n].st_info) == STB_GLOBAL);
/* Compute min and max symbols. */
if (tab->sd_minsym == NULL ||
tab->sd_minsym->st_value > nsym[n].st_value) {
tab->sd_minsym = &nsym[n];
if (nsym[n].st_value < tab->sd_minsym) {
tab->sd_minsym = nsym[n].st_value;
}
if (tab->sd_maxsym == NULL ||
tab->sd_maxsym->st_value < nsym[n].st_value) {
tab->sd_maxsym = &nsym[n];
if (nsym[n].st_value > tab->sd_maxsym) {
tab->sd_maxsym = nsym[n].st_value;
}
n++;
}
@ -502,9 +500,7 @@ ksyms_getname(const char **mod, const char **sym, vaddr_t v, int f)
TAILQ_FOREACH(st, &ksyms_symtabs, sd_queue) {
if (st->sd_gone)
continue;
if (st->sd_minsym != NULL && v < st->sd_minsym->st_value)
continue;
if (st->sd_maxsym != NULL && v > st->sd_maxsym->st_value)
if (v < st->sd_minsym || v > st->sd_maxsym)
continue;
sz = st->sd_symsize/sizeof(Elf_Sym);
for (i = 0; i < sz; i++) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ksyms.h,v 1.19 2008/11/16 15:13:35 ad Exp $ */
/* $NetBSD: ksyms.h,v 1.20 2008/11/16 15:28:15 ad Exp $ */
/*
* Copyright (c) 2001, 2003 Anders Magnusson (ragge@ludd.luth.se).
@ -39,8 +39,8 @@ struct ksyms_symtab {
TAILQ_ENTRY(ksyms_symtab) sd_queue; /* All active tables */
const char *sd_name; /* Name of this table */
Elf_Sym *sd_symstart; /* Address of symbol table */
Elf_Sym *sd_minsym; /* symbol with minimum value */
Elf_Sym *sd_maxsym; /* symbol with maximum value */
uintptr_t sd_minsym; /* symbol with minimum value */
uintptr_t sd_maxsym; /* symbol with maximum value */
char *sd_strstart; /* Address of corresponding string table */
int sd_usroffset; /* Real address for userspace */
int sd_symsize; /* Size in bytes of symbol table */