Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_ELFCORE_H |
| 2 | #define _LINUX_ELFCORE_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <linux/user.h> |
Paul Gortmaker | 187f188 | 2011-11-23 20:12:59 -0500 | [diff] [blame] | 5 | #include <linux/bug.h> |
Ingo Molnar | 68db0cf | 2017-02-08 18:51:37 +0100 | [diff] [blame] | 6 | #include <linux/sched/task_stack.h> |
| 7 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <asm/elf.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 9 | #include <uapi/linux/elfcore.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Al Viro | 506f21c | 2013-10-05 17:22:57 -0400 | [diff] [blame] | 11 | struct coredump_params; |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs) |
| 14 | { |
| 15 | #ifdef ELF_CORE_COPY_REGS |
| 16 | ELF_CORE_COPY_REGS((*elfregs), regs) |
| 17 | #else |
| 18 | BUG_ON(sizeof(*elfregs) != sizeof(*regs)); |
| 19 | *(struct pt_regs *)elfregs = *regs; |
| 20 | #endif |
| 21 | } |
| 22 | |
Tejun Heo | 6cd61c0 | 2009-02-09 22:17:39 +0900 | [diff] [blame] | 23 | static inline void elf_core_copy_kernel_regs(elf_gregset_t *elfregs, struct pt_regs *regs) |
| 24 | { |
| 25 | #ifdef ELF_CORE_COPY_KERNEL_REGS |
| 26 | ELF_CORE_COPY_KERNEL_REGS((*elfregs), regs); |
| 27 | #else |
| 28 | elf_core_copy_regs(elfregs, regs); |
| 29 | #endif |
| 30 | } |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs) |
| 33 | { |
Parag Warudkar | e9bf0cc | 2009-07-08 11:46:02 -0400 | [diff] [blame] | 34 | #if defined (ELF_CORE_COPY_TASK_REGS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | return ELF_CORE_COPY_TASK_REGS(t, elfregs); |
Parag Warudkar | e9bf0cc | 2009-07-08 11:46:02 -0400 | [diff] [blame] | 36 | #elif defined (task_pt_regs) |
Hui Zhu | a65e7bf | 2009-07-05 12:08:15 -0700 | [diff] [blame] | 37 | elf_core_copy_regs(elfregs, task_pt_regs(t)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #endif |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | extern int dump_fpu (struct pt_regs *, elf_fpregset_t *); |
| 43 | |
| 44 | static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_regs *regs, elf_fpregset_t *fpu) |
| 45 | { |
| 46 | #ifdef ELF_CORE_COPY_FPREGS |
| 47 | return ELF_CORE_COPY_FPREGS(t, fpu); |
| 48 | #else |
| 49 | return dump_fpu(regs, fpu); |
| 50 | #endif |
| 51 | } |
| 52 | |
| 53 | #ifdef ELF_CORE_COPY_XFPREGS |
| 54 | static inline int elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu) |
| 55 | { |
| 56 | return ELF_CORE_COPY_XFPREGS(t, xfpu); |
| 57 | } |
| 58 | #endif |
| 59 | |
Daisuke HATAYAMA | 1fcccba | 2010-03-05 13:44:07 -0800 | [diff] [blame] | 60 | /* |
| 61 | * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out |
| 62 | * extra segments containing the gate DSO contents. Dumping its |
| 63 | * contents makes post-mortem fully interpretable later without matching up |
| 64 | * the same kernel and hardware config to see what PC values meant. |
| 65 | * Dumping its extra ELF program headers includes all the other information |
| 66 | * a debugger needs to easily find how the gate DSO was being used. |
| 67 | */ |
| 68 | extern Elf_Half elf_core_extra_phdrs(void); |
| 69 | extern int |
Al Viro | 506f21c | 2013-10-05 17:22:57 -0400 | [diff] [blame] | 70 | elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset); |
Daisuke HATAYAMA | 1fcccba | 2010-03-05 13:44:07 -0800 | [diff] [blame] | 71 | extern int |
Al Viro | aa3e7ea | 2013-10-05 17:50:15 -0400 | [diff] [blame] | 72 | elf_core_write_extra_data(struct coredump_params *cprm); |
Daisuke HATAYAMA | 8d9032b | 2010-03-05 13:44:10 -0800 | [diff] [blame] | 73 | extern size_t elf_core_extra_data_size(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | #endif /* _LINUX_ELFCORE_H */ |