Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_ELFCORE_H |
| 2 | #define _LINUX_ELFCORE_H |
| 3 | |
| 4 | #include <linux/types.h> |
| 5 | #include <linux/signal.h> |
| 6 | #include <linux/time.h> |
Kirill A. Shutemov | c1445db | 2008-02-07 00:15:53 -0800 | [diff] [blame] | 7 | #ifdef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/user.h> |
Kirill A. Shutemov | c1445db | 2008-02-07 00:15:53 -0800 | [diff] [blame] | 9 | #endif |
Fernando Luis Vazquez Cao | 2c5d81a | 2006-02-03 03:04:39 -0800 | [diff] [blame] | 10 | #include <linux/ptrace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
| 12 | struct elf_siginfo |
| 13 | { |
| 14 | int si_signo; /* signal number */ |
| 15 | int si_code; /* extra code */ |
| 16 | int si_errno; /* errno */ |
| 17 | }; |
| 18 | |
Kirill A. Shutemov | 6cc931b | 2008-02-07 00:15:55 -0800 | [diff] [blame] | 19 | #ifdef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/elf.h> |
Kirill A. Shutemov | 6cc931b | 2008-02-07 00:15:55 -0800 | [diff] [blame] | 21 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
| 23 | #ifndef __KERNEL__ |
| 24 | typedef elf_greg_t greg_t; |
| 25 | typedef elf_gregset_t gregset_t; |
| 26 | typedef elf_fpregset_t fpregset_t; |
| 27 | typedef elf_fpxregset_t fpxregset_t; |
| 28 | #define NGREG ELF_NGREG |
| 29 | #endif |
| 30 | |
| 31 | /* |
| 32 | * Definitions to generate Intel SVR4-like core files. |
| 33 | * These mostly have the same names as the SVR4 types with "elf_" |
| 34 | * tacked on the front to prevent clashes with linux definitions, |
| 35 | * and the typedef forms have been avoided. This is mostly like |
| 36 | * the SVR4 structure, but more Linuxy, with things that Linux does |
| 37 | * not support and which gdb doesn't really use excluded. |
| 38 | * Fields present but not used are marked with "XXX". |
| 39 | */ |
| 40 | struct elf_prstatus |
| 41 | { |
| 42 | #if 0 |
| 43 | long pr_flags; /* XXX Process flags */ |
| 44 | short pr_why; /* XXX Reason for process halt */ |
| 45 | short pr_what; /* XXX More detailed reason */ |
| 46 | #endif |
| 47 | struct elf_siginfo pr_info; /* Info associated with signal */ |
| 48 | short pr_cursig; /* Current signal */ |
| 49 | unsigned long pr_sigpend; /* Set of pending signals */ |
| 50 | unsigned long pr_sighold; /* Set of held signals */ |
| 51 | #if 0 |
| 52 | struct sigaltstack pr_altstack; /* Alternate stack info */ |
| 53 | struct sigaction pr_action; /* Signal action for current sig */ |
| 54 | #endif |
| 55 | pid_t pr_pid; |
| 56 | pid_t pr_ppid; |
| 57 | pid_t pr_pgrp; |
| 58 | pid_t pr_sid; |
| 59 | struct timeval pr_utime; /* User time */ |
| 60 | struct timeval pr_stime; /* System time */ |
| 61 | struct timeval pr_cutime; /* Cumulative user time */ |
| 62 | struct timeval pr_cstime; /* Cumulative system time */ |
| 63 | #if 0 |
| 64 | long pr_instr; /* Current instruction */ |
| 65 | #endif |
| 66 | elf_gregset_t pr_reg; /* GP registers */ |
David Howells | 6d8c4e3 | 2006-07-10 04:44:55 -0700 | [diff] [blame] | 67 | #ifdef CONFIG_BINFMT_ELF_FDPIC |
| 68 | /* When using FDPIC, the loadmap addresses need to be communicated |
| 69 | * to GDB in order for GDB to do the necessary relocations. The |
| 70 | * fields (below) used to communicate this information are placed |
| 71 | * immediately after ``pr_reg'', so that the loadmap addresses may |
| 72 | * be viewed as part of the register set if so desired. |
| 73 | */ |
| 74 | unsigned long pr_exec_fdpic_loadmap; |
| 75 | unsigned long pr_interp_fdpic_loadmap; |
| 76 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | int pr_fpvalid; /* True if math co-processor being used. */ |
| 78 | }; |
| 79 | |
| 80 | #define ELF_PRARGSZ (80) /* Number of chars for args */ |
| 81 | |
| 82 | struct elf_prpsinfo |
| 83 | { |
| 84 | char pr_state; /* numeric process state */ |
| 85 | char pr_sname; /* char for pr_state */ |
| 86 | char pr_zomb; /* zombie */ |
| 87 | char pr_nice; /* nice val */ |
| 88 | unsigned long pr_flag; /* flags */ |
| 89 | __kernel_uid_t pr_uid; |
| 90 | __kernel_gid_t pr_gid; |
| 91 | pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid; |
| 92 | /* Lots missing */ |
| 93 | char pr_fname[16]; /* filename of executable */ |
| 94 | char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ |
| 95 | }; |
| 96 | |
| 97 | #ifndef __KERNEL__ |
| 98 | typedef struct elf_prstatus prstatus_t; |
| 99 | typedef struct elf_prpsinfo prpsinfo_t; |
| 100 | #define PRARGSZ ELF_PRARGSZ |
| 101 | #endif |
| 102 | |
| 103 | #ifdef __KERNEL__ |
| 104 | static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs) |
| 105 | { |
| 106 | #ifdef ELF_CORE_COPY_REGS |
| 107 | ELF_CORE_COPY_REGS((*elfregs), regs) |
| 108 | #else |
| 109 | BUG_ON(sizeof(*elfregs) != sizeof(*regs)); |
| 110 | *(struct pt_regs *)elfregs = *regs; |
| 111 | #endif |
| 112 | } |
| 113 | |
Tejun Heo | 6cd61c0 | 2009-02-09 22:17:39 +0900 | [diff] [blame] | 114 | static inline void elf_core_copy_kernel_regs(elf_gregset_t *elfregs, struct pt_regs *regs) |
| 115 | { |
| 116 | #ifdef ELF_CORE_COPY_KERNEL_REGS |
| 117 | ELF_CORE_COPY_KERNEL_REGS((*elfregs), regs); |
| 118 | #else |
| 119 | elf_core_copy_regs(elfregs, regs); |
| 120 | #endif |
| 121 | } |
| 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs) |
| 124 | { |
| 125 | #ifdef ELF_CORE_COPY_TASK_REGS |
| 126 | |
| 127 | return ELF_CORE_COPY_TASK_REGS(t, elfregs); |
| 128 | #endif |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | extern int dump_fpu (struct pt_regs *, elf_fpregset_t *); |
| 133 | |
| 134 | static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_regs *regs, elf_fpregset_t *fpu) |
| 135 | { |
| 136 | #ifdef ELF_CORE_COPY_FPREGS |
| 137 | return ELF_CORE_COPY_FPREGS(t, fpu); |
| 138 | #else |
| 139 | return dump_fpu(regs, fpu); |
| 140 | #endif |
| 141 | } |
| 142 | |
| 143 | #ifdef ELF_CORE_COPY_XFPREGS |
| 144 | static inline int elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu) |
| 145 | { |
| 146 | return ELF_CORE_COPY_XFPREGS(t, xfpu); |
| 147 | } |
| 148 | #endif |
| 149 | |
| 150 | #endif /* __KERNEL__ */ |
| 151 | |
| 152 | |
| 153 | #endif /* _LINUX_ELFCORE_H */ |