elfcore.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_ELFCORE_H
  3. #define _LINUX_ELFCORE_H
  4. #include <linux/user.h>
  5. #include <linux/bug.h>
  6. #include <linux/sched/task_stack.h>
  7. #include <asm/elf.h>
  8. #include <uapi/linux/elfcore.h>
  9. struct coredump_params;
  10. static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs)
  11. {
  12. #ifdef ELF_CORE_COPY_REGS
  13. ELF_CORE_COPY_REGS((*elfregs), regs)
  14. #else
  15. BUG_ON(sizeof(*elfregs) != sizeof(*regs));
  16. *(struct pt_regs *)elfregs = *regs;
  17. #endif
  18. }
  19. static inline void elf_core_copy_kernel_regs(elf_gregset_t *elfregs, struct pt_regs *regs)
  20. {
  21. #ifdef ELF_CORE_COPY_KERNEL_REGS
  22. ELF_CORE_COPY_KERNEL_REGS((*elfregs), regs);
  23. #else
  24. elf_core_copy_regs(elfregs, regs);
  25. #endif
  26. }
  27. static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs)
  28. {
  29. #if defined (ELF_CORE_COPY_TASK_REGS)
  30. return ELF_CORE_COPY_TASK_REGS(t, elfregs);
  31. #elif defined (task_pt_regs)
  32. elf_core_copy_regs(elfregs, task_pt_regs(t));
  33. #endif
  34. return 0;
  35. }
  36. extern int dump_fpu (struct pt_regs *, elf_fpregset_t *);
  37. static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_regs *regs, elf_fpregset_t *fpu)
  38. {
  39. #ifdef ELF_CORE_COPY_FPREGS
  40. return ELF_CORE_COPY_FPREGS(t, fpu);
  41. #else
  42. return dump_fpu(regs, fpu);
  43. #endif
  44. }
  45. #ifdef ELF_CORE_COPY_XFPREGS
  46. static inline int elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
  47. {
  48. return ELF_CORE_COPY_XFPREGS(t, xfpu);
  49. }
  50. #endif
  51. /*
  52. * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out
  53. * extra segments containing the gate DSO contents. Dumping its
  54. * contents makes post-mortem fully interpretable later without matching up
  55. * the same kernel and hardware config to see what PC values meant.
  56. * Dumping its extra ELF program headers includes all the other information
  57. * a debugger needs to easily find how the gate DSO was being used.
  58. */
  59. extern Elf_Half elf_core_extra_phdrs(void);
  60. extern int
  61. elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset);
  62. extern int
  63. elf_core_write_extra_data(struct coredump_params *cprm);
  64. extern size_t elf_core_extra_data_size(void);
  65. #endif /* _LINUX_ELFCORE_H */