freebsd-dev/usr.bin/gcore/elf32core.c
John Baldwin dbee5c671a Move the 32-bit compatible procfs types from freebsd32.h to <sys/procfs.h>
and export them to userland.
- Define __HAVE_REG32 on platforms that define a reg32 structure and check
  for this in <sys/procfs.h> to control when to export prstatus32, etc.
- Add prstatus32_t and prpsinfo32_t typedefs for the 32-bit structures.
  libbfd looks for these types, and having them fixes 'gcore' in gdb of a
  32-bit process on a 64-bit platform.
- Use the structure definitions from <sys/procfs.h> in gcore's elf32 core
  dump code instead of duplicating the definitions.

Differential Revision:	https://reviews.freebsd.org/D2142
Reviewed by:	kib, nathanw (powerpc bits)
MFC after:	1 week
2015-04-08 16:30:45 +00:00

49 lines
937 B
C

/* $FreeBSD$ */
#ifndef __LP64__
#error "this file must be compiled for LP64."
#endif
#define __ELF_WORD_SIZE 32
#define _MACHINE_ELF_WANT_32BIT
#include <sys/procfs.h>
#define ELFCORE_COMPAT_32 1
#include "elfcore.c"
static void
elf_convert_gregset(elfcore_gregset_t *rd, struct reg *rs)
{
#ifdef __amd64__
rd->r_gs = rs->r_gs;
rd->r_fs = rs->r_fs;
rd->r_es = rs->r_es;
rd->r_ds = rs->r_ds;
rd->r_edi = rs->r_rdi;
rd->r_esi = rs->r_rsi;
rd->r_ebp = rs->r_rbp;
rd->r_ebx = rs->r_rbx;
rd->r_edx = rs->r_rdx;
rd->r_ecx = rs->r_rcx;
rd->r_eax = rs->r_rax;
rd->r_eip = rs->r_rip;
rd->r_cs = rs->r_cs;
rd->r_eflags = rs->r_rflags;
rd->r_esp = rs->r_rsp;
rd->r_ss = rs->r_ss;
#else
#error Unsupported architecture
#endif
}
static void
elf_convert_fpregset(elfcore_fpregset_t *rd, struct fpreg *rs)
{
#ifdef __amd64__
/* XXX this is wrong... */
memcpy(rd, rs, sizeof(*rd));
#else
#error Unsupported architecture
#endif
}