mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
libmach, acid, db: 64-bit support
This commit is contained in:
parent
60d96f2e43
commit
443d628838
36 changed files with 2311 additions and 1125 deletions
247
acid/amd64
Normal file
247
acid/amd64
Normal file
|
@ -0,0 +1,247 @@
|
||||||
|
// 386 support
|
||||||
|
|
||||||
|
defn acidinit() // Called after all the init modules are loaded
|
||||||
|
{
|
||||||
|
bplist = {};
|
||||||
|
bpfmt = 'b';
|
||||||
|
|
||||||
|
srcpath = {
|
||||||
|
"./",
|
||||||
|
"/sys/src/libc/port/",
|
||||||
|
"/sys/src/libc/9sys/",
|
||||||
|
"/sys/src/libc/amd64/"
|
||||||
|
};
|
||||||
|
|
||||||
|
srcfiles = {}; // list of loaded files
|
||||||
|
srctext = {}; // the text of the files
|
||||||
|
}
|
||||||
|
|
||||||
|
defn linkreg(addr)
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
defn stk() // trace
|
||||||
|
{
|
||||||
|
_stk({"PC", *PC, "SP", *SP}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
defn lstk() // trace with locals
|
||||||
|
{
|
||||||
|
_stk({"PC", *PC, "SP", *SP}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
defn gpr() // print general(hah hah!) purpose registers
|
||||||
|
{
|
||||||
|
print("AX\t", *AX, " BX\t", *BX, " CX\t", *CX, " DX\t", *DX, "\n");
|
||||||
|
print("DI\t", *DI, " SI\t", *SI, " BP\t", *BP, "\n");
|
||||||
|
print("R8\t", *R8, " R9\t", *R9, " R10\t", *R10, " R11\t", *R11, "\n");
|
||||||
|
print("R12\t", *R12, " R13\t", *R13, " R14\t", *R14, " R15\t", *R15, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
defn spr() // print special processor registers
|
||||||
|
{
|
||||||
|
local pc;
|
||||||
|
local cause;
|
||||||
|
|
||||||
|
pc = *PC;
|
||||||
|
print("PC\t", pc, " ", fmt(pc, 'a'), " ");
|
||||||
|
pfl(pc);
|
||||||
|
print("SP\t", *SP, " FLAGS ", *FLAGS, "\n");
|
||||||
|
print("CS\t", *CS, " DS\t ", *DS, " SS\t", *SS, "\n");
|
||||||
|
print("GS\t", *GS, " FS\t ", *FS, " ES\t", *ES, "\n");
|
||||||
|
|
||||||
|
cause = *TRAP;
|
||||||
|
print("TRAP\t", cause, " ", reason(cause), "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
defn regs() // print all registers
|
||||||
|
{
|
||||||
|
spr();
|
||||||
|
gpr();
|
||||||
|
}
|
||||||
|
|
||||||
|
defn mmregs()
|
||||||
|
{
|
||||||
|
print("MM0\t", *MM0, " MM1\t", *MM1, "\n");
|
||||||
|
print("MM2\t", *MM2, " MM3\t", *MM3, "\n");
|
||||||
|
print("MM4\t", *MM4, " MM5\t", *MM5, "\n");
|
||||||
|
print("MM6\t", *MM6, " MM7\t", *MM7, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
defn pfixstop(pid)
|
||||||
|
{
|
||||||
|
if *fmt(*PC-1, 'b') == 0xCC then {
|
||||||
|
// Linux stops us after the breakpoint, not at it
|
||||||
|
*PC = *PC-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
defn pstop(pid)
|
||||||
|
{
|
||||||
|
local l;
|
||||||
|
local pc;
|
||||||
|
local why;
|
||||||
|
|
||||||
|
pc = *PC;
|
||||||
|
|
||||||
|
// FIgure out why we stopped.
|
||||||
|
if *fmt(pc, 'b') == 0xCC then {
|
||||||
|
why = "breakpoint";
|
||||||
|
|
||||||
|
// fix up instruction for print; will put back later
|
||||||
|
*pc = @pc;
|
||||||
|
} else if *(pc-2\x) == 0x80CD then {
|
||||||
|
pc = pc-2;
|
||||||
|
why = "system call";
|
||||||
|
} else
|
||||||
|
why = "stopped";
|
||||||
|
|
||||||
|
if printstopped then {
|
||||||
|
print(pid,": ", why, "\t");
|
||||||
|
print(fmt(pc, 'a'), "\t", *fmt(pc, 'i'), "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if why == "breakpoint" then
|
||||||
|
*fmt(pc, bpfmt) = bpinst;
|
||||||
|
|
||||||
|
if printstopped && notes then {
|
||||||
|
if notes[0] != "sys: breakpoint" then {
|
||||||
|
print("Notes pending:\n");
|
||||||
|
l = notes;
|
||||||
|
while l do {
|
||||||
|
print("\t", head l, "\n");
|
||||||
|
l = tail l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aggr Ureg
|
||||||
|
{
|
||||||
|
'Y' 0 ax;
|
||||||
|
'Y' 8 bx;
|
||||||
|
'Y' 16 cx;
|
||||||
|
'Y' 24 dx;
|
||||||
|
'Y' 32 si;
|
||||||
|
'Y' 40 di;
|
||||||
|
'Y' 48 bp;
|
||||||
|
'Y' 56 r8;
|
||||||
|
'Y' 64 r9;
|
||||||
|
'Y' 72 r10;
|
||||||
|
'Y' 80 r11;
|
||||||
|
'Y' 88 r12;
|
||||||
|
'Y' 96 r13;
|
||||||
|
'Y' 104 r14;
|
||||||
|
'Y' 112 r15;
|
||||||
|
|
||||||
|
'u' 120 ds;
|
||||||
|
'u' 122 es;
|
||||||
|
'u' 124 fs;
|
||||||
|
'u' 126 gs;
|
||||||
|
|
||||||
|
'Y' 128 type;
|
||||||
|
'Y' 136 error;
|
||||||
|
'Y' 144 pc;
|
||||||
|
'Y' 152 cs;
|
||||||
|
'Y' 160 flags;
|
||||||
|
'Y' 168 sp;
|
||||||
|
'Y' 176 ss;
|
||||||
|
};
|
||||||
|
|
||||||
|
defn
|
||||||
|
Ureg(addr) {
|
||||||
|
complex Ureg addr;
|
||||||
|
print(" ax ", addr.ax, "\n");
|
||||||
|
print(" bx ", addr.bx, "\n");
|
||||||
|
print(" cx ", addr.cx, "\n");
|
||||||
|
print(" dx ", addr.dx, "\n");
|
||||||
|
print(" si ", addr.si, "\n");
|
||||||
|
print(" di ", addr.di, "\n");
|
||||||
|
print(" bp ", addr.bp, "\n");
|
||||||
|
print(" r8 ", addr.r8, "\n");
|
||||||
|
print(" r9 ", addr.r9, "\n");
|
||||||
|
print(" r10 ", addr.r10, "\n");
|
||||||
|
print(" r11 ", addr.r11, "\n");
|
||||||
|
print(" r12 ", addr.r12, "\n");
|
||||||
|
print(" r13 ", addr.r13, "\n");
|
||||||
|
print(" r14 ", addr.r14, "\n");
|
||||||
|
print(" r15 ", addr.r15, "\n");
|
||||||
|
print(" ds ", addr.ds, "\n");
|
||||||
|
print(" es ", addr.es, "\n");
|
||||||
|
print(" fs ", addr.fs, "\n");
|
||||||
|
print(" gs ", addr.gs, "\n");
|
||||||
|
print(" type ", addr.type, "\n");
|
||||||
|
print(" error ", addr.error, "\n");
|
||||||
|
print(" pc ", addr.pc, "\n");
|
||||||
|
print(" cs ", addr.cs, "\n");
|
||||||
|
print(" flags ", addr.flags, "\n");
|
||||||
|
print(" sp ", addr.sp, "\n");
|
||||||
|
print(" ss ", addr.ss, "\n");
|
||||||
|
};
|
||||||
|
sizeofUreg = 184;
|
||||||
|
|
||||||
|
// aggr Linkdebug
|
||||||
|
// {
|
||||||
|
// 'X' 0 version;
|
||||||
|
// 'X' 4 map;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// aggr Linkmap
|
||||||
|
// {
|
||||||
|
// 'X' 0 addr;
|
||||||
|
// 'X' 4 name;
|
||||||
|
// 'X' 8 dynsect;
|
||||||
|
// 'X' 12 next;
|
||||||
|
// 'X' 16 prev;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// defn
|
||||||
|
// linkdebug()
|
||||||
|
// {
|
||||||
|
// local a;
|
||||||
|
//
|
||||||
|
// if !havesymbol("_DYNAMIC") then
|
||||||
|
// return 0;
|
||||||
|
//
|
||||||
|
// a = _DYNAMIC;
|
||||||
|
// while *a != 0 do {
|
||||||
|
// if *a == 21 then // 21 == DT_DEBUG
|
||||||
|
// return *(a+4);
|
||||||
|
// a = a+8;
|
||||||
|
// }
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// defn
|
||||||
|
// dynamicmap()
|
||||||
|
// {
|
||||||
|
// if systype == "linux" || systype == "freebsd" then {
|
||||||
|
// local r, m, n;
|
||||||
|
//
|
||||||
|
// r = linkdebug();
|
||||||
|
// if r then {
|
||||||
|
// complex Linkdebug r;
|
||||||
|
// m = r.map;
|
||||||
|
// n = 0;
|
||||||
|
// while m != 0 && n < 100 do {
|
||||||
|
// complex Linkmap m;
|
||||||
|
// if m.name && *(m.name\b) && access(*(m.name\s)) then
|
||||||
|
// print("textfile({\"", *(m.name\s), "\", ", m.addr\X, "});\n");
|
||||||
|
// m = m.next;
|
||||||
|
// n = n+1;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// */
|
||||||
|
|
||||||
|
defn
|
||||||
|
acidmap()
|
||||||
|
{
|
||||||
|
// dynamicmap();
|
||||||
|
acidtypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
print(acidfile);
|
131
include/mach.h
131
include/mach.h
|
@ -11,10 +11,9 @@ AUTOLIB(mach)
|
||||||
/*
|
/*
|
||||||
* Architecture-dependent application data.
|
* Architecture-dependent application data.
|
||||||
*
|
*
|
||||||
* The code assumes that ulong is big enough to hold
|
* The code assumes that u64int is big enough to hold
|
||||||
* an address on any system of interest as well as any
|
* an address on any system of interest as well as any
|
||||||
* register. Debugging 64-bit code on 32-bit machines
|
* register.
|
||||||
* will be interesting.
|
|
||||||
*
|
*
|
||||||
* Supported architectures:
|
* Supported architectures:
|
||||||
*
|
*
|
||||||
|
@ -39,7 +38,7 @@ typedef struct Seg Seg;
|
||||||
typedef struct Symbol Symbol;
|
typedef struct Symbol Symbol;
|
||||||
typedef struct Symtype Symtype;
|
typedef struct Symtype Symtype;
|
||||||
|
|
||||||
typedef int (*Tracer)(Map*, Regs*, ulong, ulong, Symbol*, int);
|
typedef int (*Tracer)(Map*, Regs*, u64int, u64int, Symbol*, int);
|
||||||
|
|
||||||
extern Mach *mach;
|
extern Mach *mach;
|
||||||
extern Mach *machcpu;
|
extern Mach *machcpu;
|
||||||
|
@ -84,10 +83,10 @@ struct Seg
|
||||||
uchar *p;
|
uchar *p;
|
||||||
int fd;
|
int fd;
|
||||||
int pid;
|
int pid;
|
||||||
ulong base;
|
u64int base;
|
||||||
ulong size;
|
u64int size;
|
||||||
ulong offset;
|
u64int offset;
|
||||||
int (*rw)(Map*, Seg*, ulong, void*, uint, int);
|
int (*rw)(Map*, Seg*, u64int, void*, uint, int);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Map
|
struct Map
|
||||||
|
@ -98,7 +97,7 @@ struct Map
|
||||||
|
|
||||||
struct Regs
|
struct Regs
|
||||||
{
|
{
|
||||||
int (*rw)(Regs*, char*, ulong*, int);
|
int (*rw)(Regs*, char*, u64int*, int);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct UregRegs UregRegs;
|
typedef struct UregRegs UregRegs;
|
||||||
|
@ -107,7 +106,7 @@ struct UregRegs
|
||||||
Regs r;
|
Regs r;
|
||||||
uchar *ureg;
|
uchar *ureg;
|
||||||
};
|
};
|
||||||
int _uregrw(Regs*, char*, ulong*, int);
|
int _uregrw(Regs*, char*, u64int*, int);
|
||||||
|
|
||||||
typedef struct PidRegs PidRegs;
|
typedef struct PidRegs PidRegs;
|
||||||
struct PidRegs
|
struct PidRegs
|
||||||
|
@ -119,23 +118,24 @@ struct PidRegs
|
||||||
Map* allocmap(void);
|
Map* allocmap(void);
|
||||||
int addseg(Map *map, Seg seg);
|
int addseg(Map *map, Seg seg);
|
||||||
int findseg(Map *map, char *name, char *file);
|
int findseg(Map *map, char *name, char *file);
|
||||||
int addrtoseg(Map *map, ulong addr, Seg *seg);
|
int addrtoseg(Map *map, u64int addr, Seg *seg);
|
||||||
int addrtosegafter(Map *map, ulong addr, Seg *seg);
|
int addrtosegafter(Map *map, u64int addr, Seg *seg);
|
||||||
void removeseg(Map *map, int i);
|
void removeseg(Map *map, int i);
|
||||||
void freemap(Map*);
|
void freemap(Map*);
|
||||||
|
|
||||||
int get1(Map *map, ulong addr, uchar *a, uint n);
|
int get1(Map *map, u64int addr, uchar *a, uint n);
|
||||||
int get2(Map *map, ulong addr, u16int *u);
|
int get2(Map *map, u64int addr, u16int *u);
|
||||||
int get4(Map *map, ulong addr, u32int *u);
|
int get4(Map *map, u64int addr, u32int *u);
|
||||||
int get8(Map *map, ulong addr, u64int *u);
|
int get8(Map *map, u64int addr, u64int *u);
|
||||||
|
int geta(Map *map, u64int addr, u64int *u);
|
||||||
|
|
||||||
int put1(Map *map, ulong addr, uchar *a, uint n);
|
int put1(Map *map, u64int addr, uchar *a, uint n);
|
||||||
int put2(Map *map, ulong addr, u16int u);
|
int put2(Map *map, u64int addr, u16int u);
|
||||||
int put4(Map *map, ulong addr, u32int u);
|
int put4(Map *map, u64int addr, u32int u);
|
||||||
int put8(Map *map, ulong addr, u64int u);
|
int put8(Map *map, u64int addr, u64int u);
|
||||||
|
|
||||||
int rget(Regs*, char*, ulong*);
|
int rget(Regs*, char*, u64int*);
|
||||||
int rput(Regs*, char*, ulong);
|
int rput(Regs*, char*, u64int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A location is either a memory address or a register.
|
* A location is either a memory address or a register.
|
||||||
|
@ -163,7 +163,7 @@ struct Loc
|
||||||
{
|
{
|
||||||
uint type; /* LNONE, ... */
|
uint type; /* LNONE, ... */
|
||||||
char *reg; /* LREG */
|
char *reg; /* LREG */
|
||||||
ulong addr; /* LADDR, CONST */
|
u64int addr; /* LADDR, CONST */
|
||||||
long offset; /* LOFFSET */
|
long offset; /* LOFFSET */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -171,6 +171,7 @@ int lget1(Map *map, Regs *regs, Loc loc, uchar *a, uint n);
|
||||||
int lget2(Map *map, Regs *regs, Loc loc, u16int *v);
|
int lget2(Map *map, Regs *regs, Loc loc, u16int *v);
|
||||||
int lget4(Map *map, Regs *regs, Loc loc, u32int *v);
|
int lget4(Map *map, Regs *regs, Loc loc, u32int *v);
|
||||||
int lget8(Map *map, Regs *regs, Loc loc, u64int *v);
|
int lget8(Map *map, Regs *regs, Loc loc, u64int *v);
|
||||||
|
int lgeta(Map *map, Regs *regs, Loc loc, u64int *v);
|
||||||
|
|
||||||
int lput1(Map *map, Regs *regs, Loc loc, uchar *a, uint n);
|
int lput1(Map *map, Regs *regs, Loc loc, uchar *a, uint n);
|
||||||
int lput2(Map *map, Regs *regs, Loc loc, u16int v);
|
int lput2(Map *map, Regs *regs, Loc loc, u16int v);
|
||||||
|
@ -178,8 +179,8 @@ int lput4(Map *map, Regs *regs, Loc loc, u32int v);
|
||||||
int lput8(Map *map, Regs *regs, Loc loc, u64int v);
|
int lput8(Map *map, Regs *regs, Loc loc, u64int v);
|
||||||
|
|
||||||
Loc locnone(void);
|
Loc locnone(void);
|
||||||
Loc locaddr(ulong addr);
|
Loc locaddr(u64int addr);
|
||||||
Loc locconst(ulong con);
|
Loc locconst(u64int con);
|
||||||
Loc locreg(char*);
|
Loc locreg(char*);
|
||||||
Loc locindir(char*, long);
|
Loc locindir(char*, long);
|
||||||
|
|
||||||
|
@ -242,20 +243,20 @@ struct Fhdr
|
||||||
uint atype; /* abi type ALINUX, ... */
|
uint atype; /* abi type ALINUX, ... */
|
||||||
|
|
||||||
ulong magic; /* magic number */
|
ulong magic; /* magic number */
|
||||||
ulong txtaddr; /* text address */
|
u64int txtaddr; /* text address */
|
||||||
ulong entry; /* entry point */
|
u64int entry; /* entry point */
|
||||||
ulong txtsz; /* text size */
|
u64int txtsz; /* text size */
|
||||||
ulong txtoff; /* text offset in file */
|
u64int txtoff; /* text offset in file */
|
||||||
ulong dataddr; /* data address */
|
u64int dataddr; /* data address */
|
||||||
ulong datsz; /* data size */
|
u64int datsz; /* data size */
|
||||||
ulong datoff; /* data offset in file */
|
u64int datoff; /* data offset in file */
|
||||||
ulong bsssz; /* bss size */
|
u64int bsssz; /* bss size */
|
||||||
ulong symsz; /* symbol table size */
|
u64int symsz; /* symbol table size */
|
||||||
ulong symoff; /* symbol table offset in file */
|
u64int symoff; /* symbol table offset in file */
|
||||||
ulong sppcsz; /* size of sp-pc table */
|
u64int sppcsz; /* size of sp-pc table */
|
||||||
ulong sppcoff; /* offset of sp-pc table in file */
|
u64int sppcoff; /* offset of sp-pc table in file */
|
||||||
ulong lnpcsz; /* size of line number-pc table */
|
u64int lnpcsz; /* size of line number-pc table */
|
||||||
ulong lnpcoff; /* size of line number-pc table */
|
u64int lnpcoff; /* size of line number-pc table */
|
||||||
void *elf; /* handle to elf image */
|
void *elf; /* handle to elf image */
|
||||||
void *dwarf; /* handle to dwarf image */
|
void *dwarf; /* handle to dwarf image */
|
||||||
void *macho; /* handle to mach-o image */
|
void *macho; /* handle to mach-o image */
|
||||||
|
@ -280,21 +281,21 @@ struct Fhdr
|
||||||
Fhdr *next; /* link to next fhdr (internal) */
|
Fhdr *next; /* link to next fhdr (internal) */
|
||||||
|
|
||||||
/* file mapping */
|
/* file mapping */
|
||||||
int (*map)(Fhdr*, ulong, Map*, Regs**);
|
int (*map)(Fhdr*, u64int, Map*, Regs**);
|
||||||
|
|
||||||
/* debugging symbol access; see below */
|
/* debugging symbol access; see below */
|
||||||
int (*syminit)(Fhdr*);
|
int (*syminit)(Fhdr*);
|
||||||
void (*symclose)(Fhdr*);
|
void (*symclose)(Fhdr*);
|
||||||
|
|
||||||
int (*pc2file)(Fhdr*, ulong, char*, uint, ulong*);
|
int (*pc2file)(Fhdr*, u64int, char*, uint, ulong*);
|
||||||
int (*file2pc)(Fhdr*, char*, ulong, ulong*);
|
int (*file2pc)(Fhdr*, char*, u64int, u64int*);
|
||||||
int (*line2pc)(Fhdr*, ulong, ulong, ulong*);
|
int (*line2pc)(Fhdr*, u64int, ulong, u64int*);
|
||||||
|
|
||||||
int (*lookuplsym)(Fhdr*, Symbol*, char*, Symbol*);
|
int (*lookuplsym)(Fhdr*, Symbol*, char*, Symbol*);
|
||||||
int (*indexlsym)(Fhdr*, Symbol*, uint, Symbol*);
|
int (*indexlsym)(Fhdr*, Symbol*, uint, Symbol*);
|
||||||
int (*findlsym)(Fhdr*, Symbol*, Loc, Symbol*);
|
int (*findlsym)(Fhdr*, Symbol*, Loc, Symbol*);
|
||||||
|
|
||||||
int (*unwind)(Fhdr*, Map*, Regs*, ulong*, Symbol*);
|
int (*unwind)(Fhdr*, Map*, Regs*, u64int*, Symbol*);
|
||||||
};
|
};
|
||||||
|
|
||||||
Fhdr* crackhdr(char *file, int mode);
|
Fhdr* crackhdr(char *file, int mode);
|
||||||
|
@ -310,7 +311,7 @@ int symstabs(Fhdr*);
|
||||||
int symmacho(Fhdr*);
|
int symmacho(Fhdr*);
|
||||||
void symclose(Fhdr*);
|
void symclose(Fhdr*);
|
||||||
|
|
||||||
int mapfile(Fhdr *fp, ulong base, Map *map, Regs **regs);
|
int mapfile(Fhdr *fp, u64int base, Map *map, Regs **regs);
|
||||||
void unmapfile(Fhdr *fp, Map *map);
|
void unmapfile(Fhdr *fp, Map *map);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -385,6 +386,7 @@ enum
|
||||||
MARM, /* ARM */
|
MARM, /* ARM */
|
||||||
MPOWER, /* PowerPC */
|
MPOWER, /* PowerPC */
|
||||||
MALPHA, /* DEC/Compaq Alpha */
|
MALPHA, /* DEC/Compaq Alpha */
|
||||||
|
MAMD64, /* AMD64 */
|
||||||
NMTYPE
|
NMTYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -402,8 +404,8 @@ struct Mach
|
||||||
char *sbreg; /* name of static base */
|
char *sbreg; /* name of static base */
|
||||||
ulong sb; /* value of static base */
|
ulong sb; /* value of static base */
|
||||||
uint pgsize; /* page size */
|
uint pgsize; /* page size */
|
||||||
ulong kbase; /* kernel base address for Plan 9 */
|
u64int kbase; /* kernel base address for Plan 9 */
|
||||||
ulong ktmask; /* ktzero = kbase & ~ktmask */
|
u64int ktmask; /* ktzero = kbase & ~ktmask */
|
||||||
uint pcquant; /* pc quantum */
|
uint pcquant; /* pc quantum */
|
||||||
uint szaddr; /* size of pointer in bytes */
|
uint szaddr; /* size of pointer in bytes */
|
||||||
uint szreg; /* size of integer register */
|
uint szreg; /* size of integer register */
|
||||||
|
@ -415,9 +417,9 @@ struct Mach
|
||||||
uchar bpinst[4]; /* break point instruction */
|
uchar bpinst[4]; /* break point instruction */
|
||||||
uint bpsize; /* size of bp instruction */
|
uint bpsize; /* size of bp instruction */
|
||||||
|
|
||||||
int (*foll)(Map*, Regs*, ulong, ulong*); /* follow set */
|
int (*foll)(Map*, Regs*, u64int, u64int*); /* follow set */
|
||||||
char* (*exc)(Map*, Regs*); /* last exception */
|
char* (*exc)(Map*, Regs*); /* last exception */
|
||||||
int (*unwind)(Map*, Regs*, ulong*, Symbol*);
|
int (*unwind)(Map*, Regs*, u64int*, Symbol*);
|
||||||
|
|
||||||
/* cvt to local byte order */
|
/* cvt to local byte order */
|
||||||
u16int (*swap2)(u16int);
|
u16int (*swap2)(u16int);
|
||||||
|
@ -428,11 +430,11 @@ struct Mach
|
||||||
int (*ftoa80)(char*, uint, void*);
|
int (*ftoa80)(char*, uint, void*);
|
||||||
|
|
||||||
/* disassembly */
|
/* disassembly */
|
||||||
int (*das)(Map*, ulong, char, char*, int); /* symbolic */
|
int (*das)(Map*, u64int, char, char*, int); /* symbolic */
|
||||||
int (*kendas)(Map*, ulong, char, char*, int); /* symbolic */
|
int (*kendas)(Map*, u64int, char, char*, int); /* symbolic */
|
||||||
int (*codas)(Map*, ulong, char, char*, int);
|
int (*codas)(Map*, u64int, char, char*, int);
|
||||||
int (*hexinst)(Map*, ulong, char*, int); /* hex */
|
int (*hexinst)(Map*, u64int, char*, int); /* hex */
|
||||||
int (*instsize)(Map*, ulong); /* instruction size */
|
int (*instsize)(Map*, u64int); /* instruction size */
|
||||||
};
|
};
|
||||||
|
|
||||||
Mach *machbyname(char*);
|
Mach *machbyname(char*);
|
||||||
|
@ -442,6 +444,7 @@ extern Mach mach386;
|
||||||
extern Mach machsparc;
|
extern Mach machsparc;
|
||||||
extern Mach machmips;
|
extern Mach machmips;
|
||||||
extern Mach machpower;
|
extern Mach machpower;
|
||||||
|
extern Mach machamd64;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Debugging symbols and type information.
|
* Debugging symbols and type information.
|
||||||
|
@ -494,12 +497,12 @@ struct Symbol
|
||||||
};
|
};
|
||||||
|
|
||||||
/* look through all currently cracked Fhdrs calling their fns */
|
/* look through all currently cracked Fhdrs calling their fns */
|
||||||
int pc2file(ulong pc, char *file, uint nfile, ulong *line);
|
int pc2file(u64int pc, char *file, uint nfile, ulong *line);
|
||||||
int file2pc(char *file, ulong line, ulong *addr);
|
int file2pc(char *file, ulong line, u64int *addr);
|
||||||
int line2pc(ulong basepc, ulong line, ulong *pc);
|
int line2pc(u64int basepc, ulong line, u64int *pc);
|
||||||
int fnbound(ulong pc, ulong *bounds);
|
int fnbound(u64int pc, u64int *bounds);
|
||||||
int fileline(ulong pc, char *a, uint n);
|
int fileline(u64int pc, char *a, uint n);
|
||||||
int pc2line(ulong pc, ulong *line);
|
int pc2line(u64int pc, ulong *line);
|
||||||
|
|
||||||
int lookupsym(char *fn, char *var, Symbol *s);
|
int lookupsym(char *fn, char *var, Symbol *s);
|
||||||
int indexsym(uint ndx, Symbol *s);
|
int indexsym(uint ndx, Symbol *s);
|
||||||
|
@ -509,8 +512,8 @@ int findexsym(Fhdr*, uint, Symbol*);
|
||||||
int lookuplsym(Symbol *s1, char *name, Symbol *s2);
|
int lookuplsym(Symbol *s1, char *name, Symbol *s2);
|
||||||
int indexlsym(Symbol *s1, uint ndx, Symbol *s2);
|
int indexlsym(Symbol *s1, uint ndx, Symbol *s2);
|
||||||
int findlsym(Symbol *s1, Loc loc, Symbol *s);
|
int findlsym(Symbol *s1, Loc loc, Symbol *s);
|
||||||
int symoff(char *a, uint n, ulong addr, uint class);
|
int symoff(char *a, uint n, u64int addr, uint class);
|
||||||
int unwindframe(Map *map, Regs *regs, ulong *next, Symbol*);
|
int unwindframe(Map *map, Regs *regs, u64int *next, Symbol*);
|
||||||
|
|
||||||
void _addhdr(Fhdr*);
|
void _addhdr(Fhdr*);
|
||||||
void _delhdr(Fhdr*);
|
void _delhdr(Fhdr*);
|
||||||
|
@ -536,9 +539,9 @@ Loc* windreglocs(void);
|
||||||
/*
|
/*
|
||||||
* Debugger help.
|
* Debugger help.
|
||||||
*/
|
*/
|
||||||
int localaddr(Map *map, Regs *regs, char *fn, char *var, ulong *val);
|
int localaddr(Map *map, Regs *regs, char *fn, char *var, u64int *val);
|
||||||
int fpformat(Map *map, Regdesc *reg, char *a, uint n, uint code);
|
int fpformat(Map *map, Regdesc *reg, char *a, uint n, uint code);
|
||||||
char* _hexify(char*, ulong, int);
|
char* _hexify(char*, u64int, int);
|
||||||
int locfmt(Fmt*);
|
int locfmt(Fmt*);
|
||||||
int loccmp(Loc*, Loc*);
|
int loccmp(Loc*, Loc*);
|
||||||
int locsimplify(Map *map, Regs *regs, Loc loc, Loc *newloc);
|
int locsimplify(Map *map, Regs *regs, Loc loc, Loc *newloc);
|
||||||
|
|
|
@ -146,16 +146,16 @@ typedef signed char schar;
|
||||||
typedef unsigned long long uvlong;
|
typedef unsigned long long uvlong;
|
||||||
typedef long long vlong;
|
typedef long long vlong;
|
||||||
|
|
||||||
typedef uint64_t u64int;
|
typedef uvlong u64int;
|
||||||
typedef int64_t s64int;
|
typedef vlong s64int;
|
||||||
typedef uint8_t u8int;
|
typedef uint8_t u8int;
|
||||||
typedef int8_t s8int;
|
typedef int8_t s8int;
|
||||||
typedef uint16_t u16int;
|
typedef uint16_t u16int;
|
||||||
typedef int16_t s16int;
|
typedef int16_t s16int;
|
||||||
typedef uintptr_t uintptr;
|
typedef uintptr_t uintptr;
|
||||||
typedef intptr_t intptr;
|
typedef intptr_t intptr;
|
||||||
typedef uint32_t u32int;
|
typedef uint u32int;
|
||||||
typedef int32_t s32int;
|
typedef int s32int;
|
||||||
|
|
||||||
typedef u32int uint32;
|
typedef u32int uint32;
|
||||||
typedef s32int int32;
|
typedef s32int int32;
|
||||||
|
|
|
@ -192,7 +192,7 @@ struct String
|
||||||
int len;
|
int len;
|
||||||
};
|
};
|
||||||
|
|
||||||
int acidregsrw(Regs*, char*, ulong*, int);
|
int acidregsrw(Regs*, char*, u64int*, int);
|
||||||
List* addlist(List*, List*);
|
List* addlist(List*, List*);
|
||||||
void addvarsym(Fhdr*);
|
void addvarsym(Fhdr*);
|
||||||
List* al(int);
|
List* al(int);
|
||||||
|
@ -263,7 +263,7 @@ String* strnode(char*);
|
||||||
String* strnodlen(char*, int);
|
String* strnodlen(char*, int);
|
||||||
#define system acidsystem
|
#define system acidsystem
|
||||||
char* system(void);
|
char* system(void);
|
||||||
int trlist(Map*, Regs*, ulong, ulong, Symbol*, int);
|
int trlist(Map*, Regs*, u64int, u64int, Symbol*, int);
|
||||||
void unwind(void);
|
void unwind(void);
|
||||||
void userinit(void);
|
void userinit(void);
|
||||||
void varreg(void);
|
void varreg(void);
|
||||||
|
|
|
@ -453,7 +453,7 @@ follow(Node *r, Node *args)
|
||||||
{
|
{
|
||||||
int n, i;
|
int n, i;
|
||||||
Node res;
|
Node res;
|
||||||
ulong f[10];
|
u64int f[10];
|
||||||
List **tail, *l;
|
List **tail, *l;
|
||||||
|
|
||||||
if(args == 0)
|
if(args == 0)
|
||||||
|
@ -480,7 +480,7 @@ funcbound(Node *r, Node *args)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
Node res;
|
Node res;
|
||||||
ulong bounds[2];
|
u64int bounds[2];
|
||||||
List *l;
|
List *l;
|
||||||
|
|
||||||
if(args == 0)
|
if(args == 0)
|
||||||
|
@ -523,7 +523,7 @@ filepc(Node *r, Node *args)
|
||||||
int i;
|
int i;
|
||||||
Node res;
|
Node res;
|
||||||
char *p, c;
|
char *p, c;
|
||||||
ulong v;
|
u64int v;
|
||||||
|
|
||||||
if(args == 0)
|
if(args == 0)
|
||||||
error("filepc(filename:line): arg count");
|
error("filepc(filename:line): arg count");
|
||||||
|
@ -1035,7 +1035,7 @@ static struct
|
||||||
static int nsregs;
|
static int nsregs;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
straceregrw(Regs *regs, char *name, ulong *val, int isr)
|
straceregrw(Regs *regs, char *name, u64int *val, int isr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,7 @@ indir(Map *m, ulong addr, char fmt, Node *r)
|
||||||
void
|
void
|
||||||
indirreg(Regs *regs, char *name, char fmt, Node *r)
|
indirreg(Regs *regs, char *name, char fmt, Node *r)
|
||||||
{
|
{
|
||||||
ulong val;
|
u64int val;
|
||||||
|
|
||||||
if(regs == 0)
|
if(regs == 0)
|
||||||
error("no register set for *%s=", name);
|
error("no register set for *%s=", name);
|
||||||
|
|
|
@ -168,7 +168,7 @@ oframe(Node *n, Node *res)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
Node *lp;
|
Node *lp;
|
||||||
ulong ival;
|
u64int ival;
|
||||||
Frtype *f;
|
Frtype *f;
|
||||||
|
|
||||||
p = n->sym->name;
|
p = n->sym->name;
|
||||||
|
@ -1070,12 +1070,12 @@ initexpr(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
acidregsrw(Regs *r, char *name, ulong *u, int isr)
|
acidregsrw(Regs *r, char *name, u64int *u, int isr)
|
||||||
{
|
{
|
||||||
Lsym *l;
|
Lsym *l;
|
||||||
Value *v;
|
Value *v;
|
||||||
Node *n;
|
Node *n;
|
||||||
ulong addr;
|
u64int addr;
|
||||||
u32int u32;
|
u32int u32;
|
||||||
|
|
||||||
if(!isr){
|
if(!isr){
|
||||||
|
|
|
@ -196,7 +196,7 @@ listregisters(Map *map, Regs *regs)
|
||||||
{
|
{
|
||||||
List **tail, *l2, *l;
|
List **tail, *l2, *l;
|
||||||
Regdesc *rp;
|
Regdesc *rp;
|
||||||
ulong v;
|
u64int v;
|
||||||
|
|
||||||
l2 = 0;
|
l2 = 0;
|
||||||
tail = &l2;
|
tail = &l2;
|
||||||
|
@ -255,7 +255,7 @@ listautos(Map *map, Regs *regs, Symbol *fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
trlist(Map *map, Regs *regs, ulong pc, ulong callerpc, Symbol *sym, int depth)
|
trlist(Map *map, Regs *regs, u64int pc, u64int callerpc, Symbol *sym, int depth)
|
||||||
{
|
{
|
||||||
List *q, *l;
|
List *q, *l;
|
||||||
static List **tail;
|
static List **tail;
|
||||||
|
|
|
@ -92,6 +92,8 @@ main(int argc, char *argv[])
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
||||||
|
USED(pid);
|
||||||
|
|
||||||
fmtinstall('Z', Zfmt);
|
fmtinstall('Z', Zfmt);
|
||||||
fmtinstall('L', locfmt);
|
fmtinstall('L', locfmt);
|
||||||
|
@ -195,7 +197,8 @@ attachfiles(int argc, char **argv)
|
||||||
|
|
||||||
pid = 0;
|
pid = 0;
|
||||||
interactive = 0;
|
interactive = 0;
|
||||||
|
USED(pid);
|
||||||
|
|
||||||
if(setjmp(err))
|
if(setjmp(err))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <mach.h>
|
#include <mach.h>
|
||||||
|
|
||||||
typedef long WORD;
|
typedef long WORD;
|
||||||
typedef ulong ADDR;
|
typedef u64int ADDR;
|
||||||
|
|
||||||
#define HUGEINT 0x7fffffff /* enormous WORD */
|
#define HUGEINT 0x7fffffff /* enormous WORD */
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ item(int a)
|
||||||
{ /* name [ . local ] | number | . | ^ | <register | 'x | | */
|
{ /* name [ . local ] | number | . | ^ | <register | 'x | | */
|
||||||
char *base;
|
char *base;
|
||||||
char savc;
|
char savc;
|
||||||
ulong u;
|
u64int u;
|
||||||
Symbol s;
|
Symbol s;
|
||||||
char gsym[MAXSYM], lsym[MAXSYM];
|
char gsym[MAXSYM], lsym[MAXSYM];
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ dbround(long a, long b)
|
||||||
ulong
|
ulong
|
||||||
dbrget(Map *map, char *name)
|
dbrget(Map *map, char *name)
|
||||||
{
|
{
|
||||||
ulong u;
|
u64int u;
|
||||||
|
|
||||||
USED(map);
|
USED(map);
|
||||||
if(rget(correg, name, &u) < 0)
|
if(rget(correg, name, &u) < 0)
|
||||||
|
|
|
@ -22,7 +22,7 @@ static void printfp(Map*, int);
|
||||||
* callback on stack trace
|
* callback on stack trace
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ptrace(Map *map, Regs *regs, ulong pc, ulong nextpc, Symbol *sym, int depth)
|
ptrace(Map *map, Regs *regs, u64int pc, u64int nextpc, Symbol *sym, int depth)
|
||||||
{
|
{
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ ptrace(Map *map, Regs *regs, ulong pc, ulong nextpc, Symbol *sym, int depth)
|
||||||
static ulong *adrregvals;
|
static ulong *adrregvals;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
adrrw(Regs *regs, char *name, ulong *val, int isr)
|
adrrw(Regs *regs, char *name, u64int *val, int isr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -215,6 +215,7 @@ printdollar(int modif)
|
||||||
default:
|
default:
|
||||||
error("bad `$' command");
|
error("bad `$' command");
|
||||||
}
|
}
|
||||||
|
USED(r);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +360,7 @@ void
|
||||||
printpc(void)
|
printpc(void)
|
||||||
{
|
{
|
||||||
char buf[512];
|
char buf[512];
|
||||||
ulong u;
|
u64int u;
|
||||||
|
|
||||||
if(rget(correg, mach->pc, &u) < 0)
|
if(rget(correg, mach->pc, &u) < 0)
|
||||||
error("%r");
|
error("%r");
|
||||||
|
|
|
@ -13,7 +13,7 @@ printregs(int c)
|
||||||
{
|
{
|
||||||
Regdesc *rp;
|
Regdesc *rp;
|
||||||
int i;
|
int i;
|
||||||
ulong u;
|
ADDR u;
|
||||||
|
|
||||||
if(correg == nil){
|
if(correg == nil){
|
||||||
dprint("registers not mapped\n");
|
dprint("registers not mapped\n");
|
||||||
|
|
|
@ -208,7 +208,7 @@ void
|
||||||
runstep(ulong loc, int keepnote)
|
runstep(ulong loc, int keepnote)
|
||||||
{
|
{
|
||||||
int nfoll;
|
int nfoll;
|
||||||
ulong foll[3];
|
ADDR foll[3];
|
||||||
BKPT bkpt[3];
|
BKPT bkpt[3];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ struct PtraceRegs
|
||||||
int pid;
|
int pid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ptracesegrw(Map*, Seg*, ulong, void*, uint, int);
|
static int ptracesegrw(Map*, Seg*, u64int, void*, uint, int);
|
||||||
static int ptraceregrw(Regs*, char*, ulong*, int);
|
static int ptraceregrw(Regs*, char*, u64int*, int);
|
||||||
|
|
||||||
static int attachedpids[1000];
|
static int attachedpids[1000];
|
||||||
static int nattached;
|
static int nattached;
|
||||||
|
@ -173,7 +173,7 @@ ptraceerr:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ptracesegrw(Map *map, Seg *seg, ulong addr, void *v, uint n, int isr)
|
ptracesegrw(Map *map, Seg *seg, u64int addr, void *v, uint n, int isr)
|
||||||
{
|
{
|
||||||
addr += seg->base;
|
addr += seg->base;
|
||||||
return ptracerw(isr ? PTRACE_PEEKDATA : PTRACE_POKEDATA, PTRACE_PEEKDATA,
|
return ptracerw(isr ? PTRACE_PEEKDATA : PTRACE_POKEDATA, PTRACE_PEEKDATA,
|
||||||
|
@ -212,7 +212,7 @@ reg2linux(char *reg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ptraceregrw(Regs *regs, char *name, ulong *val, int isr)
|
ptraceregrw(Regs *regs, char *name, u64int *val, int isr)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
ulong addr;
|
ulong addr;
|
||||||
|
|
|
@ -93,7 +93,7 @@ uncrackhdr(Fhdr *hdr)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mapfile(Fhdr *fp, ulong base, Map *map, Regs **regs)
|
mapfile(Fhdr *fp, u64int base, Map *map, Regs **regs)
|
||||||
{
|
{
|
||||||
if(fp == nil){
|
if(fp == nil){
|
||||||
werrstr("no file");
|
werrstr("no file");
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "elf.h"
|
#include "elf.h"
|
||||||
#include "dwarf.h"
|
#include "dwarf.h"
|
||||||
|
|
||||||
static int mapelf(Fhdr *fp, ulong base, Map *map, Regs**);
|
static int mapelf(Fhdr *fp, u64int base, Map *map, Regs**);
|
||||||
static int unpacknote(Elf *elf, uchar *a, uchar *ea, ElfNote *note, uchar **pa);
|
static int unpacknote(Elf *elf, uchar *a, uchar *ea, ElfNote *note, uchar **pa);
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
|
@ -21,6 +21,7 @@ static struct
|
||||||
ElfMachArm, MARM, nil, "arm",
|
ElfMachArm, MARM, nil, "arm",
|
||||||
ElfMachPower, MPOWER, nil, "powerpc",
|
ElfMachPower, MPOWER, nil, "powerpc",
|
||||||
ElfMachPower64, MNONE, nil, "powerpc64",
|
ElfMachPower64, MNONE, nil, "powerpc64",
|
||||||
|
ElfMachAmd64, MAMD64, &machamd64, "amd64",
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
|
@ -44,7 +45,8 @@ static struct
|
||||||
{ /* Font Tab 4 */
|
{ /* Font Tab 4 */
|
||||||
M386, ALINUX, elfcorelinux386,
|
M386, ALINUX, elfcorelinux386,
|
||||||
M386, ANONE, elfcorelinux386, /* [sic] */
|
M386, ANONE, elfcorelinux386, /* [sic] */
|
||||||
/* M386, AFREEBSD, elfcorefreebsd386, */
|
// M386, AFREEBSD, elfcorefreebsd386,
|
||||||
|
MAMD64, AFREEBSD, elfcorefreebsdamd64,
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -202,13 +204,13 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mapelf(Fhdr *fp, ulong base, Map *map, Regs **regs)
|
mapelf(Fhdr *fp, u64int base, Map *map, Regs **regs)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Elf *elf;
|
Elf *elf;
|
||||||
ElfProg *p;
|
ElfProg *p;
|
||||||
ulong sz;
|
u64int sz;
|
||||||
ulong lim;
|
u64int lim;
|
||||||
Seg s;
|
Seg s;
|
||||||
|
|
||||||
elf = fp->elf;
|
elf = fp->elf;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <mach.h>
|
#include <mach.h>
|
||||||
#include "macho.h"
|
#include "macho.h"
|
||||||
|
|
||||||
static int mapmacho(Fhdr *fp, ulong base, Map *map, Regs**);
|
static int mapmacho(Fhdr *fp, u64int base, Map *map, Regs**);
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
|
@ -136,7 +136,7 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mapmacho(Fhdr *fp, ulong base, Map *map, Regs **rp)
|
mapmacho(Fhdr *fp, u64int base, Map *map, Regs **rp)
|
||||||
{
|
{
|
||||||
int i, n;
|
int i, n;
|
||||||
uchar *u;
|
uchar *u;
|
||||||
|
|
|
@ -13,6 +13,11 @@ typedef struct ElfSectBytes ElfSectBytes;
|
||||||
typedef struct ElfProgBytes ElfProgBytes;
|
typedef struct ElfProgBytes ElfProgBytes;
|
||||||
typedef struct ElfSymBytes ElfSymBytes;
|
typedef struct ElfSymBytes ElfSymBytes;
|
||||||
|
|
||||||
|
typedef struct ElfHdrBytes64 ElfHdrBytes64;
|
||||||
|
typedef struct ElfSectBytes64 ElfSectBytes64;
|
||||||
|
typedef struct ElfProgBytes64 ElfProgBytes64;
|
||||||
|
typedef struct ElfSymBytes64 ElfSymBytes64;
|
||||||
|
|
||||||
struct ElfHdrBytes
|
struct ElfHdrBytes
|
||||||
{
|
{
|
||||||
uchar ident[16];
|
uchar ident[16];
|
||||||
|
@ -31,6 +36,24 @@ struct ElfHdrBytes
|
||||||
uchar shstrndx[2];
|
uchar shstrndx[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ElfHdrBytes64
|
||||||
|
{
|
||||||
|
uchar ident[16];
|
||||||
|
uchar type[2];
|
||||||
|
uchar machine[2];
|
||||||
|
uchar version[4];
|
||||||
|
uchar entry[8];
|
||||||
|
uchar phoff[8];
|
||||||
|
uchar shoff[8];
|
||||||
|
uchar flags[4];
|
||||||
|
uchar ehsize[2];
|
||||||
|
uchar phentsize[2];
|
||||||
|
uchar phnum[2];
|
||||||
|
uchar shentsize[2];
|
||||||
|
uchar shnum[2];
|
||||||
|
uchar shstrndx[2];
|
||||||
|
};
|
||||||
|
|
||||||
struct ElfSectBytes
|
struct ElfSectBytes
|
||||||
{
|
{
|
||||||
uchar name[4];
|
uchar name[4];
|
||||||
|
@ -45,6 +68,20 @@ struct ElfSectBytes
|
||||||
uchar entsize[4];
|
uchar entsize[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ElfSectBytes64
|
||||||
|
{
|
||||||
|
uchar name[4];
|
||||||
|
uchar type[4];
|
||||||
|
uchar flags[8];
|
||||||
|
uchar addr[8];
|
||||||
|
uchar offset[8];
|
||||||
|
uchar size[8];
|
||||||
|
uchar link[4];
|
||||||
|
uchar info[4];
|
||||||
|
uchar align[8];
|
||||||
|
uchar entsize[8];
|
||||||
|
};
|
||||||
|
|
||||||
struct ElfSymBytes
|
struct ElfSymBytes
|
||||||
{
|
{
|
||||||
uchar name[4];
|
uchar name[4];
|
||||||
|
@ -55,6 +92,16 @@ struct ElfSymBytes
|
||||||
uchar shndx[2];
|
uchar shndx[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ElfSymBytes64
|
||||||
|
{
|
||||||
|
uchar name[4];
|
||||||
|
uchar info;
|
||||||
|
uchar other;
|
||||||
|
uchar shndx[2];
|
||||||
|
uchar value[8];
|
||||||
|
uchar size[8];
|
||||||
|
};
|
||||||
|
|
||||||
struct ElfProgBytes
|
struct ElfProgBytes
|
||||||
{
|
{
|
||||||
uchar type[4];
|
uchar type[4];
|
||||||
|
@ -67,11 +114,23 @@ struct ElfProgBytes
|
||||||
uchar align[4];
|
uchar align[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ElfProgBytes64
|
||||||
|
{
|
||||||
|
uchar type[4];
|
||||||
|
uchar flags[4];
|
||||||
|
uchar offset[8];
|
||||||
|
uchar vaddr[8];
|
||||||
|
uchar paddr[8];
|
||||||
|
uchar filesz[8];
|
||||||
|
uchar memsz[8];
|
||||||
|
uchar align[8];
|
||||||
|
};
|
||||||
|
|
||||||
uchar ElfMagic[4] = { 0x7F, 'E', 'L', 'F' };
|
uchar ElfMagic[4] = { 0x7F, 'E', 'L', 'F' };
|
||||||
|
|
||||||
static void unpackhdr(ElfHdr*, ElfHdrBytes*);
|
static void unpackhdr(ElfHdr*, void*);
|
||||||
static void unpackprog(ElfHdr*, ElfProg*, ElfProgBytes*);
|
static void unpackprog(ElfHdr*, ElfProg*, void*);
|
||||||
static void unpacksect(ElfHdr*, ElfSect*, ElfSectBytes*);
|
static void unpacksect(ElfHdr*, ElfSect*, void*);
|
||||||
|
|
||||||
static char *elftypes[] = {
|
static char *elftypes[] = {
|
||||||
"none",
|
"none",
|
||||||
|
@ -128,9 +187,11 @@ elfinit(int fd)
|
||||||
int i;
|
int i;
|
||||||
Elf *e;
|
Elf *e;
|
||||||
ElfHdr *h;
|
ElfHdr *h;
|
||||||
ElfHdrBytes hdrb;
|
union {
|
||||||
ElfProgBytes progb;
|
ElfHdrBytes h32;
|
||||||
ElfSectBytes sectb;
|
ElfHdrBytes64 h64;
|
||||||
|
} hdrb;
|
||||||
|
void *p;
|
||||||
ElfSect *s;
|
ElfSect *s;
|
||||||
|
|
||||||
e = mallocz(sizeof(Elf), 1);
|
e = mallocz(sizeof(Elf), 1);
|
||||||
|
@ -146,17 +207,17 @@ elfinit(int fd)
|
||||||
goto err;
|
goto err;
|
||||||
h = &e->hdr;
|
h = &e->hdr;
|
||||||
unpackhdr(h, &hdrb);
|
unpackhdr(h, &hdrb);
|
||||||
if(h->class != ElfClass32){
|
if(h->class != ElfClass32 && h->class != ElfClass64){
|
||||||
werrstr("bad ELF class - not 32-bit");
|
werrstr("bad ELF class - not 32-bit, 64-bit");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if(h->encoding != ElfDataLsb && h->encoding != ElfDataMsb){
|
if(h->encoding != ElfDataLsb && h->encoding != ElfDataMsb){
|
||||||
werrstr("bad ELF encoding - not LSB, MSB");
|
werrstr("bad ELF encoding - not LSB, MSB");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if(hdrb.ident[6] != h->version){
|
if(hdrb.h32.ident[6] != h->version){
|
||||||
werrstr("bad ELF encoding - version mismatch %02ux and %08ux",
|
werrstr("bad ELF encoding - version mismatch %02ux and %08ux",
|
||||||
(uint)hdrb.ident[6], (uint)h->version);
|
(uint)hdrb.h32.ident[6], (uint)h->version);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,23 +226,27 @@ elfinit(int fd)
|
||||||
*/
|
*/
|
||||||
e->nprog = h->phnum;
|
e->nprog = h->phnum;
|
||||||
e->prog = mallocz(sizeof(ElfProg)*e->nprog, 1);
|
e->prog = mallocz(sizeof(ElfProg)*e->nprog, 1);
|
||||||
|
p = mallocz(h->phentsize, 1);
|
||||||
for(i=0; i<e->nprog; i++){
|
for(i=0; i<e->nprog; i++){
|
||||||
if(seek(fd, h->phoff+i*h->phentsize, 0) < 0
|
if(seek(fd, h->phoff+i*h->phentsize, 0) < 0
|
||||||
|| readn(fd, &progb, sizeof progb) != sizeof progb)
|
|| readn(fd, p, h->phentsize) != h->phentsize)
|
||||||
goto err;
|
goto err;
|
||||||
unpackprog(h, &e->prog[i], &progb);
|
unpackprog(h, &e->prog[i], p);
|
||||||
}
|
}
|
||||||
|
free(p);
|
||||||
|
|
||||||
e->nsect = h->shnum;
|
e->nsect = h->shnum;
|
||||||
if(e->nsect == 0)
|
if(e->nsect == 0)
|
||||||
goto nosects;
|
goto nosects;
|
||||||
e->sect = mallocz(sizeof(ElfSect)*e->nsect, 1);
|
e->sect = mallocz(sizeof(ElfSect)*e->nsect, 1);
|
||||||
|
p = mallocz(h->shentsize, 1);
|
||||||
for(i=0; i<e->nsect; i++){
|
for(i=0; i<e->nsect; i++){
|
||||||
if(seek(fd, h->shoff+i*h->shentsize, 0) < 0
|
if(seek(fd, h->shoff+i*h->shentsize, 0) < 0
|
||||||
|| readn(fd, §b, sizeof sectb) != sizeof sectb)
|
|| readn(fd, p, h->shentsize) != h->shentsize)
|
||||||
goto err;
|
goto err;
|
||||||
unpacksect(h, &e->sect[i], §b);
|
unpacksect(h, &e->sect[i], p);
|
||||||
}
|
}
|
||||||
|
free(p);
|
||||||
|
|
||||||
if(h->shstrndx >= e->nsect){
|
if(h->shstrndx >= e->nsect){
|
||||||
fprint(2, "warning: bad string section index %d >= %d", h->shstrndx, e->nsect);
|
fprint(2, "warning: bad string section index %d >= %d", h->shstrndx, e->nsect);
|
||||||
|
@ -243,12 +308,15 @@ elfclose(Elf *elf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unpackhdr(ElfHdr *h, ElfHdrBytes *b)
|
unpackhdr(ElfHdr *h, void *v)
|
||||||
{
|
{
|
||||||
u16int (*e2)(uchar*);
|
u16int (*e2)(uchar*);
|
||||||
u32int (*e4)(uchar*);
|
u32int (*e4)(uchar*);
|
||||||
u64int (*e8)(uchar*);
|
u64int (*e8)(uchar*);
|
||||||
|
ElfHdrBytes *b;
|
||||||
|
ElfHdrBytes64 *b64;
|
||||||
|
|
||||||
|
b = v;
|
||||||
memmove(h->magic, b->ident, 4);
|
memmove(h->magic, b->ident, 4);
|
||||||
h->class = b->ident[4];
|
h->class = b->ident[4];
|
||||||
h->encoding = b->ident[5];
|
h->encoding = b->ident[5];
|
||||||
|
@ -273,6 +341,9 @@ unpackhdr(ElfHdr *h, ElfHdrBytes *b)
|
||||||
h->e4 = e4;
|
h->e4 = e4;
|
||||||
h->e8 = e8;
|
h->e8 = e8;
|
||||||
|
|
||||||
|
if(h->class == ElfClass64)
|
||||||
|
goto b64;
|
||||||
|
|
||||||
h->type = e2(b->type);
|
h->type = e2(b->type);
|
||||||
h->machine = e2(b->machine);
|
h->machine = e2(b->machine);
|
||||||
h->version = e4(b->version);
|
h->version = e4(b->version);
|
||||||
|
@ -286,40 +357,100 @@ unpackhdr(ElfHdr *h, ElfHdrBytes *b)
|
||||||
h->shentsize = e2(b->shentsize);
|
h->shentsize = e2(b->shentsize);
|
||||||
h->shnum = e2(b->shnum);
|
h->shnum = e2(b->shnum);
|
||||||
h->shstrndx = e2(b->shstrndx);
|
h->shstrndx = e2(b->shstrndx);
|
||||||
|
return;
|
||||||
|
|
||||||
|
b64:
|
||||||
|
b64 = v;
|
||||||
|
h->type = e2(b64->type);
|
||||||
|
h->machine = e2(b64->machine);
|
||||||
|
h->version = e4(b64->version);
|
||||||
|
h->entry = e8(b64->entry);
|
||||||
|
h->phoff = e8(b64->phoff);
|
||||||
|
h->shoff = e8(b64->shoff);
|
||||||
|
h->flags = e4(b64->flags);
|
||||||
|
h->ehsize = e2(b64->ehsize);
|
||||||
|
h->phentsize = e2(b64->phentsize);
|
||||||
|
h->phnum = e2(b64->phnum);
|
||||||
|
h->shentsize = e2(b64->shentsize);
|
||||||
|
h->shnum = e2(b64->shnum);
|
||||||
|
h->shstrndx = e2(b64->shstrndx);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unpackprog(ElfHdr *h, ElfProg *p, ElfProgBytes *b)
|
unpackprog(ElfHdr *h, ElfProg *p, void *v)
|
||||||
{
|
{
|
||||||
u32int (*e4)(uchar*);
|
u32int (*e4)(uchar*);
|
||||||
|
u64int (*e8)(uchar*);
|
||||||
|
|
||||||
e4 = h->e4;
|
if(h->class == ElfClass32) {
|
||||||
p->type = e4(b->type);
|
ElfProgBytes *b;
|
||||||
p->offset = e4(b->offset);
|
|
||||||
p->vaddr = e4(b->vaddr);
|
b = v;
|
||||||
p->paddr = e4(b->paddr);
|
e4 = h->e4;
|
||||||
p->filesz = e4(b->filesz);
|
p->type = e4(b->type);
|
||||||
p->memsz = e4(b->memsz);
|
p->offset = e4(b->offset);
|
||||||
p->flags = e4(b->flags);
|
p->vaddr = e4(b->vaddr);
|
||||||
p->align = e4(b->align);
|
p->paddr = e4(b->paddr);
|
||||||
|
p->filesz = e4(b->filesz);
|
||||||
|
p->memsz = e4(b->memsz);
|
||||||
|
p->flags = e4(b->flags);
|
||||||
|
p->align = e4(b->align);
|
||||||
|
} else {
|
||||||
|
ElfProgBytes64 *b;
|
||||||
|
|
||||||
|
b = v;
|
||||||
|
e4 = h->e4;
|
||||||
|
e8 = h->e8;
|
||||||
|
p->type = e4(b->type);
|
||||||
|
p->offset = e8(b->offset);
|
||||||
|
p->vaddr = e8(b->vaddr);
|
||||||
|
p->paddr = e8(b->paddr);
|
||||||
|
p->filesz = e8(b->filesz);
|
||||||
|
p->memsz = e8(b->memsz);
|
||||||
|
p->flags = e4(b->flags);
|
||||||
|
p->align = e8(b->align);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unpacksect(ElfHdr *h, ElfSect *s, ElfSectBytes *b)
|
unpacksect(ElfHdr *h, ElfSect *s, void *v)
|
||||||
{
|
{
|
||||||
u32int (*e4)(uchar*);
|
u32int (*e4)(uchar*);
|
||||||
|
u64int (*e8)(uchar*);
|
||||||
|
|
||||||
e4 = h->e4;
|
if(h->class == ElfClass32) {
|
||||||
s->name = (char*)(uintptr)e4(b->name);
|
ElfSectBytes *b;
|
||||||
s->type = e4(b->type);
|
|
||||||
s->flags = e4(b->flags);
|
b = v;
|
||||||
s->addr = e4(b->addr);
|
e4 = h->e4;
|
||||||
s->offset = e4(b->offset);
|
s->name = (char*)(uintptr)e4(b->name);
|
||||||
s->size = e4(b->size);
|
s->type = e4(b->type);
|
||||||
s->link = e4(b->link);
|
s->flags = e4(b->flags);
|
||||||
s->info = e4(b->info);
|
s->addr = e4(b->addr);
|
||||||
s->align = e4(b->align);
|
s->offset = e4(b->offset);
|
||||||
s->entsize = e4(b->entsize);
|
s->size = e4(b->size);
|
||||||
|
s->link = e4(b->link);
|
||||||
|
s->info = e4(b->info);
|
||||||
|
s->align = e4(b->align);
|
||||||
|
s->entsize = e4(b->entsize);
|
||||||
|
} else {
|
||||||
|
ElfSectBytes64 *b;
|
||||||
|
|
||||||
|
b = v;
|
||||||
|
e4 = h->e4;
|
||||||
|
e8 = h->e8;
|
||||||
|
s->name = (char*)(uintptr)e4(b->name);
|
||||||
|
s->type = e4(b->type);
|
||||||
|
s->flags = e8(b->flags);
|
||||||
|
s->addr = e8(b->addr);
|
||||||
|
s->offset = e8(b->offset);
|
||||||
|
s->size = e8(b->size);
|
||||||
|
s->link = e4(b->link);
|
||||||
|
s->info = e4(b->info);
|
||||||
|
s->align = e8(b->align);
|
||||||
|
s->entsize = e8(b->entsize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ElfSect*
|
ElfSect*
|
||||||
|
@ -374,21 +505,39 @@ elfsym(Elf *elf, int i, ElfSym *sym)
|
||||||
extract:
|
extract:
|
||||||
if(elfmap(elf, symtab) < 0 || elfmap(elf, strtab) < 0)
|
if(elfmap(elf, symtab) < 0 || elfmap(elf, strtab) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
p = symtab->base + i * sizeof(ElfSymBytes);
|
if(elf->hdr.class == ElfClass32) {
|
||||||
s = (char*)strtab->base;
|
p = symtab->base + i * sizeof(ElfSymBytes);
|
||||||
x = elf->hdr.e4(p);
|
s = (char*)strtab->base;
|
||||||
if(x >= strtab->size){
|
x = elf->hdr.e4(p);
|
||||||
werrstr("bad symbol name offset 0x%lux", x);
|
if(x >= strtab->size){
|
||||||
return -1;
|
werrstr("bad symbol name offset 0x%lux", x);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sym->name = s + x;
|
||||||
|
sym->value = elf->hdr.e4(p+4);
|
||||||
|
sym->size = elf->hdr.e4(p+8);
|
||||||
|
x = p[12];
|
||||||
|
sym->bind = x>>4;
|
||||||
|
sym->type = x & 0xF;
|
||||||
|
sym->other = p[13];
|
||||||
|
sym->shndx = elf->hdr.e2(p+14);
|
||||||
|
} else {
|
||||||
|
p = symtab->base + i * sizeof(ElfSymBytes64);
|
||||||
|
s = (char*)strtab->base;
|
||||||
|
x = elf->hdr.e4(p);
|
||||||
|
if(x >= strtab->size){
|
||||||
|
werrstr("bad symbol name offset 0x%lux", x);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sym->name = s + x;
|
||||||
|
x = p[4];
|
||||||
|
sym->bind = x>>4;
|
||||||
|
sym->type = x & 0xF;
|
||||||
|
sym->other = p[5];
|
||||||
|
sym->shndx = elf->hdr.e2(p+6);
|
||||||
|
sym->value = elf->hdr.e8(p+8);
|
||||||
|
sym->size = elf->hdr.e8(p+16);
|
||||||
}
|
}
|
||||||
sym->name = s + x;
|
|
||||||
sym->value = elf->hdr.e4(p+4);
|
|
||||||
sym->size = elf->hdr.e4(p+8);
|
|
||||||
x = p[12];
|
|
||||||
sym->bind = x>>4;
|
|
||||||
sym->type = x & 0xF;
|
|
||||||
sym->other = p[13];
|
|
||||||
sym->shndx = elf->hdr.e2(p+14);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
i -= elf->nsymtab;
|
i -= elf->nsymtab;
|
||||||
|
|
|
@ -54,6 +54,7 @@ enum
|
||||||
ElfMachAlpha, /* Digital Alpha */
|
ElfMachAlpha, /* Digital Alpha */
|
||||||
ElfMachSH, /* Hitachi SH */
|
ElfMachSH, /* Hitachi SH */
|
||||||
ElfMachSparc9, /* SPARC V9 */
|
ElfMachSparc9, /* SPARC V9 */
|
||||||
|
ElfMachAmd64 = 62, /* x86-64 */
|
||||||
/* and the list goes on... */
|
/* and the list goes on... */
|
||||||
|
|
||||||
ElfAbiNone = 0,
|
ElfAbiNone = 0,
|
||||||
|
@ -138,9 +139,9 @@ struct ElfHdr
|
||||||
uchar abiversion;
|
uchar abiversion;
|
||||||
u32int type;
|
u32int type;
|
||||||
u32int machine;
|
u32int machine;
|
||||||
u32int entry;
|
u64int entry;
|
||||||
u32int phoff;
|
u64int phoff;
|
||||||
u32int shoff;
|
u64int shoff;
|
||||||
u32int flags;
|
u32int flags;
|
||||||
u32int ehsize;
|
u32int ehsize;
|
||||||
u32int phentsize;
|
u32int phentsize;
|
||||||
|
@ -157,27 +158,27 @@ struct ElfSect
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
u32int type;
|
u32int type;
|
||||||
u32int flags;
|
u64int flags;
|
||||||
u32int addr;
|
u64int addr;
|
||||||
u32int offset;
|
u64int offset;
|
||||||
u32int size;
|
u64int size;
|
||||||
u32int link;
|
u32int link;
|
||||||
u32int info;
|
u32int info;
|
||||||
u32int align;
|
u64int align;
|
||||||
u32int entsize;
|
u64int entsize;
|
||||||
uchar *base;
|
uchar *base;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ElfProg
|
struct ElfProg
|
||||||
{
|
{
|
||||||
u32int type;
|
u32int type;
|
||||||
u32int offset;
|
u64int offset;
|
||||||
u32int vaddr;
|
u64int vaddr;
|
||||||
u32int paddr;
|
u64int paddr;
|
||||||
u32int filesz;
|
u64int filesz;
|
||||||
u32int memsz;
|
u64int memsz;
|
||||||
u32int flags;
|
u32int flags;
|
||||||
u32int align;
|
u64int align;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ElfNote
|
struct ElfNote
|
||||||
|
@ -193,8 +194,8 @@ struct ElfNote
|
||||||
struct ElfSym
|
struct ElfSym
|
||||||
{
|
{
|
||||||
char* name;
|
char* name;
|
||||||
u32int value;
|
u64int value;
|
||||||
u32int size;
|
u64int size;
|
||||||
uchar bind;
|
uchar bind;
|
||||||
uchar type;
|
uchar type;
|
||||||
uchar other;
|
uchar other;
|
||||||
|
@ -234,4 +235,6 @@ int elfmap(Elf*, ElfSect*);
|
||||||
|
|
||||||
struct Fhdr;
|
struct Fhdr;
|
||||||
void elfcorelinux386(struct Fhdr*, Elf*, ElfNote*);
|
void elfcorelinux386(struct Fhdr*, Elf*, ElfNote*);
|
||||||
|
void elfcorefreebsd386(struct Fhdr*, Elf*, ElfNote*);
|
||||||
|
void elfcorefreebsdamd64(struct Fhdr*, Elf*, ElfNote*);
|
||||||
void elfdl386mapdl(int);
|
void elfdl386mapdl(int);
|
||||||
|
|
150
src/libmach/elfcorefreebsdamd64.c
Normal file
150
src/libmach/elfcorefreebsdamd64.c
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <mach.h>
|
||||||
|
#include "elf.h"
|
||||||
|
#include "uregamd64.h"
|
||||||
|
|
||||||
|
typedef struct Ureg Ureg;
|
||||||
|
|
||||||
|
// See FreeBSD's sys/procfs.h.
|
||||||
|
|
||||||
|
typedef struct Lreg Lreg;
|
||||||
|
typedef struct Status Status;
|
||||||
|
typedef struct Psinfo Psinfo;
|
||||||
|
|
||||||
|
struct Lreg
|
||||||
|
{
|
||||||
|
u64int r15;
|
||||||
|
u64int r14;
|
||||||
|
u64int r13;
|
||||||
|
u64int r12;
|
||||||
|
u64int r11;
|
||||||
|
u64int r10;
|
||||||
|
u64int r9;
|
||||||
|
u64int r8;
|
||||||
|
u64int rdi;
|
||||||
|
u64int rsi;
|
||||||
|
u64int rbp;
|
||||||
|
u64int rbx;
|
||||||
|
u64int rdx;
|
||||||
|
u64int rcx;
|
||||||
|
u64int rax;
|
||||||
|
u32int trapno;
|
||||||
|
u16int fs;
|
||||||
|
u16int gs;
|
||||||
|
u32int err;
|
||||||
|
u16int es;
|
||||||
|
u16int ds;
|
||||||
|
u64int rip;
|
||||||
|
u64int cs;
|
||||||
|
u64int rflags;
|
||||||
|
u64int rsp;
|
||||||
|
u64int ss;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Status
|
||||||
|
{
|
||||||
|
u32int version; /* Version number of struct (1) */
|
||||||
|
u64int statussz; /* sizeof(prstatus_t) (1) */
|
||||||
|
u64int gregsetsz; /* sizeof(gregset_t) (1) */
|
||||||
|
u64int fpregsetsz; /* sizeof(fpregset_t) (1) */
|
||||||
|
u32int osreldate; /* Kernel version (1) */
|
||||||
|
u32int cursig; /* Current signal (1) */
|
||||||
|
u32int pid; /* Process ID (1) */
|
||||||
|
Lreg reg; /* General purpose registers (1) */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Psinfo
|
||||||
|
{
|
||||||
|
u32int version;
|
||||||
|
u64int size;
|
||||||
|
char name[17];
|
||||||
|
char psargs[81];
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
elfcorefreebsdamd64(Fhdr *fp, Elf *elf, ElfNote *note)
|
||||||
|
{
|
||||||
|
Status *s;
|
||||||
|
Lreg *l;
|
||||||
|
Ureg *u;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
switch(note->type) {
|
||||||
|
case ElfNotePrStatus:
|
||||||
|
if(note->descsz < sizeof(Status)){
|
||||||
|
fprint(2, "warning: elf status note too small\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s = (Status*)note->desc;
|
||||||
|
if(s->version != 1){
|
||||||
|
fprint(2, "warning: unknown elf note status version %ud\n", (uint)s->version);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
l = &s->reg;
|
||||||
|
u = malloc(sizeof(Ureg));
|
||||||
|
|
||||||
|
/* no byte order problems - just copying and rearranging */
|
||||||
|
u->ax = l->rax;
|
||||||
|
u->bx = l->rbx;
|
||||||
|
u->cx = l->rcx;
|
||||||
|
u->dx = l->rdx;
|
||||||
|
u->si = l->rsi;
|
||||||
|
u->di = l->rdi;
|
||||||
|
u->bp = l->rbp;
|
||||||
|
u->r8 = l->r8;
|
||||||
|
u->r9 = l->r9;
|
||||||
|
u->r10 = l->r10;
|
||||||
|
u->r11 = l->r11;
|
||||||
|
u->r12 = l->r12;
|
||||||
|
u->r13 = l->r13;
|
||||||
|
u->r14 = l->r14;
|
||||||
|
u->r15 = l->r15;
|
||||||
|
|
||||||
|
u->ds = l->ds;
|
||||||
|
u->es = l->es;
|
||||||
|
u->fs = l->fs;
|
||||||
|
u->gs = l->gs;
|
||||||
|
|
||||||
|
u->type = l->trapno;
|
||||||
|
u->error = l->err;
|
||||||
|
u->ip = l->rip;
|
||||||
|
u->cs = l->cs;
|
||||||
|
u->flags = l->rflags;
|
||||||
|
u->sp = l->rsp;
|
||||||
|
u->ss = l->ss;
|
||||||
|
|
||||||
|
if((fp->thread = realloc(fp->thread, (1+fp->nthread)*sizeof(fp->thread[0]))) == nil){
|
||||||
|
fprint(2, "warning: out of memory saving thread info\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i = fp->nthread;
|
||||||
|
fp->thread[i].id = s->pid;
|
||||||
|
fp->thread[i].ureg = u;
|
||||||
|
fp->nthread++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
corecmdfreebsd386(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->name, p->psargs); */
|
||||||
|
t = malloc(80+1);
|
||||||
|
if(t == nil)
|
||||||
|
return -1;
|
||||||
|
memmove(t, p->psargs, 80);
|
||||||
|
t[80] = 0;
|
||||||
|
*pp = t;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -9,11 +9,11 @@ struct LocRegs
|
||||||
Regs r;
|
Regs r;
|
||||||
Regs *oldregs;
|
Regs *oldregs;
|
||||||
Map *map;
|
Map *map;
|
||||||
ulong *val;
|
u64int *val;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
locregrw(Regs *regs, char *name, ulong *val, int isr)
|
locregrw(Regs *regs, char *name, u64int *val, int isr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
LocRegs *lr;
|
LocRegs *lr;
|
||||||
|
@ -36,8 +36,8 @@ stacktrace(Map *map, Regs *regs, Tracer trace)
|
||||||
{
|
{
|
||||||
char *rname;
|
char *rname;
|
||||||
int i, ipc, ret;
|
int i, ipc, ret;
|
||||||
ulong nextpc, pc, v;
|
u64int nextpc, pc, v;
|
||||||
ulong *cur, *next;
|
u64int *cur, *next;
|
||||||
LocRegs lr;
|
LocRegs lr;
|
||||||
Symbol s, *sp;
|
Symbol s, *sp;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <mach.h>
|
#include <mach.h>
|
||||||
|
|
||||||
char *
|
char *
|
||||||
_hexify(char *buf, ulong p, int zeros)
|
_hexify(char *buf, u64int p, int zeros)
|
||||||
{
|
{
|
||||||
ulong d;
|
ulong d;
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ lget1(Map *map, Regs *regs, Loc loc, uchar *a, uint n)
|
||||||
int
|
int
|
||||||
lget2(Map *map, Regs *regs, Loc loc, u16int *u)
|
lget2(Map *map, Regs *regs, Loc loc, u16int *u)
|
||||||
{
|
{
|
||||||
ulong ul;
|
u64int ul;
|
||||||
|
|
||||||
if(locsimplify(map, regs, loc, &loc) < 0)
|
if(locsimplify(map, regs, loc, &loc) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -93,7 +93,7 @@ lget2(Map *map, Regs *regs, Loc loc, u16int *u)
|
||||||
int
|
int
|
||||||
lget4(Map *map, Regs *regs, Loc loc, u32int *u)
|
lget4(Map *map, Regs *regs, Loc loc, u32int *u)
|
||||||
{
|
{
|
||||||
ulong ul;
|
u64int ul;
|
||||||
|
|
||||||
if(locsimplify(map, regs, loc, &loc) < 0)
|
if(locsimplify(map, regs, loc, &loc) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -113,10 +113,23 @@ lget4(Map *map, Regs *regs, Loc loc, u32int *u)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
lgeta(Map *map, Regs *regs, Loc loc, u64int *u)
|
||||||
|
{
|
||||||
|
u32int v;
|
||||||
|
|
||||||
|
if(machcpu == &machamd64)
|
||||||
|
return lget8(map, regs, loc, u);
|
||||||
|
if(lget4(map, regs, loc, &v) < 0)
|
||||||
|
return -1;
|
||||||
|
*u = v;
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
lget8(Map *map, Regs *regs, Loc loc, u64int *u)
|
lget8(Map *map, Regs *regs, Loc loc, u64int *u)
|
||||||
{
|
{
|
||||||
ulong ul;
|
u64int ul;
|
||||||
|
|
||||||
if(locsimplify(map, regs, loc, &loc) < 0)
|
if(locsimplify(map, regs, loc, &loc) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -190,7 +203,7 @@ lput8(Map *map, Regs *regs, Loc loc, u64int u)
|
||||||
static Loc zl;
|
static Loc zl;
|
||||||
|
|
||||||
Loc
|
Loc
|
||||||
locaddr(ulong addr)
|
locaddr(u64int addr)
|
||||||
{
|
{
|
||||||
Loc l;
|
Loc l;
|
||||||
|
|
||||||
|
@ -214,7 +227,7 @@ locindir(char *reg, long offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
Loc
|
Loc
|
||||||
locconst(ulong con)
|
locconst(u64int con)
|
||||||
{
|
{
|
||||||
Loc l;
|
Loc l;
|
||||||
|
|
||||||
|
@ -248,7 +261,7 @@ locreg(char *reg)
|
||||||
int
|
int
|
||||||
locsimplify(Map *map, Regs *regs, Loc loc, Loc *newloc)
|
locsimplify(Map *map, Regs *regs, Loc loc, Loc *newloc)
|
||||||
{
|
{
|
||||||
ulong u;
|
u64int u;
|
||||||
|
|
||||||
if(loc.type == LOFFSET){
|
if(loc.type == LOFFSET){
|
||||||
if(rget(regs, loc.reg, &u) < 0)
|
if(rget(regs, loc.reg, &u) < 0)
|
||||||
|
|
|
@ -18,9 +18,9 @@ static struct {
|
||||||
} rock;
|
} rock;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ltrace(Map *map, Regs *regs, ulong pc, ulong nextpc, Symbol *sym, int depth)
|
ltrace(Map *map, Regs *regs, u64int pc, u64int nextpc, Symbol *sym, int depth)
|
||||||
{
|
{
|
||||||
ulong v;
|
u64int v;
|
||||||
Symbol s1;
|
Symbol s1;
|
||||||
|
|
||||||
USED(pc);
|
USED(pc);
|
||||||
|
@ -49,7 +49,7 @@ ltrace(Map *map, Regs *regs, ulong pc, ulong nextpc, Symbol *sym, int depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
localaddr(Map *map, Regs *regs, char *fn, char *var, ulong *val)
|
localaddr(Map *map, Regs *regs, char *fn, char *var, u64int *val)
|
||||||
{
|
{
|
||||||
Regdesc *rp;
|
Regdesc *rp;
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
197
src/libmach/machamd64.c
Normal file
197
src/libmach/machamd64.c
Normal file
|
@ -0,0 +1,197 @@
|
||||||
|
// Inferno libmach/6.c
|
||||||
|
// http://code.google.com/p/inferno-os/source/browse/utils/libmach/6.c
|
||||||
|
//
|
||||||
|
// Copyright © 1994-1999 Lucent Technologies Inc.
|
||||||
|
// Power PC support Copyright © 1995-2004 C H Forsyth (forsyth@terzarima.net).
|
||||||
|
// Portions Copyright © 1997-1999 Vita Nuova Limited.
|
||||||
|
// Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com).
|
||||||
|
// Revisions Copyright © 2000-2004 Lucent Technologies Inc. and others.
|
||||||
|
// Portions Copyright © 2009 The Go Authors. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* amd64 definition
|
||||||
|
*/
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <bio.h>
|
||||||
|
#include <mach.h>
|
||||||
|
#include "uregamd64.h"
|
||||||
|
|
||||||
|
char *i386excep(Map*, Regs*);
|
||||||
|
int i386foll(Map*, Regs*, u64int, u64int*);
|
||||||
|
int i386hexinst(Map*, u64int, char*, int);
|
||||||
|
int i386das(Map*, u64int, char, char*, int);
|
||||||
|
int i386instlen(Map*, u64int);
|
||||||
|
int i386unwind(Map*, Regs*, u64int*, Symbol*);
|
||||||
|
|
||||||
|
#define REGOFF(x) offsetof(struct Ureg, x)
|
||||||
|
|
||||||
|
#define REGSIZE sizeof(struct Ureg)
|
||||||
|
#define FP_CTLS(x) (REGSIZE+2*(x))
|
||||||
|
#define FP_CTL(x) (REGSIZE+4*(x))
|
||||||
|
#define FP_REG(x) (FP_CTL(8)+16*(x))
|
||||||
|
#define XM_REG(x) (FP_CTL(8)+8*16+16*(x))
|
||||||
|
|
||||||
|
#define FPREGSIZE 512 /* TO DO? currently only 0x1A0 used */
|
||||||
|
|
||||||
|
static Regdesc amd64reglist[] = {
|
||||||
|
{"AX", REGOFF(ax), RINT, 'Y'},
|
||||||
|
{"BX", REGOFF(bx), RINT, 'Y'},
|
||||||
|
{"CX", REGOFF(cx), RINT, 'Y'},
|
||||||
|
{"DX", REGOFF(dx), RINT, 'Y'},
|
||||||
|
{"SI", REGOFF(si), RINT, 'Y'},
|
||||||
|
{"DI", REGOFF(di), RINT, 'Y'},
|
||||||
|
{"BP", REGOFF(bp), RINT, 'Y'},
|
||||||
|
{"R8", REGOFF(r8), RINT, 'Y'},
|
||||||
|
{"R9", REGOFF(r9), RINT, 'Y'},
|
||||||
|
{"R10", REGOFF(r10), RINT, 'Y'},
|
||||||
|
{"R11", REGOFF(r11), RINT, 'Y'},
|
||||||
|
{"R12", REGOFF(r12), RINT, 'Y'},
|
||||||
|
{"R13", REGOFF(r13), RINT, 'Y'},
|
||||||
|
{"R14", REGOFF(r14), RINT, 'Y'},
|
||||||
|
{"R15", REGOFF(r15), RINT, 'Y'},
|
||||||
|
{"DS", REGOFF(ds), RINT, 'x'},
|
||||||
|
{"ES", REGOFF(es), RINT, 'x'},
|
||||||
|
{"FS", REGOFF(fs), RINT, 'x'},
|
||||||
|
{"GS", REGOFF(gs), RINT, 'x'},
|
||||||
|
{"TYPE", REGOFF(type), RINT, 'Y'},
|
||||||
|
{"TRAP", REGOFF(type), RINT, 'Y'}, /* alias for acid */
|
||||||
|
{"ERROR", REGOFF(error), RINT, 'Y'},
|
||||||
|
{"IP", REGOFF(ip), RINT, 'Y'},
|
||||||
|
{"PC", REGOFF(ip), RINT, 'Y'}, /* alias for acid */
|
||||||
|
{"CS", REGOFF(cs), RINT, 'Y'},
|
||||||
|
{"FLAGS", REGOFF(flags), RINT, 'Y'},
|
||||||
|
{"SP", REGOFF(sp), RINT, 'Y'},
|
||||||
|
{"SS", REGOFF(ss), RINT, 'Y'},
|
||||||
|
|
||||||
|
{"FCW", FP_CTLS(0), RFLT, 'x'},
|
||||||
|
{"FSW", FP_CTLS(1), RFLT, 'x'},
|
||||||
|
{"FTW", FP_CTLS(2), RFLT, 'b'},
|
||||||
|
{"FOP", FP_CTLS(3), RFLT, 'x'},
|
||||||
|
{"RIP", FP_CTL(2), RFLT, 'Y'},
|
||||||
|
{"RDP", FP_CTL(4), RFLT, 'Y'},
|
||||||
|
{"MXCSR", FP_CTL(6), RFLT, 'X'},
|
||||||
|
{"MXCSRMASK", FP_CTL(7), RFLT, 'X'},
|
||||||
|
{"M0", FP_REG(0), RFLT, 'F'}, /* assumes double */
|
||||||
|
{"M1", FP_REG(1), RFLT, 'F'},
|
||||||
|
{"M2", FP_REG(2), RFLT, 'F'},
|
||||||
|
{"M3", FP_REG(3), RFLT, 'F'},
|
||||||
|
{"M4", FP_REG(4), RFLT, 'F'},
|
||||||
|
{"M5", FP_REG(5), RFLT, 'F'},
|
||||||
|
{"M6", FP_REG(6), RFLT, 'F'},
|
||||||
|
{"M7", FP_REG(7), RFLT, 'F'},
|
||||||
|
{"X0", XM_REG(0), RFLT, 'F'}, /* assumes double */
|
||||||
|
{"X1", XM_REG(1), RFLT, 'F'},
|
||||||
|
{"X2", XM_REG(2), RFLT, 'F'},
|
||||||
|
{"X3", XM_REG(3), RFLT, 'F'},
|
||||||
|
{"X4", XM_REG(4), RFLT, 'F'},
|
||||||
|
{"X5", XM_REG(5), RFLT, 'F'},
|
||||||
|
{"X6", XM_REG(6), RFLT, 'F'},
|
||||||
|
{"X7", XM_REG(7), RFLT, 'F'},
|
||||||
|
{"X8", XM_REG(8), RFLT, 'F'},
|
||||||
|
{"X9", XM_REG(9), RFLT, 'F'},
|
||||||
|
{"X10", XM_REG(10), RFLT, 'F'},
|
||||||
|
{"X11", XM_REG(11), RFLT, 'F'},
|
||||||
|
{"X12", XM_REG(12), RFLT, 'F'},
|
||||||
|
{"X13", XM_REG(13), RFLT, 'F'},
|
||||||
|
{"X14", XM_REG(14), RFLT, 'F'},
|
||||||
|
{"X15", XM_REG(15), RFLT, 'F'},
|
||||||
|
{"X16", XM_REG(16), RFLT, 'F'},
|
||||||
|
/*
|
||||||
|
{"F0", FP_REG(7), RFLT, '3'},
|
||||||
|
{"F1", FP_REG(6), RFLT, '3'},
|
||||||
|
{"F2", FP_REG(5), RFLT, '3'},
|
||||||
|
{"F3", FP_REG(4), RFLT, '3'},
|
||||||
|
{"F4", FP_REG(3), RFLT, '3'},
|
||||||
|
{"F5", FP_REG(2), RFLT, '3'},
|
||||||
|
{"F6", FP_REG(1), RFLT, '3'},
|
||||||
|
{"F7", FP_REG(0), RFLT, '3'},
|
||||||
|
*/
|
||||||
|
{ 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static char *amd64windregs[] = {
|
||||||
|
"PC",
|
||||||
|
"SP",
|
||||||
|
"BP",
|
||||||
|
"AX",
|
||||||
|
"CX",
|
||||||
|
"DX",
|
||||||
|
"BX",
|
||||||
|
"SI",
|
||||||
|
"DI",
|
||||||
|
"R8",
|
||||||
|
"R9",
|
||||||
|
"R10",
|
||||||
|
"R11",
|
||||||
|
"R12",
|
||||||
|
"R13",
|
||||||
|
"R14",
|
||||||
|
"R15",
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Mach machamd64=
|
||||||
|
{
|
||||||
|
"amd64",
|
||||||
|
MAMD64, /* machine type */
|
||||||
|
amd64reglist, /* register list */
|
||||||
|
REGSIZE, /* size of registers in bytes */
|
||||||
|
FPREGSIZE, /* size of fp registers in bytes */
|
||||||
|
"PC", /* name of PC */
|
||||||
|
"SP", /* name of SP */
|
||||||
|
"BP", /* name of FP */
|
||||||
|
0, /* link register */
|
||||||
|
"setSB", /* static base register name (bogus anyways) */
|
||||||
|
0, /* static base register value */
|
||||||
|
0x1000, /* page size */
|
||||||
|
0xFFFFFFFF80110000ULL, /* kernel base */
|
||||||
|
0xFFFF800000000000ULL, /* kernel text mask */
|
||||||
|
1, /* quantization of pc */
|
||||||
|
8, /* szaddr */
|
||||||
|
4, /* szreg */
|
||||||
|
4, /* szfloat */
|
||||||
|
8, /* szdouble */
|
||||||
|
|
||||||
|
amd64windregs, /* locations unwound in stack trace */
|
||||||
|
17,
|
||||||
|
|
||||||
|
{0xCC, 0, 0, 0}, /* break point: INT 3 */
|
||||||
|
1, /* break point size */
|
||||||
|
|
||||||
|
i386foll, /* following addresses */
|
||||||
|
i386excep, /* print exception */
|
||||||
|
i386unwind, /* stack unwind */
|
||||||
|
|
||||||
|
leswap2, /* convert short to local byte order */
|
||||||
|
leswap4, /* convert long to local byte order */
|
||||||
|
leswap8, /* convert vlong to local byte order */
|
||||||
|
leieeeftoa32, /* single precision float pointer */
|
||||||
|
leieeeftoa64, /* double precision float pointer */
|
||||||
|
leieeeftoa80, /* long double precision floating point */
|
||||||
|
|
||||||
|
i386das, /* dissembler */
|
||||||
|
i386das, /* plan9-format disassembler */
|
||||||
|
0, /* commercial disassembler */
|
||||||
|
i386hexinst, /* print instruction */
|
||||||
|
i386instlen, /* instruction size calculation */
|
||||||
|
};
|
|
@ -14,10 +14,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char *powerexcep(Map*, Regs*);
|
static char *powerexcep(Map*, Regs*);
|
||||||
static int powerfoll(Map*, Regs*, ulong, ulong*);
|
static int powerfoll(Map*, Regs*, u64int, u64int*);
|
||||||
static int powerdas(Map*, ulong, char, char*, int);
|
static int powerdas(Map*, u64int, char, char*, int);
|
||||||
static int powerinstlen(Map*, ulong);
|
static int powerinstlen(Map*, u64int);
|
||||||
static int powerhexinst(Map*, ulong, char*, int);
|
static int powerhexinst(Map*, u64int, char*, int);
|
||||||
|
|
||||||
static char *excname[] =
|
static char *excname[] =
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ static char *excname[] =
|
||||||
static char*
|
static char*
|
||||||
powerexcep(Map *map, Regs *regs)
|
powerexcep(Map *map, Regs *regs)
|
||||||
{
|
{
|
||||||
ulong c;
|
u64int c;
|
||||||
static char buf[32];
|
static char buf[32];
|
||||||
|
|
||||||
if(rget(regs, "CAUSE", &c) < 0)
|
if(rget(regs, "CAUSE", &c) < 0)
|
||||||
|
@ -130,7 +130,7 @@ typedef struct {
|
||||||
long immediate;
|
long immediate;
|
||||||
long w0;
|
long w0;
|
||||||
long w1;
|
long w1;
|
||||||
ulong addr; /* pc of instruction */
|
u64int addr; /* pc of instruction */
|
||||||
short target;
|
short target;
|
||||||
char *curr; /* current fill level in output buffer */
|
char *curr; /* current fill level in output buffer */
|
||||||
char *end; /* end of buffer */
|
char *end; /* end of buffer */
|
||||||
|
@ -1155,14 +1155,14 @@ printins(Map *map, ulong pc, char *buf, int n)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
powerdas(Map *map, ulong pc, char modifier, char *buf, int n)
|
powerdas(Map *map, u64int pc, char modifier, char *buf, int n)
|
||||||
{
|
{
|
||||||
USED(modifier);
|
USED(modifier);
|
||||||
return printins(map, pc, buf, n);
|
return printins(map, pc, buf, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
powerhexinst(Map *map, ulong pc, char *buf, int n)
|
powerhexinst(Map *map, u64int pc, char *buf, int n)
|
||||||
{
|
{
|
||||||
Instr instr;
|
Instr instr;
|
||||||
|
|
||||||
|
@ -1183,7 +1183,7 @@ powerhexinst(Map *map, ulong pc, char *buf, int n)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
powerinstlen(Map *map, ulong pc)
|
powerinstlen(Map *map, u64int pc)
|
||||||
{
|
{
|
||||||
Instr i;
|
Instr i;
|
||||||
|
|
||||||
|
@ -1194,7 +1194,7 @@ powerinstlen(Map *map, ulong pc)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
powerfoll(Map *map, Regs *regs, ulong pc, ulong *foll)
|
powerfoll(Map *map, Regs *regs, u64int pc, u64int *foll)
|
||||||
{
|
{
|
||||||
char *reg;
|
char *reg;
|
||||||
Instr i;
|
Instr i;
|
||||||
|
@ -1337,7 +1337,7 @@ static char *powerwindregs[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
powerunwind(Map *map, Regs *regs, ulong *next, Symbol *sym)
|
powerunwind(Map *map, Regs *regs, u64int *next, Symbol *sym)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This is tremendously hard. The best we're going to
|
* This is tremendously hard. The best we're going to
|
||||||
|
|
|
@ -619,6 +619,9 @@ gccname(char **ps, char **pp)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
USED(p1);
|
||||||
|
USED(p0);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
*ps = s;
|
*ps = s;
|
||||||
*pp = p;
|
*pp = p;
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <mach.h>
|
#include <mach.h>
|
||||||
|
|
||||||
static int fdrw(Map*, Seg*, ulong, void*, uint, int);
|
static int fdrw(Map*, Seg*, u64int, void*, uint, int);
|
||||||
static int zerorw(Map*, Seg*, ulong, void*, uint, int);
|
static int zerorw(Map*, Seg*, u64int, void*, uint, int);
|
||||||
static int mrw(Map*, ulong, void*, uint, int);
|
static int mrw(Map*, u64int, void*, uint, int);
|
||||||
static int datarw(Map*, Seg*, ulong, void*, uint, int);
|
static int datarw(Map*, Seg*, u64int, void*, uint, int);
|
||||||
|
|
||||||
Map*
|
Map*
|
||||||
allocmap(void)
|
allocmap(void)
|
||||||
|
@ -71,7 +71,7 @@ findseg(Map *map, char *name, char *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
addrtoseg(Map *map, ulong addr, Seg *sp)
|
addrtoseg(Map *map, u64int addr, Seg *sp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Seg *s;
|
Seg *s;
|
||||||
|
@ -93,7 +93,7 @@ addrtoseg(Map *map, ulong addr, Seg *sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
addrtosegafter(Map *map, ulong addr, Seg *sp)
|
addrtosegafter(Map *map, u64int addr, Seg *sp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Seg *s, *best;
|
Seg *s, *best;
|
||||||
|
@ -142,13 +142,13 @@ removeseg(Map *map, int i)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get1(Map *map, ulong addr, uchar *a, uint n)
|
get1(Map *map, u64int addr, uchar *a, uint n)
|
||||||
{
|
{
|
||||||
return mrw(map, addr, a, n, 1);
|
return mrw(map, addr, a, n, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get2(Map *map, ulong addr, u16int *u)
|
get2(Map *map, u64int addr, u16int *u)
|
||||||
{
|
{
|
||||||
u16int v;
|
u16int v;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ get2(Map *map, ulong addr, u16int *u)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get4(Map *map, ulong addr, u32int *u)
|
get4(Map *map, u64int addr, u32int *u)
|
||||||
{
|
{
|
||||||
u32int v;
|
u32int v;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ get4(Map *map, ulong addr, u32int *u)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get8(Map *map, ulong addr, u64int *u)
|
get8(Map *map, u64int addr, u64int *u)
|
||||||
{
|
{
|
||||||
u64int v;
|
u64int v;
|
||||||
|
|
||||||
|
@ -181,34 +181,47 @@ get8(Map *map, ulong addr, u64int *u)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
put1(Map *map, ulong addr, uchar *a, uint n)
|
geta(Map *map, u64int addr, u64int *u)
|
||||||
|
{
|
||||||
|
u32int v;
|
||||||
|
|
||||||
|
if(machcpu == &machamd64)
|
||||||
|
return get8(map, addr, u);
|
||||||
|
if(get4(map, addr, &v) < 0)
|
||||||
|
return -1;
|
||||||
|
*u = v;
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
put1(Map *map, u64int addr, uchar *a, uint n)
|
||||||
{
|
{
|
||||||
return mrw(map, addr, a, n, 0);
|
return mrw(map, addr, a, n, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
put2(Map *map, ulong addr, u16int u)
|
put2(Map *map, u64int addr, u16int u)
|
||||||
{
|
{
|
||||||
u = mach->swap2(u);
|
u = mach->swap2(u);
|
||||||
return mrw(map, addr, &u, 2, 0);
|
return mrw(map, addr, &u, 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
put4(Map *map, ulong addr, u32int u)
|
put4(Map *map, u64int addr, u32int u)
|
||||||
{
|
{
|
||||||
u = mach->swap4(u);
|
u = mach->swap4(u);
|
||||||
return mrw(map, addr, &u, 4, 0);
|
return mrw(map, addr, &u, 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
put8(Map *map, ulong addr, u64int u)
|
put8(Map *map, u64int addr, u64int u)
|
||||||
{
|
{
|
||||||
u = mach->swap8(u);
|
u = mach->swap8(u);
|
||||||
return mrw(map, addr, &u, 8, 0);
|
return mrw(map, addr, &u, 8, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Seg*
|
static Seg*
|
||||||
reloc(Map *map, ulong addr, uint n, ulong *off, uint *nn)
|
reloc(Map *map, u64int addr, uint n, u64int *off, uint *nn)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
ulong o;
|
ulong o;
|
||||||
|
@ -236,12 +249,12 @@ reloc(Map *map, ulong addr, uint n, ulong *off, uint *nn)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mrw(Map *map, ulong addr, void *a, uint n, int r)
|
mrw(Map *map, u64int addr, void *a, uint n, int r)
|
||||||
{
|
{
|
||||||
uint nn;
|
uint nn;
|
||||||
uint tot;
|
uint tot;
|
||||||
Seg *s;
|
Seg *s;
|
||||||
ulong off;
|
u64int off;
|
||||||
|
|
||||||
for(tot=0; tot<n; tot+=nn){
|
for(tot=0; tot<n; tot+=nn){
|
||||||
s = reloc(map, addr+tot, n-tot, &off, &nn);
|
s = reloc(map, addr+tot, n-tot, &off, &nn);
|
||||||
|
@ -254,7 +267,7 @@ mrw(Map *map, ulong addr, void *a, uint n, int r)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fdrw(Map *map, Seg *seg, ulong addr, void *a, uint n, int r)
|
fdrw(Map *map, Seg *seg, u64int addr, void *a, uint n, int r)
|
||||||
{
|
{
|
||||||
int nn;
|
int nn;
|
||||||
uint tot;
|
uint tot;
|
||||||
|
@ -279,7 +292,7 @@ fdrw(Map *map, Seg *seg, ulong addr, void *a, uint n, int r)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
zerorw(Map *map, Seg *seg, ulong addr, void *a, uint n, int r)
|
zerorw(Map *map, Seg *seg, u64int addr, void *a, uint n, int r)
|
||||||
{
|
{
|
||||||
USED(map);
|
USED(map);
|
||||||
USED(seg);
|
USED(seg);
|
||||||
|
@ -294,7 +307,7 @@ zerorw(Map *map, Seg *seg, ulong addr, void *a, uint n, int r)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
datarw(Map *map, Seg *seg, ulong addr, void *a, uint n, int r)
|
datarw(Map *map, Seg *seg, u64int addr, void *a, uint n, int r)
|
||||||
{
|
{
|
||||||
USED(map);
|
USED(map);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ OFILES=\
|
||||||
elf.$O\
|
elf.$O\
|
||||||
elfdl386.$O\
|
elfdl386.$O\
|
||||||
elfcorefreebsd386.$O\
|
elfcorefreebsd386.$O\
|
||||||
|
elfcorefreebsdamd64.$O\
|
||||||
elfcorelinux386.$O\
|
elfcorelinux386.$O\
|
||||||
frame.$O\
|
frame.$O\
|
||||||
fpformat.$O\
|
fpformat.$O\
|
||||||
|
@ -28,6 +29,7 @@ OFILES=\
|
||||||
loc.$O\
|
loc.$O\
|
||||||
localaddr.$O\
|
localaddr.$O\
|
||||||
mach386.$O\
|
mach386.$O\
|
||||||
|
machamd64.$O\
|
||||||
macho.$O\
|
macho.$O\
|
||||||
machocorepower.$O\
|
machocorepower.$O\
|
||||||
machpower.$O\
|
machpower.$O\
|
||||||
|
|
|
@ -14,7 +14,7 @@ regdesc(char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rput(Regs *regs, char *name, ulong u)
|
rput(Regs *regs, char *name, u64int u)
|
||||||
{
|
{
|
||||||
if(regs == nil){
|
if(regs == nil){
|
||||||
werrstr("registers not mapped");
|
werrstr("registers not mapped");
|
||||||
|
@ -24,7 +24,7 @@ rput(Regs *regs, char *name, ulong u)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rget(Regs *regs, char *name, ulong *u)
|
rget(Regs *regs, char *name, u64int *u)
|
||||||
{
|
{
|
||||||
if(regs == nil){
|
if(regs == nil){
|
||||||
*u = ~(ulong)0;
|
*u = ~(ulong)0;
|
||||||
|
@ -35,7 +35,7 @@ rget(Regs *regs, char *name, ulong *u)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_uregrw(Regs *regs, char *name, ulong *u, int isr)
|
_uregrw(Regs *regs, char *name, u64int *u, int isr)
|
||||||
{
|
{
|
||||||
Regdesc *r;
|
Regdesc *r;
|
||||||
uchar *ureg;
|
uchar *ureg;
|
||||||
|
|
|
@ -69,7 +69,7 @@ findhdr(char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pc2file(ulong pc, char *file, uint nfile, ulong *line)
|
pc2file(u64int pc, char *file, uint nfile, ulong *line)
|
||||||
{
|
{
|
||||||
Fhdr *p;
|
Fhdr *p;
|
||||||
|
|
||||||
|
@ -81,14 +81,14 @@ pc2file(ulong pc, char *file, uint nfile, ulong *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pc2line(ulong pc, ulong *line)
|
pc2line(u64int pc, ulong *line)
|
||||||
{
|
{
|
||||||
char tmp[10]; /* just in case */
|
char tmp[10]; /* just in case */
|
||||||
return pc2file(pc, tmp, sizeof tmp, line);
|
return pc2file(pc, tmp, sizeof tmp, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
file2pc(char *file, ulong line, ulong *addr)
|
file2pc(char *file, ulong line, u64int *addr)
|
||||||
{
|
{
|
||||||
Fhdr *p;
|
Fhdr *p;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ file2pc(char *file, ulong line, ulong *addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
line2pc(ulong basepc, ulong line, ulong *pc)
|
line2pc(u64int basepc, ulong line, u64int *pc)
|
||||||
{
|
{
|
||||||
Fhdr *p;
|
Fhdr *p;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ line2pc(ulong basepc, ulong line, ulong *pc)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fnbound(ulong pc, ulong *bounds)
|
fnbound(u64int pc, u64int *bounds)
|
||||||
{
|
{
|
||||||
Fhdr *p;
|
Fhdr *p;
|
||||||
Loc l;
|
Loc l;
|
||||||
|
@ -143,7 +143,7 @@ fnbound(ulong pc, ulong *bounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fileline(ulong pc, char *a, uint n)
|
fileline(u64int pc, char *a, uint n)
|
||||||
{
|
{
|
||||||
ulong line;
|
ulong line;
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ findlsym(Symbol *s1, Loc loc, Symbol *s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
unwindframe(Map *map, Regs *regs, ulong *next, Symbol *sym)
|
unwindframe(Map *map, Regs *regs, u64int *next, Symbol *sym)
|
||||||
{
|
{
|
||||||
Fhdr *p;
|
Fhdr *p;
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ unwindframe(Map *map, Regs *regs, ulong *next, Symbol *sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
symoff(char *a, uint n, ulong addr, uint class)
|
symoff(char *a, uint n, u64int addr, uint class)
|
||||||
{
|
{
|
||||||
Loc l;
|
Loc l;
|
||||||
Symbol s;
|
Symbol s;
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
#include "dwarf.h"
|
#include "dwarf.h"
|
||||||
|
|
||||||
static void dwarfsymclose(Fhdr*);
|
static void dwarfsymclose(Fhdr*);
|
||||||
static int dwarfpc2file(Fhdr*, ulong, char*, uint, ulong*);
|
static int dwarfpc2file(Fhdr*, u64int, char*, uint, ulong*);
|
||||||
static int dwarfline2pc(Fhdr*, ulong, ulong, ulong*);
|
static int dwarfline2pc(Fhdr*, u64int, ulong, u64int*);
|
||||||
static int dwarflookuplsym(Fhdr*, Symbol*, char*, Symbol*);
|
static int dwarflookuplsym(Fhdr*, Symbol*, char*, Symbol*);
|
||||||
static int dwarfindexlsym(Fhdr*, Symbol*, uint, Symbol*);
|
static int dwarfindexlsym(Fhdr*, Symbol*, uint, Symbol*);
|
||||||
static int dwarffindlsym(Fhdr*, Symbol*, Loc, Symbol*);
|
static int dwarffindlsym(Fhdr*, Symbol*, Loc, Symbol*);
|
||||||
static void dwarfsyminit(Fhdr*);
|
static void dwarfsyminit(Fhdr*);
|
||||||
static int dwarftosym(Fhdr*, Dwarf*, DwarfSym*, Symbol*, int);
|
static int dwarftosym(Fhdr*, Dwarf*, DwarfSym*, Symbol*, int);
|
||||||
static int _dwarfunwind(Fhdr *fhdr, Map *map, Regs *regs, ulong *next, Symbol*);
|
static int _dwarfunwind(Fhdr *fhdr, Map *map, Regs *regs, u64int *next, Symbol*);
|
||||||
|
|
||||||
int
|
int
|
||||||
symdwarf(Fhdr *hdr)
|
symdwarf(Fhdr *hdr)
|
||||||
|
@ -43,7 +43,7 @@ dwarfsymclose(Fhdr *hdr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dwarfpc2file(Fhdr *fhdr, ulong pc, char *buf, uint nbuf, ulong *line)
|
dwarfpc2file(Fhdr *fhdr, u64int pc, char *buf, uint nbuf, ulong *line)
|
||||||
{
|
{
|
||||||
char *cdir, *dir, *file;
|
char *cdir, *dir, *file;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ dwarfpc2file(Fhdr *fhdr, ulong pc, char *buf, uint nbuf, ulong *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dwarfline2pc(Fhdr *fhdr, ulong basepc, ulong line, ulong *pc)
|
dwarfline2pc(Fhdr *fhdr, u64int basepc, ulong line, u64int *pc)
|
||||||
{
|
{
|
||||||
werrstr("dwarf line2pc not implemented");
|
werrstr("dwarf line2pc not implemented");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -323,11 +323,11 @@ dwarftosym(Fhdr *fp, Dwarf *d, DwarfSym *ds, Symbol *s, int infn)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dwarfeval(Dwarf *d, Map *map, Regs *regs, ulong cfa, int rno, DwarfExpr e, ulong *u)
|
dwarfeval(Dwarf *d, Map *map, Regs *regs, ulong cfa, int rno, DwarfExpr e, u64int *u)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
u32int u4;
|
u32int u4;
|
||||||
ulong uu;
|
u64int uu;
|
||||||
|
|
||||||
switch(e.type){
|
switch(e.type){
|
||||||
case RuleUndef:
|
case RuleUndef:
|
||||||
|
@ -396,11 +396,11 @@ dwarfexprfmt(Fmt *fmt)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_dwarfunwind(Fhdr *fhdr, Map *map, Regs *regs, ulong *next, Symbol *sym)
|
_dwarfunwind(Fhdr *fhdr, Map *map, Regs *regs, u64int *next, Symbol *sym)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
int i, j;
|
int i, j;
|
||||||
ulong cfa, pc, u;
|
u64int cfa, pc, u;
|
||||||
Dwarf *d;
|
Dwarf *d;
|
||||||
DwarfExpr *e, epc, ecfa;
|
DwarfExpr *e, epc, ecfa;
|
||||||
|
|
||||||
|
|
|
@ -254,6 +254,7 @@ stabssyminit(Fhdr *fp)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
USED(locals);
|
||||||
free(inc);
|
free(inc);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -263,7 +264,7 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
stabspc2file(Fhdr *fhdr, ulong pc, char *buf, uint nbuf, ulong *pline)
|
stabspc2file(Fhdr *fhdr, u64int pc, char *buf, uint nbuf, ulong *pline)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Symbol *s;
|
Symbol *s;
|
||||||
|
@ -298,7 +299,7 @@ stabspc2file(Fhdr *fhdr, ulong pc, char *buf, uint nbuf, ulong *pline)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
stabsline2pc(Fhdr *fhdr, ulong startpc, ulong line, ulong *pc)
|
stabsline2pc(Fhdr *fhdr, u64int startpc, ulong line, u64int *pc)
|
||||||
{
|
{
|
||||||
int i, trigger;
|
int i, trigger;
|
||||||
Symbol *s;
|
Symbol *s;
|
||||||
|
|
58
src/libmach/uregamd64.h
Normal file
58
src/libmach/uregamd64.h
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
// Inferno utils/libmach/ureg6.h
|
||||||
|
// http://code.google.com/p/inferno-os/source/browse/utils/libmach/ureg6.h
|
||||||
|
//
|
||||||
|
// Copyright © 1994-1999 Lucent Technologies Inc.
|
||||||
|
// Power PC support Copyright © 1995-2004 C H Forsyth (forsyth@terzarima.net).
|
||||||
|
// Portions Copyright © 1997-1999 Vita Nuova Limited.
|
||||||
|
// Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com).
|
||||||
|
// Revisions Copyright © 2000-2004 Lucent Technologies Inc. and others.
|
||||||
|
// Portions Copyright © 2009 The Go Authors. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
struct Ureg {
|
||||||
|
u64int ax;
|
||||||
|
u64int bx;
|
||||||
|
u64int cx;
|
||||||
|
u64int dx;
|
||||||
|
u64int si;
|
||||||
|
u64int di;
|
||||||
|
u64int bp;
|
||||||
|
u64int r8;
|
||||||
|
u64int r9;
|
||||||
|
u64int r10;
|
||||||
|
u64int r11;
|
||||||
|
u64int r12;
|
||||||
|
u64int r13;
|
||||||
|
u64int r14;
|
||||||
|
u64int r15;
|
||||||
|
|
||||||
|
u16int ds;
|
||||||
|
u16int es;
|
||||||
|
u16int fs;
|
||||||
|
u16int gs;
|
||||||
|
|
||||||
|
u64int type;
|
||||||
|
u64int error; /* error code (or zero) */
|
||||||
|
u64int ip; /* pc */
|
||||||
|
u64int cs; /* old context */
|
||||||
|
u64int flags; /* old flags */
|
||||||
|
u64int sp; /* sp */
|
||||||
|
u64int ss; /* old stack segment */
|
||||||
|
};
|
Loading…
Reference in a new issue