Blob
1 #include <u.h>2 #include <libc.h>3 #include <mach.h>4 #include "elf.h"5 #include "ureg386.h"7 #undef errno8 #define errno uregerrno10 typedef struct Lreg Lreg;11 typedef struct Status Status;12 typedef struct Psinfo Psinfo;14 /*15 * UregLinux386 is 64-bit aligned within status, so we shouldn't16 * have any packing problems.17 */18 struct Status19 {20 u32int signo;21 u32int code;22 u32int errno;23 u32int cursig;24 u32int sigpend;25 u32int sighold;26 u32int pid;27 u32int ppid;28 u32int pgrp;29 u32int sid;30 u32int utime[2];31 u32int stime[2];32 u32int cutime[2];33 u32int cstime[2];34 UregLinux386 reg;35 u32int fpvalid;36 };38 struct Psinfo39 {40 char state;41 char sname;42 char zomb;43 char nice;44 u32int flag;45 u16int uid;46 u16int gid;47 u32int pid;48 u32int ppid;49 u32int pgrp;50 u32int sid;51 char fname[16];52 char psargs[80];53 };55 int56 coreregslinux386(Elf *elf, ElfNote *note, uchar **up)57 {58 Status *s;59 UregLinux386 *l;60 Ureg *u;62 if(note->descsz < sizeof(Status)){63 werrstr("elf status note too small");64 return -1;65 }66 s = (Status*)note->desc;67 l = &s->reg;68 if((u = _linux2ureg386(l)) == nil)69 return -1;70 *up = (uchar*)u;71 return sizeof(Ureg);72 }74 int75 corecmdlinux386(Elf *elf, ElfNote *note, char **pp)76 {77 char *t;78 Psinfo *p;80 *pp = nil;81 if(note->descsz < sizeof(Psinfo)){82 werrstr("elf psinfo note too small");83 return -1;84 }85 p = (Psinfo*)note->desc;86 print("elf name %s\nelf args %s\n", p->fname, p->psargs);87 t = malloc(80+1);88 if(t == nil)89 return -1;90 memmove(t, p->psargs, 80);91 t[80] = 0;92 *pp = t;93 return 0;94 }