elfcore.h 2.1 KB

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