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