Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137842865
D30019.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
20 KB
Referenced Files
None
Subscribers
None
D30019.id.diff
View Options
diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c
--- a/sys/amd64/linux/linux_machdep.c
+++ b/sys/amd64/linux/linux_machdep.c
@@ -79,6 +79,7 @@
#include <vm/vm_map.h>
#include <x86/ifunc.h>
+#include <x86/reg.h>
#include <x86/sysarch.h>
#include <security/audit/audit.h>
@@ -347,3 +348,36 @@
return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
futex_xorl_smap : futex_xorl_nosmap);
}
+
+void
+bsd_to_linux_regset(struct reg *b_reg, struct linux_pt_regset *l_regset)
+{
+
+ l_regset->r15 = b_reg->r_r15;
+ l_regset->r14 = b_reg->r_r14;
+ l_regset->r13 = b_reg->r_r13;
+ l_regset->r12 = b_reg->r_r12;
+ l_regset->rbp = b_reg->r_rbp;
+ l_regset->rbx = b_reg->r_rbx;
+ l_regset->r11 = b_reg->r_r11;
+ l_regset->r10 = b_reg->r_r10;
+ l_regset->r9 = b_reg->r_r9;
+ l_regset->r8 = b_reg->r_r8;
+ l_regset->rax = b_reg->r_rax;
+ l_regset->rcx = b_reg->r_rcx;
+ l_regset->rdx = b_reg->r_rdx;
+ l_regset->rsi = b_reg->r_rsi;
+ l_regset->rdi = b_reg->r_rdi;
+ l_regset->orig_rax = b_reg->r_rax;
+ l_regset->rip = b_reg->r_rip;
+ l_regset->cs = b_reg->r_cs;
+ l_regset->eflags = b_reg->r_rflags;
+ l_regset->rsp = b_reg->r_rsp;
+ l_regset->ss = b_reg->r_ss;
+ l_regset->fs_base = 0;
+ l_regset->gs_base = 0;
+ 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;
+}
diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c
--- a/sys/amd64/linux/linux_ptrace.c
+++ b/sys/amd64/linux/linux_ptrace.c
@@ -205,39 +205,6 @@
l_reg->ss = b_reg->r_ss;
}
-void
-bsd_to_linux_regset(struct reg *b_reg, struct linux_pt_regset *l_regset)
-{
-
- l_regset->r15 = b_reg->r_r15;
- l_regset->r14 = b_reg->r_r14;
- l_regset->r13 = b_reg->r_r13;
- l_regset->r12 = b_reg->r_r12;
- l_regset->rbp = b_reg->r_rbp;
- l_regset->rbx = b_reg->r_rbx;
- l_regset->r11 = b_reg->r_r11;
- l_regset->r10 = b_reg->r_r10;
- l_regset->r9 = b_reg->r_r9;
- l_regset->r8 = b_reg->r_r8;
- l_regset->rax = b_reg->r_rax;
- l_regset->rcx = b_reg->r_rcx;
- l_regset->rdx = b_reg->r_rdx;
- l_regset->rsi = b_reg->r_rsi;
- l_regset->rdi = b_reg->r_rdi;
- l_regset->orig_rax = b_reg->r_rax;
- l_regset->rip = b_reg->r_rip;
- l_regset->cs = b_reg->r_cs;
- l_regset->eflags = b_reg->r_rflags;
- l_regset->rsp = b_reg->r_rsp;
- l_regset->ss = b_reg->r_ss;
- l_regset->fs_base = 0;
- l_regset->gs_base = 0;
- 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;
-}
-
static void
map_regs_from_linux(struct reg *b_reg, struct linux_pt_reg *l_reg)
{
diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c
--- a/sys/amd64/linux/linux_sysvec.c
+++ b/sys/amd64/linux/linux_sysvec.c
@@ -741,8 +741,8 @@
.sv_name = "Linux ELF64",
.sv_coredump = elf64_coredump,
.sv_elf_core_osabi = ELFOSABI_NONE,
- .sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
- .sv_elf_core_prepare_notes = elf64_prepare_notes,
+ .sv_elf_core_abi_vendor = LINUX_ABI_VENDOR,
+ .sv_elf_core_prepare_notes = linux64_prepare_notes,
.sv_imgact_try = linux_exec_imgact_try,
.sv_minsigstksz = LINUX_MINSIGSTKSZ,
.sv_minuser = VM_MIN_ADDRESS,
diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c
--- a/sys/amd64/linux32/linux32_sysvec.c
+++ b/sys/amd64/linux32/linux32_sysvec.c
@@ -912,9 +912,9 @@
.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 = linux32_prepare_notes,
.sv_imgact_try = linux_exec_imgact_try,
.sv_minsigstksz = LINUX_MINSIGSTKSZ,
.sv_minuser = VM_MIN_ADDRESS,
diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c
--- a/sys/arm64/linux/linux_sysvec.c
+++ b/sys/arm64/linux/linux_sysvec.c
@@ -417,8 +417,8 @@
.sv_name = "Linux ELF64",
.sv_coredump = elf64_coredump,
.sv_elf_core_osabi = ELFOSABI_NONE,
- .sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
- .sv_elf_core_prepare_notes = elf64_prepare_notes,
+ .sv_elf_core_abi_vendor = LINUX_ABI_VENDOR,
+ .sv_elf_core_prepare_notes = linux64_prepare_notes,
.sv_imgact_try = linux_exec_imgact_try,
.sv_minsigstksz = LINUX_MINSIGSTKSZ,
.sv_minuser = VM_MIN_ADDRESS,
diff --git a/sys/compat/linux/linux_elf.h b/sys/compat/linux/linux_elf.h
new file mode 100644
--- /dev/null
+++ b/sys/compat/linux/linux_elf.h
@@ -0,0 +1,56 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Chuck Tuffli
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _COMPAT_LINUX_ELF_H_
+#define _COMPAT_LINUX_ELF_H_
+
+struct l_elf_siginfo {
+ l_int si_signo;
+ l_int si_code;
+ l_int si_errno;
+};
+
+typedef struct linux_pt_regset l_elf_gregset_t;
+
+struct linux_elf_prstatus {
+ struct l_elf_siginfo pr_info;
+ l_short pr_cursig;
+ l_ulong pr_sigpend;
+ l_ulong pr_sighold;
+ l_pid_t pr_pid;
+ l_pid_t pr_ppid;
+ l_pid_t pr_pgrp;
+ l_pid_t pr_sid;
+ l_timeval pr_utime;
+ l_timeval pr_stime;
+ l_timeval pr_cutime;
+ l_timeval pr_cstime;
+ l_elf_gregset_t pr_reg;
+ l_int pr_fpvalid;
+};
+
+#endif
diff --git a/sys/compat/linux/linux_elf.c b/sys/compat/linux/linux_elf.c
new file mode 100644
--- /dev/null
+++ b/sys/compat/linux/linux_elf.c
@@ -0,0 +1,294 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 2021 Edward Tomasz Napierala <trasz@FreeBSD.org>
+ * Copyright (c) 2018 Chuck Tuffli
+ * Copyright (c) 2017 Dell EMC
+ * Copyright (c) 2000 David O'Brien
+ * Copyright (c) 1995-1996 Søren Schmidt
+ * Copyright (c) 1996 Peter Wemm
+ * All rights reserved.
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory as part of the CHERI for Hypervisors and Operating Systems
+ * (CHaOS) project, funded by EPSRC grant EP/V000292/1.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/exec.h>
+#include <sys/imgact.h>
+#include <sys/imgact_elf.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/procfs.h>
+#include <sys/ptrace.h>
+#include <sys/sbuf.h>
+#include <sys/sysent.h>
+#include <sys/user.h>
+#include <sys/vnode.h>
+
+#include <machine/elf.h>
+
+#if __ELF_WORD_SIZE == 32
+#define linux_pt_regset linux_pt_regset32
+#define bsd_to_linux_regset bsd_to_linux_regset32
+#include <machine/../linux32/linux.h>
+#else
+#include <machine/../linux/linux.h>
+#endif
+#include <compat/linux/linux_elf.h>
+#include <compat/linux/linux_emul.h>
+#include <compat/linux/linux_misc.h>
+
+/* This adds "linux32_" and "linux64_" prefixes. */
+#define __linuxN(x) __CONCAT(__CONCAT(__CONCAT(linux,__ELF_WORD_SIZE),_),x)
+
+#define LINUX_NT_AUXV 6
+
+static void __linuxN(note_fpregset)(void *, struct sbuf *, size_t *);
+static void __linuxN(note_prpsinfo)(void *, struct sbuf *, size_t *);
+static void __linuxN(note_prstatus)(void *, struct sbuf *, size_t *);
+static void __linuxN(note_threadmd)(void *, struct sbuf *, size_t *);
+static void __linuxN(note_nt_auxv)(void *, struct sbuf *, size_t *);
+
+void
+__linuxN(prepare_notes)(struct thread *td, struct note_info_list *list,
+ size_t *sizep)
+{
+ struct proc *p;
+ struct thread *thr;
+ size_t size;
+
+ p = td->td_proc;
+ size = 0;
+
+ /*
+ * To have the debugger select the right thread (LWP) as the initial
+ * thread, we dump the state of the thread passed to us in td first.
+ * This is the thread that causes the core dump and thus likely to
+ * be the right thread one wants to have selected in the debugger.
+ */
+ thr = td;
+ while (thr != NULL) {
+ size += __elfN(register_note)(td, list,
+ NT_PRSTATUS, __linuxN(note_prstatus), thr);
+ size += __elfN(register_note)(td, list,
+ NT_PRPSINFO, __linuxN(note_prpsinfo), p);
+ size += __elfN(register_note)(td, list,
+ LINUX_NT_AUXV, __linuxN(note_nt_auxv), p);
+ size += __elfN(register_note)(td, list,
+ NT_FPREGSET, __linuxN(note_fpregset), thr);
+ size += __elfN(register_note)(td, list,
+ -1, __linuxN(note_threadmd), thr);
+
+ thr = thr == td ? TAILQ_FIRST(&p->p_threads) :
+ TAILQ_NEXT(thr, td_plist);
+ if (thr == td)
+ thr = TAILQ_NEXT(thr, td_plist);
+ }
+
+ *sizep = size;
+}
+
+typedef struct linux_elf_prstatus linux_elf_prstatus_t;
+#if __ELF_WORD_SIZE == 32
+typedef struct prpsinfo32 linux_elf_prpsinfo_t;
+typedef struct fpreg32 linux_elf_prfpregset_t;
+#else
+typedef prpsinfo_t linux_elf_prpsinfo_t;
+typedef prfpregset_t linux_elf_prfpregset_t;
+#endif
+
+static void
+__linuxN(note_prpsinfo)(void *arg, struct sbuf *sb, size_t *sizep)
+{
+ struct sbuf sbarg;
+ size_t len;
+ char *cp, *end;
+ struct proc *p;
+ linux_elf_prpsinfo_t *psinfo;
+ int error;
+
+ p = arg;
+ if (sb != NULL) {
+ KASSERT(*sizep == sizeof(*psinfo), ("invalid size"));
+ psinfo = malloc(sizeof(*psinfo), M_TEMP, M_ZERO | M_WAITOK);
+ psinfo->pr_version = PRPSINFO_VERSION;
+ psinfo->pr_psinfosz = sizeof(linux_elf_prpsinfo_t);
+ strlcpy(psinfo->pr_fname, p->p_comm, sizeof(psinfo->pr_fname));
+ PROC_LOCK(p);
+ if (p->p_args != NULL) {
+ len = sizeof(psinfo->pr_psargs) - 1;
+ if (len > p->p_args->ar_length)
+ len = p->p_args->ar_length;
+ memcpy(psinfo->pr_psargs, p->p_args->ar_args, len);
+ PROC_UNLOCK(p);
+ error = 0;
+ } else {
+ _PHOLD(p);
+ PROC_UNLOCK(p);
+ sbuf_new(&sbarg, psinfo->pr_psargs,
+ sizeof(psinfo->pr_psargs), SBUF_FIXEDLEN);
+ error = proc_getargv(curthread, p, &sbarg);
+ PRELE(p);
+ if (sbuf_finish(&sbarg) == 0)
+ len = sbuf_len(&sbarg) - 1;
+ else
+ len = sizeof(psinfo->pr_psargs) - 1;
+ sbuf_delete(&sbarg);
+ }
+ if (error || len == 0)
+ strlcpy(psinfo->pr_psargs, p->p_comm,
+ sizeof(psinfo->pr_psargs));
+ else {
+ KASSERT(len < sizeof(psinfo->pr_psargs),
+ ("len is too long: %zu vs %zu", len,
+ sizeof(psinfo->pr_psargs)));
+ cp = psinfo->pr_psargs;
+ end = cp + len - 1;
+ for (;;) {
+ cp = memchr(cp, '\0', end - cp);
+ if (cp == NULL)
+ break;
+ *cp = ' ';
+ }
+ }
+ psinfo->pr_pid = p->p_pid;
+ sbuf_bcat(sb, psinfo, sizeof(*psinfo));
+ free(psinfo, M_TEMP);
+ }
+ *sizep = sizeof(*psinfo);
+}
+
+static void
+__linuxN(note_prstatus)(void *arg, struct sbuf *sb, size_t *sizep)
+{
+ struct thread *td;
+ linux_elf_prstatus_t *status;
+#if __ELF_WORD_SIZE == 32
+ struct reg32 pr_reg;
+#else
+ struct reg pr_reg;
+#endif
+
+ td = arg;
+ if (sb != NULL) {
+ KASSERT(*sizep == sizeof(*status), ("invalid size"));
+ status = malloc(sizeof(*status), M_TEMP, M_ZERO | M_WAITOK);
+
+ /*
+ * XXX: Some fields missing.
+ */
+ status->pr_cursig = td->td_proc->p_sig;
+ status->pr_pid = td->td_tid;
+
+#if __ELF_WORD_SIZE == 32
+ fill_regs32(td, &pr_reg);
+#else
+ fill_regs(td, &pr_reg);
+#endif
+ bsd_to_linux_regset(&pr_reg, &status->pr_reg);
+ sbuf_bcat(sb, status, sizeof(*status));
+ free(status, M_TEMP);
+ }
+ *sizep = sizeof(*status);
+}
+
+static void
+__linuxN(note_fpregset)(void *arg, struct sbuf *sb, size_t *sizep)
+{
+ struct thread *td;
+ linux_elf_prfpregset_t *fpregset;
+
+ td = arg;
+ if (sb != NULL) {
+ KASSERT(*sizep == sizeof(*fpregset), ("invalid size"));
+ fpregset = malloc(sizeof(*fpregset), M_TEMP, M_ZERO | M_WAITOK);
+#if __ELF_WORD_SIZE == 32
+ fill_fpregs32(td, fpregset);
+#else
+ fill_fpregs(td, fpregset);
+#endif
+ sbuf_bcat(sb, fpregset, sizeof(*fpregset));
+ free(fpregset, M_TEMP);
+ }
+ *sizep = sizeof(*fpregset);
+}
+
+/*
+ * Allow for MD specific notes, as well as any MD
+ * specific preparations for writing MI notes.
+ */
+static void
+__linuxN(note_threadmd)(void *arg, struct sbuf *sb, size_t *sizep)
+{
+ struct thread *td;
+ void *buf;
+ size_t size;
+
+ td = arg;
+ size = *sizep;
+ if (size != 0 && sb != NULL)
+ buf = malloc(size, M_TEMP, M_ZERO | M_WAITOK);
+ else
+ buf = NULL;
+ size = 0;
+ __elfN(dump_thread)(td, buf, &size);
+ KASSERT(sb == NULL || *sizep == size, ("invalid size"));
+ if (size != 0 && sb != NULL)
+ sbuf_bcat(sb, buf, size);
+ free(buf, M_TEMP);
+ *sizep = size;
+}
+
+static void
+__linuxN(note_nt_auxv)(void *arg, struct sbuf *sb, size_t *sizep)
+{
+ struct proc *p;
+ size_t size;
+
+ p = arg;
+ if (sb == NULL) {
+ size = 0;
+ sb = sbuf_new(NULL, NULL, LINUX_AT_COUNT * sizeof(Elf_Auxinfo),
+ SBUF_FIXEDLEN);
+ sbuf_set_drain(sb, sbuf_count_drain, &size);
+ PHOLD(p);
+ proc_getauxv(curthread, p, sb);
+ PRELE(p);
+ sbuf_finish(sb);
+ sbuf_delete(sb);
+ *sizep = size;
+ } else {
+ PHOLD(p);
+ proc_getauxv(curthread, p, sb);
+ PRELE(p);
+ }
+}
diff --git a/sys/compat/linux/linux_elf32.c b/sys/compat/linux/linux_elf32.c
new file mode 100644
--- /dev/null
+++ b/sys/compat/linux/linux_elf32.c
@@ -0,0 +1,38 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2021 Edward Tomasz Napierala <trasz@FreeBSD.org>
+ * Copyright (c) 2002 Doug Rabson
+ * All rights reserved.
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory as part of the CHERI for Hypervisors and Operating Systems
+ * (CHaOS) project, funded by EPSRC grant EP/V000292/1.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define __ELF_WORD_SIZE 32
+#include <compat/linux/linux_elf.c>
diff --git a/sys/compat/linux/linux_elf64.c b/sys/compat/linux/linux_elf64.c
new file mode 100644
--- /dev/null
+++ b/sys/compat/linux/linux_elf64.c
@@ -0,0 +1,38 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2021 Edward Tomasz Napierala <trasz@FreeBSD.org>
+ * Copyright (c) 2002 Doug Rabson
+ * All rights reserved.
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory as part of the CHERI for Hypervisors and Operating Systems
+ * (CHaOS) project, funded by EPSRC grant EP/V000292/1.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define __ELF_WORD_SIZE 64
+#include <compat/linux/linux_elf.c>
diff --git a/sys/compat/linux/linux_emul.h b/sys/compat/linux/linux_emul.h
--- a/sys/compat/linux/linux_emul.h
+++ b/sys/compat/linux/linux_emul.h
@@ -33,6 +33,10 @@
#define _LINUX_EMUL_H_
struct image_params;
+struct note_info_list;
+
+/* Linux core notes are labeled "CORE" */
+#define LINUX_ABI_VENDOR "CORE"
/*
* modeled after similar structure in NetBSD
@@ -58,6 +62,8 @@
void linux_thread_dtor(struct thread *);
void linux_thread_detach(struct thread *);
int linux_common_execve(struct thread *, struct image_args *);
+void linux32_prepare_notes(struct thread *, struct note_info_list *, size_t *);
+void linux64_prepare_notes(struct thread *, struct note_info_list *, size_t *);
/* process emuldata flags */
#define LINUX_XDEPR_REQUEUEOP 0x00000001 /* uses deprecated
diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile
--- a/sys/modules/linux/Makefile
+++ b/sys/modules/linux/Makefile
@@ -26,6 +26,7 @@
.endif
.if ${MACHINE_CPUARCH} == "amd64"
SRCS+= linux${SFX}_support.s
+SRCS+= linux_elf32.c
.else
SRCS+= linux_copyout.c
.endif
diff --git a/sys/modules/linux64/Makefile b/sys/modules/linux64/Makefile
--- a/sys/modules/linux64/Makefile
+++ b/sys/modules/linux64/Makefile
@@ -18,6 +18,7 @@
linux_support.s
.if ${MACHINE_CPUARCH} == "amd64"
SRCS+= linux_dummy_x86.c
+SRCS+= linux_elf64.c
.endif
DPSRCS= assym.inc linux_genassym.c
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 27, 8:29 AM (7 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26239173
Default Alt Text
D30019.id.diff (20 KB)
Attached To
Mode
D30019: linux(4): implement coredump support
Attached
Detach File
Event Timeline
Log In to Comment