linux-user: add elf_core_eflags() hook for core dump e_flags
PATCH 1/3 linux-user: add elf_core_eflags() hook for core dump e_flags
Let targets set e_flags in the core file header. Default to 0, as before.
--- linux-user/elfload.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
linux-user/elfload.c +6 -1
@@ -144,6 +144,10 @@ typedef abi_int target_pid_t;#define EXSTACK_DEFAULT false#endif +#ifndef elf_core_eflags +#define elf_core_eflags (info) 0 +#endif +/* * Provide fallback definitions that the target may omit. * One way or another, we'll get a link error if the setting of
@@ -2212,7 +2216,8 @@ static int elf_core_dump(int signr, const CPUArchState *env)/* Create elf file header. */ hptr = header; -fill_elf_header (hptr, css.count +1 ,ELF_MACHINE ,0 ); +fill_elf_header (hptr, css.count +1 ,ELF_MACHINE , +elf_core_eflags (ts->info)); hptr +=sizeof (struct elfhdr );/* Create elf program headers. */
Signature · 1 line
2.54.0
PATCH 2/3 linux-user/mips64: set EF_MIPS_ABI2 in mipsn32 core dumps
mipsn32 core files had e_flags 0, so gdb took them for o32, found no general-purpose registers and failed with an internal error in frame_unwind_find_by_frame.
Linux sets e_flags to EF_MIPS_ABI2 for n32 cores (user_mipsn32_view in arch/mips/kernel/ptrace.c).
--- linux-user/mips64/target_elf.h | 2 ++ 1 file changed, 2 insertions(+)
linux-user/mips64/target_elf.h +2 -0
@@ -16,6 +16,8 @@#ifdef TARGET_ABI_MIPSN32 #define elf_check_abi (x) ((x) & EF_MIPS_ABI2) +/* See linux kernel: arch/mips/kernel/ptrace.c, user_mipsn32_view. */ +#define elf_core_eflags (info) EF_MIPS_ABI2#else #define elf_check_abi (x) (!((x) & EF_MIPS_ABI2))#endif
Signature · 1 line
2.54.0
PATCH 3/3 linux-user/riscv: copy the executable's e_flags into core dumps
In reply to Matt TurnerSince commit 8c94db0ae97c ("binfmt_elf: preserve original ELF e_flags for core dumps"), Linux writes the main executable's e_flags into RISC-V core files, so debuggers can see the float ABI and RVC. QEMU wrote 0.
--- linux-user/riscv/target_elf.h | 3 +++ 1 file changed, 3 insertions(+)
linux-user/riscv/target_elf.h +3 -0
@@ -21,6 +21,9 @@#define HAVE_ELF_HWCAP 1#define HAVE_ELF_CORE_DUMP 1 +/* See linux kernel: ARCH_HAS_ELF_CORE_EFLAGS. */ +#define elf_core_eflags (info) ((info)->elf_flags) +/* Mirrors struct user_regs_struct: pc followed by x1 (ra) .. x31 (t6). */ typedef struct target_elf_gregset_t { abi_ulong pc;
Signature · 1 line
2.54.0
Re: [PATCH 3/3] linux-user/riscv: copy the executable's e_flags into core dumps
Quoted 4 lines · Matt Turner
Since commit
8c94db0ae97c("binfmt_elf: preserve original ELFe_flagsfor core dumps"), Linux writes the main executable'se_flagsinto RISC-V
core files, so debuggers can see the float ABI and RVC. QEMU wrote 0.
You are missing a Signed-off-by line
Alistair
Quoted 20 lines
---
linux-user/riscv/target_elf.h | 3 +++1 file changed, 3 insertions(+)./linux- renamed from ./linux-user/riscv/target_elf.h +0
-0
user/riscv/target_elf.h
index185b81a2db..e99a9d92ca100644linux-user/riscv/target_elf.h +0
-0@@ -21,6 +21,9 @@ #define HAVE_ELF_HWCAP 1 #define HAVE_ELF_CORE_DUMP 1linux-user/riscv/target_elf.h +3
-0+/* See linux kernel: ARCH_HAS_ELF_CORE_EFLAGS. */ +#define elf_core_eflags (info) ((info)->elf_flags) +/* Mirrors struct
user_regs_struct: pc followed by x1 (ra) .. x31 (t6). */
typedef structtarget_elf_gregset_t{
abi_ulongpc;
Re: [PATCH 3/3] linux-user/riscv: copy the executable's e_flags into core dumps
Quoted 8 lines · Alistair
Quoted 4 lines · Matt Turner
Since commit
8c94db0ae97c("binfmt_elf: preserve original ELFe_flagsfor core dumps"), Linux writes the main executable'se_flagsinto RISC-V
core files, so debuggers can see the float ABI and RVC. QEMU wrote 0.You are missing a Signed-off-by line
Sorry about that. All three are