Blob


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