imgact_elf.c (101308) | imgact_elf.c (101771) |
---|---|
1/*- 2 * Copyright (c) 2000 David O'Brien 3 * Copyright (c) 1995-1996 S�ren Schmidt 4 * Copyright (c) 1996 Peter Wemm 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * | 1/*- 2 * Copyright (c) 2000 David O'Brien 3 * Copyright (c) 1995-1996 S�ren Schmidt 4 * Copyright (c) 1996 Peter Wemm 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * |
30 * $FreeBSD: head/sys/kern/imgact_elf.c 101308 2002-08-04 10:29:36Z jeff $ | 30 * $FreeBSD: head/sys/kern/imgact_elf.c 101771 2002-08-13 06:55:28Z jeff $ |
31 */ 32 33#include <sys/param.h> 34#include <sys/exec.h> 35#include <sys/fcntl.h> 36#include <sys/imgact.h> 37#include <sys/imgact_elf.h> 38#include <sys/kernel.h> --- 555 unchanged lines hidden (view full) --- 594 u_long text_size = 0, data_size = 0; 595 u_long text_addr = 0, data_addr = 0; 596 u_long addr, entry = 0, proghdr = 0; 597 vm_offset_t maxuser, usrstack, pagesize; 598 int error, i; 599 const char *interp = NULL; 600 Elf_Brandinfo *brand_info; 601 char *path; | 31 */ 32 33#include <sys/param.h> 34#include <sys/exec.h> 35#include <sys/fcntl.h> 36#include <sys/imgact.h> 37#include <sys/imgact_elf.h> 38#include <sys/kernel.h> --- 555 unchanged lines hidden (view full) --- 594 u_long text_size = 0, data_size = 0; 595 u_long text_addr = 0, data_addr = 0; 596 u_long addr, entry = 0, proghdr = 0; 597 vm_offset_t maxuser, usrstack, pagesize; 598 int error, i; 599 const char *interp = NULL; 600 Elf_Brandinfo *brand_info; 601 char *path; |
602 struct thread *td = curthread; |
|
602 603 GIANT_REQUIRED; 604 605 /* 606 * Do we have a valid ELF header ? 607 */ 608 if (__elfN(check_header)(hdr) != 0 || hdr->e_type != ET_EXEC) 609 return -1; --- 9 unchanged lines hidden (view full) --- 619 return ENOEXEC; 620 } 621 phdr = (const Elf_Phdr*)(imgp->image_header + hdr->e_phoff); 622 623 /* 624 * From this point on, we may have resources that need to be freed. 625 */ 626 | 603 604 GIANT_REQUIRED; 605 606 /* 607 * Do we have a valid ELF header ? 608 */ 609 if (__elfN(check_header)(hdr) != 0 || hdr->e_type != ET_EXEC) 610 return -1; --- 9 unchanged lines hidden (view full) --- 620 return ENOEXEC; 621 } 622 phdr = (const Elf_Phdr*)(imgp->image_header + hdr->e_phoff); 623 624 /* 625 * From this point on, we may have resources that need to be freed. 626 */ 627 |
627 /* 628 * Yeah, I'm paranoid. There is every reason in the world to get 629 * VTEXT now since from here on out, there are places we can have 630 * a context switch. Better safe than sorry; I really don't want 631 * the file to change while it's being loaded. 632 * 633 * XXX We can't really set this flag safely without the vnode lock. 634 */ 635 mp_fixme("This needs the vnode lock to be safe."); 636 imgp->vp->v_vflag |= VV_TEXT; | 628 VOP_UNLOCK(imgp->vp, 0, td); |
637 638 if ((error = exec_extract_strings(imgp)) != 0) 639 goto fail; 640 641 /* 642 * Tentatively identify the brand based on the machine so that 643 * we can figure out VM ranges and page sizes. 644 */ --- 196 unchanged lines hidden (view full) --- 841 elf_auxargs->flags = 0; 842 elf_auxargs->entry = entry; 843 elf_auxargs->trace = elf_trace; 844 845 imgp->auxargs = elf_auxargs; 846 imgp->interpreted = 0; 847 848fail: | 629 630 if ((error = exec_extract_strings(imgp)) != 0) 631 goto fail; 632 633 /* 634 * Tentatively identify the brand based on the machine so that 635 * we can figure out VM ranges and page sizes. 636 */ --- 196 unchanged lines hidden (view full) --- 833 elf_auxargs->flags = 0; 834 elf_auxargs->entry = entry; 835 elf_auxargs->trace = elf_trace; 836 837 imgp->auxargs = elf_auxargs; 838 imgp->interpreted = 0; 839 840fail: |
841 vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY, td); |
|
849 return error; 850} 851 852#if __ELF_WORD_SIZE == 32 853#define suword suword32 854#define stacktype u_int32_t 855#else 856#define suword suword64 --- 399 unchanged lines hidden --- | 842 return error; 843} 844 845#if __ELF_WORD_SIZE == 32 846#define suword suword32 847#define stacktype u_int32_t 848#else 849#define suword suword64 --- 399 unchanged lines hidden --- |