blob: 8fa74ab97abd0d6df23ba765740e5210a7a7a13a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#include <u.h>
#include <libc.h>
#include <mach.h>
#include "elf.h"
#include "ureg386.h"
#undef errno
#define errno uregerrno
typedef struct Lreg Lreg;
typedef struct Status Status;
typedef struct Psinfo Psinfo;
/*
* UregLinux386 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];
UregLinux386 reg;
u32int fpvalid;
};
struct Psinfo
{
char state;
char sname;
char zomb;
char nice;
u32int flag;
u16int uid;
u16int gid;
u32int pid;
u32int ppid;
u32int pgrp;
u32int sid;
char fname[16];
char psargs[80];
};
int
coreregslinux386(Elf *elf, ElfNote *note, uchar **up)
{
Status *s;
UregLinux386 *l;
Ureg *u;
if(note->descsz < sizeof(Status)){
werrstr("elf status note too small");
return -1;
}
s = (Status*)note->desc;
l = &s->reg;
if((u = _linux2ureg386(l)) == nil)
return -1;
*up = (uchar*)u;
return sizeof(Ureg);
}
int
corecmdlinux386(Elf *elf, ElfNote *note, char **pp)
{
char *t;
Psinfo *p;
*pp = nil;
if(note->descsz < sizeof(Psinfo)){
werrstr("elf psinfo note too small");
return -1;
}
p = (Psinfo*)note->desc;
print("elf name %s\nelf args %s\n", p->fname, p->psargs);
t = malloc(80+1);
if(t == nil)
return -1;
memmove(t, p->psargs, 80);
t[80] = 0;
*pp = t;
return 0;
}
|