diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2000-05-30 21:59:31 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2000-05-30 21:59:31 +0000 |
commit | 74f1c0e7ac50e618d1b8fe339a9b0dd7c94c00a3 (patch) | |
tree | 7b344224842be17c1389ec58f2d45d0bfc19305f /sys/lib/libsa/exec_aout.c | |
parent | 45f0ff7ee11beaae4d1ffe122abe37142441114b (diff) |
split symbol loading for a.out into a separate routine (tested on i386)
add symbol loading for elf (tested on hppa)
Diffstat (limited to 'sys/lib/libsa/exec_aout.c')
-rw-r--r-- | sys/lib/libsa/exec_aout.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/sys/lib/libsa/exec_aout.c b/sys/lib/libsa/exec_aout.c index a44c7c0b0ca..b5fa341ab47 100644 --- a/sys/lib/libsa/exec_aout.c +++ b/sys/lib/libsa/exec_aout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_aout.c,v 1.1 1998/07/14 03:29:08 mickey Exp $ */ +/* $OpenBSD: exec_aout.c,v 1.2 2000/05/30 21:59:30 mickey Exp $ */ /* * Copyright (c) 1998 Michael Shalayeff @@ -77,7 +77,45 @@ aout_load(fd, xp) xp->data.size = x->a_data; xp->bss.size = x->a_bss; xp->sym.size = x->a_syms; - xp->str.size = 0; /* will be hacked later in exec() */ + xp->str.size = 0; /* will be hacked later in aout_ldsym() */ + + return 0; +} + +int +aout_ldsym(fd, xp) + int fd; + register struct x_param *xp; +{ + char *pa; + u_int i; + + /* Symbols */ + if (xp->sym.size) { + pa = (char *)xp->xp_end; + + *(u_int *)pa = xp->sym.size; + pa += sizeof(u_int); + printf("+[%u", xp->sym.size); + if (read(fd, pa, xp->sym.size) != (ssize_t)xp->sym.size) + return -1; + pa += xp->sym.size; + + if (read(fd, pa, sizeof(u_int)) != sizeof(u_int)) + return -1; + + if ((i = *(u_int *)pa)) { + pa += sizeof(u_int); + i -= sizeof(u_int); + if (read(fd, pa, i) != i) + return -1; + pa += i; + } + + /* and that many bytes of string table */ + printf("+%d]", i); + xp->xp_end = (u_long)pa; + } return 0; } |