From 27c67008ddea42303263824c8d145cb52ac76acb Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Wed, 4 Jun 2008 21:12:51 +0000 Subject: olf support starts to die (easy stuff first); ok miod --- sys/kern/exec_elf.c | 66 +++-------------------------------------------------- 1 file changed, 3 insertions(+), 63 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index cca52a150f4..f386cf5ebd6 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.61 2007/05/28 23:10:10 beck Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.62 2008/06/04 21:12:50 deraadt Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -90,7 +90,6 @@ struct ELFNAME(probe_entry) { int ELFNAME(load_file)(struct proc *, char *, struct exec_package *, struct elf_args *, Elf_Addr *); int ELFNAME(check_header)(Elf_Ehdr *, int); -int ELFNAME(olf_check_header)(Elf_Ehdr *, int, u_int8_t *); int ELFNAME(read_from)(struct proc *, struct vnode *, u_long, caddr_t, int); void ELFNAME(load_psection)(struct exec_vmcmd_set *, struct vnode *, Elf_Phdr *, Elf_Addr *, Elf_Addr *, int *, int); @@ -190,54 +189,6 @@ ELFNAME(check_header)(Elf_Ehdr *ehdr, int type) return (0); } -#ifndef SMALL_KERNEL -/* - * Check header for validity; return 0 for ok, ENOEXEC if error. - * Remember OS tag for callers sake. - */ -int -ELFNAME(olf_check_header)(Elf_Ehdr *ehdr, int type, u_int8_t *os) -{ - int i; - - /* - * We need to check magic, class size, endianess, version, and OS - * before we look at the rest of the Elf_Ehdr structure. These few - * elements are represented in a machine independant fashion. - */ - if (!IS_OLF(*ehdr) || - ehdr->e_ident[OI_CLASS] != ELF_TARG_CLASS || - ehdr->e_ident[OI_DATA] != ELF_TARG_DATA || - ehdr->e_ident[OI_VERSION] != ELF_TARG_VER) - return (ENOEXEC); - - for (i = 0; - i < sizeof(ELFNAME(probes)) / sizeof(ELFNAME(probes)[0]); - i++) { - if ((1 << ehdr->e_ident[OI_OS]) & ELFNAME(probes)[i].os_mask) - goto os_ok; - } - return (ENOEXEC); - -os_ok: - /* Now check the machine dependant header */ - if (ehdr->e_machine != ELF_TARG_MACH || - ehdr->e_version != ELF_TARG_VER) - return (ENOEXEC); - - /* Check the type */ - if (ehdr->e_type != type) - return (ENOEXEC); - - /* Don't allow an insane amount of sections. */ - if (ehdr->e_phnum > ELF_MAX_VALID_PHDR) - return (ENOEXEC); - - *os = ehdr->e_ident[OI_OS]; - return (0); -} -#endif /* !SMALL_KERNEL */ - /* * Load a psection at the appropriate address */ @@ -349,9 +300,6 @@ ELFNAME(load_file)(struct proc *p, char *path, struct exec_package *epp, u_long phsize; Elf_Addr addr; struct vnode *vp; -#ifndef SMALL_KERNEL - u_int8_t os; /* Just a dummy in this routine */ -#endif Elf_Phdr *base_ph = NULL; struct interp_ld_sec { Elf_Addr vaddr; @@ -382,11 +330,7 @@ ELFNAME(load_file)(struct proc *p, char *path, struct exec_package *epp, (caddr_t)&eh, sizeof(eh))) != 0) goto bad1; - if (ELFNAME(check_header)(&eh, ET_DYN) -#ifndef SMALL_KERNEL - && ELFNAME(olf_check_header)(&eh, ET_DYN, &os) -#endif - ) { + if (ELFNAME(check_header)(&eh, ET_DYN)) { error = ENOEXEC; goto bad1; } @@ -543,11 +487,7 @@ ELFNAME2(exec,makecmds)(struct proc *p, struct exec_package *epp) if (epp->ep_hdrvalid < sizeof(Elf_Ehdr)) return (ENOEXEC); - if (ELFNAME(check_header)(eh, ET_EXEC) -#ifndef SMALL_KERNEL - && ELFNAME(olf_check_header)(eh, ET_EXEC, &os) -#endif - ) + if (ELFNAME(check_header)(eh, ET_EXEC)) return (ENOEXEC); /* -- cgit v1.2.3