summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-22 12:05:21 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-22 12:05:21 +0000
commita2a0f6d8eec05ead8de8668a84fe9edbb856d40a (patch)
tree48cd59beeedd88e99188491fc6ed7a7246938a3c /sys
parentfd9aa9344b25e5d5c5a6ea5525ff56df3123e7e3 (diff)
fiddling
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/exec_ecoff.c153
-rw-r--r--sys/sys/exec_ecoff.h93
2 files changed, 117 insertions, 129 deletions
diff --git a/sys/kern/exec_ecoff.c b/sys/kern/exec_ecoff.c
index e6814c1013f..34cfda7fa65 100644
--- a/sys/kern/exec_ecoff.c
+++ b/sys/kern/exec_ecoff.c
@@ -1,9 +1,9 @@
-/* $OpenBSD: exec_ecoff.c,v 1.2 1996/04/19 16:08:47 niklas Exp $ */
-/* $NetBSD: exec_ecoff.c,v 1.6 1996/03/07 14:31:16 christos Exp $ */
+/* $OpenBSD: exec_ecoff.c,v 1.3 1996/05/22 12:05:19 deraadt Exp $ */
+/* $NetBSD: exec_ecoff.c,v 1.8 1996/05/19 20:36:06 jonathan Exp $ */
/*
* Copyright (c) 1994 Adam Glass
- * Copyright (c) 1993, 1994 Christopher G. Demetriou
+ * Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,15 +43,9 @@
#include <sys/exec_ecoff.h>
-int exec_ecoff_prep_omagic __P((struct proc *, struct exec_package *,
- struct ecoff_filehdr *,
- struct ecoff_aouthdr *));
-int exec_ecoff_prep_nmagic __P((struct proc *, struct exec_package *,
- struct ecoff_filehdr *,
- struct ecoff_aouthdr *));
-int exec_ecoff_prep_zmagic __P((struct proc *, struct exec_package *,
- struct ecoff_filehdr *,
- struct ecoff_aouthdr *));
+int exec_ecoff_prep_omagic __P((struct proc *, struct exec_package *));
+int exec_ecoff_prep_nmagic __P((struct proc *, struct exec_package *));
+int exec_ecoff_prep_zmagic __P((struct proc *, struct exec_package *));
int exec_ecoff_setup_stack __P((struct proc *, struct exec_package *));
/*
@@ -65,40 +59,36 @@ int exec_ecoff_setup_stack __P((struct proc *, struct exec_package *));
* used to build the process's vm space and inserting them into the exec
* package.
*/
-
int
exec_ecoff_makecmds(p, epp)
struct proc *p;
struct exec_package *epp;
{
int error;
- struct ecoff_filehdr *efp = epp->ep_hdr;
- struct ecoff_aouthdr *eap;
+ struct ecoff_exechdr *execp = epp->ep_hdr;
if (epp->ep_hdrvalid < ECOFF_HDR_SIZE)
return ENOEXEC;
- if (ECOFF_BADMAG(efp))
+ if (ECOFF_BADMAG(execp))
return ENOEXEC;
- eap = (struct ecoff_aouthdr *)
- ((caddr_t)epp->ep_hdr + sizeof(struct ecoff_filehdr));
- switch (eap->ea_magic) {
+ switch (execp->a.magic) {
case ECOFF_OMAGIC:
- error = exec_ecoff_prep_omagic(p, epp, efp, eap);
+ error = exec_ecoff_prep_omagic(p, epp);
break;
case ECOFF_NMAGIC:
- error = exec_ecoff_prep_nmagic(p, epp, efp, eap);
+ error = exec_ecoff_prep_nmagic(p, epp);
break;
case ECOFF_ZMAGIC:
- error = exec_ecoff_prep_zmagic(p, epp, efp, eap);
+ error = exec_ecoff_prep_zmagic(p, epp);
break;
default:
return ENOEXEC;
}
if (error == 0)
- error = cpu_exec_ecoff_hook(p, epp, eap);
+ error = cpu_exec_ecoff_hook(p, epp);
if (error)
kill_vmcmds(&epp->ep_vmcmds);
@@ -118,7 +108,6 @@ exec_ecoff_makecmds(p, epp)
* This function returns an int for uniformity with other (future) formats'
* stack setup functions. They might have errors to return.
*/
-
int
exec_ecoff_setup_stack(p, epp)
struct proc *p;
@@ -141,45 +130,43 @@ exec_ecoff_setup_stack(p, epp)
* <stack> ep_minsaddr
*/
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
- ((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr),
- epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE);
+ ((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr),
+ epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE);
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize,
- (epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0,
- VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ (epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
return 0;
}
-
/*
* exec_ecoff_prep_omagic(): Prepare a ECOFF OMAGIC binary's exec package
*/
-
int
-exec_ecoff_prep_omagic(p, epp, efp, eap)
+exec_ecoff_prep_omagic(p, epp)
struct proc *p;
struct exec_package *epp;
- struct ecoff_filehdr *efp;
- struct ecoff_aouthdr *eap;
{
- epp->ep_taddr = ECOFF_SEGMENT_ALIGN(eap, eap->ea_text_start);
- epp->ep_tsize = eap->ea_tsize;
- epp->ep_daddr = ECOFF_SEGMENT_ALIGN(eap, eap->ea_data_start);
- epp->ep_dsize = eap->ea_dsize + eap->ea_bsize;
- epp->ep_entry = eap->ea_entry;
+ struct ecoff_exechdr *execp = epp->ep_hdr;
+ struct ecoff_aouthdr *eap = &execp->a;
+
+ epp->ep_taddr = ECOFF_SEGMENT_ALIGN(execp, eap->text_start);
+ epp->ep_tsize = eap->tsize;
+ epp->ep_daddr = ECOFF_SEGMENT_ALIGN(execp, eap->data_start);
+ epp->ep_dsize = eap->dsize + eap->bsize;
+ epp->ep_entry = eap->entry;
/* set up command for text and data segments */
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
- eap->ea_tsize + eap->ea_dsize, epp->ep_taddr, epp->ep_vp,
- ECOFF_TXTOFF(efp, eap),
- VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ eap->tsize + eap->dsize, epp->ep_taddr, epp->ep_vp,
+ ECOFF_TXTOFF(execp),
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
/* set up command for bss segment */
- if (eap->ea_bsize > 0)
- NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, eap->ea_bsize,
- ECOFF_SEGMENT_ALIGN(eap, eap->ea_bss_start),
- NULLVP, 0,
- VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ if (eap->bsize > 0)
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, eap->bsize,
+ ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
return exec_ecoff_setup_stack(p, epp);
}
@@ -188,36 +175,35 @@ exec_ecoff_prep_omagic(p, epp, efp, eap)
* exec_ecoff_prep_nmagic(): Prepare a 'native' NMAGIC ECOFF binary's exec
* package.
*/
-
int
-exec_ecoff_prep_nmagic(p, epp, efp, eap)
+exec_ecoff_prep_nmagic(p, epp)
struct proc *p;
struct exec_package *epp;
- struct ecoff_filehdr *efp;
- struct ecoff_aouthdr *eap;
{
- epp->ep_taddr = ECOFF_SEGMENT_ALIGN(eap, eap->ea_text_start);
- epp->ep_tsize = eap->ea_tsize;
- epp->ep_daddr = ECOFF_ROUND(eap->ea_data_start, ECOFF_LDPGSZ);
- epp->ep_dsize = eap->ea_dsize + eap->ea_bsize;
- epp->ep_entry = eap->ea_entry;
+ struct ecoff_exechdr *execp = epp->ep_hdr;
+ struct ecoff_aouthdr *eap = &execp->a;
+
+ epp->ep_taddr = ECOFF_SEGMENT_ALIGN(execp, eap->text_start);
+ epp->ep_tsize = eap->tsize;
+ epp->ep_daddr = ECOFF_ROUND(eap->data_start, ECOFF_LDPGSZ);
+ epp->ep_dsize = eap->dsize + eap->bsize;
+ epp->ep_entry = eap->entry;
/* set up command for text segment */
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, epp->ep_tsize,
- epp->ep_taddr, epp->ep_vp, ECOFF_TXTOFF(efp, eap),
- VM_PROT_READ|VM_PROT_EXECUTE);
+ epp->ep_taddr, epp->ep_vp, ECOFF_TXTOFF(execp),
+ VM_PROT_READ|VM_PROT_EXECUTE);
/* set up command for data segment */
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, epp->ep_dsize,
- epp->ep_daddr, epp->ep_vp, ECOFF_DATOFF(efp, eap),
- VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ epp->ep_daddr, epp->ep_vp, ECOFF_DATOFF(execp),
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
/* set up command for bss segment */
- if (eap->ea_bsize > 0)
- NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, eap->ea_bsize,
- ECOFF_SEGMENT_ALIGN(eap, eap->ea_bss_start),
- NULLVP, 0,
- VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ if (eap->bsize > 0)
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, eap->bsize,
+ ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
return exec_ecoff_setup_stack(p, epp);
}
@@ -231,26 +217,26 @@ exec_ecoff_prep_nmagic(p, epp, efp, eap)
* out if this is not possible. Finally, set up vmcmds for the
* text, data, bss, and stack segments.
*/
-
int
-exec_ecoff_prep_zmagic(p, epp, efp, eap)
+exec_ecoff_prep_zmagic(p, epp)
struct proc *p;
struct exec_package *epp;
- struct ecoff_filehdr *efp;
- struct ecoff_aouthdr *eap;
{
- epp->ep_taddr = ECOFF_SEGMENT_ALIGN(eap, eap->ea_text_start);
- epp->ep_tsize = eap->ea_tsize;
- epp->ep_daddr = ECOFF_SEGMENT_ALIGN(eap, eap->ea_data_start);
- epp->ep_dsize = eap->ea_dsize + eap->ea_bsize;
- epp->ep_entry = eap->ea_entry;
+ struct ecoff_exechdr *execp = epp->ep_hdr;
+ struct ecoff_aouthdr *eap = &execp->a;
+
+ epp->ep_taddr = ECOFF_SEGMENT_ALIGN(execp, eap->text_start);
+ epp->ep_tsize = eap->tsize;
+ epp->ep_daddr = ECOFF_SEGMENT_ALIGN(execp, eap->data_start);
+ epp->ep_dsize = eap->dsize + eap->bsize;
+ epp->ep_entry = eap->entry;
/*
* check if vnode is in open for writing, because we want to
* demand-page out of it. if it is, don't do it, for various
* reasons
*/
- if ((eap->ea_tsize != 0 || eap->ea_dsize != 0) &&
+ if ((eap->tsize != 0 || eap->dsize != 0) &&
epp->ep_vp->v_writecount != 0) {
#ifdef DIAGNOSTIC
if (epp->ep_vp->v_flag & VTEXT)
@@ -261,20 +247,19 @@ exec_ecoff_prep_zmagic(p, epp, efp, eap)
epp->ep_vp->v_flag |= VTEXT;
/* set up command for text segment */
- NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, eap->ea_tsize,
- epp->ep_taddr, epp->ep_vp, ECOFF_TXTOFF(efp, eap),
- VM_PROT_READ|VM_PROT_EXECUTE);
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, eap->tsize,
+ epp->ep_taddr, epp->ep_vp, ECOFF_TXTOFF(execp),
+ VM_PROT_READ|VM_PROT_EXECUTE);
/* set up command for data segment */
- NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, eap->ea_dsize,
- epp->ep_daddr, epp->ep_vp,
- ECOFF_DATOFF(efp, eap),
- VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, eap->dsize,
+ epp->ep_daddr, epp->ep_vp, ECOFF_DATOFF(execp),
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
/* set up command for bss segment */
- NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, eap->ea_bsize,
- ECOFF_SEGMENT_ALIGN(eap, eap->ea_bss_start), NULLVP, 0,
- VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, eap->bsize,
+ ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
return exec_ecoff_setup_stack(p, epp);
}
diff --git a/sys/sys/exec_ecoff.h b/sys/sys/exec_ecoff.h
index c63bde1db52..5044ddf40e9 100644
--- a/sys/sys/exec_ecoff.h
+++ b/sys/sys/exec_ecoff.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: exec_ecoff.h,v 1.3 1996/04/18 21:40:54 niklas Exp $ */
-/* $NetBSD: exec_ecoff.h,v 1.8 1996/03/07 14:29:44 christos Exp $ */
+/* $OpenBSD: exec_ecoff.h,v 1.4 1996/05/22 12:05:20 deraadt Exp $ */
+/* $NetBSD: exec_ecoff.h,v 1.9 1996/05/09 23:42:08 cgd Exp $ */
/*
* Copyright (c) 1994 Adam Glass
@@ -37,71 +37,74 @@
#include <machine/ecoff.h>
struct ecoff_filehdr {
- u_short ef_magic; /* magic number */
- u_short ef_nsecs; /* # of sections */
- u_int ef_timestamp; /* time and date stamp */
- u_long ef_symptr; /* file offset of symbol table */
- u_int ef_syms; /* # of symbol table entries */
- u_short ef_opthdr; /* sizeof the optional header */
- u_short ef_flags; /* flags??? */
+ u_short f_magic; /* magic number */
+ u_short f_nscns; /* # of sections */
+ u_int f_timdat; /* time and date stamp */
+ u_long f_symptr; /* file offset of symbol table */
+ u_int f_nsyms; /* # of symbol table entries */
+ u_short f_opthdr; /* sizeof the optional header */
+ u_short f_flags; /* flags??? */
};
struct ecoff_aouthdr {
- u_short ea_magic;
- u_short ea_vstamp;
+ u_short magic;
+ u_short vstamp;
ECOFF_PAD
- u_long ea_tsize;
- u_long ea_dsize;
- u_long ea_bsize;
- u_long ea_entry;
- u_long ea_text_start;
- u_long ea_data_start;
- u_long ea_bss_start;
+ u_long tsize;
+ u_long dsize;
+ u_long bsize;
+ u_long entry;
+ u_long text_start;
+ u_long data_start;
+ u_long bss_start;
ECOFF_MACHDEP;
};
struct ecoff_scnhdr { /* needed for size info */
- char es_name[8]; /* name */
- u_long es_physaddr; /* physical addr? for ROMing?*/
- u_long es_virtaddr; /* virtual addr? */
- u_long es_size; /* size */
- u_long es_raw_offset; /* file offset of raw data */
- u_long es_reloc_offset; /* file offset of reloc data */
- u_long es_line_offset; /* file offset of line data */
- u_short es_nreloc; /* # of relocation entries */
- u_short es_nline; /* # of line entries */
- u_int es_flags; /* flags */
+ char s_name[8]; /* name */
+ u_long s_paddr; /* physical addr? for ROMing?*/
+ u_long s_vaddr; /* virtual addr? */
+ u_long s_size; /* size */
+ u_long s_scnptr; /* file offset of raw data */
+ u_long s_relptr; /* file offset of reloc data */
+ u_long s_lnnoptr; /* file offset of line data */
+ u_short s_nreloc; /* # of relocation entries */
+ u_short s_nlnno; /* # of line entries */
+ u_int s_flags; /* flags */
};
-#define ECOFF_HDR_SIZE (sizeof(struct ecoff_filehdr) + \
- sizeof(struct ecoff_aouthdr))
+struct ecoff_exechdr {
+ struct ecoff_filehdr f;
+ struct ecoff_aouthdr a;
+};
+
+#define ECOFF_HDR_SIZE (sizeof(struct ecoff_exechdr))
#define ECOFF_OMAGIC 0407
#define ECOFF_NMAGIC 0410
#define ECOFF_ZMAGIC 0413
#define ECOFF_ROUND(value, by) \
- (((value) + by - 1) & ~(by - 1))
+ (((value) + (by) - 1) & ~((by) - 1))
-#define ECOFF_BLOCK_ALIGN(eap, value) \
- ((eap)->ea_magic == ECOFF_ZMAGIC ? ECOFF_ROUND(value, ECOFF_LDPGSZ) : \
- value)
+#define ECOFF_BLOCK_ALIGN(ep, value) \
+ ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_ROUND((value), ECOFF_LDPGSZ) : \
+ (value))
-#define ECOFF_TXTOFF(efp, eap) \
- ((eap)->ea_magic == ECOFF_ZMAGIC ? 0 : \
- ECOFF_ROUND(ECOFF_HDR_SIZE + (efp)->ef_nsecs * \
- sizeof(struct ecoff_scnhdr),ECOFF_SEGMENT_ALIGNMENT(eap)))
+#define ECOFF_TXTOFF(ep) \
+ ((ep)->a.magic == ECOFF_ZMAGIC ? 0 : \
+ ECOFF_ROUND(ECOFF_HDR_SIZE + (ep)->f.f_nscns * \
+ sizeof(struct ecoff_scnhdr), ECOFF_SEGMENT_ALIGNMENT(ep)))
-#define ECOFF_DATOFF(efp, eap) \
- (ECOFF_BLOCK_ALIGN(eap, ECOFF_TXTOFF(efp, eap) + (eap)->ea_tsize))
+#define ECOFF_DATOFF(ep) \
+ (ECOFF_BLOCK_ALIGN((ep), ECOFF_TXTOFF(ep) + (ep)->a.tsize))
-#define ECOFF_SEGMENT_ALIGN(eap, value) \
- (ECOFF_ROUND(value, ((eap)->ea_magic == ECOFF_ZMAGIC ? ECOFF_LDPGSZ : \
- ECOFF_SEGMENT_ALIGNMENT(eap))))
+#define ECOFF_SEGMENT_ALIGN(ep, value) \
+ (ECOFF_ROUND((value), ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_LDPGSZ : \
+ ECOFF_SEGMENT_ALIGNMENT(ep))))
#ifdef _KERNEL
int exec_ecoff_makecmds __P((struct proc *, struct exec_package *));
-int cpu_exec_ecoff_hook __P((struct proc *, struct exec_package *,
- struct ecoff_aouthdr *));
+int cpu_exec_ecoff_hook __P((struct proc *, struct exec_package *));
#endif /* _KERNEL */
#endif /* !_SYS_EXEC_ECOFF_H_ */