Add Linux/x86_64 core support to i[3-7]86-*-linux
[external/binutils.git] / bfd / hosts / x86-64linux.h
1 /* Copyright (C) 2006, 2011, 2012
2    Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 /* This is somewhat modelled after the file of the same name on SVR4
21    systems.  It provides a definition of the core file format for ELF
22    used on Linux.  It doesn't have anything to do with the /proc file
23    system, even though Linux has one.
24
25    Anyway, the whole purpose of this file is for GDB and GDB only.
26    Don't read too much into it.  Don't use it for anything other than
27    GDB unless you know what you are doing.  */
28
29 #include <features.h>
30 #include <sys/time.h>
31 #include <sys/types.h>
32
33 /* We define here only the symbols differing from their 64-bit variant.  */
34 #include <sys/procfs.h>
35
36 #ifdef HAVE_STDINT_H
37 #include <stdint.h>
38 #else
39 typedef unsigned int uint32_t;
40 typedef unsigned long long int uint64_t;
41 #endif
42
43 /* Unsigned 64-bit integer aligned to 8 bytes.  */
44 typedef uint64_t __attribute__ ((__aligned__ (8))) a8_uint64_t;
45
46 #undef HAVE_PRPSINFO32_T
47 #define HAVE_PRPSINFO32_T
48 #undef HAVE_PRPSINFO32_T_PR_PID
49 #define HAVE_PRPSINFO32_T_PR_PID
50
51 #undef HAVE_PRSTATUS32_T
52 #define HAVE_PRSTATUS32_T
53
54 /* These are the 32-bit x86 structures.  */
55
56 struct user_regs32_struct
57 {
58   int32_t ebx;
59   int32_t ecx;
60   int32_t edx;
61   int32_t esi;
62   int32_t edi;
63   int32_t ebp;
64   int32_t eax;
65   int32_t xds;
66   int32_t xes;
67   int32_t xfs;
68   int32_t xgs;
69   int32_t orig_eax;
70   int32_t eip;
71   int32_t xcs;
72   int32_t eflags;
73   int32_t esp;
74   int32_t xss;
75 };
76
77 struct user_regs64_struct
78 {
79   a8_uint64_t r15;
80   a8_uint64_t r14;
81   a8_uint64_t r13;
82   a8_uint64_t r12;
83   a8_uint64_t rbp;
84   a8_uint64_t rbx;
85   a8_uint64_t r11;
86   a8_uint64_t r10;
87   a8_uint64_t r9;
88   a8_uint64_t r8;
89   a8_uint64_t rax;
90   a8_uint64_t rcx;
91   a8_uint64_t rdx;
92   a8_uint64_t rsi;
93   a8_uint64_t rdi;
94   a8_uint64_t orig_rax;
95   a8_uint64_t rip;
96   a8_uint64_t cs;
97   a8_uint64_t eflags;
98   a8_uint64_t rsp;
99   a8_uint64_t ss;
100   a8_uint64_t fs_base;
101   a8_uint64_t gs_base;
102   a8_uint64_t ds;
103   a8_uint64_t es;
104   a8_uint64_t fs;
105   a8_uint64_t gs;
106 };
107
108 /* Type for a general-purpose register.  */
109 typedef uint32_t elf_greg32_t;
110 typedef a8_uint64_t elf_greg64_t;
111
112 /* And the whole bunch of them.  We could have used `struct
113    user_regs_struct' directly in the typedef, but tradition says that
114    the register set is an array, which does have some peculiar
115    semantics, so leave it that way.  */
116 #define ELF_NGREG32 (sizeof (struct user_regs32_struct) / sizeof(elf_greg32_t))
117 typedef elf_greg32_t elf_gregset32_t[ELF_NGREG32];
118 #define ELF_NGREG64 (sizeof (struct user_regs64_struct) / sizeof(elf_greg64_t))
119 typedef elf_greg64_t elf_gregset64_t[ELF_NGREG64];
120
121 /* Definitions to generate Intel SVR4-like core files.  These mostly
122    have the same names as the SVR4 types with "elf_" tacked on the
123    front to prevent clashes with Linux definitions, and the typedef
124    forms have been avoided.  This is mostly like the SVR4 structure,
125    but more Linuxy, with things that Linux does not support and which
126    GDB doesn't really use excluded.  */
127
128 struct prstatus32_timeval
129   {
130     int tv_sec;
131     int tv_usec;
132   };
133
134 struct prstatus64_timeval
135   {
136     a8_uint64_t tv_sec;
137     a8_uint64_t tv_usec;
138   };
139
140 struct elf_prstatus32
141   {
142     struct elf_siginfo pr_info;         /* Info associated with signal.  */
143     short int pr_cursig;                /* Current signal.  */
144     unsigned int pr_sigpend;            /* Set of pending signals.  */
145     unsigned int pr_sighold;            /* Set of held signals.  */
146     pid_t pr_pid;
147     pid_t pr_ppid;
148     pid_t pr_pgrp;
149     pid_t pr_sid;
150     struct prstatus32_timeval pr_utime;         /* User time.  */
151     struct prstatus32_timeval pr_stime;         /* System time.  */
152     struct prstatus32_timeval pr_cutime;        /* Cumulative user time.  */
153     struct prstatus32_timeval pr_cstime;        /* Cumulative system time.  */
154     elf_gregset32_t pr_reg;             /* GP registers.  */
155     int pr_fpvalid;                     /* True if math copro being used.  */
156   };
157
158 struct elf_prstatusx32
159   {
160     struct elf_siginfo pr_info;         /* Info associated with signal.  */
161     short int pr_cursig;                /* Current signal.  */
162     unsigned int pr_sigpend;            /* Set of pending signals.  */
163     unsigned int pr_sighold;            /* Set of held signals.  */
164     pid_t pr_pid;
165     pid_t pr_ppid;
166     pid_t pr_pgrp;
167     pid_t pr_sid;
168     struct prstatus32_timeval pr_utime;         /* User time.  */
169     struct prstatus32_timeval pr_stime;         /* System time.  */
170     struct prstatus32_timeval pr_cutime;        /* Cumulative user time.  */
171     struct prstatus32_timeval pr_cstime;        /* Cumulative system time.  */
172     elf_gregset64_t pr_reg;             /* GP registers.  */
173     int pr_fpvalid;                     /* True if math copro being used.  */
174   };
175
176 struct elf_prstatus64
177   {
178     struct elf_siginfo pr_info; /* Info associated with signal.  */
179     short int pr_cursig;                /* Current signal.  */
180     a8_uint64_t pr_sigpend;             /* Set of pending signals.  */
181     a8_uint64_t pr_sighold;             /* Set of held signals.  */
182     pid_t pr_pid;
183     pid_t pr_ppid;
184     pid_t pr_pgrp;
185     pid_t pr_sid;
186     struct prstatus64_timeval pr_utime;         /* User time.  */
187     struct prstatus64_timeval pr_stime;         /* System time.  */
188     struct prstatus64_timeval pr_cutime;        /* Cumulative user time.  */
189     struct prstatus64_timeval pr_cstime;        /* Cumulative system time.  */
190     elf_gregset64_t pr_reg;             /* GP registers.  */
191     int pr_fpvalid;                     /* True if math copro being used.  */
192   };
193
194 struct elf_prpsinfo32
195   {
196     char pr_state;                      /* Numeric process state.  */
197     char pr_sname;                      /* Char for pr_state.  */
198     char pr_zomb;                       /* Zombie.  */
199     char pr_nice;                       /* Nice val.  */
200     unsigned int pr_flag;               /* Flags.  */
201     unsigned short int pr_uid;
202     unsigned short int pr_gid;
203     int pr_pid, pr_ppid, pr_pgrp, pr_sid;
204     /* Lots missing */
205     char pr_fname[16];                  /* Filename of executable.  */
206     char pr_psargs[ELF_PRARGSZ];        /* Initial part of arg list.  */
207   };
208
209 struct elf_prpsinfo64
210   {
211     char pr_state;                      /* Numeric process state.  */
212     char pr_sname;                      /* Char for pr_state.  */
213     char pr_zomb;                       /* Zombie.  */
214     char pr_nice;                       /* Nice val.  */
215     a8_uint64_t pr_flag;                /* Flags.  */
216     unsigned int pr_uid;
217     unsigned int pr_gid;
218     int pr_pid, pr_ppid, pr_pgrp, pr_sid;
219     /* Lots missing */
220     char pr_fname[16];                  /* Filename of executable.  */
221     char pr_psargs[ELF_PRARGSZ];        /* Initial part of arg list.  */
222   };
223
224 /* The rest of this file provides the types for emulation of the
225    Solaris <proc_service.h> interfaces that should be implemented by
226    users of libthread_db.  */
227
228 /* Process status and info.  In the end we do provide typedefs for them.  */
229 typedef struct elf_prstatus32 prstatus32_t;
230 typedef struct elf_prstatusx32 prstatusx32_t;
231 typedef struct elf_prstatus64 prstatus64_t;
232 typedef struct elf_prpsinfo32 prpsinfo32_t;
233 typedef struct elf_prpsinfo64 prpsinfo64_t;