xref: /freebsd/usr.bin/gcore/elf32core.c (revision 8eb2bee6c0f4957c6c1cea826e59cda4d18a2a64)
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_siginfo(struct siginfo32 *sid, siginfo_t *sis)
17 {
18 
19 	bzero(sid, sizeof(*sid));
20 	sid->si_signo = sis->si_signo;
21 	sid->si_errno = sis->si_errno;
22 	sid->si_code = sis->si_code;
23 	sid->si_pid = sis->si_pid;
24 	sid->si_uid = sis->si_uid;
25 	sid->si_status = sis->si_status;
26 	sid->si_addr = (uintptr_t)sis->si_addr;
27 #if _BYTE_ORDER == _BIG_ENDIAN
28 	if (sis->si_value.sival_int == 0)
29 		sid->si_value.sival_ptr = (uintptr_t)sis->si_value.sival_ptr;
30 	else
31 #endif
32 		sid->si_value.sival_int = sis->si_value.sival_int;
33 	sid->si_timerid = sis->si_timerid;
34 	sid->si_overrun = sis->si_overrun;
35 }
36 
37 static void
38 elf_convert_lwpinfo(struct ptrace_lwpinfo32 *pld, struct ptrace_lwpinfo *pls)
39 {
40 
41 	pld->pl_lwpid = pls->pl_lwpid;
42 	pld->pl_event = pls->pl_event;
43 	pld->pl_flags = pls->pl_flags;
44 	pld->pl_sigmask = pls->pl_sigmask;
45 	pld->pl_siglist = pls->pl_siglist;
46 	elf_convert_siginfo(&pld->pl_siginfo, &pls->pl_siginfo);
47 	memcpy(pld->pl_tdname, pls->pl_tdname, sizeof(pld->pl_tdname));
48 	pld->pl_child_pid = pls->pl_child_pid;
49 	pld->pl_syscall_code = pls->pl_syscall_code;
50 	pld->pl_syscall_narg = pls->pl_syscall_narg;
51 }
52 
53