elf32core.c revision 269128
1269128Smarcel/* $FreeBSD: head/usr.bin/gcore/elf32core.c 269128 2014-07-26 16:45:11Z marcel $ */ 2269128Smarcel#ifndef __LP64__ 3269128Smarcel#error "this file must be compiled for LP64." 4269128Smarcel#endif 5269128Smarcel 6269128Smarcel#define __ELF_WORD_SIZE 32 7269128Smarcel#define _MACHINE_ELF_WANT_32BIT 8269128Smarcel 9269128Smarcel#include <sys/procfs.h> 10269128Smarcel 11269128Smarcelstruct prpsinfo32 { 12269128Smarcel int pr_version; 13269128Smarcel u_int pr_psinfosz; 14269128Smarcel char pr_fname[PRFNAMESZ+1]; 15269128Smarcel char pr_psargs[PRARGSZ+1]; 16269128Smarcel}; 17269128Smarcel 18269128Smarcelstruct prstatus32 { 19269128Smarcel int pr_version; 20269128Smarcel u_int pr_statussz; 21269128Smarcel u_int pr_gregsetsz; 22269128Smarcel u_int pr_fpregsetsz; 23269128Smarcel int pr_osreldate; 24269128Smarcel int pr_cursig; 25269128Smarcel pid_t pr_pid; 26269128Smarcel struct reg32 pr_reg; 27269128Smarcel}; 28269128Smarcel 29269128Smarcel#define ELFCORE_COMPAT_32 1 30269128Smarcel#include "elfcore.c" 31269128Smarcel 32269128Smarcelstatic void 33269128Smarcelelf_convert_gregset(elfcore_gregset_t *rd, struct reg *rs) 34269128Smarcel{ 35269128Smarcel#ifdef __amd64__ 36269128Smarcel rd->r_gs = rs->r_gs; 37269128Smarcel rd->r_fs = rs->r_fs; 38269128Smarcel rd->r_es = rs->r_es; 39269128Smarcel rd->r_ds = rs->r_ds; 40269128Smarcel rd->r_edi = rs->r_rdi; 41269128Smarcel rd->r_esi = rs->r_rsi; 42269128Smarcel rd->r_ebp = rs->r_rbp; 43269128Smarcel rd->r_ebx = rs->r_rbx; 44269128Smarcel rd->r_edx = rs->r_rdx; 45269128Smarcel rd->r_ecx = rs->r_rcx; 46269128Smarcel rd->r_eax = rs->r_rax; 47269128Smarcel rd->r_eip = rs->r_rip; 48269128Smarcel rd->r_cs = rs->r_cs; 49269128Smarcel rd->r_eflags = rs->r_rflags; 50269128Smarcel rd->r_esp = rs->r_rsp; 51269128Smarcel rd->r_ss = rs->r_ss; 52269128Smarcel#else 53269128Smarcel#error Unsupported architecture 54269128Smarcel#endif 55269128Smarcel} 56269128Smarcel 57269128Smarcelstatic void 58269128Smarcelelf_convert_fpregset(elfcore_fpregset_t *rd, struct fpreg *rs) 59269128Smarcel{ 60269128Smarcel#ifdef __amd64__ 61269128Smarcel /* XXX this is wrong... */ 62269128Smarcel memcpy(rd, rs, sizeof(*rd)); 63269128Smarcel#else 64269128Smarcel#error Unsupported architecture 65269128Smarcel#endif 66269128Smarcel} 67