int osf1_exec_ecoff_hook(struct proc *p, struct exec_package *epp) { struct ecoff_exechdr *execp = (struct ecoff_exechdr *)epp->ep_hdr; struct osf1_exec_emul_arg *emul_arg; int error; /* if we're here and we're exec-able at all, we're an OSF/1 binary */ epp->ep_emul = &emul_osf1; /* set up the exec package emul arg as appropriate */ emul_arg = malloc(sizeof *emul_arg, M_TEMP, M_WAITOK); epp->ep_emul_arg = emul_arg; emul_arg->flags = 0; if (epp->ep_ndp->ni_segflg == UIO_SYSSPACE) error = copystr(epp->ep_ndp->ni_dirp, emul_arg->exec_name, MAXPATHLEN + 1, NULL); else error = copyinstr(epp->ep_ndp->ni_dirp, emul_arg->exec_name, MAXPATHLEN + 1, NULL); #ifdef DIAGNOSTIC if (error != 0) panic("osf1_exec_ecoff_hook: copyinstr failed"); #endif /* do any special object file handling */ switch (execp->f.f_flags & ECOFF_FLAG_OBJECT_TYPE_MASK) { case ECOFF_OBJECT_TYPE_SHARABLE: /* can't exec a shared library! */ uprintf("can't execute OSF/1 shared libraries\n"); error = ENOEXEC; break; case ECOFF_OBJECT_TYPE_CALL_SHARED: error = osf1_exec_ecoff_dynamic(p, epp); break; default: /* just let the normal ECOFF handlers deal with it. */ error = 0; break; } if (error) { free(epp->ep_emul_arg, M_TEMP); epp->ep_emul_arg = NULL; kill_vmcmds(&epp->ep_vmcmds); /* if any */ } return (error); }
int osf1_exec_ecoff_probe(struct lwp *l, struct exec_package *epp) { struct ecoff_exechdr *execp = (struct ecoff_exechdr *)epp->ep_hdr; struct osf1_exec_emul_arg *emul_arg; int error; /* check if the binary is osf1 ecoff */ if (execp->f.f_magic != ECOFF_MAGIC_ALPHA) return ENOEXEC; /* set up the exec package emul arg as appropriate */ emul_arg = kmem_alloc(sizeof(*emul_arg), KM_SLEEP); epp->ep_emul_arg = emul_arg; epp->ep_emul_arg_free = osf1_free_emul_arg; emul_arg->flags = 0; /* this cannot overflow because both are size PATH_MAX */ strcpy(emul_arg->exec_name, epp->ep_kname); /* do any special object file handling */ switch (execp->f.f_flags & ECOFF_FLAG_OBJECT_TYPE_MASK) { case ECOFF_OBJECT_TYPE_SHARABLE: /* can't exec a shared library! */ #if 0 uprintf("can't execute OSF/1 shared libraries\n"); #endif error = ENOEXEC; break; case ECOFF_OBJECT_TYPE_CALL_SHARED: error = osf1_exec_ecoff_dynamic(l, epp); break; default: /* just let the normal ECOFF handlers deal with it. */ error = 0; break; } if (error) { exec_free_emul_arg(epp); kill_vmcmds(&epp->ep_vmcmds); /* if any */ } return (error); }