linux(4): Add coredump support to i386.

MFC after:		1 week
This commit is contained in:
Dmitry Chagin 2023-02-02 17:58:06 +03:00
parent 6f8439db24
commit cc1b0f7d96
4 changed files with 61 additions and 4 deletions

View File

@ -395,4 +395,32 @@ struct l_desc_struct {
#define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r))
/* This corresponds to 'struct user_regs_struct' in Linux. */
struct linux_pt_regset {
l_uint ebx;
l_uint ecx;
l_uint edx;
l_uint esi;
l_uint edi;
l_uint ebp;
l_uint eax;
l_uint ds;
l_uint es;
l_uint fs;
l_uint gs;
l_uint orig_eax;
l_uint eip;
l_uint cs;
l_uint eflags;
l_uint esp;
l_uint ss;
};
#ifdef _KERNEL
struct reg;
void bsd_to_linux_regset(const struct reg *b_reg,
struct linux_pt_regset *l_regset);
#endif /* _KERNEL */
#endif /* !_I386_LINUX_H_ */

View File

@ -60,6 +60,8 @@ __FBSDID("$FreeBSD$");
#include <vm/vm.h>
#include <vm/vm_map.h>
#include <x86/reg.h>
#include <i386/linux/linux.h>
#include <i386/linux/linux_proto.h>
#include <compat/linux/linux_emul.h>
@ -675,3 +677,27 @@ linux_mq_getsetattr(struct thread *td, struct linux_mq_getsetattr_args *args)
return (ENOSYS);
#endif
}
void
bsd_to_linux_regset(const struct reg *b_reg,
struct linux_pt_regset *l_regset)
{
l_regset->ebx = b_reg->r_ebx;
l_regset->ecx = b_reg->r_ecx;
l_regset->edx = b_reg->r_edx;
l_regset->esi = b_reg->r_esi;
l_regset->edi = b_reg->r_edi;
l_regset->ebp = b_reg->r_ebp;
l_regset->eax = b_reg->r_eax;
l_regset->ds = b_reg->r_ds;
l_regset->es = b_reg->r_es;
l_regset->fs = b_reg->r_fs;
l_regset->gs = b_reg->r_gs;
l_regset->orig_eax = b_reg->r_eax;
l_regset->eip = b_reg->r_eip;
l_regset->cs = b_reg->r_cs;
l_regset->eflags = b_reg->r_eflags;
l_regset->esp = b_reg->r_esp;
l_regset->ss = b_reg->r_ss;
}

View File

@ -29,6 +29,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#define __ELF_WORD_SIZE 32
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/exec.h>
@ -65,6 +67,7 @@ __FBSDID("$FreeBSD$");
#include <x86/linux/linux_x86.h>
#include <i386/linux/linux.h>
#include <i386/linux/linux_proto.h>
#include <compat/linux/linux_elf.h>
#include <compat/linux/linux_emul.h>
#include <compat/linux/linux_fork.h>
#include <compat/linux/linux_ioctl.h>
@ -804,9 +807,9 @@ struct sysentvec elf_linux_sysvec = {
.sv_szsigcode = &linux_szsigcode,
.sv_name = "Linux ELF32",
.sv_coredump = elf32_coredump,
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
.sv_elf_core_prepare_notes = elf32_prepare_notes,
.sv_elf_core_osabi = ELFOSABI_NONE,
.sv_elf_core_abi_vendor = LINUX_ABI_VENDOR,
.sv_elf_core_prepare_notes = __linuxN(prepare_notes),
.sv_imgact_try = linux_exec_imgact_try,
.sv_minsigstksz = LINUX_MINSIGSTKSZ,
.sv_minuser = VM_MIN_ADDRESS,

View File

@ -12,6 +12,7 @@ CFLAGS+=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32
KMOD= linux
SRCS= linux${SFX}_dummy_machdep.c \
linux_elf32.c \
linux_event.c \
linux_file.c \
linux_fork.c \
@ -47,7 +48,6 @@ VDSODEPS=linux_vdso_gettc_x86.inc
.endif
.if ${MACHINE_CPUARCH} == "amd64"
SRCS+= linux${SFX}_support.S
SRCS+= linux_elf32.c
.else
SRCS+= linux_copyout.c
.endif