summaryrefslogtreecommitdiff
path: root/sys/lib/libsa/exec.new.c
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2000-05-30 21:59:31 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2000-05-30 21:59:31 +0000
commit74f1c0e7ac50e618d1b8fe339a9b0dd7c94c00a3 (patch)
tree7b344224842be17c1389ec58f2d45d0bfc19305f /sys/lib/libsa/exec.new.c
parent45f0ff7ee11beaae4d1ffe122abe37142441114b (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.new.c')
-rw-r--r--sys/lib/libsa/exec.new.c46
1 files changed, 7 insertions, 39 deletions
diff --git a/sys/lib/libsa/exec.new.c b/sys/lib/libsa/exec.new.c
index 8045e3da5b3..22d03a59b46 100644
--- a/sys/lib/libsa/exec.new.c
+++ b/sys/lib/libsa/exec.new.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.new.c,v 1.4 1998/08/27 20:36:00 mickey Exp $ */
+/* $OpenBSD: exec.new.c,v 1.5 2000/05/30 21:59:30 mickey Exp $ */
/*
* Copyright (c) 1998 Michael Shalayeff
@@ -53,7 +53,6 @@ exec(path, loadaddr, howto)
union x_header hdr;
register u_char *pa;
register int save_err;
- u_int sz;
if ((fd = open(path, 0)) < 0 || fstat(fd, &sb))
return;
@@ -109,45 +108,14 @@ exec(path, loadaddr, howto)
printf("+%u", param.bss.size);
bzero (pa + param.bss.addr, param.bss.size);
- if (!param.sym.size)
- pa += param.bss.addr + param.bss.size;
- else {
- *(u_int *)(pa + param.sym.addr) = param.sym.size;
- param.sym.addr += sizeof(u_int);
- printf("+[%u", param.sym.size);
- if (lseek(fd, param.sym.foff, SEEK_SET) <= 0 ||
- read(fd,pa+param.sym.addr,param.sym.size) != param.sym.size)
- goto err;
-
- /* .str */
- if (param.str.foff && lseek(fd, param.str.foff, SEEK_SET) <= 0)
- goto err;
-
- pa += param.sym.addr + param.sym.size;
- sz = param.str.size;
-
- /* special hack for a.out, where .str size is it's first int */
- if (param.str.foff && !sz) {
- if (read(fd, pa, sizeof(u_int)) != sizeof(u_int))
- goto err;
- else {
- sz = param.str.size = *(u_int*)pa;
- pa += sizeof(u_int);
- sz -= sizeof(u_int);
- }
- }
- if (sz) {
- if (sz && read(fd, pa, sz) != sz)
- goto err;
- }
- printf("+%u]", sz);
- pa += sz;
+ param.xp_end = (int)pa + param.bss.addr + param.bss.size;
+ if (sw->ldsym && sw->ldsym(fd, &param)) {
+ errno = errno? errno : EFTYPE;
+ goto err;
}
- /* round to int */
- param.xp_end = ((u_int)pa + sizeof(int) - 1) & ~(sizeof(int) - 1);
-
- printf(" total=0x%x start=0x%x\n", param.xp_end, param.xp_entry);
+ /* ldsym will adjust the xp_end */
+ printf("=0x%x start=0x%x\n", param.xp_end, param.xp_entry);
/* call the joker */
machdep_exec(&param, howto, loadaddr);