PageRenderTime 62ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/include/linux/elfcore.h

https://github.com/mstsirkin/linux
C Header | 171 lines | 130 code | 17 blank | 24 comment | 1 complexity | a2c3d46a93b41c7c651090b5e1e14a05 MD5 | raw file
  1. #ifndef _LINUX_ELFCORE_H
  2. #define _LINUX_ELFCORE_H
  3. #include <linux/types.h>
  4. #include <linux/signal.h>
  5. #include <linux/time.h>
  6. #ifdef __KERNEL__
  7. #include <linux/user.h>
  8. #endif
  9. #include <linux/ptrace.h>
  10. #include <linux/elf.h>
  11. #include <linux/fs.h>
  12. struct elf_siginfo
  13. {
  14. int si_signo; /* signal number */
  15. int si_code; /* extra code */
  16. int si_errno; /* errno */
  17. };
  18. #ifdef __KERNEL__
  19. #include <asm/elf.h>
  20. #endif
  21. #ifndef __KERNEL__
  22. typedef elf_greg_t greg_t;
  23. typedef elf_gregset_t gregset_t;
  24. typedef elf_fpregset_t fpregset_t;
  25. typedef elf_fpxregset_t fpxregset_t;
  26. #define NGREG ELF_NGREG
  27. #endif
  28. /*
  29. * Definitions to generate Intel SVR4-like core files.
  30. * These mostly have the same names as the SVR4 types with "elf_"
  31. * tacked on the front to prevent clashes with linux definitions,
  32. * and the typedef forms have been avoided. This is mostly like
  33. * the SVR4 structure, but more Linuxy, with things that Linux does
  34. * not support and which gdb doesn't really use excluded.
  35. * Fields present but not used are marked with "XXX".
  36. */
  37. struct elf_prstatus
  38. {
  39. #if 0
  40. long pr_flags; /* XXX Process flags */
  41. short pr_why; /* XXX Reason for process halt */
  42. short pr_what; /* XXX More detailed reason */
  43. #endif
  44. struct elf_siginfo pr_info; /* Info associated with signal */
  45. short pr_cursig; /* Current signal */
  46. unsigned long pr_sigpend; /* Set of pending signals */
  47. unsigned long pr_sighold; /* Set of held signals */
  48. #if 0
  49. struct sigaltstack pr_altstack; /* Alternate stack info */
  50. struct sigaction pr_action; /* Signal action for current sig */
  51. #endif
  52. pid_t pr_pid;
  53. pid_t pr_ppid;
  54. pid_t pr_pgrp;
  55. pid_t pr_sid;
  56. struct timeval pr_utime; /* User time */
  57. struct timeval pr_stime; /* System time */
  58. struct timeval pr_cutime; /* Cumulative user time */
  59. struct timeval pr_cstime; /* Cumulative system time */
  60. #if 0
  61. long pr_instr; /* Current instruction */
  62. #endif
  63. elf_gregset_t pr_reg; /* GP registers */
  64. #ifdef CONFIG_BINFMT_ELF_FDPIC
  65. /* When using FDPIC, the loadmap addresses need to be communicated
  66. * to GDB in order for GDB to do the necessary relocations. The
  67. * fields (below) used to communicate this information are placed
  68. * immediately after ``pr_reg'', so that the loadmap addresses may
  69. * be viewed as part of the register set if so desired.
  70. */
  71. unsigned long pr_exec_fdpic_loadmap;
  72. unsigned long pr_interp_fdpic_loadmap;
  73. #endif
  74. int pr_fpvalid; /* True if math co-processor being used. */
  75. };
  76. #define ELF_PRARGSZ (80) /* Number of chars for args */
  77. struct elf_prpsinfo
  78. {
  79. char pr_state; /* numeric process state */
  80. char pr_sname; /* char for pr_state */
  81. char pr_zomb; /* zombie */
  82. char pr_nice; /* nice val */
  83. unsigned long pr_flag; /* flags */
  84. __kernel_uid_t pr_uid;
  85. __kernel_gid_t pr_gid;
  86. pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
  87. /* Lots missing */
  88. char pr_fname[16]; /* filename of executable */
  89. char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
  90. };
  91. #ifndef __KERNEL__
  92. typedef struct elf_prstatus prstatus_t;
  93. typedef struct elf_prpsinfo prpsinfo_t;
  94. #define PRARGSZ ELF_PRARGSZ
  95. #endif
  96. #ifdef __KERNEL__
  97. static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs)
  98. {
  99. #ifdef ELF_CORE_COPY_REGS
  100. ELF_CORE_COPY_REGS((*elfregs), regs)
  101. #else
  102. BUG_ON(sizeof(*elfregs) != sizeof(*regs));
  103. *(struct pt_regs *)elfregs = *regs;
  104. #endif
  105. }
  106. static inline void elf_core_copy_kernel_regs(elf_gregset_t *elfregs, struct pt_regs *regs)
  107. {
  108. #ifdef ELF_CORE_COPY_KERNEL_REGS
  109. ELF_CORE_COPY_KERNEL_REGS((*elfregs), regs);
  110. #else
  111. elf_core_copy_regs(elfregs, regs);
  112. #endif
  113. }
  114. static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs)
  115. {
  116. #if defined (ELF_CORE_COPY_TASK_REGS)
  117. return ELF_CORE_COPY_TASK_REGS(t, elfregs);
  118. #elif defined (task_pt_regs)
  119. elf_core_copy_regs(elfregs, task_pt_regs(t));
  120. #endif
  121. return 0;
  122. }
  123. extern int dump_fpu (struct pt_regs *, elf_fpregset_t *);
  124. static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_regs *regs, elf_fpregset_t *fpu)
  125. {
  126. #ifdef ELF_CORE_COPY_FPREGS
  127. return ELF_CORE_COPY_FPREGS(t, fpu);
  128. #else
  129. return dump_fpu(regs, fpu);
  130. #endif
  131. }
  132. #ifdef ELF_CORE_COPY_XFPREGS
  133. static inline int elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
  134. {
  135. return ELF_CORE_COPY_XFPREGS(t, xfpu);
  136. }
  137. #endif
  138. /*
  139. * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out
  140. * extra segments containing the gate DSO contents. Dumping its
  141. * contents makes post-mortem fully interpretable later without matching up
  142. * the same kernel and hardware config to see what PC values meant.
  143. * Dumping its extra ELF program headers includes all the other information
  144. * a debugger needs to easily find how the gate DSO was being used.
  145. */
  146. extern Elf_Half elf_core_extra_phdrs(void);
  147. extern int
  148. elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size,
  149. unsigned long limit);
  150. extern int
  151. elf_core_write_extra_data(struct file *file, size_t *size, unsigned long limit);
  152. extern size_t elf_core_extra_data_size(void);
  153. #endif /* __KERNEL__ */
  154. #endif /* _LINUX_ELFCORE_H */