[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 36/42] bsd-user: add stubbed out core dump support
From: |
imp |
Subject: |
[PULL 36/42] bsd-user: add stubbed out core dump support |
Date: |
Tue, 7 Sep 2021 15:53:26 -0600 |
From: Warner Losh <imp@FreeBSD.org>
Add a stubbed-out version of the bsd-user fork's core dump support. This
allows elfload.c to be almost the same between what's upstream and
what's in qemu-project upstream w/o the burden of reviewing the core
dump support.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/elfcore.c | 10 ++++++++++
bsd-user/elfload.c | 22 ++++++++++++++++++++--
bsd-user/qemu.h | 6 ++++++
3 files changed, 36 insertions(+), 2 deletions(-)
create mode 100644 bsd-user/elfcore.c
diff --git a/bsd-user/elfcore.c b/bsd-user/elfcore.c
new file mode 100644
index 0000000000..c49d9280e2
--- /dev/null
+++ b/bsd-user/elfcore.c
@@ -0,0 +1,10 @@
+/* Stubbed out version of core dump support, explicitly in public domain */
+
+static int elf_core_dump(int signr, CPUArchState *env)
+{
+ struct elf_note en = { 0 };
+
+ bswap_note(&en);
+
+ return 0;
+}
diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
index 11ca813c7a..05751f3ce7 100644
--- a/bsd-user/elfload.c
+++ b/bsd-user/elfload.c
@@ -26,15 +26,17 @@
static abi_ulong target_auxents; /* Where the AUX entries are in target */
static size_t target_auxents_sz; /* Size of AUX entries including AT_NULL */
+#include "target_arch_reg.h"
#include "target_os_elf.h"
#include "target_os_stack.h"
#include "target_os_thread.h"
-
-#include "elf.h"
+#include "target_os_user.h"
abi_ulong target_stksiz;
abi_ulong target_stkbas;
+static int elf_core_dump(int signr, CPUArchState *env);
+
static inline void memcpy_fromfs(void *to, const void *from, unsigned long n)
{
memcpy(to, from, n);
@@ -100,15 +102,25 @@ static void bswap_sym(struct elf_sym *sym)
bswap16s(&sym->st_shndx);
}
+static void bswap_note(struct elf_note *en)
+{
+ bswap32s(&en->n_namesz);
+ bswap32s(&en->n_descsz);
+ bswap32s(&en->n_type);
+}
+
#else /* ! BSWAP_NEEDED */
static void bswap_ehdr(struct elfhdr *ehdr) { }
static void bswap_phdr(struct elf_phdr *phdr, int phnum) { }
static void bswap_shdr(struct elf_shdr *shdr, int shnum) { }
static void bswap_sym(struct elf_sym *sym) { }
+static void bswap_note(struct elf_note *en) { }
#endif /* ! BSWAP_NEEDED */
+#include "elfcore.c"
+
/*
* 'copy_elf_strings()' copies argument/envelope strings from user
* memory to free pages in kernel mem. These are in a format ready
@@ -834,6 +846,12 @@ int load_elf_binary(struct bsd_binprm *bprm, struct
target_pt_regs *regs,
info->entry = elf_entry;
+#ifdef USE_ELF_CORE_DUMP
+ bprm->core_dump = &elf_core_dump;
+#else
+ bprm->core_dump = NULL;
+#endif
+
return 0;
}
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 3685156123..8d20554688 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -51,6 +51,7 @@ extern enum BSDType bsd_type;
* kernel
*/
struct image_info {
+ abi_ulong load_bias;
abi_ulong load_addr;
abi_ulong start_code;
abi_ulong end_code;
@@ -65,6 +66,9 @@ struct image_info {
abi_ulong entry;
abi_ulong code_offset;
abi_ulong data_offset;
+ abi_ulong arg_start;
+ abi_ulong arg_end;
+ uint32_t elf_flags;
};
#define MAX_SIGQUEUE_SIZE 1024
@@ -132,6 +136,7 @@ struct bsd_binprm {
char **envp;
char *filename; /* (Given) Name of binary */
char *fullpath; /* Full path of binary */
+ int (*core_dump)(int, CPUArchState *);
};
void do_init_thread(struct target_pt_regs *regs, struct image_info *infop);
@@ -145,6 +150,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct
target_pt_regs *regs,
struct image_info *info);
int load_flt_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
struct image_info *info);
+int is_target_elf_binary(int fd);
abi_long memcpy_to_target(abi_ulong dest, const void *src,
unsigned long len);
--
2.32.0
- [PULL 21/42] bsd-user: pull in target_arch_thread.h update target_arch_elf.h, (continued)
- [PULL 21/42] bsd-user: pull in target_arch_thread.h update target_arch_elf.h, imp, 2021/09/07
- [PULL 27/42] bsd-user: Implement --seed and initialize random state, imp, 2021/09/07
- [PULL 26/42] bsd-user: *BSD specific siginfo defintions, imp, 2021/09/07
- [PULL 30/42] bsd-user: elf cleanup, imp, 2021/09/07
- [PULL 32/42] bsd-user: Rewrite target system call definintion glue, imp, 2021/09/07
- [PULL 11/42] bsd-user: Eliminate elf personality, imp, 2021/09/07
- [PULL 24/42] bsd-user: Create target specific vmparam.h, imp, 2021/09/07
- [PULL 20/42] bsd-user: Move per-cpu code into target_arch_cpu.h, imp, 2021/09/07
- [PULL 31/42] bsd-user: Remove dead #ifdefs from elfload.c, imp, 2021/09/07
- [PULL 33/42] bsd-user: update debugging in mmap.c, imp, 2021/09/07
- [PULL 36/42] bsd-user: add stubbed out core dump support,
imp <=
- [PULL 35/42] bsd-user: Add target_os_user.h to capture the user/kernel structures, imp, 2021/09/07
- [PULL 39/42] bsd-user: move gemu_log to later in the file, imp, 2021/09/07
- [PULL 34/42] bsd-user: Add target_arch_reg to describe a target's register set, imp, 2021/09/07
- [PULL 38/42] bsd-user: Refactor load_elf_sections and is_target_elf_binary, imp, 2021/09/07
- [PULL 40/42] bsd-user: Implement interlock for atomic operations, imp, 2021/09/07
- [PULL 41/42] bsd-user: Add '-0 argv0' option to bsd-user/main.c, imp, 2021/09/07
- [PULL 37/42] bsd-user: elfload.c style catch up patch, imp, 2021/09/07
- [PULL 28/42] bsd-user: Move stack initializtion into a per-os file., imp, 2021/09/07
- [PULL 42/42] bsd-user: Update mapping to handle reserved and starting conditions, imp, 2021/09/07
- Re: [PULL 00/42] bsd-user updates to run hello world, Peter Maydell, 2021/09/09