diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2013-10-17 08:45:03 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2013-10-17 08:45:03 +0000 |
commit | e5c8709102eeaac67bb97a1ee67ed8b5ea981263 (patch) | |
tree | d577bcf04530faaf3b1cdd103c4d8493b7aa961f /sys/lib | |
parent | e113d10070344c2a43cad66b9440395e7b3267db (diff) |
more a.out/ecoff removal; ok phessler
Diffstat (limited to 'sys/lib')
-rw-r--r-- | sys/lib/libsa/loadfile.c | 299 |
1 files changed, 1 insertions, 298 deletions
diff --git a/sys/lib/libsa/loadfile.c b/sys/lib/libsa/loadfile.c index 6f23c8d787c..bf2a2b23e91 100644 --- a/sys/lib/libsa/loadfile.c +++ b/sys/lib/libsa/loadfile.c @@ -1,5 +1,5 @@ /* $NetBSD: loadfile.c,v 1.10 2000/12/03 02:53:04 tsutsui Exp $ */ -/* $OpenBSD: loadfile.c,v 1.18 2008/06/26 05:42:20 ray Exp $ */ +/* $OpenBSD: loadfile.c,v 1.19 2013/10/17 08:45:02 deraadt Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -83,15 +83,6 @@ #include "loadfile.h" -#ifdef BOOT_ECOFF -#include <sys/exec_ecoff.h> -static int coff_exec(int, struct ecoff_exechdr *, u_long *, int); -#endif -#ifdef BOOT_AOUT -/* #include <sys/exec_aout.h> done from <sys/exec.h> above */ -static int aout_exec(int, struct exec *, u_long *, int); -#endif - #ifdef BOOT_ELF #include <sys/exec_elf.h> #if defined(BOOT_ELF32) && defined(BOOT_ELF64) @@ -115,18 +106,12 @@ int loadfile(const char *fname, u_long *marks, int flags) { union { -#ifdef BOOT_ECOFF - struct ecoff_exechdr coff; -#endif #if defined(BOOT_ELF32) || (defined(BOOT_ELF) && ELFSIZE == 32) Elf32_Ehdr elf32; #endif #if defined(BOOT_ELF64) || (defined(BOOT_ELF) && ELFSIZE == 64) Elf64_Ehdr elf64; #endif -#ifdef BOOT_AOUT - struct exec aout; -#endif } hdr; ssize_t nr; @@ -144,11 +129,6 @@ loadfile(const char *fname, u_long *marks, int flags) goto err; } -#ifdef BOOT_ECOFF - if (!ECOFF_BADMAG(&hdr.coff)) { - rval = coff_exec(fd, &hdr.coff, marks, flags); - } else -#endif #if defined(BOOT_ELF32) || (defined(BOOT_ELF) && ELFSIZE == 32) if (memcmp(hdr.elf32.e_ident, ELFMAG, SELFMAG) == 0 && hdr.elf32.e_ident[EI_CLASS] == ELFCLASS32) { @@ -161,15 +141,6 @@ loadfile(const char *fname, u_long *marks, int flags) rval = elf64_exec(fd, &hdr.elf64, marks, flags); } else #endif -#ifdef BOOT_AOUT - if (OKMAGIC(N_GETMAGIC(hdr.aout)) -#ifndef NO_MID_CHECK - && N_GETMID(hdr.aout) == MID_MACHINE -#endif - ) { - rval = aout_exec(fd, &hdr.aout, marks, flags); - } else -#endif { rval = 1; errno = EFTYPE; @@ -184,271 +155,3 @@ err: (void)close(fd); return -1; } - -#ifdef BOOT_ECOFF -static int -coff_exec(int fd, struct ecoff_exechdr *coff, u_long *marks, int flags) -{ - paddr_t offset = marks[MARK_START]; - paddr_t minp = ~0, maxp = 0, pos; - - /* Read in text. */ - if (lseek(fd, ECOFF_TXTOFF(coff), SEEK_SET) == -1) { - WARN(("lseek text")); - return 1; - } - - if (coff->a.tsize != 0) { - if (flags & LOAD_TEXT) { - PROGRESS(("%lu", coff->a.tsize)); - if (READ(fd, coff->a.text_start, coff->a.tsize) != - coff->a.tsize) { - return 1; - } - } - else { - if (lseek(fd, coff->a.tsize, SEEK_CUR) == -1) { - WARN(("read text")); - return 1; - } - } - if (flags & (COUNT_TEXT|LOAD_TEXT)) { - pos = coff->a.text_start; - if (minp > pos) - minp = pos; - pos += coff->a.tsize; - if (maxp < pos) - maxp = pos; - } - } - - /* Read in data. */ - if (coff->a.dsize != 0) { - if (flags & LOAD_DATA) { - PROGRESS(("+%lu", coff->a.dsize)); - if (READ(fd, coff->a.data_start, coff->a.dsize) != - coff->a.dsize) { - WARN(("read data")); - return 1; - } - } - if (flags & (COUNT_DATA|LOAD_DATA)) { - pos = coff->a.data_start; - if (minp > pos) - minp = pos; - pos += coff->a.dsize; - if (maxp < pos) - maxp = pos; - } - } - - /* Zero out bss. */ - if (coff->a.bsize != 0) { - if (flags & LOAD_BSS) { - PROGRESS(("+%lu", coff->a.bsize)); - BZERO(coff->a.bss_start, coff->a.bsize); - } - if (flags & (COUNT_BSS|LOAD_BSS)) { - pos = coff->a.bss_start; - if (minp > pos) - minp = pos; - pos = coff->a.bsize; - if (maxp < pos) - maxp = pos; - } - } - - marks[MARK_START] = LOADADDR(minp); - marks[MARK_ENTRY] = LOADADDR(coff->a.entry); - marks[MARK_NSYM] = 1; /* XXX: Kernel needs >= 0 */ - marks[MARK_SYM] = LOADADDR(maxp); - marks[MARK_END] = LOADADDR(maxp); - return 0; -} -#endif /* BOOT_ECOFF */ - -#ifdef BOOT_AOUT -static int -aout_exec(int fd, struct exec *x, u_long *marks, int flags) -{ - u_long entry = x->a_entry; - paddr_t aoutp = 0; - paddr_t minp, maxp; - int cc; - paddr_t offset = marks[MARK_START]; - u_long magic = N_GETMAGIC(*x); - int sub; - - /* In OMAGIC and NMAGIC, exec header isn't part of text segment */ - if (magic == OMAGIC || magic == NMAGIC) - sub = 0; - else - sub = sizeof(*x); - - minp = maxp = ALIGNENTRY(entry); - - if (lseek(fd, sizeof(*x), SEEK_SET) == -1) { - WARN(("lseek text")); - return 1; - } - - /* - * Leave a copy of the exec header before the text. - * The kernel may use this to verify that the - * symbols were loaded by this boot program. - */ - if (magic == OMAGIC || magic == NMAGIC) { - if (flags & LOAD_HDR && maxp >= sizeof(*x)) - BCOPY(x, maxp - sizeof(*x), sizeof(*x)); - } - else { - if (flags & LOAD_HDR) - BCOPY(x, maxp, sizeof(*x)); - if (flags & (LOAD_HDR|COUNT_HDR)) { - minp += sizeof(*x); - maxp += sizeof(*x); - } - } - - /* - * Read in the text segment. - */ - if (flags & LOAD_TEXT) { - PROGRESS(("%d", x->a_text)); - - if (READ(fd, maxp, x->a_text - sub) != x->a_text - sub) { - WARN(("read text")); - return 1; - } - } else { - if (lseek(fd, x->a_text - sub, SEEK_CUR) == -1) { - WARN(("seek text")); - return 1; - } - } - if (flags & (LOAD_TEXT|COUNT_TEXT)) - maxp += x->a_text - sub; - - /* - * Provide alignment if required - */ - if (magic == ZMAGIC || magic == NMAGIC) { - int size = -(unsigned int)maxp & (__LDPGSZ - 1); - - if (flags & LOAD_TEXTA) { - PROGRESS(("/%d", size)); - BZERO(maxp, size); - } - - if (flags & (LOAD_TEXTA|COUNT_TEXTA)) - maxp += size; - } - - /* - * Read in the data segment. - */ - if (flags & LOAD_DATA) { - PROGRESS(("+%d", x->a_data)); - - if (READ(fd, maxp, x->a_data) != x->a_data) { - WARN(("read data")); - return 1; - } - } - else { - if (lseek(fd, x->a_data, SEEK_CUR) == -1) { - WARN(("seek data")); - return 1; - } - } - if (flags & (LOAD_DATA|COUNT_DATA)) - maxp += x->a_data; - - /* - * Zero out the BSS section. - * (Kernel doesn't care, but do it anyway.) - */ - if (flags & LOAD_BSS) { - PROGRESS(("+%d", x->a_bss)); - - BZERO(maxp, x->a_bss); - } - - if (flags & (LOAD_BSS|COUNT_BSS)) - maxp += x->a_bss; - - /* - * Read in the symbol table and strings. - * (Always set the symtab size word.) - */ - if (flags & LOAD_SYM) - BCOPY(&x->a_syms, maxp, sizeof(x->a_syms)); - - if (flags & (LOAD_SYM|COUNT_SYM)) { - maxp += sizeof(x->a_syms); - aoutp = maxp; - } - - if (x->a_syms > 0) { - /* Symbol table and string table length word. */ - - if (flags & LOAD_SYM) { - PROGRESS(("+[%d", x->a_syms)); - - if (READ(fd, maxp, x->a_syms) != x->a_syms) { - WARN(("read symbols")); - return 1; - } - } else { - if (lseek(fd, x->a_syms, SEEK_CUR) == -1) { - WARN(("seek symbols")); - return 1; - } - } - if (flags & (LOAD_SYM|COUNT_SYM)) - maxp += x->a_syms; - - if (read(fd, &cc, sizeof(cc)) != sizeof(cc)) { - WARN(("read string table")); - return 1; - } - - if (flags & LOAD_SYM) { - BCOPY(&cc, maxp, sizeof(cc)); - - /* String table. Length word includes itself. */ - - PROGRESS(("+%d]", cc)); - } - if (flags & (LOAD_SYM|COUNT_SYM)) - maxp += sizeof(cc); - - cc -= sizeof(int); - if (cc <= 0) { - WARN(("symbol table too short")); - return 1; - } - - if (flags & LOAD_SYM) { - if (READ(fd, maxp, cc) != cc) { - WARN(("read strings")); - return 1; - } - } else { - if (lseek(fd, cc, SEEK_CUR) == -1) { - WARN(("seek strings")); - return 1; - } - } - if (flags & (LOAD_SYM|COUNT_SYM)) - maxp += cc; - } - - marks[MARK_START] = LOADADDR(minp); - marks[MARK_ENTRY] = LOADADDR(entry); - marks[MARK_NSYM] = x->a_syms; - marks[MARK_SYM] = LOADADDR(aoutp); - marks[MARK_END] = LOADADDR(maxp); - return 0; -} -#endif /* BOOT_AOUT */ |