summaryrefslogtreecommitdiff
path: root/usr/src/uts
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts')
-rw-r--r--usr/src/uts/common/conf/param.c24
-rw-r--r--usr/src/uts/common/exec/aout/aout.c347
-rw-r--r--usr/src/uts/common/os/mmapobj.c263
-rw-r--r--usr/src/uts/common/sys/exec.h23
-rw-r--r--usr/src/uts/sparc/Makefile.sparc2
-rw-r--r--usr/src/uts/sparc/aoutexec/Makefile88
-rw-r--r--usr/src/uts/sun4/vm/vm_dep.c81
7 files changed, 7 insertions, 821 deletions
diff --git a/usr/src/uts/common/conf/param.c b/usr/src/uts/common/conf/param.c
index 9a7a08d380..a4266ba267 100644
--- a/usr/src/uts/common/conf/param.c
+++ b/usr/src/uts/common/conf/param.c
@@ -23,6 +23,7 @@
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012 Milan Jurik. All rights reserved.
+ * Copyright 2022 Garrett D'Amore <garrett@damore.org>
*/
#include <sys/types.h>
@@ -336,11 +337,6 @@ short elfmagic = 0x7f45;
short intpmagic = 0x2321;
short jmagic = 0x504b;
-#if defined(__sparc)
-short aout_nmagic = NMAGIC;
-short aout_zmagic = ZMAGIC;
-short aout_omagic = OMAGIC;
-#endif
short nomagic = 0;
/*
@@ -350,9 +346,6 @@ short nomagic = 0;
#define ELF64MAGIC_STRING "\x7f""ELF\x2"
#define INTPMAGIC_STRING "#!"
#define JAVAMAGIC_STRING "PK\003\004"
-#define AOUT_OMAGIC_STRING "\x1""\x07" /* 0407 */
-#define AOUT_NMAGIC_STRING "\x1""\x08" /* 0410 */
-#define AOUT_ZMAGIC_STRING "\x1""\x0b" /* 0413 */
#define NOMAGIC_STRING ""
#define SHBIN_CNTL(x) ((x)&037)
@@ -364,11 +357,6 @@ char elf64magicstr[] = ELF64MAGIC_STRING;
char intpmagicstr[] = INTPMAGIC_STRING;
char shbinmagicstr[] = SHBINMAGIC_STRING;
char javamagicstr[] = JAVAMAGIC_STRING;
-#if defined(__sparc)
-char aout_nmagicstr[] = AOUT_NMAGIC_STRING;
-char aout_zmagicstr[] = AOUT_ZMAGIC_STRING;
-char aout_omagicstr[] = AOUT_OMAGIC_STRING;
-#endif
char nomagicstr[] = NOMAGIC_STRING;
char *execswnames[] = {
@@ -379,11 +367,6 @@ char *execswnames[] = {
"intpexec",
"shbinexec",
"javaexec",
-#if defined(__sparc)
- "aoutexec",
- "aoutexec",
- "aoutexec",
-#endif
NULL,
NULL,
NULL
@@ -397,11 +380,6 @@ struct execsw execsw[] = {
{ intpmagicstr, 0, 2, NULL, NULL, NULL },
{ shbinmagicstr, 0, SHBINMAGIC_LEN, NULL, NULL, NULL },
{ javamagicstr, 0, 4, NULL, NULL, NULL },
-#if defined(__sparc)
- { aout_zmagicstr, 2, 2, NULL, NULL, NULL },
- { aout_nmagicstr, 2, 2, NULL, NULL, NULL },
- { aout_omagicstr, 2, 2, NULL, NULL, NULL },
-#endif
{ nomagicstr, 0, 0, NULL, NULL, NULL },
{ nomagicstr, 0, 0, NULL, NULL, NULL },
{ nomagicstr, 0, 0, NULL, NULL, NULL },
diff --git a/usr/src/uts/common/exec/aout/aout.c b/usr/src/uts/common/exec/aout/aout.c
deleted file mode 100644
index fc45bd9544..0000000000
--- a/usr/src/uts/common/exec/aout/aout.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/fpu/fpusystm.h>
-#include <sys/sysmacros.h>
-#include <sys/signal.h>
-#include <sys/cred.h>
-#include <sys/user.h>
-#include <sys/errno.h>
-#include <sys/vnode.h>
-#include <sys/mman.h>
-#include <sys/kmem.h>
-#include <sys/proc.h>
-#include <sys/pathname.h>
-#include <sys/cmn_err.h>
-#include <sys/debug.h>
-#include <sys/exec.h>
-#include <sys/exechdr.h>
-#include <sys/auxv.h>
-#include <sys/core.h>
-#include <sys/vmparam.h>
-#include <sys/archsystm.h>
-#include <sys/fs/swapnode.h>
-#include <sys/modctl.h>
-#include <vm/anon.h>
-#include <vm/as.h>
-#include <vm/seg.h>
-
-static int aoutexec(vnode_t *vp, execa_t *uap, uarg_t *args,
- intpdata_t *idatap, int level, long *execsz, int setid,
- caddr_t exec_file, cred_t *cred, int brand_action);
-static int get_aout_head(struct vnode **vpp, struct exdata *edp, long *execsz,
- int *isdyn);
-static int aoutcore(vnode_t *vp, proc_t *pp, cred_t *credp,
- rlim64_t rlimit, int sig, core_content_t content);
-extern int elf32exec(vnode_t *, execa_t *, uarg_t *, intpdata_t *, int,
- long *, int, caddr_t, cred_t *, int);
-extern int elf32core(vnode_t *, proc_t *, cred_t *, rlim64_t, int,
- core_content_t);
-
-static struct execsw nesw = {
- aout_nmagicstr,
- 2,
- 2,
- aoutexec,
- aoutcore
-};
-
-static struct execsw zesw = {
- aout_zmagicstr,
- 2,
- 2,
- aoutexec,
- aoutcore
-};
-
-static struct execsw oesw = {
- aout_omagicstr,
- 2,
- 2,
- aoutexec,
- aoutcore
-};
-
-/*
- * Module linkage information for the kernel.
- */
-static struct modlexec nexec = {
- &mod_execops, "exec for NMAGIC", &nesw
-};
-
-static struct modlexec zexec = {
- &mod_execops, "exec for ZMAGIC", &zesw
-};
-
-static struct modlexec oexec = {
- &mod_execops, "exec for OMAGIC", &oesw
-};
-
-static struct modlinkage modlinkage = {
- MODREV_1, &nexec, &zexec, &oexec, NULL
-};
-
-int
-_init(void)
-{
- return (mod_install(&modlinkage));
-}
-
-int
-_fini(void)
-{
- return (mod_remove(&modlinkage));
-}
-
-int
-_info(struct modinfo *modinfop)
-{
- return (mod_info(&modlinkage, modinfop));
-}
-
-
-/*ARGSUSED*/
-static int
-aoutexec(vnode_t *vp, struct execa *uap, struct uarg *args,
- struct intpdata *idatap, int level, long *execsz, int setid,
- caddr_t exec_file, cred_t *cred, int brand_action)
-{
- auxv32_t auxflags_auxv32;
- int error;
- struct exdata edp, edpout;
- struct execenv exenv;
- proc_t *pp = ttoproc(curthread);
- struct vnode *nvp;
- int pagetext, pagedata;
- int dataprot = PROT_ALL;
- int textprot = PROT_ALL & ~PROT_WRITE;
- int isdyn;
-
-
- args->to_model = DATAMODEL_ILP32;
- *execsz = btopr(SINCR) + btopr(SSIZE) + btopr(NCARGS32-1);
-
- /*
- * Read in and validate the file header.
- */
- if (error = get_aout_head(&vp, &edp, execsz, &isdyn))
- return (error);
-
- if (error = chkaout(&edp))
- return (error);
-
- /*
- * Take a quick look to see if it looks like we will have
- * enough swap space for the program to get started. This
- * is not a guarantee that we will succeed, but it is definitely
- * better than finding this out after we are committed to the
- * new memory image. Maybe what is needed is a way to "prereserve"
- * swap space for some segment mappings here.
- *
- * But with shared libraries the process can make it through
- * the exec only to have ld.so fail to get the program going
- * because its mmap's will not be able to succeed if the system
- * is running low on swap space. In fact this is a far more
- * common failure mode, but we cannot do much about this here
- * other than add some slop to our anonymous memory resources
- * requirements estimate based on some guess since we cannot know
- * what else the program will really need to get to a useful state.
- *
- * XXX - The stack size (clrnd(SSIZE + btopr(nargc))) should also
- * be used when checking for swap space. This requires some work
- * since nargc is actually determined in exec_args() which is done
- * after this check and hence we punt for now.
- *
- * nargc = SA(nc + (na + 4) * NBPW) + sizeof (struct rwindow);
- */
- if (CURRENT_TOTAL_AVAILABLE_SWAP < btopr(edp.ux_dsize) + btopr(SSIZE))
- return (ENOMEM);
-
- /*
- * Load the trap 0 interpreter.
- */
- if (error = lookupname("/usr/4lib/sbcp", UIO_SYSSPACE, FOLLOW,
- NULLVPP, &nvp)) {
- goto done;
- }
- if (error = elf32exec(nvp, uap, args, idatap, level, execsz,
- setid, exec_file, cred, brand_action)) {
- VN_RELE(nvp);
- return (error);
- }
- VN_RELE(nvp);
-
- /*
- * Determine the a.out's characteristics.
- */
- getexinfo(&edp, &edpout, &pagetext, &pagedata);
-
- /*
- * Load the a.out's text and data.
- */
- if (error = execmap(edp.vp, edp.ux_txtorg, edp.ux_tsize,
- (size_t)0, edp.ux_toffset, textprot, pagetext, 0))
- goto done;
- if (error = execmap(edp.vp, edp.ux_datorg, edp.ux_dsize,
- edp.ux_bsize, edp.ux_doffset, dataprot, pagedata, 0))
- goto done;
-
- exenv.ex_bssbase = (caddr_t)edp.ux_datorg;
- exenv.ex_brkbase = (caddr_t)edp.ux_datorg;
- exenv.ex_brksize = edp.ux_dsize + edp.ux_bsize;
- exenv.ex_magic = edp.ux_mag;
- exenv.ex_vp = edp.vp;
- setexecenv(&exenv);
-
- /*
- * It's time to manipulate the process aux vectors.
- * We need to update the AT_SUN_AUXFLAGS aux vector to set
- * the AF_SUN_NOPLM flag.
- */
- if (copyin(args->auxp_auxflags, &auxflags_auxv32,
- sizeof (auxflags_auxv32)) != 0)
- return (EFAULT);
-
- ASSERT(auxflags_auxv32.a_type == AT_SUN_AUXFLAGS);
- auxflags_auxv32.a_un.a_val |= AF_SUN_NOPLM;
- if (copyout(&auxflags_auxv32, args->auxp_auxflags,
- sizeof (auxflags_auxv32)) != 0)
- return (EFAULT);
-
-done:
- if (error != 0)
- psignal(pp, SIGKILL);
- else {
- /*
- * Ensure that the max fds do not exceed 256 (this is
- * applicable to 4.x binaries, which is why we only
- * do it on a.out files).
- */
- struct rlimit64 fdno_rlim;
- rctl_alloc_gp_t *gp = rctl_rlimit_set_prealloc(1);
-
- mutex_enter(&curproc->p_lock);
- (void) rctl_rlimit_get(rctlproc_legacy[RLIMIT_NOFILE], curproc,
- &fdno_rlim);
- if (fdno_rlim.rlim_cur > 256) {
- fdno_rlim.rlim_cur = fdno_rlim.rlim_max = 256;
- (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_NOFILE],
- curproc, &fdno_rlim, gp,
- rctlproc_flags[RLIMIT_NOFILE],
- rctlproc_signals[RLIMIT_NOFILE], CRED());
- } else if (fdno_rlim.rlim_max > 256) {
- fdno_rlim.rlim_max = 256;
- (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_NOFILE],
- curproc, &fdno_rlim, gp,
- rctlproc_flags[RLIMIT_NOFILE],
- rctlproc_signals[RLIMIT_NOFILE], CRED());
- }
- mutex_exit(&curproc->p_lock);
-
- rctl_prealloc_destroy(gp);
- }
-
- return (error);
-}
-
-/*
- * Read in and validate the file header.
- */
-static int
-get_aout_head(struct vnode **vpp, struct exdata *edp, long *execsz, int *isdyn)
-{
- struct vnode *vp = *vpp;
- struct exec filhdr;
- int error;
- ssize_t resid;
- rlim64_t limit;
- rlim64_t roundlimit;
-
- if (error = vn_rdwr(UIO_READ, vp, (caddr_t)&filhdr,
- (ssize_t)sizeof (filhdr), (offset_t)0, UIO_SYSSPACE, 0,
- (rlim64_t)0, CRED(), &resid))
- return (error);
-
- if (resid != 0)
- return (ENOEXEC);
-
- switch (filhdr.a_magic) {
- case OMAGIC:
- filhdr.a_data += filhdr.a_text;
- filhdr.a_text = 0;
- break;
- case ZMAGIC:
- case NMAGIC:
- break;
- default:
- return (ENOEXEC);
- }
-
- /*
- * Check total memory requirements (in pages) for a new process
- * against the available memory or upper limit of memory allowed.
- *
- * For the 64-bit kernel, the limit can be set large enough so that
- * rounding it up to a page can overflow, so we check for btopr()
- * overflowing here by comparing it with the unrounded limit in pages.
- */
- *execsz += btopr(filhdr.a_text + filhdr.a_data);
- limit = btop(curproc->p_vmem_ctl);
- roundlimit = btopr(curproc->p_vmem_ctl);
- if ((roundlimit > limit && *execsz > roundlimit) ||
- (roundlimit < limit && *execsz > limit)) {
- mutex_enter(&curproc->p_lock);
- (void) rctl_action(rctlproc_legacy[RLIMIT_VMEM],
- curproc->p_rctls, curproc, RCA_SAFE);
- mutex_exit(&curproc->p_lock);
- return (ENOMEM);
- }
-
- edp->ux_mach = filhdr.a_machtype;
- edp->ux_tsize = filhdr.a_text;
- edp->ux_dsize = filhdr.a_data;
- edp->ux_bsize = filhdr.a_bss;
- edp->ux_mag = filhdr.a_magic;
- edp->ux_toffset = gettfile(&filhdr);
- edp->ux_doffset = getdfile(&filhdr);
- edp->ux_txtorg = gettmem(&filhdr);
- edp->ux_datorg = getdmem(&filhdr);
- edp->ux_entloc = (caddr_t)(uintptr_t)filhdr.a_entry;
- edp->vp = vp;
- *isdyn = filhdr.a_dynamic;
-
- return (0);
-}
-
-static int
-aoutcore(vnode_t *vp, proc_t *pp, struct cred *credp, rlim64_t rlimit, int sig,
- core_content_t content)
-{
- return (elf32core(vp, pp, credp, rlimit, sig, content));
-}
diff --git a/usr/src/uts/common/os/mmapobj.c b/usr/src/uts/common/os/mmapobj.c
index 779cd340f4..d85df39a62 100644
--- a/usr/src/uts/common/os/mmapobj.c
+++ b/usr/src/uts/common/os/mmapobj.c
@@ -22,6 +22,7 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2014 Joyent, Inc. All rights reserved.
+ * Copyright 2022 Garrett D'Amore <garrett@damore.org>
*/
#include <sys/types.h>
@@ -179,19 +180,6 @@ struct mobj_stats {
uint_t mobjs_lib_va_add_delete;
uint_t mobjs_lib_va_create_failure;
uint_t mobjs_min_align;
-#if defined(__sparc)
- uint_t mobjs_aout_uzero_fault;
- uint_t mobjs_aout_64bit_try;
- uint_t mobjs_aout_noexec;
- uint_t mobjs_aout_e2big;
- uint_t mobjs_aout_lib;
- uint_t mobjs_aout_fixed;
- uint_t mobjs_aout_zfoddiff;
- uint_t mobjs_aout_map_bss;
- uint_t mobjs_aout_bss_fail;
- uint_t mobjs_aout_nlist;
- uint_t mobjs_aout_addr_in_use;
-#endif
} mobj_stats;
#define MOBJ_STAT_ADD(stat) ((mobj_stats.mobjs_##stat)++)
@@ -2054,244 +2042,6 @@ doelfwork(Ehdr *ehdrp, vnode_t *vp, mmapobj_result_t *mrp,
return (error);
}
-#if defined(__sparc)
-/*
- * Hack to support 64 bit kernels running AOUT 4.x programs.
- * This is the sizeof (struct nlist) for a 32 bit kernel.
- * Since AOUT programs are 32 bit only, they will never use the 64 bit
- * sizeof (struct nlist) and thus creating a #define is the simplest
- * way around this since this is a format which is not being updated.
- * This will be used in the place of sizeof (struct nlist) below.
- */
-#define NLIST_SIZE (0xC)
-
-static int
-doaoutwork(vnode_t *vp, mmapobj_result_t *mrp,
- uint_t *num_mapped, struct exec *hdr, cred_t *fcred)
-{
- int error;
- size_t size;
- size_t osize;
- size_t nsize; /* nlist size */
- size_t msize;
- size_t zfoddiff;
- caddr_t addr;
- caddr_t start_addr;
- struct as *as = curproc->p_as;
- int prot = PROT_USER | PROT_READ | PROT_EXEC;
- uint_t mflag = MAP_PRIVATE | _MAP_LOW32;
- offset_t off = 0;
- int segnum = 0;
- uint_t to_map;
- int is_library = 0;
- struct segvn_crargs crargs = SEGVN_ZFOD_ARGS(PROT_ZFOD, PROT_ALL);
-
- /* Only 32bit apps supported by this file format */
- if (get_udatamodel() != DATAMODEL_ILP32) {
- MOBJ_STAT_ADD(aout_64bit_try);
- return (ENOTSUP);
- }
-
- /* Check to see if this is a library */
- if (hdr->a_magic == ZMAGIC && hdr->a_entry < PAGESIZE) {
- is_library = 1;
- }
-
- /*
- * Can't execute code from "noexec" mounted filesystem. Unlike ELF,
- * aout libraries are always mapped with something PROT_EXEC, so this
- * doesn't need to be checked for specific parts
- */
- if ((vp->v_vfsp->vfs_flag & VFS_NOEXEC) != 0) {
- MOBJ_STAT_ADD(aout_noexec);
- return (EACCES);
- }
-
- /*
- * There are 2 ways to calculate the mapped size of executable:
- * 1) rounded text size + data size + bss size.
- * 2) starting offset for text + text size + data size + text relocation
- * size + data relocation size + room for nlist data structure.
- *
- * The larger of the two sizes will be used to map this binary.
- */
- osize = P2ROUNDUP(hdr->a_text, PAGESIZE) + hdr->a_data + hdr->a_bss;
-
- off = hdr->a_magic == ZMAGIC ? 0 : sizeof (struct exec);
-
- nsize = off + hdr->a_text + hdr->a_data + hdr->a_trsize +
- hdr->a_drsize + NLIST_SIZE;
-
- size = MAX(osize, nsize);
- if (size != nsize) {
- nsize = 0;
- }
-
- /*
- * 1 seg for text and 1 seg for initialized data.
- * 1 seg for bss (if can't fit in leftover space of init data)
- * 1 seg for nlist if needed.
- */
- to_map = 2 + (nsize ? 1 : 0) +
- (hdr->a_bss > PAGESIZE - P2PHASE(hdr->a_data, PAGESIZE) ? 1 : 0);
- if (*num_mapped < to_map) {
- *num_mapped = to_map;
- MOBJ_STAT_ADD(aout_e2big);
- return (E2BIG);
- }
-
- /* Reserve address space for the whole mapping */
- if (is_library) {
- /* We'll let VOP_MAP below pick our address for us */
- addr = NULL;
- MOBJ_STAT_ADD(aout_lib);
- } else {
- /*
- * default start address for fixed binaries from AOUT 4.x
- * standard.
- */
- MOBJ_STAT_ADD(aout_fixed);
- mflag |= MAP_FIXED;
- addr = (caddr_t)0x2000;
- as_rangelock(as);
- if (as_gap(as, size, &addr, &size, 0, NULL) != 0) {
- as_rangeunlock(as);
- MOBJ_STAT_ADD(aout_addr_in_use);
- return (EADDRINUSE);
- }
- crargs.flags |= MAP_NORESERVE;
- error = as_map(as, addr, size, segvn_create, &crargs);
- ASSERT(addr == (caddr_t)0x2000);
- as_rangeunlock(as);
- }
-
- start_addr = addr;
- osize = size;
-
- /*
- * Map as large as we need, backed by file, this will be text, and
- * possibly the nlist segment. We map over this mapping for bss and
- * initialized data segments.
- */
- error = VOP_MAP(vp, off, as, &addr, size, prot, PROT_ALL,
- mflag, fcred, NULL);
- if (error) {
- if (!is_library) {
- (void) as_unmap(as, start_addr, osize);
- }
- return (error);
- }
-
- /* pickup the value of start_addr and osize for libraries */
- start_addr = addr;
- osize = size;
-
- /*
- * We have our initial reservation/allocation so we need to use fixed
- * addresses from now on.
- */
- mflag |= MAP_FIXED;
-
- mrp[0].mr_addr = addr;
- mrp[0].mr_msize = hdr->a_text;
- mrp[0].mr_fsize = hdr->a_text;
- mrp[0].mr_offset = 0;
- mrp[0].mr_prot = PROT_READ | PROT_EXEC;
- mrp[0].mr_flags = MR_HDR_AOUT;
-
-
- /*
- * Map initialized data. We are mapping over a portion of the
- * previous mapping which will be unmapped in VOP_MAP below.
- */
- off = P2ROUNDUP((offset_t)(hdr->a_text), PAGESIZE);
- msize = off;
- addr += off;
- size = hdr->a_data;
- error = VOP_MAP(vp, off, as, &addr, size, PROT_ALL, PROT_ALL,
- mflag, fcred, NULL);
- if (error) {
- (void) as_unmap(as, start_addr, osize);
- return (error);
- }
- msize += size;
- mrp[1].mr_addr = addr;
- mrp[1].mr_msize = size;
- mrp[1].mr_fsize = size;
- mrp[1].mr_offset = 0;
- mrp[1].mr_prot = PROT_READ | PROT_WRITE | PROT_EXEC;
- mrp[1].mr_flags = 0;
-
- /* Need to zero out remainder of page */
- addr += hdr->a_data;
- zfoddiff = P2PHASE((size_t)addr, PAGESIZE);
- if (zfoddiff) {
- label_t ljb;
-
- MOBJ_STAT_ADD(aout_zfoddiff);
- zfoddiff = PAGESIZE - zfoddiff;
- if (on_fault(&ljb)) {
- no_fault();
- MOBJ_STAT_ADD(aout_uzero_fault);
- (void) as_unmap(as, start_addr, osize);
- return (EFAULT);
- }
- uzero(addr, zfoddiff);
- no_fault();
- }
- msize += zfoddiff;
- segnum = 2;
-
- /* Map bss */
- if (hdr->a_bss > zfoddiff) {
- struct segvn_crargs crargs =
- SEGVN_ZFOD_ARGS(PROT_ZFOD, PROT_ALL);
- MOBJ_STAT_ADD(aout_map_bss);
- addr += zfoddiff;
- size = hdr->a_bss - zfoddiff;
- as_rangelock(as);
- (void) as_unmap(as, addr, size);
- error = as_map(as, addr, size, segvn_create, &crargs);
- as_rangeunlock(as);
- msize += size;
-
- if (error) {
- MOBJ_STAT_ADD(aout_bss_fail);
- (void) as_unmap(as, start_addr, osize);
- return (error);
- }
- mrp[2].mr_addr = addr;
- mrp[2].mr_msize = size;
- mrp[2].mr_fsize = 0;
- mrp[2].mr_offset = 0;
- mrp[2].mr_prot = PROT_READ | PROT_WRITE | PROT_EXEC;
- mrp[2].mr_flags = 0;
-
- addr += size;
- segnum = 3;
- }
-
- /*
- * If we have extra bits left over, we need to include that in how
- * much we mapped to make sure the nlist logic is correct
- */
- msize = P2ROUNDUP(msize, PAGESIZE);
-
- if (nsize && msize < nsize) {
- MOBJ_STAT_ADD(aout_nlist);
- mrp[segnum].mr_addr = addr;
- mrp[segnum].mr_msize = nsize - msize;
- mrp[segnum].mr_fsize = 0;
- mrp[segnum].mr_offset = 0;
- mrp[segnum].mr_prot = PROT_READ | PROT_EXEC;
- mrp[segnum].mr_flags = 0;
- }
-
- *num_mapped = to_map;
- return (0);
-}
-#endif
-
/*
* These are the two types of files that we can interpret and we want to read
* in enough info to cover both types when looking at the initial header.
@@ -2412,17 +2162,6 @@ mmapobj_map_interpret(vnode_t *vp, mmapobj_result_t *mrp,
padding, fcred));
}
-#if defined(__sparc)
- /* On sparc, check for 4.X AOUT format */
- switch (((struct exec *)header)->a_magic) {
- case OMAGIC:
- case ZMAGIC:
- case NMAGIC:
- return (doaoutwork(vp, mrp, num_mapped,
- (struct exec *)lheader, fcred));
- }
-#endif
-
/* Unsupported type */
MOBJ_STAT_ADD(unsupported);
return (ENOTSUP);
diff --git a/usr/src/uts/common/sys/exec.h b/usr/src/uts/common/sys/exec.h
index 8056f9a8e8..7849e75370 100644
--- a/usr/src/uts/common/sys/exec.h
+++ b/usr/src/uts/common/sys/exec.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Garrett D'Amore <garrett@damore.org>
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -190,22 +191,12 @@ extern kmutex_t execsw_lock;
extern short elfmagic;
extern short intpmagic;
extern short javamagic;
-#if defined(__sparc)
-extern short aout_zmagic;
-extern short aout_nmagic;
-extern short aout_omagic;
-#endif
extern short nomagic;
extern char elf32magicstr[];
extern char elf64magicstr[];
extern char intpmagicstr[];
extern char javamagicstr[];
-#if defined(__sparc)
-extern char aout_nmagicstr[];
-extern char aout_zmagicstr[];
-extern char aout_omagicstr[];
-#endif
extern char nomagicstr[];
extern int exec_args(execa_t *, uarg_t *, intpdata_t *, void **);
@@ -260,18 +251,6 @@ extern int core_seg(proc_t *, vnode_t *, offset_t, caddr_t,
extern int core_write(vnode_t *, enum uio_seg, offset_t,
const void *, size_t, rlim64_t, cred_t *);
-/* a.out stuff */
-
-struct exec;
-
-extern caddr_t gettmem(struct exec *exp);
-extern caddr_t getdmem(struct exec *exp);
-extern ulong_t getdfile(struct exec *exp);
-extern uint_t gettfile(struct exec *exp);
-extern int chkaout(struct exdata *exp);
-extern void getexinfo(struct exdata *edp_in, struct exdata *edp_out,
- int *pagetext, int *pagedata);
-
#endif /* _KERNEL */
#ifdef __cplusplus
diff --git a/usr/src/uts/sparc/Makefile.sparc b/usr/src/uts/sparc/Makefile.sparc
index a031e1606c..8c8ca81e30 100644
--- a/usr/src/uts/sparc/Makefile.sparc
+++ b/usr/src/uts/sparc/Makefile.sparc
@@ -350,7 +350,7 @@ DRV_KMODS += pcic
#
# Exec Class Modules (/kernel/exec):
#
-EXEC_KMODS += aoutexec elfexec intpexec shbinexec javaexec
+EXEC_KMODS += elfexec intpexec shbinexec javaexec
#
# Scheduling Class Modules (/kernel/sched):
diff --git a/usr/src/uts/sparc/aoutexec/Makefile b/usr/src/uts/sparc/aoutexec/Makefile
deleted file mode 100644
index 225726fc7c..0000000000
--- a/usr/src/uts/sparc/aoutexec/Makefile
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# uts/sparc/aoutexec/Makefile
-# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-# Copyright (c) 2011 Bayard G. Bell. All rights reserved.
-#
-# This makefile drives the production of the aoutexec exec kernel
-# module (binary compatibility).
-#
-# sparc architecture dependent
-#
-
-#
-# Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE = ../..
-
-#
-# Define the module and object file sets.
-#
-MODULE = aoutexec
-OBJECTS = $(AOUTEXEC_OBJS:%=$(OBJS_DIR)/%)
-ROOTMODULE = $(ROOT_EXEC_DIR)/$(MODULE)
-
-#
-# Include common rules.
-#
-include $(UTSBASE)/sparc/Makefile.sparc
-
-#
-# Define targets
-#
-ALL_TARGET = $(BINARY)
-INSTALL_TARGET = $(BINARY) $(ROOTMODULE)
-
-#
-# For now, disable these warnings; maintainers should endeavor
-# to investigate and remove these for maximum coverage.
-# Please do not carry these forward to new Makefiles.
-#
-CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-parentheses
-
-#
-# Define dependency on elfexec
-#
-LDFLAGS += -N exec/elfexec
-
-#
-# Default build targets.
-#
-.KEEP_STATE:
-
-def: $(DEF_DEPS)
-
-all: $(ALL_DEPS)
-
-clean: $(CLEAN_DEPS)
-
-clobber: $(CLOBBER_DEPS)
-
-install: $(INSTALL_DEPS)
-
-#
-# Include common targets.
-#
-include $(UTSBASE)/sparc/Makefile.targ
diff --git a/usr/src/uts/sun4/vm/vm_dep.c b/usr/src/uts/sun4/vm/vm_dep.c
index 835d321c1d..1243162085 100644
--- a/usr/src/uts/sun4/vm/vm_dep.c
+++ b/usr/src/uts/sun4/vm/vm_dep.c
@@ -22,6 +22,7 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2016 Joyent, Inc.
+ * Copyright 2022 Garrett D'Amore <garrett@damore.org>
*/
/*
@@ -426,82 +427,6 @@ chkaout(struct exdata *exp)
return (ENOEXEC);
}
-/*
- * The following functions return information about an a.out
- * which is used when a program is executed.
- */
-
-/*
- * Return the load memory address for the data segment.
- */
-caddr_t
-getdmem(struct exec *exp)
-{
- /*
- * XXX - Sparc Reference Hack approaching
- * Remember that we are loading
- * 8k executables into a 4k machine
- * DATA_ALIGN == 2 * PAGESIZE
- */
- if (exp->a_text)
- return ((caddr_t)(roundup(USRTEXT + exp->a_text, DATA_ALIGN)));
- else
- return ((caddr_t)USRTEXT);
-}
-
-/*
- * Return the starting disk address for the data segment.
- */
-ulong_t
-getdfile(struct exec *exp)
-{
- if (exp->a_magic == ZMAGIC)
- return (exp->a_text);
- else
- return (sizeof (struct exec) + exp->a_text);
-}
-
-/*
- * Return the load memory address for the text segment.
- */
-
-/*ARGSUSED*/
-caddr_t
-gettmem(struct exec *exp)
-{
- return ((caddr_t)USRTEXT);
-}
-
-/*
- * Return the file byte offset for the text segment.
- */
-uint_t
-gettfile(struct exec *exp)
-{
- if (exp->a_magic == ZMAGIC)
- return (0);
- else
- return (sizeof (struct exec));
-}
-
-void
-getexinfo(
- struct exdata *edp_in,
- struct exdata *edp_out,
- int *pagetext,
- int *pagedata)
-{
- *edp_out = *edp_in; /* structure copy */
-
- if ((edp_in->ux_mag == ZMAGIC) &&
- ((edp_in->vp->v_flag & VNOMAP) == 0)) {
- *pagetext = 1;
- *pagedata = 1;
- } else {
- *pagetext = 0;
- *pagedata = 0;
- }
-}
/*
* Return non 0 value if the address may cause a VAC alias with KPM mappings.
@@ -747,7 +672,7 @@ map_pgszcvec(caddr_t addr, size_t size, uintptr_t off, int flags, int type,
*
* page_counters[page_size][region_size]
*
- * page_size: TTE size code of pages on page_size freelist.
+ * page_size: TTE size code of pages on page_size freelist.
*
* region_size: TTE size code of a candidate larger page made up
* made up of contiguous free page_size pages.
@@ -757,7 +682,7 @@ map_pgszcvec(caddr_t addr, size_t size, uintptr_t off, int flags, int type,
* made up of page_size free pages can be coalesced into a
* regsion_size page. Yuck! Lets try an example:
*
- * page_counters[1][3] is the table element used for identifying
+ * page_counters[1][3] is the table element used for identifying
* candidate 4M pages from contiguous pages off the 64K free list.
* Each index in the page_counters[1][3].array spans 4M. Its the
* number of free 512K size (regsion_size - 1) groups of contiguous