| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: netbsd32_exec_elf32.c,v 1.29 2008/10/26 07:07:35 mrg Exp $ */ | | 1 | /* $NetBSD: netbsd32_exec_elf32.c,v 1.29.14.1 2009/09/12 17:45:08 matt Exp $ */ |
2 | /* from: NetBSD: exec_aout.c,v 1.15 1996/09/26 23:34:46 cgd Exp */ | | 2 | /* from: NetBSD: exec_aout.c,v 1.15 1996/09/26 23:34:46 cgd Exp */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 1998, 2001 Matthew R. Green. | | 5 | * Copyright (c) 1998, 2001 Matthew R. Green. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -47,65 +47,71 @@ | | | @@ -47,65 +47,71 @@ |
47 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 47 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
57 | */ | | 57 | */ |
58 | | | 58 | |
59 | #include <sys/cdefs.h> | | 59 | #include <sys/cdefs.h> |
60 | __KERNEL_RCSID(0, "$NetBSD: netbsd32_exec_elf32.c,v 1.29 2008/10/26 07:07:35 mrg Exp $"); | | 60 | __KERNEL_RCSID(0, "$NetBSD: netbsd32_exec_elf32.c,v 1.29.14.1 2009/09/12 17:45:08 matt Exp $"); |
61 | | | 61 | |
62 | #define ELFSIZE 32 | | 62 | #define ELFSIZE 32 |
63 | | | 63 | |
64 | #include <sys/param.h> | | 64 | #include <sys/param.h> |
65 | #include <sys/systm.h> | | 65 | #include <sys/systm.h> |
66 | #include <sys/proc.h> | | 66 | #include <sys/proc.h> |
67 | #include <sys/malloc.h> | | 67 | #include <sys/malloc.h> |
68 | #include <sys/vnode.h> | | 68 | #include <sys/vnode.h> |
69 | #include <sys/exec.h> | | 69 | #include <sys/exec.h> |
70 | #include <sys/exec_elf.h> | | 70 | #include <sys/exec_elf.h> |
71 | #include <sys/resourcevar.h> | | 71 | #include <sys/resourcevar.h> |
72 | #include <sys/signal.h> | | 72 | #include <sys/signal.h> |
73 | #include <sys/signalvar.h> | | 73 | #include <sys/signalvar.h> |
74 | #include <sys/kauth.h> | | 74 | #include <sys/kauth.h> |
75 | #include <sys/namei.h> | | 75 | #include <sys/namei.h> |
76 | | | 76 | |
77 | #include <compat/netbsd32/netbsd32.h> | | 77 | #include <compat/netbsd32/netbsd32.h> |
78 | #include <compat/netbsd32/netbsd32_exec.h> | | 78 | #include <compat/netbsd32/netbsd32_exec.h> |
79 | | | 79 | |
80 | #include <machine/frame.h> | | | |
81 | #include <machine/netbsd32_machdep.h> | | 80 | #include <machine/netbsd32_machdep.h> |
82 | | | 81 | |
83 | int netbsd32_copyinargs(struct exec_package *, struct ps_strings *, | | 82 | int netbsd32_copyinargs(struct exec_package *, struct ps_strings *, |
84 | void *, size_t, const void *, const void *); | | 83 | void *, size_t, const void *, const void *); |
85 | int ELFNAME2(netbsd32,probe_noteless)(struct lwp *, struct exec_package *epp, | | 84 | int ELFNAME2(netbsd32,probe_noteless)(struct lwp *, struct exec_package *epp, |
86 | void *eh, char *itp, vaddr_t *pos); | | 85 | void *eh, char *itp, vaddr_t *pos); |
87 | extern int ELFNAME2(netbsd,signature)(struct lwp *, struct exec_package *, | | 86 | extern int ELFNAME2(netbsd,signature)(struct lwp *, struct exec_package *, |
88 | Elf_Ehdr *); | | 87 | Elf_Ehdr *); |
89 | | | 88 | |
90 | int | | 89 | int |
91 | ELFNAME2(netbsd32,probe)(struct lwp *l, struct exec_package *epp, | | 90 | ELFNAME2(netbsd32,probe)(struct lwp *l, struct exec_package *epp, |
92 | void *eh, char *itp, vaddr_t *pos) | | 91 | void *eh, char *itp, vaddr_t *pos) |
93 | { | | 92 | { |
94 | int error; | | 93 | int error; |
95 | | | 94 | |
96 | if ((error = ELFNAME2(netbsd,signature)(l, epp, eh)) != 0) | | 95 | if ((error = ELFNAME2(netbsd,signature)(l, epp, eh)) != 0) |
97 | return error; | | 96 | return error; |
98 | | | 97 | |
| | | 98 | #ifdef ELF_MD_PROBE_FUNC |
| | | 99 | if ((error = ELF_MD_PROBE_FUNC(l, epp, eh, itp, pos)) != 0) |
| | | 100 | return error; |
| | | 101 | #elif defined(ELF_INTERP_NON_RELOCATABLE) |
| | | 102 | *pos = ELF_LINK_ADDR; |
| | | 103 | #endif |
| | | 104 | |
99 | return ELFNAME2(netbsd32,probe_noteless)(l, epp, eh, itp, pos); | | 105 | return ELFNAME2(netbsd32,probe_noteless)(l, epp, eh, itp, pos); |
100 | } | | 106 | } |
101 | | | 107 | |
102 | int | | 108 | int |
103 | ELFNAME2(netbsd32,probe_noteless)(struct lwp *l, struct exec_package *epp, | | 109 | ELFNAME2(netbsd32,probe_noteless)(struct lwp *l, struct exec_package *epp, |
104 | void *eh, char *itp, vaddr_t *pos) | | 110 | void *eh, char *itp, vaddr_t *pos) |
105 | { | | 111 | { |
106 | int error; | | 112 | int error; |
107 | | | 113 | |
108 | if (itp) { | | 114 | if (itp) { |
109 | /* | | 115 | /* |
110 | * If the path is exactly "/usr/libexec/ld.elf_so", first | | 116 | * If the path is exactly "/usr/libexec/ld.elf_so", first |
111 | * try to see if "/usr/libexec/ld.elf_so-<arch>" exists | | 117 | * try to see if "/usr/libexec/ld.elf_so-<arch>" exists |