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 #define _WANT_LWPINFO32 9 10 #include <sys/procfs.h> 11 12 #define ELFCORE_COMPAT_32 1 13 #include "elfcore.c" 14 15 static void 16 elf_convert_gregset(elfcore_gregset_t *rd, struct reg *rs) 17 { 18 #ifdef __amd64__ 19 rd->r_gs = rs->r_gs; 20 rd->r_fs = rs->r_fs; 21 rd->r_es = rs->r_es; 22 rd->r_ds = rs->r_ds; 23 rd->r_edi = rs->r_rdi; 24 rd->r_esi = rs->r_rsi; 25 rd->r_ebp = rs->r_rbp; 26 rd->r_ebx = rs->r_rbx; 27 rd->r_edx = rs->r_rdx; 28 rd->r_ecx = rs->r_rcx; 29 rd->r_eax = rs->r_rax; 30 rd->r_eip = rs->r_rip; 31 rd->r_cs = rs->r_cs; 32 rd->r_eflags = rs->r_rflags; 33 rd->r_esp = rs->r_rsp; 34 rd->r_ss = rs->r_ss; 35 #else 36 #error Unsupported architecture 37 #endif 38 } 39 40 static void 41 elf_convert_fpregset(elfcore_fpregset_t *rd, struct fpreg *rs) 42 { 43 #ifdef __amd64__ 44 /* XXX this is wrong... */ 45 memcpy(rd, rs, sizeof(*rd)); 46 #else 47 #error Unsupported architecture 48 #endif 49 } 50 51 static void 52 elf_convert_siginfo(struct siginfo32 *sid, siginfo_t *sis) 53 { 54 55 bzero(sid, sizeof(*sid)); 56 sid->si_signo = sis->si_signo; 57 sid->si_errno = sis->si_errno; 58 sid->si_code = sis->si_code; 59 sid->si_pid = sis->si_pid; 60 sid->si_uid = sis->si_uid; 61 sid->si_status = sis->si_status; 62 sid->si_addr = (uintptr_t)sis->si_addr; 63 #if _BYTE_ORDER == _BIG_ENDIAN 64 if (sis->si_value.sival_int == 0) 65 sid->si_value.sival_ptr = (uintptr_t)sis->si_value.sival_ptr; 66 else 67 #endif 68 sid->si_value.sival_int = sis->si_value.sival_int; 69 sid->si_timerid = sis->si_timerid; 70 sid->si_overrun = sis->si_overrun; 71 } 72 73 static void 74 elf_convert_lwpinfo(struct ptrace_lwpinfo32 *pld, struct ptrace_lwpinfo *pls) 75 { 76 77 pld->pl_lwpid = pls->pl_lwpid; 78 pld->pl_event = pls->pl_event; 79 pld->pl_flags = pls->pl_flags; 80 pld->pl_sigmask = pls->pl_sigmask; 81 pld->pl_siglist = pls->pl_siglist; 82 elf_convert_siginfo(&pld->pl_siginfo, &pls->pl_siginfo); 83 memcpy(pld->pl_tdname, pls->pl_tdname, sizeof(pld->pl_tdname)); 84 pld->pl_child_pid = pls->pl_child_pid; 85 pld->pl_syscall_code = pls->pl_syscall_code; 86 pld->pl_syscall_narg = pls->pl_syscall_narg; 87 } 88 89