Mobe the SYMTAB_SPACE stuff to ksyms_init, so that it can be used without

DDB compiled-in.
This commit is contained in:
ragge 2003-04-25 20:30:57 +00:00
parent 0aa3fc4996
commit cddfd23e42
3 changed files with 42 additions and 27 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_sym.c,v 1.36 2003/04/24 21:18:34 ragge Exp $ */
/* $NetBSD: db_sym.c,v 1.37 2003/04/25 20:30:58 ragge Exp $ */
/*
* Mach Operating System
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_sym.c,v 1.36 2003/04/24 21:18:34 ragge Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_sym.c,v 1.37 2003/04/25 20:30:58 ragge Exp $");
#include "opt_ddbparam.h"
@ -44,13 +44,6 @@ __KERNEL_RCSID(0, "$NetBSD: db_sym.c,v 1.36 2003/04/24 21:18:34 ragge Exp $");
#include <ddb/db_extern.h>
#include <ddb/db_command.h>
#ifdef SYMTAB_SPACE
#define SYMTAB_FILLER "|This is the symbol table!"
char db_symtab[SYMTAB_SPACE] = SYMTAB_FILLER;
int db_symtabsize = SYMTAB_SPACE;
#endif
static void db_symsplit(char *, char **, char **);
@ -72,17 +65,6 @@ extern db_symformat_t db_symformat_aout;
void
ddb_init(int symsize, void *vss, void *vse)
{
#ifdef SYMTAB_SPACE
if (symsize <= 0) {
if (strncmp(db_symtab, SYMTAB_FILLER, sizeof(SYMTAB_FILLER))) {
symsize = db_symtabsize;
vss = db_symtab;
vse = db_symtab + db_symtabsize;
}
}
#endif
#ifdef DB_AOUT_SYMBOLS
db_symformat = &db_symformat_aout;
if ((*db_symformat->sym_init)(symsize, vss, vse, TBLNAME) == TRUE) {
@ -90,7 +72,7 @@ ddb_init(int symsize, void *vss, void *vse)
return;
}
#endif
ksyms_init(vss, vse); /* Will complain if necessary */
ksyms_init(symsize, vss, vse); /* Will complain if necessary */
}
boolean_t

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ksyms.c,v 1.2 2003/04/25 07:35:21 ragge Exp $ */
/* $NetBSD: kern_ksyms.c,v 1.3 2003/04/25 20:30:58 ragge Exp $ */
/*
* Copyright (c) 2001, 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@ -48,6 +48,7 @@
#ifdef _KERNEL
#include "opt_ddb.h"
#include "opt_ddbparam.h" /* for SYMTAB_SPACE */
#endif
#include <sys/param.h>
@ -102,6 +103,12 @@ const struct cdevsw ksyms_cdevsw = {
};
#endif
#ifdef SYMTAB_SPACE
#define SYMTAB_FILLER "|This is the symbol table!"
char db_symtab[SYMTAB_SPACE] = SYMTAB_FILLER;
int db_symtabsize = SYMTAB_SPACE;
#endif
/*
* Store the different symbol tables in a double-linked list.
@ -192,16 +199,42 @@ addsymtab(char *name, Elf_Ehdr *ehdr, struct symtab *tab)
* Setup the kernel symbol table stuff.
*/
void
ksyms_init(caddr_t start, caddr_t end)
ksyms_init(int symsize, caddr_t start, caddr_t end)
{
Elf_Ehdr *ehdr = (Elf_Ehdr *)start;
Elf_Ehdr *ehdr;
#ifdef SYMTAB_SPACE
if (symsize <= 0 &&
strncmp(db_symtab, SYMTAB_FILLER, sizeof(SYMTAB_FILLER))) {
symsize = db_symtabsize;
start = db_symtab;
end = db_symtab + db_symtabsize;
}
#endif
if (symsize <= 0) {
printf("[ Kernel symbol table missing! ]\n");
return;
}
/* Sanity check */
if (ALIGNED_POINTER(start, long) == 0) {
printf("[ Kernel symbol table has bad start address %p ]\n",
start);
return;
}
ehdr = (Elf_Ehdr *)start;
/* check if this is a valid ELF header */
/* No reason to verify arch type, the kernel is actually running! */
if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) ||
ehdr->e_ident[EI_CLASS] != ELFCLASS ||
ehdr->e_version > 1) {
printf("Kernel symbol table invalid!\n");
#ifdef notyet /* DDB */
if (ddb_init(symsize, start, end))
return; /* old-style symbol table */
#endif
printf("[ Kernel symbol table invalid! ]\n");
return; /* nothing to do */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ksyms.h,v 1.1 2003/04/24 19:56:44 ragge Exp $ */
/* $NetBSD: ksyms.h,v 1.2 2003/04/25 20:30:57 ragge Exp $ */
/*
* Copyright (c) 2001, 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@ -62,7 +62,7 @@ int ksyms_getname(char **, char **, vaddr_t, int);
int ksyms_getval(char *, char *, unsigned long *, int);
int ksyms_addsymtab(char *, void *, vsize_t, char *, vsize_t);
int ksyms_delsymtab(char *);
void ksyms_init(caddr_t, caddr_t);
void ksyms_init(int, caddr_t, caddr_t);
#ifdef DDB
int ksyms_sift(char *mod, char *sym, int mode);
#endif