• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _LINUX_ELFCORE_H
2 #define _LINUX_ELFCORE_H
3 
4 #include <linux/user.h>
5 #include <linux/bug.h>
6 #include <asm/elf.h>
7 #include <uapi/linux/elfcore.h>
8 
9 struct coredump_params;
10 
elf_core_copy_regs(elf_gregset_t * elfregs,struct pt_regs * regs)11 static 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 
elf_core_copy_kernel_regs(elf_gregset_t * elfregs,struct pt_regs * regs)21 static 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 
elf_core_copy_task_regs(struct task_struct * t,elf_gregset_t * elfregs)30 static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs)
31 {
32 #if defined (ELF_CORE_COPY_TASK_REGS)
33 	return ELF_CORE_COPY_TASK_REGS(t, elfregs);
34 #elif defined (task_pt_regs)
35 	elf_core_copy_regs(elfregs, task_pt_regs(t));
36 #endif
37 	return 0;
38 }
39 
40 extern int dump_fpu (struct pt_regs *, elf_fpregset_t *);
41 
elf_core_copy_task_fpregs(struct task_struct * t,struct pt_regs * regs,elf_fpregset_t * fpu)42 static 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
elf_core_copy_task_xfpregs(struct task_struct * t,elf_fpxregset_t * xfpu)52 static 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 
58 #if (defined(CONFIG_UML) && defined(CONFIG_X86_32)) || defined(CONFIG_IA64)
59 /*
60  * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out
61  * extra segments containing the gate DSO contents.  Dumping its
62  * contents makes post-mortem fully interpretable later without matching up
63  * the same kernel and hardware config to see what PC values meant.
64  * Dumping its extra ELF program headers includes all the other information
65  * a debugger needs to easily find how the gate DSO was being used.
66  */
67 extern Elf_Half elf_core_extra_phdrs(void);
68 extern int
69 elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset);
70 extern int
71 elf_core_write_extra_data(struct coredump_params *cprm);
72 extern size_t elf_core_extra_data_size(void);
73 #else
elf_core_extra_phdrs(void)74 static inline Elf_Half elf_core_extra_phdrs(void)
75 {
76 	return 0;
77 }
78 
elf_core_write_extra_phdrs(struct coredump_params * cprm,loff_t offset)79 static inline int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
80 {
81 	return 1;
82 }
83 
elf_core_write_extra_data(struct coredump_params * cprm)84 static inline int elf_core_write_extra_data(struct coredump_params *cprm)
85 {
86 	return 1;
87 }
88 
elf_core_extra_data_size(void)89 static inline size_t elf_core_extra_data_size(void)
90 {
91 	return 0;
92 }
93 #endif
94 
95 #endif /* _LINUX_ELFCORE_H */
96