Module Name: src
Committed By: maxv
Date: Tue Jun 24 11:59:11 UTC 2014
Modified Files:
src/sys/arch/amd64/conf: ALL
src/sys/arch/i386/conf: ALL
src/sys/compat/freebsd: freebsd_exec_elf32.c
Log Message:
Remove dead code. The kernel already checks for PT_INTERP sections, and puts
their content into "itp". There's no need for re-reading the whole binary and
trying to find this section again. Just use "itp".
DEBUG_FREEBSD_ELF is now unused, so remove its references in amd64/conf/ALL
and i386/conf/ALL.
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.376 -r1.377 src/sys/arch/i386/conf/ALL
cvs rdiff -u -r1.17 -r1.18 src/sys/compat/freebsd/freebsd_exec_elf32.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.9 src/sys/arch/amd64/conf/ALL:1.10
--- src/sys/arch/amd64/conf/ALL:1.9 Tue Jun 10 01:42:39 2014
+++ src/sys/arch/amd64/conf/ALL Tue Jun 24 11:59:10 2014
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.9 2014/06/10 01:42:39 hikaru Exp $
+# $NetBSD: ALL,v 1.10 2014/06/24 11:59:10 maxv Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@@ -17,7 +17,7 @@ include "arch/amd64/conf/std.amd64"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "ALL-$Revision: 1.9 $"
+#ident "ALL-$Revision: 1.10 $"
maxusers 64 # estimated number of users
@@ -1829,7 +1829,6 @@ options DEBUG_FIND_COMPORT
options DEBUG_FIND_PCIC
options DEBUG_FIND_PCIC_I82365SL_ONLY
options DEBUG_FPE
-options DEBUG_FREEBSD_ELF
options DEBUG_GPIO
options DEBUG_GPIO2
options DEBUG_HPUX
Index: src/sys/arch/i386/conf/ALL
diff -u src/sys/arch/i386/conf/ALL:1.376 src/sys/arch/i386/conf/ALL:1.377
--- src/sys/arch/i386/conf/ALL:1.376 Tue Jun 10 01:42:39 2014
+++ src/sys/arch/i386/conf/ALL Tue Jun 24 11:59:10 2014
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.376 2014/06/10 01:42:39 hikaru Exp $
+# $NetBSD: ALL,v 1.377 2014/06/24 11:59:10 maxv Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "ALL-$Revision: 1.376 $"
+#ident "ALL-$Revision: 1.377 $"
maxusers 64 # estimated number of users
@@ -2030,7 +2030,6 @@ options DEBUG_FIND_COMPORT
options DEBUG_FIND_PCIC
options DEBUG_FIND_PCIC_I82365SL_ONLY
options DEBUG_FPE
-options DEBUG_FREEBSD_ELF
options DEBUG_GPIO
options DEBUG_GPIO2
options DEBUG_HPUX
Index: src/sys/compat/freebsd/freebsd_exec_elf32.c
diff -u src/sys/compat/freebsd/freebsd_exec_elf32.c:1.17 src/sys/compat/freebsd/freebsd_exec_elf32.c:1.18
--- src/sys/compat/freebsd/freebsd_exec_elf32.c:1.17 Sun Apr 22 08:29:56 2007
+++ src/sys/compat/freebsd/freebsd_exec_elf32.c Tue Jun 24 11:59:10 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: freebsd_exec_elf32.c,v 1.17 2007/04/22 08:29:56 dsl Exp $ */
+/* $NetBSD: freebsd_exec_elf32.c,v 1.18 2014/06/24 11:59:10 maxv Exp $ */
/*
* Copyright (c) 1993, 1994 Christopher G. Demetriou
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: freebsd_exec_elf32.c,v 1.17 2007/04/22 08:29:56 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: freebsd_exec_elf32.c,v 1.18 2014/06/24 11:59:10 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -54,25 +54,15 @@ __KERNEL_RCSID(0, "$NetBSD: freebsd_exec
int
-ELFNAME2(freebsd,probe)(
- struct lwp *l,
- struct exec_package *epp,
- void *veh,
- char *itp,
- vaddr_t *pos)
+ELFNAME2(freebsd,probe)(struct lwp *l, struct exec_package *epp, void *veh,
+ char *itp, vaddr_t *pos)
{
int error;
- size_t i;
- size_t phsize;
Elf_Ehdr *eh = (Elf_Ehdr *) veh;
- Elf_Phdr *ph;
- Elf_Phdr *ephp;
- Elf_Nhdr *np;
+ static const char wantBrand[] = FREEBSD_ELF_BRAND_STRING;
+ static const char wantInterp[] = FREEBSD_ELF_INTERP_PREFIX_STRING;
- static const char wantBrand[] = FREEBSD_ELF_BRAND_STRING;
- static const char wantInterp[] = FREEBSD_ELF_INTERP_PREFIX_STRING;
-
- /*
+ /*
* Insist that the executable have a brand, and that it be "FreeBSD".
* Newer FreeBSD binaries have OSABI set to ELFOSABI_FREEBSD. This
* is arguably broken, but they seem to think they need it, for
@@ -81,56 +71,17 @@ ELFNAME2(freebsd,probe)(
#ifndef EI_BRAND
#define EI_BRAND 8
#endif
- if ((eh->e_ident[EI_BRAND] == '\0'
- || strcmp(&eh->e_ident[EI_BRAND], wantBrand) != 0)
- && eh->e_ident[EI_OSABI] != ELFOSABI_FREEBSD)
+ if ((eh->e_ident[EI_BRAND] == '\0' ||
+ strcmp(&eh->e_ident[EI_BRAND], wantBrand) != 0) &&
+ eh->e_ident[EI_OSABI] != ELFOSABI_FREEBSD)
return ENOEXEC;
- i = eh->e_phnum;
- if (i != 0) {
- phsize = i * sizeof(Elf_Phdr);
- ph = (Elf_Phdr *) malloc(phsize, M_TEMP, M_WAITOK);
- if ((error = exec_read_from(l, epp->ep_vp, eh->e_phoff, ph,
- phsize)) != 0)
- goto bad1;
-
- for (ephp = ph; i--; ephp++) {
- if (ephp->p_type != PT_INTERP)
- continue;
-
- /* Check for "legal" intepreter name. */
- if (ephp->p_filesz < sizeof wantInterp)
- goto bad1;
-
- np = (Elf_Nhdr *) malloc(ephp->p_filesz+1,
- M_TEMP, M_WAITOK);
-
- if (((error = exec_read_from(l, epp->ep_vp,
- ephp->p_offset, np, ephp->p_filesz)) != 0))
- goto bad2;
-
- if (strncmp((char *)np, wantInterp,
- sizeof wantInterp - 1))
- goto bad2;
-
- free(np, M_TEMP);
- break;
- }
- free(ph, M_TEMP);
- }
-
if (itp) {
+ if (strncmp(itp, wantInterp, sizeof(wantInterp) - 1))
+ return ENOEXEC;
if ((error = emul_find_interp(l, epp, itp)))
return error;
}
-#ifdef DEBUG_FREEBSD_ELF
- printf("freebsd_elf32_probe: returning 0\n");
-#endif
- return 0;
-bad2:
- free(np, M_TEMP);
-bad1:
- free(ph, M_TEMP);
- return ENOEXEC;
+ return 0;
}