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