elfcore.h 2.0 KB

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