blob: 698d51a0eea3f3892f0912996f9ca50bd54d8d78 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_ELFCORE_H
2#define _LINUX_ELFCORE_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <linux/user.h>
Paul Gortmaker187f1882011-11-23 20:12:59 -05005#include <linux/bug.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <asm/elf.h>
David Howells607ca462012-10-13 10:46:48 +01007#include <uapi/linux/elfcore.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Al Viro506f21c2013-10-05 17:22:57 -04009struct coredump_params;
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs)
12{
13#ifdef ELF_CORE_COPY_REGS
14 ELF_CORE_COPY_REGS((*elfregs), regs)
15#else
16 BUG_ON(sizeof(*elfregs) != sizeof(*regs));
17 *(struct pt_regs *)elfregs = *regs;
18#endif
19}
20
Tejun Heo6cd61c02009-02-09 22:17:39 +090021static inline void elf_core_copy_kernel_regs(elf_gregset_t *elfregs, struct pt_regs *regs)
22{
23#ifdef ELF_CORE_COPY_KERNEL_REGS
24 ELF_CORE_COPY_KERNEL_REGS((*elfregs), regs);
25#else
26 elf_core_copy_regs(elfregs, regs);
27#endif
28}
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs)
31{
Parag Warudkare9bf0cc2009-07-08 11:46:02 -040032#if defined (ELF_CORE_COPY_TASK_REGS)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 return ELF_CORE_COPY_TASK_REGS(t, elfregs);
Parag Warudkare9bf0cc2009-07-08 11:46:02 -040034#elif defined (task_pt_regs)
Hui Zhua65e7bf2009-07-05 12:08:15 -070035 elf_core_copy_regs(elfregs, task_pt_regs(t));
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#endif
37 return 0;
38}
39
40extern int dump_fpu (struct pt_regs *, elf_fpregset_t *);
41
42static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_regs *regs, elf_fpregset_t *fpu)
43{
44#ifdef ELF_CORE_COPY_FPREGS
45 return ELF_CORE_COPY_FPREGS(t, fpu);
46#else
47 return dump_fpu(regs, fpu);
48#endif
49}
50
51#ifdef ELF_CORE_COPY_XFPREGS
52static inline int elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
53{
54 return ELF_CORE_COPY_XFPREGS(t, xfpu);
55}
56#endif
57
Daisuke HATAYAMA1fcccba2010-03-05 13:44:07 -080058/*
59 * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out
60 * extra segments containing the gate DSO contents. Dumping its
61 * contents makes post-mortem fully interpretable later without matching up
62 * the same kernel and hardware config to see what PC values meant.
63 * Dumping its extra ELF program headers includes all the other information
64 * a debugger needs to easily find how the gate DSO was being used.
65 */
66extern Elf_Half elf_core_extra_phdrs(void);
67extern int
Al Viro506f21c2013-10-05 17:22:57 -040068elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset);
Daisuke HATAYAMA1fcccba2010-03-05 13:44:07 -080069extern int
Al Viroaa3e7ea2013-10-05 17:50:15 -040070elf_core_write_extra_data(struct coredump_params *cprm);
Daisuke HATAYAMA8d9032b2010-03-05 13:44:10 -080071extern size_t elf_core_extra_data_size(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#endif /* _LINUX_ELFCORE_H */