diff options
author | rsc <devnull@localhost> | 2004-04-19 19:29:25 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-04-19 19:29:25 +0000 |
commit | a84cbb2a17c9d0b88c561d5b7cb50d79a19e7c46 (patch) | |
tree | 59a0e921597e5aa53e83d487c16727a7bf01547a /src/libmach/elfcorelinux386.c | |
parent | 0e3cc9f456ea49919459bf1164d0c8309a6134fa (diff) | |
download | plan9port-a84cbb2a17c9d0b88c561d5b7cb50d79a19e7c46.tar.gz plan9port-a84cbb2a17c9d0b88c561d5b7cb50d79a19e7c46.tar.bz2 plan9port-a84cbb2a17c9d0b88c561d5b7cb50d79a19e7c46.zip |
libmach
Diffstat (limited to 'src/libmach/elfcorelinux386.c')
-rw-r--r-- | src/libmach/elfcorelinux386.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/libmach/elfcorelinux386.c b/src/libmach/elfcorelinux386.c new file mode 100644 index 00000000..f6a0234c --- /dev/null +++ b/src/libmach/elfcorelinux386.c @@ -0,0 +1,95 @@ +#include <u.h> +#include <libc.h> +#include <mach.h> +#include "elf.h" +#include "ureg386.h" + +typedef struct Lreg Lreg; +typedef struct Status Status; + +struct Lreg +{ + u32int ebx; + u32int ecx; + u32int edx; + u32int esi; + u32int edi; + u32int ebp; + u32int eax; + u32int ds; + u32int es; + u32int fs; + u32int gs; + u32int origeax; + u32int eip; + u32int cs; + u32int eflags; + u32int esp; + u32int ss; +}; + +/* + * Lreg is 64-bit aligned within status, so we shouldn't + * have any packing problems. + */ +struct Status +{ + u32int signo; + u32int code; + u32int errno; + u32int cursig; + u32int sigpend; + u32int sighold; + u32int pid; + u32int ppid; + u32int pgrp; + u32int sid; + u32int utime[2]; + u32int stime[2]; + u32int cutime[2]; + u32int cstime[2]; + Lreg reg; + u32int fpvalid; +}; + +int +coreregslinux386(Elf *elf, ElfNote *note, uchar **up) +{ + Status *s; + Lreg *l; + Ureg *u; + + if(note->descsz < sizeof(Status)){ + werrstr("elf status note too small"); + return -1; + } + s = (Status*)note->desc; + l = &s->reg; + u = malloc(sizeof(Ureg)); + if(u == nil) + return -1; + + /* no byte order problems - just copying and rearranging */ + u->di = l->edi; + u->si = l->esi; + u->bp = l->ebp; + u->nsp = l->esp; + u->bx = l->ebx; + u->dx = l->edx; + u->cx = l->ecx; + u->ax = l->eax; + u->gs = l->gs; + u->fs = l->fs; + u->es = l->es; + u->ds = l->ds; + u->trap = ~0; // l->trapno; + u->ecode = ~0; // l->err; + u->pc = l->eip; + u->cs = l->cs; + u->flags = l->eflags; + u->sp = l->esp; + u->ss = l->ss; + *up = (uchar*)u; + return sizeof(Ureg); +} + |