Since ELF_NREG is defined if and only if USE_ELF_CORE_DUMP is also defined, and since ELF_NREG carries useful information, remove USE_ELF_CORE_DUMP and instead use ELF_NREG as a signal that core dumps are supported.
Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- linux-user/elfload.c | 44 +++++--------------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0e02e8541b..4e0d52f1f6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -267,7 +267,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUX86State *env) #define VDSO_HEADER "vdso.c.inc" -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #endif /* TARGET_I386 */ @@ -292,7 +291,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUARMState *env) regs[17] = tswapl(env->regs[0]); /* XXX */ } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 /* The commpage only exists for 32 bit kernels */ @@ -379,7 +377,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUARMState *env) regs[33] = tswapl(pstate_read((CPUARMState *)env)); } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #if TARGET_BIG_ENDIAN @@ -472,7 +469,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUPPCState *env) regs[38] = tswapl(ccr); } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #ifndef TARGET_PPC64 @@ -518,7 +514,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPULoongArchState *env) regs[TARGET_EF_CSR_BADV] = tswapl(env->CSR_BADV); } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #endif /* TARGET_LOONGARCH64 */ @@ -583,7 +578,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUMIPSState *env) regs[TARGET_EF_CP0_CAUSE] = tswapl(env->CP0_Cause); } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #endif /* TARGET_MIPS */ @@ -597,7 +591,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUMIPSState *env) #define ELF_EXEC_PAGESIZE 4096 -#define USE_ELF_CORE_DUMP #define ELF_NREG 38 /* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ @@ -625,7 +618,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUMBState *env) #define ELF_CLASS ELFCLASS32 #define ELF_DATA ELFDATA2MSB -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 8192 /* See linux kernel arch/openrisc/include/asm/elf.h. */ @@ -680,7 +672,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUSH4State *env) regs[TARGET_REG_SYSCALL] = 0; /* FIXME */ } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #endif @@ -717,7 +708,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUM68KState *env) regs[19] = 0; /* FIXME: regs->format | regs->vector */ } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 8192 #endif @@ -765,7 +755,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUS390XState *env) regs[TARGET_REG_ORIG_R2] = 0; } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #define VDSO_HEADER "vdso.c.inc" @@ -871,7 +860,6 @@ void elf_core_copy_regs(target_ulong *regs, const CPUXtensaState *env) } } -#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #endif /* TARGET_XTENSA */ @@ -1080,9 +1068,9 @@ static void bswap_mips_abiflags(Mips_elf_abiflags_v0 *abiflags) } #endif -#ifdef USE_ELF_CORE_DUMP +#ifdef ELF_NREG static int elf_core_dump(int, const CPUArchState *); -#endif /* USE_ELF_CORE_DUMP */ +#endif static void load_symbols(struct elfhdr *hdr, const ImageSource *src, abi_ulong load_bias); @@ -2792,14 +2780,14 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) g_free(elf_interpreter); } -#ifdef USE_ELF_CORE_DUMP +#ifdef ELF_NREG bprm->core_dump = &elf_core_dump; #endif return 0; } -#ifdef USE_ELF_CORE_DUMP +#ifdef ELF_NREG /* * Definitions to generate Intel SVR4-like core files. @@ -2813,28 +2801,6 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) * are marked with XXX. * * Core dump code is copied from linux kernel (fs/binfmt_elf.c). - * - * Porting ELF coredump for target is (quite) simple process. First you - * define USE_ELF_CORE_DUMP in target ELF code (where init_thread() for - * the target resides): - * - * #define USE_ELF_CORE_DUMP - * - * Next you define type of register set used for dumping. ELF specification - * says that it needs to be array of elf_greg_t that has size of ELF_NREG. - * - * #define ELF_NREG <number of registers> - * - * Last step is to implement target specific function that copies registers - * from given cpu into just specified register set. Prototype is: - * - * void elf_core_copy_regs(target_ulong *regs, const CPUArchState *env); - * - * Parameters: - * regs - copy register values into here (allocated and zeroed by caller) - * env - copy registers from here - * - * Example for ARM target is provided in this file. */ struct target_elf_siginfo { @@ -3359,4 +3325,4 @@ static int elf_core_dump(int signr, const CPUArchState *env) } return ret; } -#endif /* USE_ELF_CORE_DUMP */ +#endif /* ELF_NREG */ -- 2.43.0