link_elf.c (240997) | link_elf.c (241896) |
---|---|
1/*- 2 * Copyright (c) 1998-2000 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998-2000 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/kern/link_elf.c 240997 2012-09-27 14:55:15Z trociny $"); | 28__FBSDID("$FreeBSD: head/sys/kern/link_elf.c 241896 2012-10-22 17:50:54Z kib $"); |
29 30#include "opt_ddb.h" 31#include "opt_gdb.h" 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#ifdef GPROF 36#include <sys/gmon.h> --- 708 unchanged lines hidden (view full) --- 745 int flags; 746 elf_file_t ef; 747 linker_file_t lf; 748 Elf_Shdr *shdr; 749 int symtabindex; 750 int symstrindex; 751 int symcnt; 752 int strcnt; | 29 30#include "opt_ddb.h" 31#include "opt_gdb.h" 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#ifdef GPROF 36#include <sys/gmon.h> --- 708 unchanged lines hidden (view full) --- 745 int flags; 746 elf_file_t ef; 747 linker_file_t lf; 748 Elf_Shdr *shdr; 749 int symtabindex; 750 int symstrindex; 751 int symcnt; 752 int strcnt; |
753 int vfslocked; | |
754 755 shdr = NULL; 756 lf = NULL; 757 | 753 754 shdr = NULL; 755 lf = NULL; 756 |
758 NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, filename, td); | 757 NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td); |
759 flags = FREAD; 760 error = vn_open(&nd, &flags, 0, NULL); 761 if (error != 0) 762 return (error); | 758 flags = FREAD; 759 error = vn_open(&nd, &flags, 0, NULL); 760 if (error != 0) 761 return (error); |
763 vfslocked = NDHASGIANT(&nd); | |
764 NDFREE(&nd, NDF_ONLY_PNBUF); 765 if (nd.ni_vp->v_type != VREG) { 766 error = ENOEXEC; 767 firstpage = NULL; 768 goto out; 769 } 770#ifdef MAC 771 error = mac_kld_check_load(curthread->td_ucred, nd.ni_vp); --- 270 unchanged lines hidden (view full) --- 1042 if (error != 0) 1043 goto out; 1044 1045 *result = lf; 1046 1047out: 1048 VOP_UNLOCK(nd.ni_vp, 0); 1049 vn_close(nd.ni_vp, FREAD, td->td_ucred, td); | 762 NDFREE(&nd, NDF_ONLY_PNBUF); 763 if (nd.ni_vp->v_type != VREG) { 764 error = ENOEXEC; 765 firstpage = NULL; 766 goto out; 767 } 768#ifdef MAC 769 error = mac_kld_check_load(curthread->td_ucred, nd.ni_vp); --- 270 unchanged lines hidden (view full) --- 1040 if (error != 0) 1041 goto out; 1042 1043 *result = lf; 1044 1045out: 1046 VOP_UNLOCK(nd.ni_vp, 0); 1047 vn_close(nd.ni_vp, FREAD, td->td_ucred, td); |
1050 VFS_UNLOCK_GIANT(vfslocked); | |
1051 if (error != 0 && lf != NULL) 1052 linker_file_unload(lf, LINKER_UNLOAD_FORCE); 1053 if (shdr != NULL) 1054 free(shdr, M_LINKER); 1055 if (firstpage != NULL) 1056 free(firstpage, M_LINKER); 1057 1058 return (error); --- 570 unchanged lines hidden --- | 1048 if (error != 0 && lf != NULL) 1049 linker_file_unload(lf, LINKER_UNLOAD_FORCE); 1050 if (shdr != NULL) 1051 free(shdr, M_LINKER); 1052 if (firstpage != NULL) 1053 free(firstpage, M_LINKER); 1054 1055 return (error); --- 570 unchanged lines hidden --- |