5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
25 */
26
27 #include <sys/types.h>
28 #include <sys/param.h>
29 #include <sys/systm.h>
30 #include <sys/fpu/fpusystm.h>
31 #include <sys/sysmacros.h>
32 #include <sys/signal.h>
33 #include <sys/cred.h>
34 #include <sys/user.h>
35 #include <sys/errno.h>
36 #include <sys/vnode.h>
37 #include <sys/mman.h>
38 #include <sys/kmem.h>
39 #include <sys/proc.h>
40 #include <sys/pathname.h>
41 #include <sys/cmn_err.h>
42 #include <sys/debug.h>
43 #include <sys/exec.h>
44 #include <sys/exechdr.h>
45 #include <sys/auxv.h>
46 #include <sys/core.h>
47 #include <sys/vmparam.h>
48 #include <sys/archsystm.h>
49 #include <sys/fs/swapnode.h>
50 #include <sys/modctl.h>
51 #include <vm/anon.h>
52 #include <vm/as.h>
53 #include <vm/seg.h>
54
55 static int aoutexec(vnode_t *vp, execa_t *uap, uarg_t *args,
56 intpdata_t *idatap, int level, long *execsz, int setid,
57 caddr_t exec_file, cred_t *cred, int brand_action);
58 static int get_aout_head(struct vnode **vpp, struct exdata *edp, long *execsz,
59 int *isdyn);
60 static int aoutcore(vnode_t *vp, proc_t *pp, cred_t *credp,
61 rlim64_t rlimit, int sig, core_content_t content);
62 extern int elf32exec(vnode_t *, execa_t *, uarg_t *, intpdata_t *, int,
63 long *, int, caddr_t, cred_t *, int);
64 extern int elf32core(vnode_t *, proc_t *, cred_t *, rlim64_t, int,
65 core_content_t);
66
67 static struct execsw nesw = {
68 aout_nmagicstr,
69 2,
70 2,
71 aoutexec,
72 aoutcore
73 };
74
75 static struct execsw zesw = {
76 aout_zmagicstr,
77 2,
113 return (mod_install(&modlinkage));
114 }
115
116 int
117 _fini(void)
118 {
119 return (mod_remove(&modlinkage));
120 }
121
122 int
123 _info(struct modinfo *modinfop)
124 {
125 return (mod_info(&modlinkage, modinfop));
126 }
127
128
129 /*ARGSUSED*/
130 static int
131 aoutexec(vnode_t *vp, struct execa *uap, struct uarg *args,
132 struct intpdata *idatap, int level, long *execsz, int setid,
133 caddr_t exec_file, cred_t *cred, int brand_action)
134 {
135 auxv32_t auxflags_auxv32;
136 int error;
137 struct exdata edp, edpout;
138 struct execenv exenv;
139 proc_t *pp = ttoproc(curthread);
140 struct vnode *nvp;
141 int pagetext, pagedata;
142 int dataprot = PROT_ALL;
143 int textprot = PROT_ALL & ~PROT_WRITE;
144 int isdyn;
145
146
147 args->to_model = DATAMODEL_ILP32;
148 *execsz = btopr(SINCR) + btopr(SSIZE) + btopr(NCARGS32-1);
149
150 /*
151 * Read in and validate the file header.
152 */
153 if (error = get_aout_head(&vp, &edp, execsz, &isdyn))
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
25 * Copyright 2015, Joyent, Inc.
26 */
27
28 #include <sys/types.h>
29 #include <sys/param.h>
30 #include <sys/systm.h>
31 #include <sys/fpu/fpusystm.h>
32 #include <sys/sysmacros.h>
33 #include <sys/signal.h>
34 #include <sys/cred.h>
35 #include <sys/user.h>
36 #include <sys/errno.h>
37 #include <sys/vnode.h>
38 #include <sys/mman.h>
39 #include <sys/kmem.h>
40 #include <sys/proc.h>
41 #include <sys/pathname.h>
42 #include <sys/cmn_err.h>
43 #include <sys/debug.h>
44 #include <sys/exec.h>
45 #include <sys/exechdr.h>
46 #include <sys/auxv.h>
47 #include <sys/core.h>
48 #include <sys/vmparam.h>
49 #include <sys/archsystm.h>
50 #include <sys/fs/swapnode.h>
51 #include <sys/modctl.h>
52 #include <vm/anon.h>
53 #include <vm/as.h>
54 #include <vm/seg.h>
55
56 static int aoutexec(vnode_t *vp, execa_t *uap, uarg_t *args,
57 intpdata_t *idatap, int level, long *execsz, int setid,
58 caddr_t exec_file, cred_t *cred, int *brand_action);
59 static int get_aout_head(struct vnode **vpp, struct exdata *edp, long *execsz,
60 int *isdyn);
61 static int aoutcore(vnode_t *vp, proc_t *pp, cred_t *credp,
62 rlim64_t rlimit, int sig, core_content_t content);
63 extern int elf32exec(vnode_t *, execa_t *, uarg_t *, intpdata_t *, int,
64 long *, int, caddr_t, cred_t *, int);
65 extern int elf32core(vnode_t *, proc_t *, cred_t *, rlim64_t, int,
66 core_content_t);
67
68 static struct execsw nesw = {
69 aout_nmagicstr,
70 2,
71 2,
72 aoutexec,
73 aoutcore
74 };
75
76 static struct execsw zesw = {
77 aout_zmagicstr,
78 2,
114 return (mod_install(&modlinkage));
115 }
116
117 int
118 _fini(void)
119 {
120 return (mod_remove(&modlinkage));
121 }
122
123 int
124 _info(struct modinfo *modinfop)
125 {
126 return (mod_info(&modlinkage, modinfop));
127 }
128
129
130 /*ARGSUSED*/
131 static int
132 aoutexec(vnode_t *vp, struct execa *uap, struct uarg *args,
133 struct intpdata *idatap, int level, long *execsz, int setid,
134 caddr_t exec_file, cred_t *cred, int *brand_action)
135 {
136 auxv32_t auxflags_auxv32;
137 int error;
138 struct exdata edp, edpout;
139 struct execenv exenv;
140 proc_t *pp = ttoproc(curthread);
141 struct vnode *nvp;
142 int pagetext, pagedata;
143 int dataprot = PROT_ALL;
144 int textprot = PROT_ALL & ~PROT_WRITE;
145 int isdyn;
146
147
148 args->to_model = DATAMODEL_ILP32;
149 *execsz = btopr(SINCR) + btopr(SSIZE) + btopr(NCARGS32-1);
150
151 /*
152 * Read in and validate the file header.
153 */
154 if (error = get_aout_head(&vp, &edp, execsz, &isdyn))
|