xref: /freebsd/usr.bin/gcore/elf32core.c (revision 246e7a2b6494cd991b08ac669ed761ecea0cc98c)
1 /* $FreeBSD$ */
2 #ifndef __LP64__
3 #error "this file must be compiled for LP64."
4 #endif
5 
6 #define __ELF_WORD_SIZE 32
7 #define _MACHINE_ELF_WANT_32BIT
8 
9 #include <sys/procfs.h>
10 
11 struct prpsinfo32 {
12 	int	pr_version;
13 	u_int	pr_psinfosz;
14 	char	pr_fname[PRFNAMESZ+1];
15 	char	pr_psargs[PRARGSZ+1];
16 };
17 
18 struct prstatus32 {
19 	int	pr_version;
20 	u_int	pr_statussz;
21 	u_int	pr_gregsetsz;
22 	u_int	pr_fpregsetsz;
23 	int	pr_osreldate;
24 	int	pr_cursig;
25 	pid_t	pr_pid;
26 	struct reg32 pr_reg;
27 };
28 
29 #define	ELFCORE_COMPAT_32	1
30 #include "elfcore.c"
31 
32 static void
33 elf_convert_gregset(elfcore_gregset_t *rd, struct reg *rs)
34 {
35 #ifdef __amd64__
36 	rd->r_gs = rs->r_gs;
37 	rd->r_fs = rs->r_fs;
38 	rd->r_es = rs->r_es;
39 	rd->r_ds = rs->r_ds;
40 	rd->r_edi = rs->r_rdi;
41 	rd->r_esi = rs->r_rsi;
42 	rd->r_ebp = rs->r_rbp;
43 	rd->r_ebx = rs->r_rbx;
44 	rd->r_edx = rs->r_rdx;
45 	rd->r_ecx = rs->r_rcx;
46 	rd->r_eax = rs->r_rax;
47 	rd->r_eip = rs->r_rip;
48 	rd->r_cs = rs->r_cs;
49 	rd->r_eflags = rs->r_rflags;
50 	rd->r_esp = rs->r_rsp;
51 	rd->r_ss = rs->r_ss;
52 #else
53 #error Unsupported architecture
54 #endif
55 }
56 
57 static void
58 elf_convert_fpregset(elfcore_fpregset_t *rd, struct fpreg *rs)
59 {
60 #ifdef __amd64__
61 	/* XXX this is wrong... */
62 	memcpy(rd, rs, sizeof(*rd));
63 #else
64 #error Unsupported architecture
65 #endif
66 }
67