Nuke syssrc/usr.sbin/dbsym, since it has been replaced by
gnusrc/gnu/usr.sbin/dbsym. Ok'd by thorpej.
This commit is contained in:
parent
f838750c17
commit
c7acbbe729
|
@ -1,9 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.7 1997/10/18 04:37:24 lukem Exp $
|
||||
|
||||
.if ${MACHINE} == "sun3" || ${MACHINE} == "sun3x"
|
||||
PROG=dbsym
|
||||
.endif
|
||||
|
||||
MAN=dbsym.8
|
||||
|
||||
.include <bsd.prog.mk>
|
|
@ -1,45 +0,0 @@
|
|||
.\" $NetBSD: dbsym.8,v 1.4 2001/04/11 19:35:31 wiz Exp $
|
||||
.\"
|
||||
.Dd May 12, 1994
|
||||
.Dt DBSYM 8 sun3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dbsym
|
||||
.Nd copy kernel symbol table into db_symtab space
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Ar kernel
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is used to copy the symbol table in a newly linked kernel into the
|
||||
.Va db_symtab
|
||||
array (in the data section) so that the
|
||||
.Xr ddb 4
|
||||
kernel debugger can find the symbols. This is program is only used
|
||||
on systems for which the boot program does not load the symbol table
|
||||
into memory with the kernel. The space for these symbols is
|
||||
reserved in the data segment using a config option like:
|
||||
.Pp
|
||||
.Li options SYMTAB_SPACE=72000
|
||||
.Pp
|
||||
The size of the db_symtab array (the value of SYMTAB_SPACE) must be
|
||||
at least as large as the kernel symbol table. If insufficient space
|
||||
is reserved, dbsym will refuse to copy the symbol table.
|
||||
.Pp
|
||||
Note that debugging symbols are not useful to the
|
||||
.Xr ddb 4
|
||||
kernel debugger, so to minimize the size of the kernel, one should
|
||||
either compile the kernel without debugging symbols (no
|
||||
.Fl g
|
||||
flag) or use the
|
||||
.Xr strip 1
|
||||
command to strip debugging symbols from the kernel before
|
||||
.Nm
|
||||
is used to copy the symbol table. The command
|
||||
.Pp
|
||||
.Li strip -d netbsd
|
||||
.Pp
|
||||
will strip out debugging symbols.
|
||||
.Sh SEE ALSO
|
||||
.Xr strip 1 ,
|
||||
.Xr ddb 4
|
|
@ -1,230 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1994 Gordon W. Ross
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $NetBSD: dbsym.c,v 1.14 1998/02/20 09:27:21 mycroft Exp $
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: dbsym.c,v 1.14 1998/02/20 09:27:21 mycroft Exp $");
|
||||
#endif
|
||||
|
||||
/* Copy the symbol table into the space reserved for it. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <a.out.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct exec head;
|
||||
char *file;
|
||||
|
||||
/* Virtual addresses of the symbols we frob. */
|
||||
long db_symtab_va, db_symtabsize_va;
|
||||
|
||||
/* Offsets relative to start of data segment. */
|
||||
long db_symtab_off, db_symtabsize_off;
|
||||
|
||||
/* value in the location at db_symtabsize_off */
|
||||
int db_symtabsize_val;
|
||||
|
||||
/* pointers to pieces of mapped file */
|
||||
char *dataseg;
|
||||
char *symbols;
|
||||
char *strings;
|
||||
int *strtab;
|
||||
/* and lengths */
|
||||
int strtab_len;
|
||||
int file_len;
|
||||
int data_off;
|
||||
int data_pgoff;
|
||||
|
||||
void find_db_symtab __P((const char *));
|
||||
int main __P((int, char **));
|
||||
|
||||
int
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int fd, n;
|
||||
int *ip;
|
||||
|
||||
if (argc < 2)
|
||||
errx(1, "missing file name");
|
||||
file = argv[1];
|
||||
|
||||
fd = open(file, O_RDWR);
|
||||
if (fd < 0)
|
||||
err(1, "open `%s'", file);
|
||||
|
||||
n = read(fd, &head, sizeof(head));
|
||||
if (n < sizeof(head))
|
||||
errx(1, "reading header of `%s'", file);
|
||||
file_len = lseek(fd, (off_t)0, 2);
|
||||
|
||||
if (N_BADMAG(head))
|
||||
errx(1, "%s: bad magic number", file);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" text: %9d\n", head.a_text);
|
||||
printf(" data: %9d\n", head.a_data);
|
||||
printf(" bss: %9d\n", head.a_bss);
|
||||
printf(" syms: %9d\n", head.a_syms);
|
||||
printf("entry: 0x%08X\n", head.a_entry);
|
||||
printf("trsiz: %9d\n", head.a_trsize);
|
||||
printf("drsiz: %9d\n", head.a_drsize);
|
||||
#endif
|
||||
|
||||
if (head.a_syms <= 0) {
|
||||
printf("%s: no symbols\n", file);
|
||||
exit(1);
|
||||
}
|
||||
if (head.a_trsize || head.a_drsize)
|
||||
errx(1, "%s: has relocations", file);
|
||||
|
||||
find_db_symtab(file);
|
||||
|
||||
/*
|
||||
* Map in the file from start of data to EOF.
|
||||
* The file offset needs to be page aligned.
|
||||
*/
|
||||
data_off = N_DATOFF(head);
|
||||
data_pgoff = N_PAGSIZ(head) - 1;
|
||||
data_pgoff &= data_off;
|
||||
data_off -= data_pgoff;
|
||||
dataseg = mmap(NULL, /* any address is ok */
|
||||
file_len - data_off, /* length */
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED,
|
||||
fd, data_off);
|
||||
if ((long)dataseg == -1) {
|
||||
printf("%s: can not map data seg\n", file);
|
||||
err(1, "%s", file);
|
||||
}
|
||||
dataseg += data_pgoff;
|
||||
symbols = dataseg + head.a_data;
|
||||
strings = symbols + head.a_syms;
|
||||
/* Find the string table length (first word after symtab). */
|
||||
strtab_len = *((int*)strings);
|
||||
#ifdef DEBUG
|
||||
printf("strtab_len: %d\n", strtab_len);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Find value in the location: db_symtabsize
|
||||
*/
|
||||
ip = (int*) (dataseg + db_symtabsize_off);
|
||||
db_symtabsize_val = *ip;
|
||||
#ifdef DEBUG
|
||||
printf("db_symtabsize val: 0x%08X (%d)\n",
|
||||
db_symtabsize_val, db_symtabsize_val);
|
||||
#endif
|
||||
/* Is there room for the symbols + strings? */
|
||||
if (db_symtabsize_val < (head.a_syms + strtab_len))
|
||||
errx(1, "symbol space too small (%ld < %ld)",
|
||||
(long)db_symtabsize_val, (long)(head.a_syms + strtab_len));
|
||||
printf("Symbols use %ld of %ld bytes available (%ld%%)\n",
|
||||
(long)(head.a_syms + strtab_len), (long)db_symtabsize_val,
|
||||
(long)((head.a_syms + strtab_len) * 100 / db_symtabsize_val));
|
||||
|
||||
/*
|
||||
* Copy the symbol table and string table.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
printf("copying symbol table...\n");
|
||||
#endif
|
||||
ip = (int*) (dataseg + db_symtab_off);
|
||||
/* Write symtab length */
|
||||
*ip++ = head.a_syms;
|
||||
memcpy((char*)ip, symbols, head.a_syms + strtab_len);
|
||||
|
||||
msync(dataseg - data_pgoff, file_len - data_off, 0);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("...done\n");
|
||||
#endif
|
||||
close(fd);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Find locations of the symbols to patch.
|
||||
*/
|
||||
struct nlist wantsyms[] = {
|
||||
{ { "_db_symtabsize" }, 0 },
|
||||
{ { "_db_symtab" }, 0 },
|
||||
{ { NULL }, 0 },
|
||||
};
|
||||
|
||||
void
|
||||
find_db_symtab(file)
|
||||
const char *file;
|
||||
{
|
||||
int data_va;
|
||||
int std_entry;
|
||||
|
||||
if (nlist(file, wantsyms)) {
|
||||
printf("%s: no db_symtab symbols?\n", file);
|
||||
exit(1);
|
||||
}
|
||||
std_entry = N_TXTADDR(head) +
|
||||
(head.a_entry & (N_PAGSIZ(head)-1));
|
||||
data_va = N_DATADDR(head);
|
||||
if (head.a_entry != std_entry) {
|
||||
printf("%s: warning: non-standard entry point: 0x%08lx\n",
|
||||
file, head.a_entry);
|
||||
printf("\texpecting entry=0x%X\n", std_entry);
|
||||
data_va += (head.a_entry - std_entry);
|
||||
}
|
||||
|
||||
db_symtabsize_off = wantsyms[0].n_value - data_va;
|
||||
db_symtab_off = wantsyms[1].n_value - data_va;
|
||||
#ifdef DEBUG
|
||||
printf(".data segment va: 0x%08X\n", data_va);
|
||||
printf("db_symtabsize va: 0x%08X\n", wantsyms[0].n_value);
|
||||
printf("db_symtab va: 0x%08X\n", wantsyms[1].n_value);
|
||||
printf("db_symtabsize off: 0x%08X\n", db_symtabsize_off);
|
||||
printf("db_symtab off: 0x%08X\n", db_symtab_off);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Sanity check locations of db_* symbols
|
||||
*/
|
||||
if (db_symtab_off < 0 || db_symtab_off >= head.a_data) {
|
||||
printf("%s: db_symtab not in data segment?\n", file);
|
||||
exit(1);
|
||||
}
|
||||
if (db_symtabsize_off < 0 || db_symtabsize_off >= head.a_data) {
|
||||
printf("%s: db_symtabsize not in data segment?\n", file);
|
||||
exit(1);
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/* $NetBSD: dbtest.c,v 1.2 1998/01/09 08:09:21 perry Exp $ */
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <a.out.h>
|
||||
|
||||
#define SYMTAB_SPACE 0x8000
|
||||
int db_symtabsize = SYMTAB_SPACE;
|
||||
char db_symtab[SYMTAB_SPACE] = { 0,0,0,0,1 };
|
||||
/*
|
||||
* The actual format of the above is:
|
||||
* int symtab_length = NSYMS;
|
||||
* struct nlist[NSYMS];
|
||||
* int strtab_length;
|
||||
* char strtab[];
|
||||
*/
|
||||
|
||||
/* Print out our symbol table. */
|
||||
main()
|
||||
{
|
||||
struct nlist *nl;
|
||||
int symtab_len, strtab_len;
|
||||
char *strtab;
|
||||
char *p;
|
||||
int *ip;
|
||||
int st, sc, x;
|
||||
|
||||
/* symbol table */
|
||||
ip = (int*) db_symtab;
|
||||
symtab_len = *ip++;
|
||||
if (symtab_len < 4) {
|
||||
printf("no symbol table\n");
|
||||
exit(1);
|
||||
}
|
||||
nl = (struct nlist *) ip;
|
||||
|
||||
/* string table pointer and length */
|
||||
ip = (int*) ((char*)ip + symtab_len);
|
||||
strtab = (char*)ip;
|
||||
strtab_len = *ip;
|
||||
|
||||
if (strtab_len > (SYMTAB_SPACE - symtab_len))
|
||||
strtab_len = (SYMTAB_SPACE - symtab_len);
|
||||
|
||||
/* print symbol table */
|
||||
while ((x=nl->n_un.n_strx) != 0) {
|
||||
if (x < 0 || x >= strtab_len) p = "?";
|
||||
else p = strtab + x;
|
||||
st = nl->n_type & 0x1F;
|
||||
sc = "uatdbxxxxcxxxxxxx"[st>1];
|
||||
if (st & 1) sc &= ~0x20; /* to upper */
|
||||
printf("%08X %c %s\n", nl->n_value, sc, p);
|
||||
nl++;
|
||||
if ((char*)nl >= strtab) {
|
||||
printf("symbol table missing null terminator\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
Loading…
Reference in New Issue