From owner-p4-projects@FreeBSD.ORG Tue Mar 30 15:15:47 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D22CC16A4D0; Tue, 30 Mar 2004 15:15:46 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 89AD416A4CE for ; Tue, 30 Mar 2004 15:15:46 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6919043D3F for ; Tue, 30 Mar 2004 15:15:46 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i2UNFkGe055239 for ; Tue, 30 Mar 2004 15:15:46 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i2UNFjRT055236 for perforce@freebsd.org; Tue, 30 Mar 2004 15:15:45 -0800 (PST) (envelope-from peter@freebsd.org) Date: Tue, 30 Mar 2004 15:15:45 -0800 (PST) Message-Id: <200403302315.i2UNFjRT055236@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 50016 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Mar 2004 23:15:47 -0000 http://perforce.freebsd.org/chv.cgi?CH=50016 Change 50016 by peter@peter_daintree on 2004/03/30 15:14:48 Dont waste a whole page for the elf header. There is nothing in close proximity anymore that makes it worth it anymore. Affected files ... .. //depot/projects/hammer/sys/kern/link_elf_obj.c#11 edit Differences ... ==== //depot/projects/hammer/sys/kern/link_elf_obj.c#11 (text+ko) ==== @@ -143,9 +143,9 @@ static struct linker_class link_elf_class = { #if ELF_TARG_CLASS == ELFCLASS32 - "elf32", + "elf32_obj", #else - "elf64", + "elf64_obj", #endif link_elf_methods, sizeof(struct elf_file) }; @@ -165,18 +165,20 @@ linker_add_class(&link_elf_class); } -SYSINIT(link_elf, SI_SUB_KLD, SI_ORDER_SECOND, link_elf_init, 0); +SYSINIT(link_elf_obj, SI_SUB_KLD, SI_ORDER_SECOND, link_elf_init, 0); static int link_elf_link_preload(linker_class_t cls, const char *filename, linker_file_t *result) { + /* preload not done this way */ return (EFTYPE); } static int link_elf_link_preload_finish(linker_file_t lf) { + /* preload not done this way */ return (EFTYPE); } @@ -187,7 +189,6 @@ struct nameidata nd; struct thread *td = curthread; /* XXX */ Elf_Ehdr *hdr; - caddr_t firstpage; int nbytes, i; caddr_t mapbase; size_t mapsize; @@ -207,6 +208,7 @@ shdr = NULL; lf = NULL; mapsize = 0; + hdr = NULL; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td); flags = FREAD; @@ -217,27 +219,22 @@ #ifdef MAC error = mac_check_kld_load(curthread->td_ucred, nd.ni_vp); if (error) { - firstpage = NULL; goto out; } #endif - /* - * Read the elf header from the file. - */ - firstpage = malloc(PAGE_SIZE, M_LINKER, M_WAITOK); - if (firstpage == NULL) { + /* Read the elf header from the file. */ + hdr = malloc(sizeof(Elf_Ehdr *), M_LINKER, M_WAITOK); + if (hdr == NULL) { error = ENOMEM; goto out; } - hdr = (Elf_Ehdr *)firstpage; - error = vn_rdwr(UIO_READ, nd.ni_vp, firstpage, PAGE_SIZE, 0, + error = vn_rdwr(UIO_READ, nd.ni_vp, hdr, PAGE_SIZE, 0, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, &resid, td); - nbytes = PAGE_SIZE - resid; if (error) goto out; - if (nbytes < sizeof(Elf_Ehdr)){ + if (resid != 0){ error = ENOEXEC; goto out; } @@ -523,8 +520,8 @@ linker_file_unload(lf); if (shdr) free(shdr, M_LINKER); - if (firstpage) - free(firstpage, M_LINKER); + if (hdr) + free(hdr, M_LINKER); VOP_UNLOCK(nd.ni_vp, 0, td); vn_close(nd.ni_vp, FREAD, td->td_ucred, td);