Do not call FreeBSD-ABI specific code for all ABIs

(cherry picked from commit 28a66fc3da)
This commit is contained in:
Konstantin Belousov 2021-07-01 21:00:29 +03:00
parent cdb79e2e08
commit 39f259b1d5
14 changed files with 45 additions and 3 deletions

View file

@ -82,6 +82,8 @@ struct sysentvec elf64_freebsd_sysvec_la48 = {
.sv_thread_detach = NULL,
.sv_trap = NULL,
.sv_stackgap = elf64_stackgap,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
struct sysentvec elf64_freebsd_sysvec_la57 = {
@ -117,6 +119,8 @@ struct sysentvec elf64_freebsd_sysvec_la57 = {
.sv_thread_detach = NULL,
.sv_trap = NULL,
.sv_stackgap = elf64_stackgap,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
static void

View file

@ -97,6 +97,8 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_trap = NULL,
.sv_hwcap = &elf_hwcap,
.sv_hwcap2 = &elf_hwcap2,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);

View file

@ -109,6 +109,8 @@ static struct sysentvec elf32_freebsd_sysvec = {
.sv_schedtail = NULL,
.sv_thread_detach = NULL,
.sv_trap = NULL,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);

View file

@ -92,6 +92,8 @@ static struct sysentvec elf64_freebsd_sysvec = {
.sv_trap = NULL,
.sv_hwcap = &elf_hwcap,
.sv_hwcap2 = &elf_hwcap2,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);

View file

@ -128,6 +128,8 @@ struct sysentvec ia32_freebsd_sysvec = {
.sv_thread_detach = NULL,
.sv_trap = NULL,
.sv_stackgap = elf32_stackgap,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec);

View file

@ -83,6 +83,8 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_schedtail = NULL,
.sv_thread_detach = NULL,
.sv_trap = NULL,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);

View file

@ -101,6 +101,8 @@ struct sysentvec aout_sysvec = {
.sv_schedtail = NULL,
.sv_thread_detach = NULL,
.sv_trap = NULL,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
#elif defined(__amd64__)
@ -137,6 +139,8 @@ struct sysentvec aout_sysvec = {
.sv_set_syscall_retval = ia32_set_syscall_retval,
.sv_fetch_syscall_args = ia32_fetch_syscall_args,
.sv_syscallnames = freebsd32_syscallnames,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
#else
#error "Port me"

View file

@ -1033,6 +1033,13 @@ exec_unmap_first_page(struct image_params *imgp)
}
}
void
exec_onexec_old(struct thread *td)
{
sigfastblock_clear(td);
umtx_exec(td->td_proc);
}
/*
* Destroy old address space, and allocate a new stack.
* The new stack is only sgrowsiz large because it is grown
@ -1055,8 +1062,6 @@ exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv)
imgp->vmspace_destroyed = 1;
imgp->sysent = sv;
sigfastblock_clear(td);
umtx_exec(p);
if (p->p_sysent->sv_onexec_old != NULL)
p->p_sysent->sv_onexec_old(td);
itimers_exec(p);

View file

@ -195,6 +195,13 @@ proc_clear_orphan(struct proc *p)
p->p_treeflag &= ~P_TREE_ORPHANED;
}
void
exit_onexit(struct proc *p)
{
MPASS(p->p_numthreads == 1);
umtx_thread_exit(FIRST_THREAD_IN_PROC(p));
}
/*
* exit -- death of process.
*/
@ -370,7 +377,6 @@ exit1(struct thread *td, int rval, int signo)
PROC_UNLOCK(p);
umtx_thread_exit(td);
if (p->p_sysent->sv_onexit != NULL)
p->p_sysent->sv_onexit(p);
seltdfini(td);

View file

@ -89,6 +89,8 @@ static struct sysentvec elf_freebsd_sysvec = {
.sv_schedtail = NULL,
.sv_thread_detach = NULL,
.sv_trap = NULL,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
static __ElfN(Brandinfo) freebsd_brand_info = {

View file

@ -131,6 +131,8 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_trap = NULL,
.sv_hwcap = &cpu_features,
.sv_hwcap2 = &cpu_features2,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);

View file

@ -93,6 +93,8 @@ struct sysentvec elf64_freebsd_sysvec_v1 = {
.sv_trap = NULL,
.sv_hwcap = &cpu_features,
.sv_hwcap2 = &cpu_features2,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
struct sysentvec elf64_freebsd_sysvec_v2 = {
@ -129,6 +131,8 @@ struct sysentvec elf64_freebsd_sysvec_v2 = {
.sv_trap = NULL,
.sv_hwcap = &cpu_features,
.sv_hwcap2 = &cpu_features2,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
static boolean_t ppc64_elfv1_header_match(struct image_params *params,

View file

@ -96,6 +96,8 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_trap = NULL,
.sv_hwcap = &elf_hwcap,
.sv_machine_arch = riscv_machine_arch,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
};
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);

View file

@ -317,6 +317,9 @@ void exec_sysvec_init(void *param);
void exec_sysvec_init_secondary(struct sysentvec *sv, struct sysentvec *sv2);
void exec_inittk(void);
void exit_onexit(struct proc *p);
void exec_onexec_old(struct thread *td);
#define INIT_SYSENTVEC(name, sv) \
SYSINIT(name, SI_SUB_EXEC, SI_ORDER_ANY, \
(sysinit_cfunc_t)exec_sysvec_init, sv);