Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys EXEC_COFF cleanup
details: https://anonhg.NetBSD.org/src/rev/c5d3db935ed2
branches: trunk
changeset: 480083:c5d3db935ed2
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Sun Jan 02 13:39:49 2000 +0000
description:
EXEC_COFF cleanup
diffstat:
sys/arch/sh3/include/coff_machdep.h | 215 ++++++++++++++++++++++++++++++-----
sys/arch/sh3/sh3/coff_exec.c | 44 +-------
sys/kern/exec_conf.c | 18 +-
sys/sys/exec_coff.h | 48 ++++++++
4 files changed, 239 insertions(+), 86 deletions(-)
diffs (truncated from 398 to 300 lines):
diff -r 076774b646f1 -r c5d3db935ed2 sys/arch/sh3/include/coff_machdep.h
--- a/sys/arch/sh3/include/coff_machdep.h Sun Jan 02 13:34:25 2000 +0000
+++ b/sys/arch/sh3/include/coff_machdep.h Sun Jan 02 13:39:49 2000 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: coff_machdep.h,v 1.1 1999/09/13 10:31:15 itojun Exp $ */
+/* $NetBSD: coff_machdep.h,v 1.2 2000/01/02 13:39:51 msaitoh Exp $ */
-/*-
- * Copyright (c) 1997 The NetBSD Foundation, Inc.
+/*
+ * Copyright (c) 1994, 1995 Scott Bartram
* All rights reserved.
*
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum.
+ * adapted from sys/sys/exec_ecoff.h
+ * based on Intel iBCS2
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -15,39 +15,188 @@
* 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``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 FOUNDATION OR CONTRIBUTORS
- * 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.
+ * 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.
+ */
+
+#ifndef _SH3_COFF_MACHDEP_H_
+#define _SH3_COFF_MACHDEP_H_
+
+/*
+ * COFF file header
+ */
+
+struct coff_filehdr {
+ u_short f_magic; /* magic number */
+ u_short f_nscns; /* # of sections */
+ long f_timdat; /* timestamp */
+ long f_symptr; /* file offset of symbol table */
+ long f_nsyms; /* # of symbol table entries */
+ u_short f_opthdr; /* size of optional header */
+ u_short f_flags; /* flags */
+};
+
+/* f_magic flags */
+#define COFF_MAGIC_SH3_BIG 0x500
+#define COFF_MAGIC_SH3_LITTLE 0x550
+
+/* f_flags */
+#define COFF_F_RELFLG 0x1
+#define COFF_F_EXEC 0x2
+#define COFF_F_LNNO 0x4
+#define COFF_F_LSYMS 0x8
+#define COFF_F_SWABD 0x40
+#define COFF_F_AR16WR 0x80
+#define COFF_F_AR32WR 0x100
+#define COFF_F_AR32W 0x200
+
+/*
+ * COFF system header
+ */
+
+struct coff_aouthdr {
+ short a_magic;
+ short a_vstamp;
+ long a_tsize;
+ long a_dsize;
+ long a_bsize;
+ long a_entry;
+ long a_tstart;
+ long a_dstart;
+};
+
+/* magic */
+#define COFF_OMAGIC 0444 /* text not write-protected; data seg
+ is contiguous with text */
+#define COFF_NMAGIC 0410 /* text is write-protected; data starts
+ at next seg following text */
+#define COFF_ZMAGIC 0000 /* text and data segs are aligned for
+ direct paging */
+#define COFF_SMAGIC 0443 /* shared lib */
+
+/*
+ * COFF section header
*/
-#ifndef _COFF_MACHDEP_H_
-#define _COFF_MACHDEP_H_
+struct coff_scnhdr {
+ char s_name[8];
+ long s_paddr;
+ long s_vaddr;
+ long s_size;
+ long s_scnptr;
+ long s_relptr;
+ long s_lnnoptr;
+ u_short s_nreloc;
+ u_short s_nlnno;
+ long s_flags;
+};
-#ifdef _KERNEL
-struct exec_package;
-struct exec_vmcmd;
+/* s_flags */
+#define COFF_STYP_REG 0x00
+#define COFF_STYP_DSECT 0x01
+#define COFF_STYP_NOLOAD 0x02
+#define COFF_STYP_GROUP 0x04
+#define COFF_STYP_PAD 0x08
+#define COFF_STYP_COPY 0x10
+#define COFF_STYP_TEXT 0x20
+#define COFF_STYP_DATA 0x40
+#define COFF_STYP_BSS 0x80
+#define COFF_STYP_INFO 0x200
+#define COFF_STYP_OVER 0x400
+#define COFF_STYP_SHLIB 0x800
+
+/*
+ * COFF shared library header
+ */
+
+struct coff_slhdr {
+ long entry_len; /* in words */
+ long path_index; /* in words */
+ char sl_name[1];
+};
+
+struct coff_exechdr {
+ struct coff_filehdr f;
+ struct coff_aouthdr a;
+};
+
+#define COFF_ROUND(val, by) (((val) + by - 1) & ~(by - 1))
+
+#define COFF_ALIGN(a) ((a) & ~(COFF_LDPGSZ - 1))
+
+#define COFF_HDR_SIZE \
+ (sizeof(struct coff_filehdr) + sizeof(struct coff_aouthdr))
+
+#define COFF_BLOCK_ALIGN(ap, value) \
+ ((ap)->a_magic == COFF_ZMAGIC ? COFF_ROUND(value, COFF_LDPGSZ) : \
+ value)
-#if 0
-void ibcs2_setregs __P((struct proc *, struct exec_package *,
- u_long));
+#define COFF_TXTOFF(fp, ap) \
+ ((ap)->a_magic == COFF_ZMAGIC ? 0 : \
+ COFF_ROUND(COFF_HDR_SIZE + (fp)->f_nscns * \
+ sizeof(struct coff_scnhdr), \
+ COFF_SEGMENT_ALIGNMENT(fp, ap)))
+
+#define COFF_DATOFF(fp, ap) \
+ (COFF_BLOCK_ALIGN(ap, COFF_TXTOFF(fp, ap) + (ap)->a_tsize))
+
+#define COFF_SEGMENT_ALIGN(fp, ap, value) \
+ (COFF_ROUND(value, ((ap)->a_magic == COFF_ZMAGIC ? COFF_LDPGSZ : \
+ COFF_SEGMENT_ALIGNMENT(fp, ap))))
+
+#define COFF_LDPGSZ 4096
+
+#define COFF_SEGMENT_ALIGNMENT(fp, ap) \
+ (((fp)->f_flags & COFF_F_EXEC) == 0 ? 4 : 16)
+
+#ifndef BYTE_ORDER
+#error Define BYTE_ORDER!
+#endif
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define COFF_BADMAG(ex) ((ex)->f_magic != COFF_MAGIC_SH3_BIG)
+#endif
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define COFF_BADMAG(ex) ((ex)->f_magic != COFF_MAGIC_SH3_LITTLE)
#endif
-#endif /* _KERNEL */
+
+#define IBCS2_HIGH_SYSCALL(n) (((n) & 0x7f) == 0x28)
+#define IBCS2_CVT_HIGH_SYSCALL(n) (((n) >> 8) + 128)
+
+#ifdef DEBUG_COFF
+#define DPRINTF(a) printf a;
+#else
+#define DPRINTF(a)
+#endif
+
+#define COFF_ES_SYMNMLEN 8
+#define COFF_ES_SYMENTSZ 18
-#endif /* !_COFF_MACHDEP_H_ */
+struct external_syment {
+ union {
+ char e_name[COFF_ES_SYMNMLEN];
+ struct {
+ char e_zeroes[4];
+ char e_offset[4];
+ } e;
+ } e;
+ char e_value[4];
+ char e_scnum[2];
+ char e_type[2];
+ char e_sclass[1];
+ char e_numaux[1];
+};
+#endif /* !_SH3_COFF_MACHDEP_H_ */
+
diff -r 076774b646f1 -r c5d3db935ed2 sys/arch/sh3/sh3/coff_exec.c
--- a/sys/arch/sh3/sh3/coff_exec.c Sun Jan 02 13:34:25 2000 +0000
+++ b/sys/arch/sh3/sh3/coff_exec.c Sun Jan 02 13:39:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: coff_exec.c,v 1.5 1999/12/24 08:32:58 msaitoh Exp $ */
+/* $NetBSD: coff_exec.c,v 1.6 2000/01/02 13:39:51 msaitoh Exp $ */
/*
* Copyright (c) 1994, 1995 Scott Bartram
@@ -44,21 +44,7 @@
#include <sys/namei.h>
#include <vm/vm.h>
-#include <machine/exec_coff.h>
-#include <machine/coff_machdep.h>
-
-int exec_coff_prep_omagic __P((struct proc *, struct exec_package *,
- struct coff_filehdr *,
- struct coff_aouthdr *));
-int exec_coff_prep_nmagic __P((struct proc *, struct exec_package *,
- struct coff_filehdr *,
- struct coff_aouthdr *));
-int exec_coff_prep_zmagic __P((struct proc *, struct exec_package *,
- struct coff_filehdr *,
- struct coff_aouthdr *));
-int exec_coff_setup_stack __P((struct proc *, struct exec_package *));
-void cpu_exec_coff_setup __P((int, struct proc *, struct exec_package *,
- void *));
+#include <sys/exec_coff.h>
#if 0
int coff_load_shlib __P((struct proc *, char *, struct exec_package *));
@@ -68,32 +54,6 @@
struct coff_filehdr *, struct coff_scnhdr *,
int));
-#if 0
-
-extern int bsd2ibcs_errno[];
-extern struct sysent ibcs2_sysent[];
-extern char *ibcs2_syscallnames[];
-extern void ibcs2_sendsig __P((sig_t, int, int, u_long));
-extern char sigcode[], esigcode[];
-
-const char ibcs2_emul_path[] = "/emul/ibcs2";
-
-struct emul emul_ibcs2 = {
- "ibcs2",
- bsd2ibcs_errno,
- ibcs2_sendsig,
- 0,
- IBCS2_SYS_MAXSYSCALL,
- ibcs2_sysent,
- ibcs2_syscallnames,
- 0,
- copyargs,
- ibcs2_setregs,
- sigcode,
- esigcode,
-};
-#endif
-
/*
Home |
Main Index |
Thread Index |
Old Index