Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/news68k/stand/installboot Add some ELF stuff. (not ...



details:   https://anonhg.NetBSD.org/src/rev/a9939de4cd23
branches:  trunk
changeset: 499980:a9939de4cd23
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Dec 03 03:35:40 2000 +0000

description:
Add some ELF stuff. (not tested)

XXX should use MI loadfile(). (see sparc)

diffstat:

 sys/arch/news68k/stand/installboot/installboot.c |  42 +++++++++++++++++------
 1 files changed, 31 insertions(+), 11 deletions(-)

diffs (99 lines):

diff -r 5367fa80bdb5 -r a9939de4cd23 sys/arch/news68k/stand/installboot/installboot.c
--- a/sys/arch/news68k/stand/installboot/installboot.c  Sun Dec 03 02:56:25 2000 +0000
+++ b/sys/arch/news68k/stand/installboot/installboot.c  Sun Dec 03 03:35:40 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: installboot.c,v 1.1 1999/12/09 14:53:25 tsutsui Exp $ */
+/*     $NetBSD: installboot.c,v 1.2 2000/12/03 03:35:40 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -36,8 +36,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifdef __ELF__
+#define        BOOT_ELF
+#undef BOOT_AOUT
+#else
 #define        BOOT_AOUT
 #undef BOOT_ELF
+#endif
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -48,9 +53,7 @@
 #include <ufs/ufs/dir.h>
 #include <ufs/ffs/fs.h>
 #include <err.h>
-#ifdef BOOT_AOUT
 #include <a.out.h>
-#endif
 #include <sys/exec_elf.h>
 #include <fcntl.h>
 #include <nlist.h>
@@ -68,16 +71,27 @@
 #define DEFAULT_ENTRY 0x3e0000
 #endif
 
+#if 0
+#ifdef __ELF__
+#define        SYMNAME(a)      a
+#else
+#define        SYMNAME(a)      __CONCAT("_",a)
+#endif
+#else
+/* XXX: Hack in libc nlist works with both formats */
+#define        SYMNAME(a)      __CONCAT("_",a)
+#endif
+
 struct nlist nl[] = {
 #define X_BLOCKTABLE   0
-       {"_block_table"},
+       { {SYMNAME("block_table")} },
 #define X_BLOCKCOUNT   1
-       {"_block_count"},
+       { {SYMNAME("block_count")} },
 #define X_BLOCKSIZE    2
-       {"_block_size"},
+       { {SYMNAME("block_size")} },
 #define X_ENTRY_POINT  3
-       {"_entry_point"},
-       {NULL}
+       { {SYMNAME("entry_point")} },
+       { {NULL} }
 };
 
 daddr_t        *block_table;           /* block number array in prototype image */
@@ -200,7 +214,7 @@
        long *size;
 {
        int     fd, sz;
-       char    *bp;
+       char    *bp, *p;
        struct  stat statbuf;
 #ifdef BOOT_AOUT
        struct  exec *hp;
@@ -264,7 +278,7 @@
        sz = 1024*7;
 
        /* Find first executable psect */
-       while ((ph->p_flags & Elf_pf_x) == 0) {
+       while ((ph->p_flags & PF_X) == 0) {
                ph++;           /* XXX check overrun (eh->e_phnum) */
                eh->e_phnum--;
                if (eh->e_phnum == 0) {
@@ -321,7 +335,13 @@
        }
 
        *size = sz;
-       return bp + sizeof(struct exec) + 0x200;        /* XXX 0x200 */
+#ifdef BOOT_AOUT
+       p = bp + sizeof(struct exec) + 0x200;   /* XXX 0x200 */
+#endif
+#ifdef BOOT_ELF
+       p = bp + ph->p_offset + 0x200;          /* XXX 0x200 */
+#endif
+       return p;
 }
 
 static void



Home | Main Index | Thread Index | Old Index