summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1997-07-08 10:42:26 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1997-07-08 10:42:26 +0000
commitccd6fc9178847141a460dbc67c20f8c222c3c1da (patch)
tree36aad6f3102858640859078ec62a6fa286b6799a
parent667b313d2eaabb1397bfc732d8d981d5bfe19b78 (diff)
Load the kernel symbol table for DDB to use
-rw-r--r--sys/arch/alpha/stand/boot/boot.c6
-rw-r--r--sys/arch/alpha/stand/loadfile.c54
2 files changed, 54 insertions, 6 deletions
diff --git a/sys/arch/alpha/stand/boot/boot.c b/sys/arch/alpha/stand/boot/boot.c
index 5af7bdb9274..d79987b7356 100644
--- a/sys/arch/alpha/stand/boot/boot.c
+++ b/sys/arch/alpha/stand/boot/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.9 1997/05/05 06:01:51 millert Exp $ */
+/* $OpenBSD: boot.c,v 1.10 1997/07/08 10:42:25 niklas Exp $ */
/* $NetBSD: boot.c,v 1.10 1997/01/18 01:58:33 cgd Exp $ */
/*
@@ -59,7 +59,7 @@ char boot_flags[128];
extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[];
-vm_offset_t ffp_save, ptbr_save;
+vm_offset_t ffp_save, ptbr_save, esym;
int debug;
@@ -109,7 +109,7 @@ main()
printf("\n");
if (win) {
(void)printf("Entering %s at 0x%lx...\n", name, entry);
- (*(void (*)())entry)(ffp_save, ptbr_save, 0);
+ (*(void (*)())entry)(ffp_save, ptbr_save, esym);
}
(void)printf("Boot failed! Halting...\n");
diff --git a/sys/arch/alpha/stand/loadfile.c b/sys/arch/alpha/stand/loadfile.c
index 63951062504..81b94a4f4a1 100644
--- a/sys/arch/alpha/stand/loadfile.c
+++ b/sys/arch/alpha/stand/loadfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loadfile.c,v 1.3 1997/05/05 06:01:49 millert Exp $ */
+/* $OpenBSD: loadfile.c,v 1.4 1997/07/08 10:42:24 niklas Exp $ */
/* $NetBSD: loadfile.c,v 1.3 1997/04/06 08:40:59 cgd Exp $ */
/*
@@ -52,6 +52,10 @@
#include <machine/rpb.h>
#include <machine/prom.h>
+/* XXX this is a userland header!!! must go. */
+#define _AOUT_INCLUDE_
+#include <nlist.h>
+
#define _KERNEL
#include "include/pte.h"
@@ -63,7 +67,7 @@ static int elf_exec __P((int, Elf_Ehdr *, u_int64_t *));
#endif
int loadfile __P((char *, u_int64_t *));
-vm_offset_t ffp_save, ptbr_save;
+vm_offset_t ffp_save, ptbr_save, esym;
/*
* Open 'filename', read in program and return the entry point or -1 if error.
@@ -127,6 +131,10 @@ coff_exec(fd, coff, entryp)
struct ecoff_exechdr *coff;
u_int64_t *entryp;
{
+ struct nlist *symtab;
+ struct ecoff_symhdr symhdr;
+ struct ecoff_extsym sym;
+ int i, symsize;
/* Read in text. */
(void)printf("%lu", coff->a.tsize);
@@ -159,7 +167,47 @@ coff_exec(fd, coff, entryp)
ffp_save = coff->a.data_start + coff->a.dsize;
if (ffp_save < coff->a.bss_start + coff->a.bsize)
ffp_save = coff->a.bss_start + coff->a.bsize;
- ffp_save = ALPHA_K0SEG_TO_PHYS((ffp_save + PGOFSET & ~PGOFSET)) >> PGSHIFT;
+
+ /* Get symbols if there for DDB's sake. */
+ if (coff->f.f_symptr) {
+ lseek(fd, coff->f.f_symptr, 0);
+ if (read(fd, &symhdr, coff->f.f_nsyms) != coff->f.f_nsyms) {
+ printf("read data: %s\n", strerror(errno));
+ return (1);
+ }
+ *(long *)ffp_save = symsize =
+ symhdr.esymMax * sizeof(struct nlist);
+ ffp_save += sizeof(long);
+ printf("+[%d", symsize);
+ symtab = (struct nlist *)ffp_save;
+ bzero(symtab, symsize);
+ lseek(fd, symhdr.cbExtOffset, 0);
+ for (i = 0; i < symhdr.esymMax; i++) {
+ if (read(fd, &sym, sizeof(sym)) != sizeof(sym)) {
+ printf("read data: %s\n", strerror(errno));
+ return (1);
+ }
+ symtab->n_un.n_strx = sym.es_strindex;
+ symtab->n_value = sym.es_value;
+ symtab->n_type = N_EXT;
+ symtab++;
+ }
+ ffp_save += symsize;
+ *(int *)ffp_save = symhdr.estrMax + sizeof(int);
+ ffp_save += sizeof(int);
+ lseek(fd, symhdr.cbSsExtOffset, 0);
+ if (read(fd, (char *)ffp_save, symhdr.estrMax) !=
+ symhdr.estrMax) {
+ printf("read data: %s\n", strerror(errno));
+ return (1);
+ }
+ ffp_save += symhdr.estrMax;
+ printf("+%d]", symhdr.estrMax);
+ esym = ((ffp_save + sizeof(int) - 1) & ~(sizeof(int) - 1));
+ }
+
+ ffp_save = ALPHA_K0SEG_TO_PHYS((ffp_save + PGOFSET & ~PGOFSET)) >>
+ PGSHIFT;
ffp_save += 2; /* XXX OSF/1 does this, no idea why. */
(void)printf("\n");