2004-04-19 19:29:25 +00:00
|
|
|
#include <u.h>
|
|
|
|
#include <libc.h>
|
|
|
|
#include <mach.h>
|
|
|
|
#include "elf.h"
|
|
|
|
#include "ureg386.h"
|
|
|
|
|
2005-01-11 17:43:53 +00:00
|
|
|
#undef errno
|
|
|
|
#define errno uregerrno
|
|
|
|
|
2004-04-19 19:29:25 +00:00
|
|
|
typedef struct Lreg Lreg;
|
|
|
|
typedef struct Status Status;
|
2004-12-25 22:03:28 +00:00
|
|
|
typedef struct Psinfo Psinfo;
|
2004-04-19 19:29:25 +00:00
|
|
|
|
|
|
|
/*
|
2004-12-25 22:03:28 +00:00
|
|
|
* UregLinux386 is 64-bit aligned within status, so we shouldn't
|
2004-04-19 19:29:25 +00:00
|
|
|
* 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];
|
2004-12-25 22:03:28 +00:00
|
|
|
UregLinux386 reg;
|
2004-04-19 19:29:25 +00:00
|
|
|
u32int fpvalid;
|
|
|
|
};
|
|
|
|
|
2004-12-25 22:03:28 +00:00
|
|
|
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];
|
|
|
|
};
|
|
|
|
|
2004-04-19 19:29:25 +00:00
|
|
|
int
|
|
|
|
coreregslinux386(Elf *elf, ElfNote *note, uchar **up)
|
|
|
|
{
|
|
|
|
Status *s;
|
2004-12-25 22:03:28 +00:00
|
|
|
UregLinux386 *l;
|
2004-04-19 19:29:25 +00:00
|
|
|
Ureg *u;
|
|
|
|
|
|
|
|
if(note->descsz < sizeof(Status)){
|
|
|
|
werrstr("elf status note too small");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
s = (Status*)note->desc;
|
|
|
|
l = &s->reg;
|
2004-12-25 22:03:28 +00:00
|
|
|
if((u = _linux2ureg386(l)) == nil)
|
2004-04-19 19:29:25 +00:00
|
|
|
return -1;
|
|
|
|
*up = (uchar*)u;
|
|
|
|
return sizeof(Ureg);
|
|
|
|
}
|
|
|
|
|
2004-12-25 22:03:28 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|