From 3a38f291a77d6047dd0d11641b2c9fdf43bed257 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Wed, 23 Apr 2014 21:43:09 -0700 Subject: [PATCH] Merged kernel support for ELF executable format from karolina.lindqvist. Now kernel can directly run executables generated by gcc. --- include/a.out.h | 24 +- src/cmd/as/aout.c | 12 +- src/cmd/as/as.c | 2 +- src/cmd/ld/ld.c | 10 +- src/cmd/strip.c | 4 +- sys/include/exec.h | 116 +++++- sys/include/exec_aout.h | 102 +++++ sys/include/exec_elf.h | 496 +++++++++++++++++++++++++ sys/include/proc.h | 2 + sys/kernel/exec_aout.c | 95 +++++ sys/kernel/exec_conf.c | 59 +++ sys/kernel/exec_elf.c | 207 +++++++++++ sys/kernel/exec_script.c | 96 +++++ sys/kernel/exec_subr.c | 425 +++++++++++++++++++++ sys/kernel/kern_exec.c | 555 +++++----------------------- sys/kernel/kern_sig.c | 37 ++ sys/pic32/32mxsdram-uart/Makefile | 5 +- sys/pic32/baremetal/Makefile | 5 +- sys/pic32/cfg/kernel.dev | 8 + sys/pic32/dip/Makefile | 5 +- sys/pic32/duinomite-uart/Makefile | 5 +- sys/pic32/duinomite/Makefile | 5 +- sys/pic32/elf_machdep.h | 88 +++++ sys/pic32/explorer16/Makefile | 5 +- sys/pic32/fubarino/Makefile | 5 +- sys/pic32/max32-eth/Makefile | 5 +- sys/pic32/max32/Makefile | 5 +- sys/pic32/maximite/Makefile | 5 +- sys/pic32/meb/Makefile | 5 +- sys/pic32/mmb-mx7/Makefile | 5 +- sys/pic32/pinguino-micro/Makefile | 5 +- sys/pic32/starter-kit/Makefile | 5 +- sys/pic32/ubw32-uart-sdram/Makefile | 5 +- sys/pic32/ubw32-uart/Makefile | 5 +- sys/pic32/ubw32/Makefile | 5 +- 35 files changed, 1881 insertions(+), 542 deletions(-) create mode 100644 sys/include/exec_aout.h create mode 100644 sys/include/exec_elf.h create mode 100644 sys/kernel/exec_aout.c create mode 100644 sys/kernel/exec_conf.c create mode 100644 sys/kernel/exec_elf.c create mode 100644 sys/kernel/exec_script.c create mode 100644 sys/kernel/exec_subr.c create mode 100644 sys/pic32/elf_machdep.h diff --git a/include/a.out.h b/include/a.out.h index af3533e..4b03a12 100644 --- a/include/a.out.h +++ b/include/a.out.h @@ -33,29 +33,7 @@ #ifndef _AOUT_H_ #define _AOUT_H_ -#include - -/* Valid magic number check. */ -#define N_BADMAG(x) (((x).a_magic) != RMAGIC && \ - ((x).a_magic) != OMAGIC && \ - ((x).a_magic) != NMAGIC) - -/* Text segment offset. */ -#define N_TXTOFF(x) sizeof(struct exec) - -/* Data segment offset. */ -#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text) - -/* Text relocation table offset. */ -#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data) - -/* Data relocation table offset. */ -#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_reltext) - -/* Symbol table offset. */ -#define N_SYMOFF(x) ((x).a_magic == RMAGIC ? \ - N_DRELOFF(x) + (x).a_reldata : \ - N_DATOFF(x) + (x).a_data) +#include #define _AOUT_INCLUDE_ #include diff --git a/src/cmd/as/aout.c b/src/cmd/as/aout.c index f47b013..f22f82e 100644 --- a/src/cmd/as/aout.c +++ b/src/cmd/as/aout.c @@ -55,7 +55,7 @@ int fgethdr (text, h) register FILE *text; register struct exec *h; { - h->a_magic = fgetword (text); + h->a_midmag = fgetword (text); h->a_text = fgetword (text); h->a_data = fgetword (text); h->a_bss = fgetword (text); @@ -235,7 +235,7 @@ void disasm (fname) return; } if (rflag) { - if (hdr.a_magic != RMAGIC) { + if (N_GETMAGIC(hdr) != RMAGIC) { fprintf (stderr, "aout: %s is not relocatable\n", fname); rflag = 0; @@ -250,9 +250,9 @@ void disasm (fname) } printf ("File %s:\n", fname); printf (" a_magic = %08x (%s)\n", hdr.a_magic, - hdr.a_magic == RMAGIC ? "relocatable" : - hdr.a_magic == OMAGIC ? "OMAGIC" : - hdr.a_magic == NMAGIC ? "NMAGIC" : "unknown"); + N_GETMAGIC(hdr) == RMAGIC ? "relocatable" : + N_GETMAGIC(hdr) == OMAGIC ? "OMAGIC" : + N_GETMAGIC(hdr) == NMAGIC ? "NMAGIC" : "unknown"); printf (" a_text = %08x (%u bytes)\n", hdr.a_text, hdr.a_text); printf (" a_data = %08x (%u bytes)\n", hdr.a_data, hdr.a_data); printf (" a_bss = %08x (%u bytes)\n", hdr.a_bss, hdr.a_bss); @@ -261,7 +261,7 @@ void disasm (fname) printf (" a_syms = %08x (%u bytes)\n", hdr.a_syms, hdr.a_syms); printf (" a_entry = %08x\n", hdr.a_entry); - addr = (hdr.a_magic == RMAGIC) ? 0 : USER_CODE_START; + addr = ((hdr.a_magic) == RMAGIC) ? 0 : USER_CODE_START; if (hdr.a_text > 0) { printf ("\nSection .text:\n"); diff --git a/src/cmd/as/as.c b/src/cmd/as/as.c index 3d00eae..06bab88 100644 --- a/src/cmd/as/as.c +++ b/src/cmd/as/as.c @@ -2339,7 +2339,7 @@ void makeheader (rtsize, rdsize) { struct exec hdr; - hdr.a_magic = RMAGIC; + hdr.a_midmag = RMAGIC; hdr.a_text = count [STEXT]; hdr.a_data = count [SDATA] + count [SSTRNG]; hdr.a_bss = count [SBSS]; diff --git a/src/cmd/ld/ld.c b/src/cmd/ld/ld.c index c3ee90d..00a24da 100644 --- a/src/cmd/ld/ld.c +++ b/src/cmd/ld/ld.c @@ -172,7 +172,7 @@ int fgethdr (text, h) register FILE *text; register struct exec *h; { - h->a_magic = fgetword (text); + h->a_midmag = fgetword (text); h->a_text = fgetword (text); h->a_data = fgetword (text); h->a_bss = fgetword (text); @@ -860,7 +860,7 @@ void readhdr (loc) fseek (text, loc, 0); if (! fgethdr (text, &filhdr)) error (2, "bad format"); - if (filhdr.a_magic != RMAGIC) + if (N_GETMAGIC(filhdr) != RMAGIC) error (2, "bad magic"); if (filhdr.a_text % W) error (2, "bad length of text"); @@ -880,7 +880,7 @@ int load1 (loc, libflg, nloc) int savindex, ndef, type, symlen, nsymbol; readhdr (loc); - if (filhdr.a_magic != RMAGIC) { + if (N_GETMAGIC(filhdr) != RMAGIC) { error (1, "file not relocatable"); return (0); } @@ -1293,7 +1293,7 @@ void setupout () } else { close(fd); } - + tcreat (&toutb, 1); tcreat (&doutb, 1); @@ -1494,7 +1494,7 @@ void finishout () while (ssize++ % W) putc (0, outb); } - filhdr.a_magic = output_relinfo ? RMAGIC : OMAGIC; + filhdr.a_midmag = output_relinfo ? RMAGIC : OMAGIC; filhdr.a_text = tsize; filhdr.a_data = dsize; filhdr.a_bss = bsize; diff --git a/src/cmd/strip.c b/src/cmd/strip.c index 5fa9970..4db2d96 100644 --- a/src/cmd/strip.c +++ b/src/cmd/strip.c @@ -35,7 +35,7 @@ strip(name) status = 1; goto out; } - if (head.a_syms == 0 && head.a_magic != RMAGIC) + if (head.a_syms == 0 && (head.a_magic) != RMAGIC) goto out; size = N_DATOFF(head) + head.a_data; @@ -45,7 +45,7 @@ strip(name) status = 1; goto out; } - head.a_magic = OMAGIC; + head.a_midmag = OMAGIC; head.a_reltext = 0; head.a_reldata = 0; head.a_syms = 0; diff --git a/sys/include/exec.h b/sys/include/exec.h index 1d11579..13c5880 100644 --- a/sys/include/exec.h +++ b/sys/include/exec.h @@ -4,25 +4,103 @@ * specifies the terms and conditions for redistribution. */ -#ifndef _EXEC_ -#define _EXEC_ -/* - * Header prepended to each a.out file. - */ -struct exec { - int a_magic; /* magic number */ -unsigned int a_text; /* size of text segment */ -unsigned int a_data; /* size of initialized data */ -unsigned int a_bss; /* size of uninitialized data */ -unsigned int a_reltext; /* size of text relocation info */ -unsigned int a_reldata; /* size of data relocation info */ -unsigned int a_syms; /* size of symbol table */ -unsigned int a_entry; /* entry point */ +#ifndef _SYS_EXEC_H_ +#define _SYS_EXEC_H_ +#ifdef KERNEL + +#ifdef EXEC_SCRIPT +#define SHSIZE 64 +#define SHPATHLEN 64 +#endif +#ifdef EXEC_ELF +#define STRLEN 32 +#endif +#ifdef EXEC_AOUT +#include "exec_aout.h" +#endif +#ifdef EXEC_ELF +#include "exec_elf.h" +#endif + +#define NO_ADDR ((caddr_t)(~0U)) /* Indicates addr. not yet filled in */ + +struct memsect { + caddr_t vaddr; + unsigned len; }; -/* a_magic */ -#define RMAGIC 0406 /* relocatable object file */ -#define OMAGIC 0407 /* old impure format */ -#define NMAGIC 0410 /* read-only text */ - +struct exec_params { + char *userfname; /* The arguments to the exec() call */ + char **userargp; + char **userenvp; + union { +#ifdef EXEC_SCRIPT + char sh[SHSIZE]; +#endif +#ifdef EXEC_AOUT + struct exec aout; +#endif +#ifdef EXEC_ELF + struct elf_ehdr elf; +#endif + } hdr; /* head of file to exec */ + int hdr_len; /* number of bytes valid in image_header */ + char **argp, **envp; + u_short argc, envc; /* count of argument and environment strings */ + u_short argbc, envbc; /* total number of chars in argc and envc string pool */ + union { +#ifdef EXEC_SCRIPT + struct { + char interpname[20]; /* real name of the script interpreter */ + char interparg[SHPATHLEN]; /* interpreter arg */ + char interpreted; /* flag - this executable is interpreted */ + } sh; +#endif +#ifdef EXEC_ELF + struct { + struct buf *stbp; /* String table buffer pointer */ + int stbpos; /* String table pos in buffer */ + int stsize; /* String table size */ + int stoffset; /* String table file pos */ + char str[STRLEN]; + } elf; +#endif +#ifdef EXEC_AOUT + struct { + } aout; +#endif + }; + + gid_t gid; + uid_t uid; +#define MAXALLOCBUF 6 + struct { + struct buf *bp; /* Memory allocator buffer */ + u_short fill; /* Memory allocator "free" pointer */ + } alloc[MAXALLOCBUF]; + u_long ep_taddr, ep_tsize, ep_daddr, ep_dsize; + struct inode *ip; /* executable file ip */ + struct memsect text, data, bss, heap, stack; +}; + +struct execsw { + int (*es_check)(struct exec_params *epp); + const char* es_name; +}; +extern const struct execsw execsw[]; +extern int nexecs, exec_maxhdrsz; + + +struct buf *exec_copy_args(char **argp, struct exec_params *epp, int isargv, int *argc, int *argbc); +int exec_check(struct exec_params *epp); +void exec_setupstack(unsigned entryaddr, struct exec_params *epp); +void exec_alloc_freeall(struct exec_params *epp); +void *exec_alloc(int size, int ru, struct exec_params *epp); +int exec_estab(struct exec_params *epp); +void exec_save_args(struct exec_params *epp); +void exec_clear(struct exec_params *epp); + +#else /* KERNEL */ +#include +#endif #endif diff --git a/sys/include/exec_aout.h b/sys/include/exec_aout.h new file mode 100644 index 0000000..5afbcf0 --- /dev/null +++ b/sys/include/exec_aout.h @@ -0,0 +1,102 @@ +#ifndef _SYS_EXEC_AOUT_H_ +#define _SYS_EXEC_AOUT_H_ + +/* + * Header prepended to each a.out file. + */ +struct exec { + unsigned a_midmag; /* magic number */ + unsigned a_text; /* size of text segment */ + unsigned a_data; /* size of initialized data */ + unsigned a_bss; /* size of uninitialized data */ + unsigned a_reltext; /* size of text relocation info */ + unsigned a_reldata; /* size of data relocation info */ + unsigned a_syms; /* size of symbol table */ + unsigned a_entry; /* entry point */ +}; + +#define a_magic a_midmag & 0xffff + +/* a_magic (a_midmag & 0x0000ffff) */ +#define RMAGIC 0406 /* relocatable object file */ +#define OMAGIC 0407 /* old impure format */ +#define NMAGIC 0410 /* read-only text */ + +/* + * a_mid ((a_midmag & 0x03ff0000) >> 16) + */ +#define MID_ZERO 0 /* unknown - implementation dependent */ +#define MID_SUN010 1 /* sun 68010/68020 binary */ +#define MID_SUN020 2 /* sun 68020-only binary */ +#define MID_PC386 100 /* 386 PC binary. (so quoth BFD) */ +#define MID_HP200 200 /* hp200 (68010) BSD binary */ +#define MID_I386 134 /* i386 BSD binary */ +#define MID_M68K 135 /* m68k BSD binary with 8K page sizes */ +#define MID_M68K4K 136 /* m68k BSD binary with 4K page sizes */ +#define MID_NS32532 137 /* ns32532 */ +#define MID_SPARC 138 /* sparc */ +#define MID_PMAX 139 /* pmax */ +#define MID_VAX1K 140 /* vax 1K page size binaries */ +#define MID_ALPHA 141 /* Alpha BSD binary */ +#define MID_MIPS 142 /* big-endian MIPS */ +#define MID_ARM6 143 /* ARM6 */ +#define MID_SH3 145 /* SH3 */ +#define MID_POWERPC 149 /* big-endian PowerPC */ +#define MID_VAX 150 /* vax */ +#define MID_SPARC64 151 /* LP64 sparc */ +#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */ +#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */ +#define MID_HPUX800 0x20B /* hp800 HP-UX binary */ + +/* + * a_flags ((a_midmag & 0xfc000000 ) << 26) + */ +#define EX_PIC 0x10 +#define EX_DYNAMIC 0x20 +#define EX_DPMASK 0x30 +/* + * Interpretation of the (a_flags & EX_DPMASK) bits: + * + * 00 traditional executable or object file + * 01 object file contains PIC code (set by `as -k') + * 10 dynamic executable + * 11 position independent executable image + * (eg. a shared library) + */ + +/* + * The a.out structure's a_midmag field is a network-byteorder encoding + * of this int + * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM + * Where `F' is 6 bits of flag like EX_DYNAMIC, + * `m' is 10 bits of machine-id like MID_I386, and + * `M' is 16 bits worth of magic number, ie. ZMAGIC. + * The macros below will set/get the needed fields. + */ +#define N_GETMAGIC(ex) (((ex).a_midmag)&0x0000ffff) +#define N_GETMID(ex) ((((ex).a_midmag)&0x03ff0000) >> 16) +#define N_GETFLAG(ex) ((((ex).a_midmag)&0xfc000000 ) << 26) + +/* Valid magic number check. */ +#define N_BADMAG(x) (N_GETMAGIC(x) != RMAGIC && \ + N_GETMAGIC(x) != OMAGIC && \ + N_GETMAGIC(x) != NMAGIC) + +/* Text segment offset. */ +#define N_TXTOFF(x) sizeof(struct exec) + +/* Data segment offset. */ +#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text) + +/* Text relocation table offset. */ +#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data) + +/* Data relocation table offset. */ +#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_reltext) + +/* Symbol table offset. */ +#define N_SYMOFF(x) (N_GETMAGIC(x) == RMAGIC ? \ + N_DRELOFF(x) + (x).a_reldata : \ + N_DATOFF(x) + (x).a_data) + +#endif diff --git a/sys/include/exec_elf.h b/sys/include/exec_elf.h new file mode 100644 index 0000000..ccaded0 --- /dev/null +++ b/sys/include/exec_elf.h @@ -0,0 +1,496 @@ +/* $NetBSD: exec_elf.h,v 1.37.4.1 2000/07/26 23:57:06 mycroft Exp $ */ + +/*- + * Copyright (c) 1994 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. + * + * 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. +*/ + +#ifndef _SYS_EXEC_ELF_H_ +#define _SYS_EXEC_ELF_H_ + +#ifndef _SYS_TYPES_H_ +#include +#endif + +/* + * ELF Header + */ +#define ELF_NIDENT 16 + +struct elf_ehdr { + unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ + unsigned short e_type; /* file type */ + unsigned short e_machine; /* machine type */ + unsigned int e_version; /* version number */ + unsigned int e_entry; /* entry point */ + unsigned int e_phoff; /* Program header table offset */ + unsigned int e_shoff; /* Section header table offset */ + unsigned int e_flags; /* Processor flags (currently unused, should be 0) */ + unsigned short e_ehsize; /* sizeof elf_ehdr */ + unsigned short e_phentsize; /* Program header entry size */ + unsigned short e_phnum; /* Number of program headers */ + unsigned short e_shentsize; /* Section header entry size */ + unsigned short e_shnum; /* Number of section headers */ + unsigned short e_shstrndx; /* String table index */ +}; + +/* e_ident offsets */ +#define EI_MAG0 0 /* first byte of magic number */ +#define ELFMAG0 0x7f +#define EI_MAG1 1 /* second byte of magic number */ +#define ELFMAG1 'E' +#define EI_MAG2 2 /* third byte of magic number */ +#define ELFMAG2 'L' +#define EI_MAG3 3 /* fourth byte of magic number */ +#define ELFMAG3 'F' + +#define EI_CLASS 4 /* 5:th byte: File class */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +#define EI_DATA 5 /* 6:th byte: Data encoding */ +#define ELFDATANONE 0 /* Unknown data format */ +#define ELFDATA2LSB 1 /* two's complement, little-endian */ +#define ELFDATA2MSB 2 /* two's complement, big-endian */ + +#define EI_VERSION 6 /* Version number of the ELF specification */ +#define EV_NONE 0 /* Invalid version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +#define EI_OSABI 7 /* Operating system/ABI identification */ +#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX operating system */ +#define ELFOSABI_NETBSD /* NetBSD ABI */ +#define ELFOSABI_LINUX /* Linux ABI */ +#define ELFOSABI_SOLARIS /* Solaris ABI */ +#define ELFOSABI_FREEBSD /* FreeBSD ABI */ +#define ELFOSABI_ARM /* ARM architecture ABI */ +#define ELFOSABI_STANDALONE 255 /* Stand-alone (embedded) application */ + +#define EI_ABIVERSION 8 /* ABI version */ + +#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/ + +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +/* e_type */ +#define ET_NONE 0 /* Unknown file type */ +#define ET_REL 1 /* A Relocatable file */ +#define ET_EXEC 2 /* An Executable file */ +#define ET_DYN 3 /* A Shared object file */ +#define ET_CORE 4 /* A Core file */ +#define ET_NUM 5 + +#define ET_LOOS 0xfe00 /* Operating system specific range */ +#define ET_HIOS 0xfeff +#define ET_LOPROC 0xff00 /* Processor-specific range */ +#define ET_HIPROC 0xffff + +/* e_machine */ +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola 68000 */ +#define EM_88K 5 /* Motorola 88000 */ +#define EM_486 6 /* Intel 80486 */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS I Architecture */ +#define EM_S370 9 /* Amdahl UTS on System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */ +#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */ +#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */ +#define EM_NCUBE 16 /* NCube XXX reserved */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_V800 36 /* NEC V800 */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* Advanced RISC Machines ARM */ +#define EM_ALPHA 41 /* DIGITAL Alpha */ +#define EM_SH 42 /* Hitachi Super-H */ +#define EM_SPARCV9 43 /* SPARC Version 9 */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel Merced Processor */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola MC68HC12 */ +#define EM_VAX 75 /* DIGITAL VAX */ +#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */ +#define EM_NUM 36903 + +/* + * ELF Program Header + */ +struct elf_phdr { + unsigned int p_type; /* entry type */ + unsigned int p_offset; /* file offset */ + unsigned int p_vaddr; /* virtual address */ + unsigned int p_paddr; /* physical address (reserved, 0) */ + unsigned int p_filesz; /* file size of segment (may be 0) */ + unsigned int p_memsz; /* memory size of segment (may be 0) */ + unsigned int p_flags; /* flags */ + unsigned int p_align; /* memory & file alignment */ +}; + +/* p_type */ +#define PT_NULL 0 /* Program header table entry unused */ +#define PT_LOAD 1 /* Loadable program segment */ +#define PT_DYNAMIC 2 /* Dynamic linking information */ +#define PT_INTERP 3 /* Program interpreter */ +#define PT_NOTE 4 /* Auxiliary information */ +#define PT_SHLIB 5 /* Reserved, unspecified semantics */ +#define PT_PHDR 6 /* Entry for header table itself */ +#define PT_NUM 7 +#define PT_LOPROC 0x70000000 /* Start of processor-specific semantics */ +#define PT_HIPROC 0x7fffffff /* end of processor-specific semantics */ +#define PT_GNU_STACK /* GNU stack extension */ + +/* p_flags */ +#define PF_R 0x4 /* Segment is readable */ +#define PF_W 0x2 /* Segment is writable */ +#define PF_X 0x1 /* Segment is executable */ +/* A text segment commonly have PF_X|PF_R, a data segment PF_X|PF_W and PF_R */ + +#define PF_MASKOS 0x0ff00000 /* Opersting system specific values */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific values */ + + +#define PT_MIPS_REGINFO 0x70000000 + +/* + * Section Headers + */ +struct elf_shdr { + unsigned int sh_name; /* section name (.shstrtab index) */ + unsigned int sh_type; /* section type */ + unsigned int sh_flags; /* section flags */ + unsigned int sh_addr; /* virtual address */ + unsigned int sh_offset; /* file offset */ + unsigned int sh_size; /* section size */ + unsigned int sh_link; /* link to another */ + unsigned int sh_info; /* misc info */ + unsigned int sh_addralign; /* memory alignment */ + unsigned int sh_entsize; /* table entry size */ +}; + +/* sh_type */ +#define SHT_NULL 0 /* inactive */ +#define SHT_PROGBITS 1 /* program defined contents */ +#define SHT_SYMTAB 2 /* holds symbol table */ +#define SHT_STRTAB 3 /* holds string table */ +#define SHT_RELA 4 /* holds relocation info with explicit addends */ +#define SHT_HASH 5 /* holds symbol hash table */ +#define SHT_DYNAMIC 6 /* holds dynamic linking information */ +#define SHT_NOTE 7 /* holds information marking */ +#define SHT_NOBITS 8 /* holds a section that does not occupy space */ +#define SHT_REL 9 /* holds relocation info without explicit addends */ +#define SHT_SHLIB 10 /* reserved with unspecified semantics */ +#define SHT_DYNSYM 11 /* holds a minimal set of dynamic linking symbols */ +#define SHT_NUM 12 + +#define SHT_LOOS 0x60000000 /* Operating system specific range */ +#define SHT_HIOS 0x6fffffff +#define SHT_LOPROC 0x70000000 /* Processor-specific range */ +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 /* Application-specific range */ +#define SHT_HIUSER 0xffffffff + +/* sh_flags */ +#define SHF_WRITE 0x1 /* Section contains writable data */ +#define SHF_ALLOC 0x2 /* Section occupies memory */ +#define SHF_EXECINSTR 0x4 /* Section contains executable insns */ + +#define SHF_MASKOS 0x0f000000 /* Operating system specific values */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific values */ + +/* + * Symbol Table + */ +struct elf_sym { + unsigned int st_name; /* Symbol name (.symtab index) */ + unsigned int st_value; /* value of symbol */ + unsigned int st_size; /* size of symbol */ + unsigned char st_info; /* type / binding attrs */ + unsigned char st_other; /* unused */ + unsigned short st_shndx; /* section index of symbol */ +}; + +/* Symbol Table index of the undefined symbol */ +#define ELF_SYM_UNDEFINED 0 + +/* st_info: Symbol Bindings */ +#define STB_LOCAL 0 /* local symbol */ +#define STB_GLOBAL 1 /* global symbol */ +#define STB_WEAK 2 /* weakly defined global symbol */ +#define STB_NUM 3 + +#define STB_LOOS 10 /* Operating system specific range */ +#define STB_HIOS 12 +#define STB_LOPROC 13 /* Processor-specific range */ +#define STB_HIPROC 15 + +/* st_info: Symbol Types */ +#define STT_NOTYPE 0 /* Type not specified */ +#define STT_OBJECT 1 /* Associated with a data object */ +#define STT_FUNC 2 /* Associated with a function */ +#define STT_SECTION 3 /* Associated with a section */ +#define STT_FILE 4 /* Associated with a file name */ +#define STT_NUM 5 + +#define STT_LOOS 10 /* Operating system specific range */ +#define STT_HIOS 12 +#define STT_LOPROC 13 /* Processor-specific range */ +#define STT_HIPROC 15 + +/* st_info utility macros */ +#define ELF_ST_BIND(info) ((unsigned int)(info) >> 4) +#define ELF_ST_TYPE(info) ((unsigned int)(info) & 0xf) +#define ELF_ST_INFO(bind,type) ((unsigned char)(((bind) << 4) | ((type) & 0xf))) + +/* + * Special section indexes + */ +#define SHN_UNDEF 0 /* Undefined section */ + +#define SHN_LORESERVE 0xff00 /* Start of Reserved range */ +#define SHN_ABS 0xfff1 /* Absolute symbols */ +#define SHN_COMMON 0xfff2 /* Common symbols */ +#define SHN_HIRESERVE 0xffff + +#define SHN_LOPROC 0xff00 /* Start of Processor-specific range */ +#define SHN_HIPROC 0xff1f +#define SHN_LOOS 0xff20 /* Operating system specific range */ +#define SHN_HIOS 0xff3f + +#define SHN_MIPS_ACOMMON 0xff00 +#define SHN_MIPS_TEXT 0xff01 +#define SHN_MIPS_DATA 0xff02 +#define SHN_MIPS_SCOMMON 0xff03 + +/* + * Relocation Entries + */ +struct elf_rel { + unsigned int r_offset; /* where to do it */ + unsigned int r_info; /* index & type of relocation */ +}; + +struct elf_rela { + unsigned int r_offset; /* where to do it */ + unsigned int r_info; /* index & type of relocation */ + int r_addend; /* adjustment value */ +}; + +/* r_info utility macros */ +#define ELF_R_SYM(info) ((info) >> 8) +#define ELF_R_TYPE(info) ((info) & 0xff) +#define ELF_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) + +/* + * Dynamic Section structure array + */ +struct elf_dyn { + unsigned int d_tag; /* entry tag value */ + union { + unsigned int d_ptr; + unsigned int d_val; + } d_un; +}; + +/* d_tag */ +#define DT_NULL 0 /* Marks end of dynamic array */ +#define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */ +#define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */ +#define DT_PLTGOT 3 /* Address of PLT and/or GOT */ +#define DT_HASH 4 /* Address of symbol hash table */ +#define DT_STRTAB 5 /* Address of string table */ +#define DT_SYMTAB 6 /* Address of symbol table */ +#define DT_RELA 7 /* Address of Rela relocation table */ +#define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */ +#define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */ +#define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */ +#define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */ +#define DT_INIT 12 /* Address of initialization function */ +#define DT_FINI 13 /* Address of termination function */ +#define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */ +#define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */ +#define DT_SYMBOLIC 16 /* Start symbol search within local object */ +#define DT_REL 17 /* Address of Rel relocation table */ +#define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */ +#define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */ +#define DT_PLTREL 20 /* Type of PLT relocation entries */ +#define DT_DEBUG 21 /* Used for debugging; unspecified */ +#define DT_TEXTREL 22 /* Relocations might modify non-writable seg */ +#define DT_JMPREL 23 /* Address of relocations associated with PLT */ +#define DT_BIND_NOW 24 /* Process all relocations at load-time */ +#define DT_INIT_ARRAY 25 /* Address of initialization function array */ +#define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */ +#define DT_INIT_ARRAYSZ 27 /* Address of termination function array */ +#define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/ +#define DT_NUM 29 + +#define DT_LOOS 0x60000000 /* Operating system specific range */ +#define DT_HIOS 0x6fffffff +#define DT_LOPROC 0x70000000 /* Processor-specific range */ +#define DT_HIPROC 0x7fffffff + +/* + * Auxiliary Vectors + */ +struct elf_auxinfo { + unsigned int a_type; /* 32-bit id */ + unsigned int a_v; /* 32-bit id */ +}; + +/* a_type */ +#define AT_NULL 0 /* Marks end of array */ +#define AT_IGNORE 1 /* No meaning, a_un is undefined */ +#define AT_EXECFD 2 /* Open file descriptor of object file */ +#define AT_PHDR 3 /* &phdr[0] */ +#define AT_PHENT 4 /* sizeof(phdr[0]) */ +#define AT_PHNUM 5 /* # phdr entries */ +#define AT_PAGESZ 6 /* PAGESIZE */ +#define AT_BASE 7 /* Interpreter base addr */ +#define AT_FLAGS 8 /* Processor flags */ +#define AT_ENTRY 9 /* Entry address of executable */ +#define AT_DCACHEBSIZE 10 /* Data cache block size */ +#define AT_ICACHEBSIZE 11 /* Instruction cache block size */ +#define AT_UCACHEBSIZE 12 /* Unified cache block size */ + + /* Vendor specific */ +#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */ + +#define AT_SUN_UID 2000 /* euid */ +#define AT_SUN_RUID 2001 /* ruid */ +#define AT_SUN_GID 2002 /* egid */ +#define AT_SUN_RGID 2003 /* rgid */ + + /* Solaris kernel specific */ +#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ +#define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */ +#define AT_SUN_LDNAME 2006 /* dynamic linker's name */ +#define AT_SUN_LPGSIZE 2007 /* large pagesize */ + + /* Other information */ +#define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */ +#define AT_SUN_HWCAP 2009 /* process hardware capabilities */ +#define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */ +#define AT_SUN_CPU 2011 /* cpu name */ + /* ibcs2 emulation band aid */ +#define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */ +#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */ + /* Executable's fully resolved name */ +#define AT_SUN_EXECNAME 2014 + +/* + * Note Headers + */ +struct elf_nhdr { + + unsigned int n_namesz; + unsigned int n_descsz; + unsigned int n_type; +}; + +#define ELF_NOTE_TYPE_OSVERSION 1 + +/* NetBSD-specific note type: Emulation name. desc is emul name string. */ +#define ELF_NOTE_NETBSD_TYPE_EMULNAME 2 + +/* NetBSD-specific note name and description sizes */ +#define ELF_NOTE_NETBSD_NAMESZ 7 +#define ELF_NOTE_NETBSD_DESCSZ 4 +/* NetBSD-specific note name */ +#define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" + +/* GNU-specific note name and description sizes */ +#define ELF_NOTE_GNU_NAMESZ 4 +#define ELF_NOTE_GNU_DESCSZ 4 +/* GNU-specific note name */ +#define ELF_NOTE_GNU_NAME "GNU\0" + +/* GNU-specific OS/version value stuff */ +#define ELF_NOTE_GNU_OSMASK (unsigned int)0xff000000 +#define ELF_NOTE_GNU_OSLINUX (unsigned int)0x01000000 +#define ELF_NOTE_GNU_OSMACH (unsigned int)0x00000000 + +//#define CONCAT(x,y) __CONCAT(x,y) + + +#include + + +#ifdef _KERNEL + +#define ELF_AUX_ENTRIES 8 /* Size of aux array passed to loader */ + +struct elf_args { + unsigned int arg_entry; /* program entry point */ + unsigned int arg_interp; /* Interpreter load address */ + unsigned int arg_phaddr; /* program header address */ + unsigned int arg_phentsize; /* Size of program header */ + unsigned int arg_phnum; /* Number of program headers */ +}; + +#ifndef _LKM +#include "opt_execfmt.h" +#endif + +#ifdef EXEC_ELF +int exec_elf_makecmds __P((struct proc *, struct exec_package *)); +int elf_read_from __P((struct proc *, struct vnode *, u_long, + caddr_t, int)); +void *elf_copyargs __P((struct exec_package *, struct ps_strings *, + void *, void *)); +#endif + +/* common */ +int exec_elf_setup_stack __P((struct proc *, struct exec_package *)); + +#endif /* _KERNEL */ + +#endif /* !_SYS_EXEC_ELF_H_ */ diff --git a/sys/include/proc.h b/sys/include/proc.h index f06c010..f0d932b 100644 --- a/sys/include/proc.h +++ b/sys/include/proc.h @@ -272,6 +272,8 @@ void fatalsig (int signum); */ int procxmt (void); +void execsigs(register struct proc *p); + #endif /* KERMEL */ /* stat codes */ diff --git a/sys/kernel/exec_aout.c b/sys/kernel/exec_aout.c new file mode 100644 index 0000000..9aa78d1 --- /dev/null +++ b/sys/kernel/exec_aout.c @@ -0,0 +1,95 @@ +#include "param.h" +#include "systm.h" +#include "map.h" +#include "inode.h" +#include "user.h" +#include "proc.h" +#include "buf.h" +#include "namei.h" +#include "fs.h" +#include "mount.h" +#include "file.h" +#include "resource.h" +#include "exec.h" +#include "exec_aout.h" +#include "dir.h" +#include "uio.h" +#include "debug.h" + +int exec_aout_check(struct exec_params *epp) +{ + int error; + + if (epp->hdr_len < sizeof(struct exec)) + return ENOEXEC; + if (!(N_GETMID(epp->hdr.aout) == MID_ZERO && + N_GETFLAG(epp->hdr.aout) == 0)) + return ENOEXEC; + + switch (N_GETMAGIC(epp->hdr.aout)) { + case OMAGIC: + epp->hdr.aout.a_data += epp->hdr.aout.a_text; + epp->hdr.aout.a_text = 0; + break; + default: + printf("Bad a.out magic = %0o\n", N_GETMAGIC(epp->hdr.aout)); + return ENOEXEC; + } + + /* + * Save arglist + */ + exec_save_args(epp); + + DEBUG("Exec file header:\n"); + DEBUG("a_midmag = %#x\n", epp->hdr.aout.a_midmag); /* magic number */ + DEBUG("a_text = %d\n", epp->hdr.aout.a_text); /* size of text segment */ + DEBUG("a_data = %d\n", epp->hdr.aout.a_data); /* size of initialized data */ + DEBUG("a_bss = %d\n", epp->hdr.aout.a_bss); /* size of uninitialized data */ + DEBUG("a_reltext = %d\n", epp->hdr.aout.a_reltext); /* size of text relocation info */ + DEBUG("a_reldata = %d\n", epp->hdr.aout.a_reldata); /* size of data relocation info */ + DEBUG("a_syms = %d\n", epp->hdr.aout.a_syms); /* size of symbol table */ + DEBUG("a_entry = %#x\n", epp->hdr.aout.a_entry); /* entry point */ + + /* + * Set up memory allocation + */ + epp->text.vaddr = epp->heap.vaddr = NO_ADDR; + epp->text.len = epp->heap.len = 0; + + epp->data.vaddr = (caddr_t)USER_DATA_START; + epp->data.len = epp->hdr.aout.a_data; + epp->bss.vaddr = epp->data.vaddr + epp->data.len; + epp->bss.len = epp->hdr.aout.a_bss; + epp->heap.vaddr = epp->bss.vaddr + epp->bss.len; + epp->heap.len = 0; + epp->stack.len = SSIZE + roundup(epp->argbc + epp->envbc, NBPW) + (epp->argc + epp->envc+4)*NBPW; + epp->stack.vaddr = (caddr_t)USER_DATA_END - epp->stack.len; + + /* + * Allocate core at this point, committed to the new image. + * TODO: What to do for errors? + */ + exec_estab(epp); + + /* read in text and data */ + DEBUG("reading a.out image\n"); + error = rdwri (UIO_READ, epp->ip, + (caddr_t)epp->data.vaddr, epp->hdr.aout.a_data, + sizeof(struct exec) + epp->hdr.aout.a_text, IO_UNIT, 0); + if (error) + DEBUG("read image returned error=%d\n", error); + if (error) { + /* + * Error - all is lost, when the old image is possible corrupt + * and we could not load a new. + */ + psignal (u.u_procp, SIGSEGV); + return error; + } + + exec_clear(epp); + exec_setupstack(epp->hdr.aout.a_entry, epp); + + return 0; +} diff --git a/sys/kernel/exec_conf.c b/sys/kernel/exec_conf.c new file mode 100644 index 0000000..a541218 --- /dev/null +++ b/sys/kernel/exec_conf.c @@ -0,0 +1,59 @@ +/* $NetBSD: exec_conf.c,v 1.43 2000/06/09 22:38:57 oki Exp $ */ + +/* + * Copyright (c) 1993, 1994 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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 Christopher G. Demetriou. + * 4. 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 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. + */ + +#include "param.h" +#include "inode.h" +#include "exec.h" + +#ifdef EXEC_SCRIPT +int exec_script_check(struct exec_params *epp); +#endif +#ifdef EXEC_AOUT +int exec_aout_check(struct exec_params *epp); +#endif +#ifdef EXEC_ELF +int exec_elf_check(struct exec_params *epp); +#endif + +const struct execsw execsw[] = { +#ifdef EXEC_AOUT + { exec_aout_check, "a.out" }, /* a.out binaries */ +#endif +#ifdef EXEC_ELF + { exec_elf_check, "elf" }, /* 32bit ELF bins */ +#endif +#ifdef EXEC_SCRIPT + { exec_script_check, "script" }, /* shell scripts */ +#endif + }; +int nexecs = (sizeof(execsw) / sizeof(*execsw)); +int exec_maxhdrsz; diff --git a/sys/kernel/exec_elf.c b/sys/kernel/exec_elf.c new file mode 100644 index 0000000..423ebf4 --- /dev/null +++ b/sys/kernel/exec_elf.c @@ -0,0 +1,207 @@ +/* $NetBSD: exec_elf32.c,v 1.49.2.2 2000/11/03 20:00:38 tv Exp $ */ + +/*- + * Copyright (c) 1994 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. + * + * 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. + */ + +/* + * Copyright (c) 1996 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. 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 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. + */ + + +#include "param.h" +#include "systm.h" +#include "kernel.h" +#include "map.h" +#include "user.h" +#include "proc.h" +//#include "malloc.h" +#include "inode.h" +#include "namei.h" +//#include "vnode.h" +#include "exec.h" +#include "exec_elf.h" +#include "fcntl.h" +//#include "syscall.h" +#include "signalvar.h" +#include "mount.h" +#include "stat.h" + + +extern char sigcode[], esigcode[]; + +/* round up and down to page boundaries. */ +#define ELF_ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1)) +#define ELF_TRUNC(a, b) ((a) & ~((b) - 1)) + +/* + * elf_check(): Prepare an Elf binary's exec package + * + * First, set of the various offsets/lengths in the exec package. + * + * Then, mark the text image busy (so it can be demand paged) or error + * out if this is not possible. Finally, set up vmcmds for the + * text, data, bss, and stack segments. + */ +int +exec_elf_check(struct exec_params *epp) +{ + struct elf_phdr *ph; + int error, i, phsize; + + const char elfident[] = {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, + ELFCLASS32, ELFDATA2LSB, EV_CURRENT, ELFOSABI_SYSV, 0}; + + /* + * Check that this is an ELF file that we can handle, + * and do some sanity checks on the header + */ + if (epp->hdr_len < sizeof(struct elf_ehdr)) + return ENOEXEC; + for (i = 0; i < sizeof elfident; i++) + if (epp->hdr.elf.e_ident[i] != elfident[i]) + return ENOEXEC; + if (epp->hdr.elf.e_type != ET_EXEC) + return ENOEXEC; + if (epp->hdr.elf.e_machine != EM_MIPS || epp->hdr.elf.e_version != EV_CURRENT) + return ENOEXEC; + if (epp->hdr.elf.e_phentsize != sizeof(struct elf_phdr) || epp->hdr.elf.e_phoff == 0 || epp->hdr.elf.e_phnum == 0) + return ENOEXEC; + if (epp->hdr.elf.e_shnum == 0 || epp->hdr.elf.e_shentsize != sizeof(struct elf_shdr)) + return ENOEXEC; + + /* + * Read program headers + */ + phsize = epp->hdr.elf.e_phnum * sizeof(struct elf_phdr); + ph = exec_alloc(phsize, NBPW, epp); + if (ph == NULL) { + printf("can't alloc ph[] sz=%d\n", phsize); + return ENOEXEC; + } + if ((error = rdwri(UIO_READ, epp->ip, (caddr_t)ph, phsize, epp->hdr.elf.e_phoff, IO_UNIT, 0)) != 0) + return ENOEXEC; + + epp->text.len = epp->data.len = epp->bss.len = epp->stack.len = epp->heap.len = 0; + epp->text.vaddr = epp->data.vaddr = epp->bss.vaddr = epp->stack.vaddr = epp->heap.vaddr = NO_ADDR; + + if (epp->hdr.elf.e_phnum == 1 && ph[0].p_type == PT_LOAD && ph[0].p_flags == (PF_R|PF_W|PF_X)) { + /* + * In the simple a.out type link, in elf format, there is only + * one loadable segment that is RWE containing everything + * Here we fix the memory allocation, and we are done. + */ + epp->data.vaddr = (caddr_t)ph[0].p_vaddr; + epp->data.len = ph[0].p_memsz; + epp->heap.vaddr = (caddr_t)ph[0].p_vaddr + ph[0].p_memsz; + epp->heap.len = 0; + epp->stack.len = SSIZE + epp->argbc + epp->envbc + (epp->argc+epp->envc+4)*NBPW; + epp->stack.vaddr = (caddr_t)USER_DATA_END - epp->stack.len; + + /* + * We assume .bss is the different between the memory data + * section size and the file size. + */ + epp->bss.vaddr = epp->data.vaddr + ph[0].p_filesz; + epp->bss.len = ph[0].p_memsz - ph[0].p_filesz; + epp->data.len = epp->bss.vaddr - epp->data.vaddr; + } else { + /* + * At the current moment we don't handle anything else + * The rest of the code is implemented as need arise. + */ + return ENOEXEC; + } + + /* + * Save arglist + */ + exec_save_args(epp); + + /* + * Establish memory + */ + if ((error = exec_estab(epp)) != 0) + return error; + + /* + * Now load the program sections into memory + */ + for (i = 0; i < epp->hdr.elf.e_phnum; i++) { + if (ph[i].p_type != PT_LOAD) + continue; + /* + * Sanity check that the load is to our intended address space. + */ + if (!((epp->text.vaddr != NO_ADDR + && ((caddr_t)ph[i].p_vaddr >= epp->text.vaddr + && (caddr_t)ph[i].p_vaddr + ph[i].p_filesz <= epp->text.vaddr + epp->text.len)) + || (epp->data.vaddr != NO_ADDR + && (caddr_t)ph[i].p_vaddr >= epp->data.vaddr + && (caddr_t)ph[i].p_vaddr + ph[i].p_filesz <= epp->data.vaddr + epp->data.len)) + || ph[i].p_filesz >= ph[i].p_memsz || ph[i].p_filesz <= 0) + return ENOEXEC; + + error = rdwri(UIO_READ, epp->ip, (caddr_t)ph[i].p_vaddr, ph[i].p_filesz, ph[i].p_offset, IO_UNIT, 0); + } + + exec_clear(epp); + exec_setupstack(epp->hdr.elf.e_entry, epp); + + return 0; +} diff --git a/sys/kernel/exec_script.c b/sys/kernel/exec_script.c new file mode 100644 index 0000000..1d59a70 --- /dev/null +++ b/sys/kernel/exec_script.c @@ -0,0 +1,96 @@ +#include "param.h" +#include "inode.h" +#include "dir.h" +#include "namei.h" +#include "exec.h" +#include "user.h" +#include "systm.h" + +int +exec_script_check(struct exec_params *epp) +{ + char *cp; + struct nameidata nd; + struct nameidata *ndp; + int error; + struct inode *ip = 0; + + /* + * We come here with the first line of the executable + * script file. + * Check is to see if it starts with the magic marker: #! + */ + if (epp->hdr.sh[0] != '#' || epp->hdr.sh[1] != '!' || epp->sh.interpreted) + return ENOEXEC; + epp->sh.interpreted = 1; + + /* + * If setuid/gid scripts were to be disallowed this is where it would + * have to be done. + * u.u_uid = uid; + * u.u_gid = u_groups[0]; + */ + + /* + * The first line of the text file + * should be one line on the format: + * #! \n + */ + cp = &epp->hdr.sh[2]; + while (cp < &epp->hdr.sh[MIN(epp->hdr_len, SHSIZE)]) { + if (*cp == '\t') + *cp = ' '; + else if (*cp == '\n') { + *cp = '\0'; + break; + } + cp++; + } + if (cp == &epp->hdr.sh[MIN(epp->hdr_len, SHSIZE)]) + return ENOEXEC; + + /* + * Pick up script interpreter file name + */ + cp = &epp->hdr.sh[2]; + while (*cp == ' ') + cp++; + if (!*cp) + return ENOEXEC; + bzero(&nd, sizeof nd); + ndp = &nd; + ndp->ni_dirp = cp; + while (*cp && *cp != ' ') + cp++; + if (*cp != '\0') { + *cp++ = 0; + while (*cp && *cp == ' ') + cp++; + if (*cp) { + if ((error = copystr(cp, epp->sh.interparg, sizeof epp->sh.interparg, NULL))) + goto done; + } + } + + /* + * the interpreter is the new file to exec + */ + ndp->ni_nameiop = LOOKUP | FOLLOW; + ip = namei (ndp); + if (ip == NULL) + return u.u_error; + if ((error = copystr(ndp->ni_dent.d_name, epp->sh.interpname, sizeof epp->sh.interpname, NULL))) + goto done; + + /* + * Everything set up, do the recursive exec() + */ + if (epp->ip) + iput(epp->ip); + epp->ip = ip; + error = exec_check(epp); +done: + if (ip) + iput(ip); + return error; +} diff --git a/sys/kernel/exec_subr.c b/sys/kernel/exec_subr.c new file mode 100644 index 0000000..4e12abb --- /dev/null +++ b/sys/kernel/exec_subr.c @@ -0,0 +1,425 @@ +#include "param.h" +#include "systm.h" +#include "map.h" +#include "inode.h" +#include "user.h" +#include "proc.h" +#include "buf.h" +#include "namei.h" +#include "fs.h" +#include "mount.h" +#include "file.h" +#include "resource.h" +#include "exec.h" +#include "dir.h" +#include "uio.h" +#include "debug.h" + +/* + * How memory is set up. + * + * var a: + * USER_DATA_END: !----------! + * ! +P_ssize ! stack + * p_saddr -> ¡----------! + * + * !----------! + * ! +P_dsize ! .data + .bss + heap + * P_daddr -> !----------! + * + * var b: + * + * USER_DATA_END: !--------! + * ! +ssize ! stack + * saddr -> ¡--------! + * ! +hsize ! heap + * haddr -> !--------! + * ! +dsize ! .data + .bss + * daddr -> !--------! + * ! +tsize ! .text + * taddr -> !--------! + * paddr -> +psize + * + * var c: + * !--------! + * ! +tsize ! .text (read only section) + * taddr -> !--------! + * ! +ssize ! stack + * saddr -> ¡--------! + * ! +hsize ! heap + * haddr -> !--------! + * ! +dsize ! .data + .bss + * daddr -> !--------! + * paddr -> +psize + * + */ + +/* + * Set up user memory. + * + * The following is a key to top of the stack and the variables used. + * + * topp-> [argv] top word for /bin/ps + * <0> + * n + * g + * r + * a + * ... + * <0> + * 0 + * g + * r + * ucp -> a + * [0] + * [envn] + * ... + * envp -> [env0] + * [0] + * [argn] ptr to argn + * ... + * argp -> [arg0] ptr to arg0 + * [] + * [] + * [] + * sp -> [] + * + */ +void exec_setupstack(unsigned entryaddr, struct exec_params *epp) +{ + int nc,i; + u_int len; + char *ucp; + char **argp, **envp, ***topp; + + DEBUG("exec_setupstack:\n"); + + /* + * Set up top of stack structure as above + * This depends on that kernel and user spaces + * map to the same addresses. + */ + topp = (char ***)(epp->stack.vaddr + epp->stack.len - NBPW); /* Last word of RAM */ + ucp = (char *)((unsigned)topp - roundup(epp->envbc + epp->argbc,NBPW)); /* arg string space */ + envp = (char **)(ucp - (epp->envc+1)*NBPW); /* Make place for envp[...], +1 for the 0 */ + argp = envp - (epp->argc+1)*NBPW; /* Make place for argv[...] */ + u.u_frame [FRAME_SP] = (int)(argp-16); + u.u_frame [FRAME_R4] = epp->argc; /* $a0 := argc */ + u.u_frame [FRAME_R5] = (int)argp; /* $a1 := argp */ + u.u_frame [FRAME_R6] = (int)envp; /* $a2 := env */ + *topp = argp; /* for /bin/ps */ + + /* + * copy the arguments into the structure + */ + nc = 0; + for (i = 0; i < epp->argc; i++) { + argp[i] = (caddr_t)ucp; + if (copystr((caddr_t)epp->argp[i], (caddr_t)ucp, (caddr_t)topp-ucp, &len) == 0) { + nc += len; + ucp += len; + } + } + argp[epp->argc] = NULL; + + for (i = 0; i < epp->envc; i++) { + envp[i] = ucp; + if (copystr((caddr_t)epp->envp[i], (caddr_t)ucp, (caddr_t)topp-ucp, &len) == 0) { + nc += len; + ucp += len; + } + } + envp[epp->envc] = NULL; + + ucp = (caddr_t)roundup((unsigned)ucp, NBPW); + if ((caddr_t)ucp != (caddr_t)topp) { + DEBUG("Copying of arg list went wrong, ucp=%#x, topp=%#x\n", ucp, topp); + panic("exec check"); + } + + u.u_frame [FRAME_PC] = entryaddr; + DEBUG("Setting up new PC=%#x\n", entryaddr); + + /* + * Remember file name for accounting. + */ + (void) copystr(argp[0], u.u_comm, MAXCOMLEN, 0); +} + +/* + * A simple memory allocator used within exec code using file buffers as storage. + * Will return NULL if allocation is not possible. + * Total max memory allocatable is MAXALLOCBUF*MAXBSIZE + * Max size of allocatable chunk is MAXBSIZE + * + * All memory allocated with this function will be freed by a call + * to exec_alloc_freeall() + */ +void *exec_alloc(int size, int ru, struct exec_params *epp) +{ + char *cp; + int i; + + for (i = 0; i < MAXALLOCBUF; i++) + if (MAXBSIZE - (ru<=1?epp->alloc[i].fill:roundup(epp->alloc[i].fill,ru)) >= size) + break; + if (i == MAXALLOCBUF) + return NULL; + if (epp->alloc[i].bp == NULL) { + if ((epp->alloc[i].bp = geteblk()) == NULL) { + DEBUG("exec_alloc: no buf\n"); + return NULL; + } + } + if (ru > 1) + epp->alloc[i].fill = roundup(epp->alloc[i].fill, ru); + cp = epp->alloc[i].bp->b_addr + epp->alloc[i].fill; + epp->alloc[i].fill += size; + bzero (cp, size); + return cp; +} + +/* + * this will deallocate all memory allocated by exec_alloc + */ +void exec_alloc_freeall(struct exec_params *epp) +{ + int i; + for (i = 0; i < MAXALLOCBUF; i++) { + if (epp->alloc[i].bp) { + brelse(epp->alloc[i].bp); + epp->alloc[i].bp = NULL; + epp->alloc[i].fill = 0; + } + } +} + +/* + * Establish memory for the image based on the + * values picked up from the executable file and stored + * in the exec params block. + */ +int exec_estab(struct exec_params *epp) +{ + DEBUG("text = %#x..%#x, len=%d\n", epp->text.vaddr, epp->text.vaddr+epp->text.len, epp->text.len); + DEBUG("data = %#x..%#x, len=%d\n", epp->data.vaddr, epp->data.vaddr+epp->data.len, epp->data.len); + DEBUG("bss = %#x..%#x, len=%d\n", epp->bss.vaddr, epp->bss.vaddr+epp->bss.len, epp->bss.len); + DEBUG("heap = %#x..%#x, len=%d\n", epp->heap.vaddr, epp->heap.vaddr+epp->heap.len, epp->heap.len); + DEBUG("stack = %#x..%#x, len=%d\n", epp->stack.vaddr, epp->stack.vaddr+epp->stack.len, epp->stack.len); + + /* + * Right now we can only handle the simple original a.out + * case, so we double check for that case here. + */ + if (epp->text.vaddr != NO_ADDR || epp->data.vaddr == NO_ADDR + || epp->data.vaddr != (caddr_t)USER_DATA_START || epp->stack.vaddr != (caddr_t)USER_DATA_END - epp->stack.len) + return ENOMEM; + + /* + * Try out for overflow + */ + if (epp->text.len + epp->data.len + epp->heap.len + epp->stack.len > MAXMEM) + return ENOMEM; + + if (roundup((unsigned)epp->data.vaddr + epp->data.len, NBPW) != roundup((unsigned)epp->bss.vaddr, NBPW)) { + DEBUG(".bss do not follow .data\n"); + return ENOMEM; + } + + /* + * Allocate core at this point, committed to the new image. + */ + u.u_prof.pr_scale = 0; + if (u.u_procp->p_flag & SVFORK) + endvfork(); + u.u_procp->p_dsize = epp->data.len + epp->bss.len; + u.u_procp->p_daddr = (size_t)epp->data.vaddr; + u.u_procp->p_ssize = epp->stack.len; + u.u_procp->p_saddr = (size_t)epp->stack.vaddr; + + DEBUG("core allocation: \n"); + DEBUG("daddr =%#x..%#x\n", u.u_procp->p_daddr, u.u_procp->p_daddr + u.u_procp->p_dsize); + DEBUG("saddr =%#x..%#x\n", u.u_procp->p_saddr, u.u_procp->p_saddr + u.u_procp->p_ssize); + return 0; +} + + +/* + * Save argv[] and envp[] + */ +void exec_save_args(struct exec_params *epp) +{ + unsigned len; + caddr_t cp; + int argc, i, l; + char **argp, *ap; + + epp->argc = epp->envc = 0; + epp->argbc = epp->envbc = 0; + + argc = 0; + if ((argp = epp->userargp) != NULL) + while (argp[argc]) + argc++; +#ifdef EXEC_SCRIPT + if (epp->sh.interpreted) { + argc++; + if (epp->sh.interparg[0]) + argc++; + } +#endif + if (argc != 0) { + if ((epp->argp = (char **)exec_alloc(argc * sizeof(char *), NBPW, epp)) == NULL) + return; + for (;;) { + /* + * For a interpreter script, the arg list is changed to + * #! + * arg[0] - the interpreter executable name (path) + * arg[1] - interpreter arg (optional) + * arg[2 or 1] - script name + * arg[3 or 2...] - script arg[1...] + */ + if (argp) + ap = *argp++; + else + ap = NULL; +#ifdef EXEC_SCRIPT + if (epp->sh.interpreted) { + if (epp->argc == 0) + ap = epp->sh.interpname; + else if (epp->argc == 1 && epp->sh.interparg[0]) { + ap = epp->sh.interparg; + --argp; + } else if ((epp->argc == 1 || (epp->argc == 2 && epp->sh.interparg[0]))) { + ap = epp->userfname; + --argp; + } + } +#endif + if (ap == 0) + break; + l = strlen(ap)+1; + if ((cp = exec_alloc(l, 1, epp)) == NULL) + return; + if (copystr(ap, cp, l, &len) != 0) + return; + epp->argp[epp->argc++] = cp; + epp->argbc += len;; + } + } + argc = 0; + if ((argp = epp->userenvp) != NULL) + while (argp[argc]) + argc++; + epp->envc = 0; + epp->envbc = 0; + if (argc != 0) { + if ((epp->envp = (char **)exec_alloc(argc * sizeof(char *), NBPW, epp)) == NULL) + return; + for (;;) { + if (argp) + ap = *argp++; + else + ap = NULL; + if (ap == 0) + break; + l = strlen(ap)+1; + if ((cp = exec_alloc(l, 1, epp)) == NULL) + return; + if (copystr(ap, cp, l, &len) != 0) + return; + epp->envp[epp->envc++] = cp; + epp->envbc += len; + } + } + + for (i = 0; i < epp->argc; i++) + DEBUG("arg[%d] = \"%s\"\n", i, epp->argp[i]); + + for (i = 0; i < epp->envc; i++) + DEBUG("env[%d] = \"%s\"\n", i, epp->envp[i]); + + + /* + * Number of string pool chars needed for this arg list + */ +// return (bc + NBPW-1) & ~(NBPW-1); + return; +} + +void exec_clear(struct exec_params *epp) +{ + char *cp; + int cc; + + /* clear BSS */ + if (epp->bss.len > 0) + bzero((void *)epp->bss.vaddr, epp->bss.len); + if (epp->heap.len > 0) + bzero((void *)epp->heap.vaddr, epp->heap.len); + /* Clear stack */ + bzero((void *)epp->stack.vaddr, epp->stack.len); + + /* + * set SUID/SGID protections, if no tracing + */ + if ((u.u_procp->p_flag & P_TRACED) == 0) { + u.u_uid = epp->uid; + u.u_procp->p_uid = epp->uid; + u.u_groups[0] = epp->gid; + } else + psignal (u.u_procp, SIGTRAP); + u.u_svuid = u.u_uid; + u.u_svgid = u.u_groups[0]; + + u.u_tsize = epp->text.len; + u.u_dsize = epp->data.len + epp->bss.len; + u.u_ssize = epp->stack.len; + + /* + * Clear registers. + */ + u.u_frame [FRAME_R1] = 0; /* $at */ + u.u_frame [FRAME_R2] = 0; /* $v0 */ + u.u_frame [FRAME_R3] = 0; /* $v1 */ + u.u_frame [FRAME_R7] = 0; /* $a3 */ + u.u_frame [FRAME_R8] = 0; /* $t0 */ + u.u_frame [FRAME_R9] = 0; /* $t1 */ + u.u_frame [FRAME_R10] = 0; /* $t2 */ + u.u_frame [FRAME_R11] = 0; /* $t3 */ + u.u_frame [FRAME_R12] = 0; /* $t4 */ + u.u_frame [FRAME_R13] = 0; /* $t5 */ + u.u_frame [FRAME_R14] = 0; /* $t6 */ + u.u_frame [FRAME_R15] = 0; /* $t7 */ + u.u_frame [FRAME_R16] = 0; /* $s0 */ + u.u_frame [FRAME_R17] = 0; /* $s1 */ + u.u_frame [FRAME_R18] = 0; /* $s2 */ + u.u_frame [FRAME_R19] = 0; /* $s3 */ + u.u_frame [FRAME_R20] = 0; /* $s4 */ + u.u_frame [FRAME_R21] = 0; /* $s5 */ + u.u_frame [FRAME_R22] = 0; /* $s6 */ + u.u_frame [FRAME_R23] = 0; /* $s7 */ + u.u_frame [FRAME_R24] = 0; /* $t8 */ + u.u_frame [FRAME_R25] = 0; /* $t9 */ + u.u_frame [FRAME_FP] = 0; + u.u_frame [FRAME_RA] = 0; + u.u_frame [FRAME_LO] = 0; + u.u_frame [FRAME_HI] = 0; + u.u_frame [FRAME_GP] = 0; + + execsigs (u.u_procp); + + /* + * Clear (close) files + */ + for (cp = u.u_pofile, cc = 0; cc <= u.u_lastfile; cc++, cp++) { + if (*cp & UF_EXCLOSE) { + (void) closef (u.u_ofile [cc]); + u.u_ofile [cc] = NULL; + *cp = 0; + } + } + while (u.u_lastfile >= 0 && u.u_ofile [u.u_lastfile] == NULL) + u.u_lastfile--; +} diff --git a/sys/kernel/kern_exec.c b/sys/kernel/kern_exec.c index 18cfbbf..68745b0 100644 --- a/sys/kernel/kern_exec.c +++ b/sys/kernel/kern_exec.c @@ -6,15 +6,17 @@ #include "param.h" #include "systm.h" #include "map.h" +#include "inode.h" #include "user.h" #include "proc.h" #include "buf.h" -#include "inode.h" #include "namei.h" #include "fs.h" #include "mount.h" #include "file.h" #include "signalvar.h" +#include "exec.h" +#include "debug.h" /* * exec system call, with and without environments. @@ -26,135 +28,70 @@ struct execa { }; /* - * Reset signals for an exec of the specified process. In 4.4 this function - * was in kern_sig.c but since in 2.11 kern_sig and kern_exec will likely be - * in different overlays placing this here potentially saves a kernel overlay - * switch. + * This is the internal form of the exec() function. + * + * It is called with the inode of the executable + * and the exec_params structure, which is used to + * keep information during the exec. + * + * It returns the error code, and with the ip still locked. */ -static void -execsigs(p) - register struct proc *p; +int exec_check(struct exec_params *epp) { - register int nc; - unsigned long mask; + int error, i, r; + + DEBUG("Entering exec_check\n"); + if (access (epp->ip, IEXEC)) + return ENOEXEC; + if ((u.u_procp->p_flag & P_TRACED) && access (epp->ip, IREAD)) + return ENOEXEC; + if ((epp->ip->i_mode & IFMT) != IFREG || + (epp->ip->i_mode & (IEXEC | (IEXEC>>3) | (IEXEC>>6))) == 0) + return EACCES; /* - * Reset caught signals. Held signals remain held - * through p_sigmask (unless they were caught, - * and are now ignored by default). + * Read in first few bytes of file for segment sizes, magic number: + * 407 = plain executable + * Also an ASCII line beginning with #! is + * the file name of a ``interpreter'' and arguments may be prepended + * to the argument list if given here. + * + * INTERPRETER NAMES ARE LIMITED IN LENGTH. + * + * ONLY ONE ARGUMENT MAY BE PASSED TO THE INTERPRETER FROM + * THE ASCII LINE. */ - while (p->p_sigcatch) { - nc = ffs(p->p_sigcatch); - mask = sigmask(nc); - p->p_sigcatch &= ~mask; - if (sigprop[nc] & SA_IGNORE) { - if (nc != SIGCONT) - p->p_sigignore |= mask; - p->p_sig &= ~mask; - } - u.u_signal[nc] = SIG_DFL; + + /* + * Read the first 'SHSIZE' bytes from the file to execute + */ + DEBUG("Read header %d bytes from %d\n", sizeof(epp->hdr), 0); +#ifdef EXEC_SCRIPT + epp->hdr.sh[0] = '\0'; /* for zero length files */ +#endif + error = rdwri (UIO_READ, epp->ip, + (caddr_t) &epp->hdr, sizeof(epp->hdr), + (off_t)0, IO_UNIT, &r); + if (error) + return error; + epp->hdr_len = sizeof(epp->hdr) - r; + + /* + * Given the first part of the image + * loop through the exec file handlers to find + * someone who can handle this file format. + */ + error = ENOEXEC; + DEBUG("Trying %d exec formats\n", nexecs); + for (i = 0; i < nexecs && error != 0; i++) { + DEBUG("Trying exec format %d : %s\n", i, execsw[i].es_name); + if (execsw[i].es_check == NULL) + continue; + error = (*execsw[i].es_check)(epp); + if (error == 0) + break; } - /* - * Reset stack state to the user stack (disable the alternate stack). - */ - u.u_sigstk.ss_flags = SA_DISABLE; - u.u_sigstk.ss_size = 0; - u.u_sigstk.ss_base = 0; - u.u_psflags = 0; -} - -/* - * Read in and set up memory for executed file. - * u.u_error set on error - */ -static void -getxfile (ip, ep, nargc, uid, gid) - struct inode *ip; - register struct exec *ep; - int nargc, uid, gid; -{ - u_int ds, ts, ss; - - if (ep->a_magic == OMAGIC) { - ep->a_data += ep->a_text; - ep->a_text = 0; - } - - if (ep->a_text != 0 && (ip->i_flag & ITEXT) == 0 && - ip->i_count != 1) { - register struct file *fp; - - for (fp = file; fp < file+NFILE; fp++) { - if (fp->f_type == DTYPE_INODE && - fp->f_count > 0 && - (struct inode*)fp->f_data == ip && - (fp->f_flag & FWRITE)) { - u.u_error = ETXTBSY; - return; - } - } - } - - /* - * find text and data sizes try; them out for possible - * overflow of max sizes - */ - ts = ep->a_text; - ds = ep->a_data + ep->a_bss; - ss = SSIZE + nargc; - -//printf ("getxfile: size t/d/s = %u/%u/%u\n", ts, ds, ss); - if (ts + ds + ss > MAXMEM) { - u.u_error = ENOMEM; - return; - } - - /* - * Allocate core at this point, committed to the new image. - */ - u.u_prof.pr_scale = 0; - if (u.u_procp->p_flag & SVFORK) - endvfork(); - u.u_procp->p_dsize = ds; - u.u_procp->p_daddr = USER_DATA_START; - u.u_procp->p_ssize = ss; - u.u_procp->p_saddr = USER_DATA_END - ss; - - /* read in text and data */ -//printf ("getxfile: read %u bytes at %08x\n", ep->a_data, USER_DATA_START); - rdwri (UIO_READ, ip, (caddr_t) USER_DATA_START, ep->a_data, - sizeof(struct exec) + ep->a_text, IO_UNIT, (int*) 0); - - /* clear BSS and stack */ -//printf ("getxfile: clear %u bytes at %08x\n", USER_DATA_END - USER_DATA_START - ep->a_data, USER_DATA_START + ep->a_data); - bzero ((void*) (USER_DATA_START + ep->a_data), - USER_DATA_END - USER_DATA_START - ep->a_data); - - /* - * set SUID/SGID protections, if no tracing - */ - if ((u.u_procp->p_flag & P_TRACED) == 0) { - u.u_uid = uid; - u.u_procp->p_uid = uid; - u.u_groups[0] = gid; - } else - psignal (u.u_procp, SIGTRAP); - u.u_svuid = u.u_uid; - u.u_svgid = u.u_groups[0]; - - u.u_tsize = ts; - u.u_dsize = ds; - u.u_ssize = ss; -} - -void printmem (unsigned addr, int nbytes) -{ - for (; nbytes>0; addr+=16, nbytes-=16) { - unsigned char *p = (unsigned char*) addr; - printf ("%08x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - addr, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], - p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); - } + return error; } void @@ -169,371 +106,51 @@ execv() void execve() { - register char *cp; - register struct buf *bp; struct execa *uap = (struct execa *)u.u_arg; - int nc, na, ne, ucp, ap, indir, uid, gid, resid, error; - register int cc; - unsigned len; - char *sharg; + int error; struct inode *ip; - size_t bno; - char cfname [MAXCOMLEN + 1]; -#define SHSIZE 32 - char cfarg [SHSIZE]; - union { - char ex_shell [SHSIZE]; /* #! and name of interpreter */ - struct exec ex_exec; - } exdata; struct nameidata nd; register struct nameidata *ndp = &nd; + struct exec_params eparam; -//printf ("execve ('%s', ['%s', '%s', ...])\n", uap->fname, uap->argp[0], uap->argp[1]); + DEBUG("execve ('%s', ['%s', '%s', ...])\n", uap->fname, uap->argp[0], uap->argp[1]); NDINIT (ndp, LOOKUP, FOLLOW, uap->fname); ip = namei (ndp); if (ip == NULL) { -//printf ("execve: file not found\n"); + DEBUG("execve: file '%s' not found\n", uap->fname); return; } - bno = 0; - bp = 0; - indir = 0; - uid = u.u_uid; - gid = u.u_groups[0]; + /* + * The exec_param structure is used to + * keep information about the executable during exec's processing + */ + bzero(&eparam, sizeof eparam); + eparam.userfname = uap->fname; + eparam.userargp = uap->argp; + eparam.userenvp = uap->envp; + eparam.uid = u.u_uid; + eparam.gid = u.u_groups[0]; + if (ip->i_fs->fs_flags & MNT_NOEXEC) { -//printf ("execve: NOEXEC, flags=%o\n", ip->i_fs->fs_flags); u.u_error = EACCES; + DEBUG("EACCES\n"); goto done; } if ((ip->i_fs->fs_flags & MNT_NOSUID) == 0) { if (ip->i_mode & ISUID) - uid = ip->i_uid; + eparam.uid = ip->i_uid; if (ip->i_mode & ISGID) - gid = ip->i_gid; - } -again: - if (access (ip, IEXEC)) { -//printf ("execve: no IEXEC\n"); - goto done; - } - if ((u.u_procp->p_flag & P_TRACED) && access (ip, IREAD)) { -//printf ("execve: traced, but no IREAD\n"); - goto done; - } - if ((ip->i_mode & IFMT) != IFREG || - (ip->i_mode & (IEXEC | (IEXEC>>3) | (IEXEC>>6))) == 0) { -//printf ("execve: no IEXEC, mode=%o\n", ip->i_mode); - u.u_error = EACCES; - goto done; + eparam.gid = ip->i_gid; } - /* - * Read in first few bytes of file for segment sizes, magic number: - * 407 = plain executable - * Also an ASCII line beginning with #! is - * the file name of a ``shell'' and arguments may be prepended - * to the argument list if given here. - * - * SHELL NAMES ARE LIMITED IN LENGTH. - * - * ONLY ONE ARGUMENT MAY BE PASSED TO THE SHELL FROM - * THE ASCII LINE. - */ - exdata.ex_shell[0] = '\0'; /* for zero length files */ - u.u_error = rdwri (UIO_READ, ip, (caddr_t) &exdata, sizeof(exdata), - (off_t) 0, IO_UNIT, &resid); - if (u.u_error) { -//printf ("execve: rdwri error %d\n", u.u_error); - goto done; - } - if (resid > sizeof(exdata) - sizeof(exdata.ex_exec) && - exdata.ex_shell[0] != '#') { -//printf ("execve: short read, resid = %d, shell=%.32s\n", resid, exdata.ex_shell); - u.u_error = ENOEXEC; - goto done; - } -//printf ("execve: text=%u, data=%u, bss=%u\n", exdata.ex_exec.a_text, exdata.ex_exec.a_data, exdata.ex_exec.a_bss); - - switch ((int) exdata.ex_exec.a_magic) { - case OMAGIC: - case NMAGIC: - break; - default: - if (exdata.ex_shell[0] != '#' || - exdata.ex_shell[1] != '!' || - indir) { -//printf ("execve: bad shell=%.32s\n", exdata.ex_shell); - u.u_error = ENOEXEC; - goto done; - } - /* - * If setuid/gid scripts were to be disallowed this is where it would - * have to be done. - * u.u_uid = uid; - * u.u_gid = u_groups[0]; - */ - cp = &exdata.ex_shell[2]; /* skip "#!" */ - while (cp < &exdata.ex_shell[SHSIZE]) { - if (*cp == '\t') - *cp = ' '; - else if (*cp == '\n') { - *cp = '\0'; - break; - } - cp++; - } - if (*cp != '\0') { - u.u_error = ENOEXEC; - goto done; - } - cp = &exdata.ex_shell[2]; - while (*cp == ' ') - cp++; - ndp->ni_dirp = cp; - while (*cp && *cp != ' ') - cp++; - cfarg[0] = '\0'; - if (*cp) { - *cp++ = '\0'; - while (*cp == ' ') - cp++; - if (*cp) - bcopy ((caddr_t) cp, (caddr_t) cfarg, SHSIZE); - } - indir = 1; - iput (ip); - ndp->ni_nameiop = LOOKUP | FOLLOW; - ip = namei (ndp); - if (ip == NULL) - return; - bcopy ((caddr_t) ndp->ni_dent.d_name, (caddr_t) cfname, MAXCOMLEN); - cfname [MAXCOMLEN] = '\0'; - goto again; - } - - /* - * Collect arguments on "file" in swap space. - */ - na = 0; - ne = 0; - nc = 0; - cc = 0; - cp = 0; - bno = malloc (swapmap, btod (NCARGS + MAXBSIZE)); - if (bno == 0) { - u.u_error = ENOMEM; - goto done; - } - /* - * Copy arguments into file in argdev area. - */ - if (uap->argp) for (;;) { - ap = NULL; - sharg = NULL; - if (indir && na == 0) { - sharg = cfname; - ap = (int) sharg; - uap->argp++; /* ignore argv[0] */ - } else if (indir && (na == 1 && cfarg[0])) { - sharg = cfarg; - ap = (int) sharg; - } else if (indir && (na == 1 || (na == 2 && cfarg[0]))) - ap = (int) uap->fname; - else if (uap->argp) { - ap = *(int*) uap->argp; - uap->argp++; - } - if (ap == NULL && uap->envp) { - uap->argp = NULL; - ap = *(int*) uap->envp; - if (ap != NULL) - uap->envp++, ne++; - } - if (ap == NULL) - break; - na++; - if (ap == -1) { - u.u_error = EFAULT; - break; - } - do { - if (cc <= 0) { - /* - * We depend on NCARGS being a multiple of - * DEV_BSIZE. This way we need only check - * overflow before each buffer allocation. - */ - if (nc >= NCARGS-1) { -//printf ("execve: too many args = %d\n", nc); - error = E2BIG; - break; - } - if (bp) { - bdwrite(bp); - } - cc = DEV_BSIZE; - bp = getblk (swapdev, dbtofsb(bno) + lblkno(nc)); - cp = bp->b_addr; - } - if (sharg) { - error = copystr (sharg, cp, (unsigned) cc, &len); -//printf ("execve arg%d=%s: %u bytes from %08x to %08x\n", na-1, sharg, len, sharg, cp); - sharg += len; - } else { - error = copystr ((caddr_t) ap, cp, (unsigned) cc, &len); -//printf ("execve arg%d=%s: %u bytes from %08x to %08x\n", na-1, ap, len, ap, cp); - ap += len; - } - cp += len; - nc += len; - cc -= len; - } while (error == ENOENT); - if (error) { -//printf ("execve: copy arg error = %d\n", error); - u.u_error = error; - if (bp) { - bp->b_flags |= B_AGE; - bp->b_flags &= ~B_DELWRI; - brelse(bp); - } - bp = 0; - goto badarg; - } - } -//printf ("execve: argc=%d, envc=%d, total %d bytes\n", na, ne, nc); - if (bp) { - bdwrite (bp); - } - bp = 0; - nc = (nc + NBPW-1) & ~(NBPW-1); - getxfile (ip, &exdata.ex_exec, nc + (na+4)*NBPW, uid, gid); - if (u.u_error) { -//printf ("execve: getxfile error = %d\n", u.u_error); -badarg: - for (cc = 0; cc < nc; cc += DEV_BSIZE) { - daddr_t blkno; - - blkno = dbtofsb(bno) + lblkno(cc); - if (incore (swapdev, blkno)) { - bp = bread (swapdev, blkno); - bp->b_flags |= B_AGE; /* throw away */ - bp->b_flags &= ~B_DELWRI; /* cancel io */ - brelse(bp); - bp = 0; - } - } - goto done; - } - iput(ip); - ip = NULL; - - /* - * Copy back arglist. - */ - ucp = USER_DATA_END - nc - NBPW; - ap = ucp - na*NBPW - 2*NBPW; - u.u_frame [FRAME_SP] = ap - 16; - u.u_frame [FRAME_R4] = na - ne; /* $a0 := argc */ - u.u_frame [FRAME_R5] = ap; /* $a1 := argv */ - u.u_frame [FRAME_R6] = ap + (na-ne+1)*NBPW; /* $a2 := env */ - *(int*) (USER_DATA_END - NBPW) = ap; /* for /bin/ps */ - nc = 0; - cc = 0; - for (;;) { - if (na == ne) { - *(int*) ap = 0; - ap += NBPW; - } - if (--na < 0) - break; - *(int*) ap = ucp; - do { - if (cc <= 0) { - if (bp) { - brelse(bp); - } - cc = DEV_BSIZE; - bp = bread (swapdev, dbtofsb(bno) + lblkno(nc)); - bp->b_flags |= B_AGE; /* throw away */ - bp->b_flags &= ~B_DELWRI; /* cancel io */ - cp = bp->b_addr; - } - error = copystr (cp, (caddr_t) ucp, (unsigned) cc, - &len); -//printf ("execve copy '%s' %u bytes from %08x to %08x\n", cp, len, cp, ucp); - ucp += len; - cp += len; - nc += len; - cc -= len; - } while (error == ENOENT); - if (error == EFAULT) - panic ("exec: EFAULT"); - ap += NBPW; - } - *(int*) ap = 0; - if (bp) { - bp->b_flags |= B_AGE; - brelse (bp); - bp = NULL; - } - execsigs (u.u_procp); - for (cp = u.u_pofile, cc = 0; cc <= u.u_lastfile; cc++, cp++) { - if (*cp & UF_EXCLOSE) { - (void) closef (u.u_ofile [cc]); - u.u_ofile [cc] = NULL; - *cp = 0; - } - } - while (u.u_lastfile >= 0 && u.u_ofile [u.u_lastfile] == NULL) - u.u_lastfile--; - - /* - * Clear registers. - */ - u.u_frame [FRAME_R1] = 0; /* $at */ - u.u_frame [FRAME_R2] = 0; /* $v0 */ - u.u_frame [FRAME_R3] = 0; /* $v1 */ - u.u_frame [FRAME_R7] = 0; /* $a3 */ - u.u_frame [FRAME_R8] = 0; /* $t0 */ - u.u_frame [FRAME_R9] = 0; /* $t1 */ - u.u_frame [FRAME_R10] = 0; /* $t2 */ - u.u_frame [FRAME_R11] = 0; /* $t3 */ - u.u_frame [FRAME_R12] = 0; /* $t4 */ - u.u_frame [FRAME_R13] = 0; /* $t5 */ - u.u_frame [FRAME_R14] = 0; /* $t6 */ - u.u_frame [FRAME_R15] = 0; /* $t7 */ - u.u_frame [FRAME_R16] = 0; /* $s0 */ - u.u_frame [FRAME_R17] = 0; /* $s1 */ - u.u_frame [FRAME_R18] = 0; /* $s2 */ - u.u_frame [FRAME_R19] = 0; /* $s3 */ - u.u_frame [FRAME_R20] = 0; /* $s4 */ - u.u_frame [FRAME_R21] = 0; /* $s5 */ - u.u_frame [FRAME_R22] = 0; /* $s6 */ - u.u_frame [FRAME_R23] = 0; /* $s7 */ - u.u_frame [FRAME_R24] = 0; /* $t8 */ - u.u_frame [FRAME_R25] = 0; /* $t9 */ - u.u_frame [FRAME_FP] = 0; - u.u_frame [FRAME_RA] = 0; - u.u_frame [FRAME_LO] = 0; - u.u_frame [FRAME_HI] = 0; - u.u_frame [FRAME_GP] = 0; - u.u_frame [FRAME_PC] = exdata.ex_exec.a_entry; - - /* - * Remember file name for accounting. - */ - bcopy ((caddr_t) (indir ? cfname : ndp->ni_dent.d_name), - (caddr_t) u.u_comm, MAXCOMLEN); + eparam.ip = ip; + DEBUG("calling exec_check()\n"); + if ((error = exec_check(&eparam))) + u.u_error = error; + DEBUG("back from exec_check()\n"); done: -//printf ("execve done: PC=%08x, SP=%08x, R4=%08x, R5=%08x, R6=%08x\n", -// u.u_frame [FRAME_PC], u.u_frame [FRAME_SP], -// u.u_frame [FRAME_R4], u.u_frame [FRAME_R5], u.u_frame [FRAME_R6]); - if (bp) { - bp->b_flags |= B_AGE; - brelse (bp); - } - if (bno) - mfree (swapmap, btod (NCARGS + MAXBSIZE), bno); + exec_alloc_freeall(&eparam); if (ip) iput(ip); } + diff --git a/sys/kernel/kern_sig.c b/sys/kernel/kern_sig.c index a30e66e..34b19a5 100644 --- a/sys/kernel/kern_sig.c +++ b/sys/kernel/kern_sig.c @@ -662,3 +662,40 @@ postsig(sig) } exit(sig); } + +/* + * Reset signals for an exec of the specified process. In 4.4 this function + * was in kern_sig.c but since in 2.11 kern_sig and kern_exec will likely be + * in different overlays placing this here potentially saves a kernel overlay + * switch. + */ +void +execsigs(register struct proc *p) +{ + register int nc; + unsigned long mask; + + /* + * Reset caught signals. Held signals remain held + * through p_sigmask (unless they were caught, + * and are now ignored by default). + */ + while (p->p_sigcatch) { + nc = ffs(p->p_sigcatch); + mask = sigmask(nc); + p->p_sigcatch &= ~mask; + if (sigprop[nc] & SA_IGNORE) { + if (nc != SIGCONT) + p->p_sigignore |= mask; + p->p_sig &= ~mask; + } + u.u_signal[nc] = SIG_DFL; + } + /* + * Reset stack state to the user stack (disable the alternate stack). + */ + u.u_sigstk.ss_flags = SA_DISABLE; + u.u_sigstk.ss_size = 0; + u.u_sigstk.ss_base = 0; + u.u_psflags = 0; +} diff --git a/sys/pic32/32mxsdram-uart/Makefile b/sys/pic32/32mxsdram-uart/Makefile index a4bfded..4edfea6 100644 --- a/sys/pic32/32mxsdram-uart/Makefile +++ b/sys/pic32/32mxsdram-uart/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o oc.o rd_sd.o rd_sdramp.o rdisk.o sdram.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o oc.o rd_sd.o rd_sdramp.o rdisk.o sdram.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = bootloader DEFS += -DADC_ENABLED=YES @@ -48,6 +48,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DFLASH_USER=0x1d005000 DEFS += -DGPIO_ENABLED=YES DEFS += -DHID_FEATURE_REPORT_BYTES=2 diff --git a/sys/pic32/baremetal/Makefile b/sys/pic32/baremetal/Makefile index 3c92ffd..ba3e606 100644 --- a/sys/pic32/baremetal/Makefile +++ b/sys/pic32/baremetal/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o clock.o cons.o devcfg.o devsw.o exception.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o clock.o cons.o devcfg.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = DEFS += -DBUS_DIV=1 @@ -41,6 +41,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DKERNEL DEFS += -DLED_DISK_PIN=2 DEFS += -DLED_DISK_PORT=TRISD diff --git a/sys/pic32/cfg/kernel.dev b/sys/pic32/cfg/kernel.dev index 88e32a2..e18f2b8 100644 --- a/sys/pic32/cfg/kernel.dev +++ b/sys/pic32/cfg/kernel.dev @@ -1,6 +1,9 @@ always define KERNEL define UCB_METER + define EXEC_AOUT + define EXEC_ELF + define EXEC_SCRIPT file _startup.o file clock.o file devsw.o @@ -9,6 +12,11 @@ always file machdep.o file mem.o file exception.o + file exec_aout.o + file exec_conf.o + file exec_elf.o + file exec_script.o + file exec_subr.o file init_main.o file init_sysent.o file kern_clock.o diff --git a/sys/pic32/dip/Makefile b/sys/pic32/dip/Makefile index a3de049..2a83cab 100644 --- a/sys/pic32/dip/Makefile +++ b/sys/pic32/dip/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = bootloader DEFS += -DBL_BUTTON_PIN=6 @@ -52,6 +52,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DFLASH_JUMP=0x9d000000 DEFS += -DGPIO_ENABLED=YES DEFS += -DHID_FEATURE_REPORT_BYTES=2 diff --git a/sys/pic32/duinomite-uart/Makefile b/sys/pic32/duinomite-uart/Makefile index 2883e97..2a94d01 100644 --- a/sys/pic32/duinomite-uart/Makefile +++ b/sys/pic32/duinomite-uart/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = DEFS += -DBUS_DIV=1 @@ -41,6 +41,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DGPIO_ENABLED=YES DEFS += -DKERNEL DEFS += -DLED_DISK_PIN=12 diff --git a/sys/pic32/duinomite/Makefile b/sys/pic32/duinomite/Makefile index 687441c..a62bfe2 100644 --- a/sys/pic32/duinomite/Makefile +++ b/sys/pic32/duinomite/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = DEFS += -DBUS_DIV=1 @@ -41,6 +41,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DGPIO_ENABLED=YES DEFS += -DKERNEL DEFS += -DLED_DISK_PIN=12 diff --git a/sys/pic32/elf_machdep.h b/sys/pic32/elf_machdep.h new file mode 100644 index 0000000..f02aa75 --- /dev/null +++ b/sys/pic32/elf_machdep.h @@ -0,0 +1,88 @@ +/* $NetBSD: elf_machdep.h,v 1.7 2000/04/02 15:35:50 minoura Exp $ */ + +#define ELF_MACHDEP_ID_CASES \ + case EM_MIPS: \ + break; + +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* mips relocs. */ + +#define R_MIPS_NONE 0 +#define R_MIPS_16 1 +#define R_MIPS_32 2 +#define R_MIPS_REL32 3 +#define R_MIPS_REL R_MIPS_REL32 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 /* high 16 bits of symbol value */ +#define R_MIPS_LO16 6 /* low 16 bits of symbol value */ +#define R_MIPS_GPREL16 7 /* GP-relative reference */ +#define R_MIPS_LITERAL 8 /* Reference to literal section */ +#define R_MIPS_GOT16 9 /* Reference to global offset table */ +#define R_MIPS_GOT R_MIPS_GOT16 +#define R_MIPS_PC16 10 /* 16 bit PC relative reference */ +#define R_MIPS_CALL16 11 /* 16 bit call thru glbl offset tbl */ +#define R_MIPS_CALL R_MIPS_CALL16 +#define R_MIPS_GPREL32 12 + +/* 13, 14, 15 are not defined at this point. */ +#define R_MIPS_UNUSED1 13 +#define R_MIPS_UNUSED2 14 +#define R_MIPS_UNUSED3 15 + +/* + * The remaining relocs are apparently part of the 64-bit Irix ELF ABI. + */ +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 + +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 + +#define R_MIPS_max 37 +#define R_TYPE(name) __CONCAT(R_MIPS_,name) + + +/* mips dynamic tags */ + +#define DT_MIPS_RLD_VERSION 0x70000001 +#define DT_MIPS_TIME_STAMP 0x70000002 +#define DT_MIPS_ICHECKSUM 0x70000003 +#define DT_MIPS_IVERSION 0x70000004 +#define DT_MIPS_FLAGS 0x70000005 +#define DT_MIPS_BASE_ADDRESS 0x70000006 +#define DT_MIPS_CONFLICT 0x70000008 +#define DT_MIPS_LIBLIST 0x70000009 +#define DT_MIPS_CONFLICTNO 0x7000000b +#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* number of local got ents */ +#define DT_MIPS_LIBLISTNO 0x70000010 +#define DT_MIPS_SYMTABNO 0x70000011 /* number of .dynsym entries */ +#define DT_MIPS_UNREFEXTNO 0x70000012 +#define DT_MIPS_GOTSYM 0x70000013 /* first dynamic sym in got */ +#define DT_MIPS_HIPAGENO 0x70000014 +#define DT_MIPS_RLD_MAP 0x70000016 /* address of loader map */ + +/* + * Tell the kernel ELF exec code not to try relocating the interpreter + * (ld.so) for dynamically-linked ELF binaries. + */ +#ifdef _KERNEL +#define ELF_INTERP_NON_RELOCATABLE +#endif diff --git a/sys/pic32/explorer16/Makefile b/sys/pic32/explorer16/Makefile index e494508..a4a9fd7 100644 --- a/sys/pic32/explorer16/Makefile +++ b/sys/pic32/explorer16/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o clock.o cons.o devcfg.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o clock.o cons.o devcfg.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = DEFS += -DBUS_DIV=1 @@ -41,6 +41,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DGPIO_ENABLED=YES DEFS += -DKERNEL DEFS += -DLED_DISK_PIN=0 diff --git a/sys/pic32/fubarino/Makefile b/sys/pic32/fubarino/Makefile index 53cc266..5f852c2 100644 --- a/sys/pic32/fubarino/Makefile +++ b/sys/pic32/fubarino/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o glcd.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o oc.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o glcd.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o oc.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = bootloader DEFS += -DADC_ENABLED=YES @@ -47,6 +47,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DFLASH_JUMP=0x9d000000 DEFS += -DGLCD_ENABLED=YES DEFS += -DGPIO_ENABLED=YES diff --git a/sys/pic32/max32-eth/Makefile b/sys/pic32/max32-eth/Makefile index 47e7b66..12601e9 100644 --- a/sys/pic32/max32-eth/Makefile +++ b/sys/pic32/max32-eth/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = DEFS += -DADC_ENABLED=YES @@ -42,6 +42,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DGPIO_ENABLED=YES DEFS += -DKERNEL DEFS += -DLED_KERNEL_PIN=3 diff --git a/sys/pic32/max32/Makefile b/sys/pic32/max32/Makefile index 6875356..5a647f2 100644 --- a/sys/pic32/max32/Makefile +++ b/sys/pic32/max32/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = DEFS += -DADC_ENABLED=YES @@ -42,6 +42,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DGPIO_ENABLED=YES DEFS += -DKERNEL DEFS += -DLED_DISK_PIN=10 diff --git a/sys/pic32/maximite/Makefile b/sys/pic32/maximite/Makefile index bdf7c81..248067b 100644 --- a/sys/pic32/maximite/Makefile +++ b/sys/pic32/maximite/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = bootloader DEFS += -DBL_BUTTON_PIN=13 @@ -47,6 +47,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DFLASH_USER=0x1d003000 DEFS += -DGPIO_ENABLED=YES DEFS += -DHID_FEATURE_REPORT_BYTES=2 diff --git a/sys/pic32/meb/Makefile b/sys/pic32/meb/Makefile index 8fe1470..ba53acd 100644 --- a/sys/pic32/meb/Makefile +++ b/sys/pic32/meb/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o clock.o cons.o devcfg.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o clock.o cons.o devcfg.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = DEFS += -DBUS_DIV=1 @@ -41,6 +41,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DGPIO_ENABLED=YES DEFS += -DKERNEL DEFS += -DLED_DISK_PIN=1 diff --git a/sys/pic32/mmb-mx7/Makefile b/sys/pic32/mmb-mx7/Makefile index c9aa575..9eae304 100644 --- a/sys/pic32/mmb-mx7/Makefile +++ b/sys/pic32/mmb-mx7/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = bootloader DEFS += -DADC_ENABLED=YES @@ -56,6 +56,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DFLASH_JUMP=0x9d000000 DEFS += -DGPIO_CLEAR_PIN=2 DEFS += -DGPIO_CLEAR_PORT=TRISD diff --git a/sys/pic32/pinguino-micro/Makefile b/sys/pic32/pinguino-micro/Makefile index bffac60..2b3706f 100644 --- a/sys/pic32/pinguino-micro/Makefile +++ b/sys/pic32/pinguino-micro/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = bootloader DEFS += -DADC_ENABLED=YES @@ -46,6 +46,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DFLASH_USER=0x1d005000 DEFS += -DGPIO_ENABLED=YES DEFS += -DHID_FEATURE_REPORT_BYTES=2 diff --git a/sys/pic32/starter-kit/Makefile b/sys/pic32/starter-kit/Makefile index c49714c..efba415 100644 --- a/sys/pic32/starter-kit/Makefile +++ b/sys/pic32/starter-kit/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = bootloader DEFS += -DADC_ENABLED=YES @@ -52,6 +52,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DFLASH_JUMP=0x9d000000 DEFS += -DGPIO_ENABLED=YES DEFS += -DHID_FEATURE_REPORT_BYTES=2 diff --git a/sys/pic32/ubw32-uart-sdram/Makefile b/sys/pic32/ubw32-uart-sdram/Makefile index 55f67a2..84b52ed 100644 --- a/sys/pic32/ubw32-uart-sdram/Makefile +++ b/sys/pic32/ubw32-uart-sdram/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rd_sdramp.o rdisk.o sdram.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rd_sdramp.o rdisk.o sdram.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = bootloader DEFS += -DBL_BUTTON_PIN=7 @@ -52,6 +52,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DFLASH_USER=0x1d005000 DEFS += -DHID_FEATURE_REPORT_BYTES=2 DEFS += -DHID_INPUT_REPORT_BYTES=2 diff --git a/sys/pic32/ubw32-uart/Makefile b/sys/pic32/ubw32-uart/Makefile index b8d8588..8ff0aec 100644 --- a/sys/pic32/ubw32-uart/Makefile +++ b/sys/pic32/ubw32-uart/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = bootloader DEFS += -DBL_BUTTON_PIN=7 @@ -52,6 +52,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DFLASH_USER=0x1d005000 DEFS += -DGPIO_ENABLED=YES DEFS += -DHID_FEATURE_REPORT_BYTES=2 diff --git a/sys/pic32/ubw32/Makefile b/sys/pic32/ubw32/Makefile index 8801812..39699a2 100644 --- a/sys/pic32/ubw32/Makefile +++ b/sys/pic32/ubw32/Makefile @@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel vpath %.c $(M):$(S) vpath %.S $(M):$(S) -KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +KERNOBJ += _startup.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o EXTRA_TARGETS = bootloader DEFS += -DBL_BUTTON_PIN=7 @@ -52,6 +52,9 @@ DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT DEFS += -DFLASH_USER=0x1d005000 DEFS += -DGPIO_ENABLED=YES DEFS += -DHID_FEATURE_REPORT_BYTES=2