64-bit fixes. [rsc] --rw-rw-r-- M 451989 glenda sys 4080 Nov 6 10:02 sys/src/libmach/0.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/0.c:130,137 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/0.c:130,138 "setR30", /* static base register name */ 0, /* SB value */ 0x1000, /* page size */ - 0xC0000000, /* kernel base */ - 0x40000000, /* kernel text mask */ + 0xC0000000ULL, /* kernel base */ + 0x40000000ULL, /* kernel text mask */ + 0x7FFFFFFFULL, /* user stack top */ 4, /* quantization of pc */ 4, /* szaddr */ 8, /* szreg */ [rsc] --rw-rw-r-- M 451989 glenda sys 2074 Nov 6 10:02 sys/src/libmach/2.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2.c:75,82 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2.c:75,83 "a6base", /* static base register name */ 0, /* value */ 0x2000, /* page size */ - 0x80000000, /* kernel base */ + 0x80000000ULL, /* kernel base */ 0, /* kernel text mask */ + 0x7FFFFFFFULL, /* user stack top */ 2, /* quantization of pc */ 4, /* szaddr */ 4, /* szreg */ [rsc] --rw-rw-r-- M 451989 glenda sys 61298 Nov 6 10:03 sys/src/libmach/2db.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:9,18 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:9,18 static char *m68020excep(Map*, Rgetter); - static int m68020foll(Map*, ulong, Rgetter, ulong*); - static int m68020inst(Map*, ulong, char, char*, int); - static int m68020das(Map*, ulong, char*, int); - static int m68020instlen(Map*, ulong); + static int m68020foll(Map*, uvlong, Rgetter, uvlong*); + static int m68020inst(Map*, uvlong, char, char*, int); + static int m68020das(Map*, uvlong, char*, int); + static int m68020instlen(Map*, uvlong); Machdata m68020mach = { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:95,103 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:95,104 { struct ftype *ft; int i, size, vec; - ulong efl[2], stktop; + ulong efl[2]; uchar *ef=(uchar*)efl; - long l; + ulong l; + uvlong stktop; short fvo; /* The kernel proc pointer on a 68020 is always /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:112,118 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:113,120 if ((l&0xfc000000) == 0x04000000) /* if NeXT */ size = 30*2; else - size = 46*2; /* 68020 */ + size = 46*2; /* 68020 */ + USED(size); stktop = mach->kbase+mach->pgsize; for(i=3; i<100; i++){ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:145,151 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:147,153 static char * m68020excep(Map *map, Rgetter rget) { - ulong pc; + uvlong pc; uchar buf[4]; if (m68020ufix(map) < 0) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:381,387 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:383,389 struct inst { int n; /* # bytes in instruction */ - ulong addr; /* addr of start of instruction */ + uvlong addr; /* addr of start of instruction */ ushort raw[4+12]; /* longest instruction: 24 byte packed immediate */ Operand and[2]; char *end; /* end of print buffer */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:906,912 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:908,914 } static int - getword(Inst *ip, long offset) + getword(Inst *ip, uvlong offset) { if (ip->n < nelem(ip->raw)) { if (get2(mymap, offset, &ip->raw[ip->n++]) > 0) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:1314,1320 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:1316,1322 plocal(Inst *ip, Operand *ap) { int ret, offset; - long moved; + uvlong moved; Symbol s; offset = ap->disp; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:1979,1985 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:1981,1987 } static int - m68020instlen(Map *map, ulong pc) + m68020instlen(Map *map, uvlong pc) { Inst i; Optable *op; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:1994,2003 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:1996,2006 } static int - m68020foll(Map *map, ulong pc, Rgetter rget, ulong *foll) + m68020foll(Map *map, uvlong pc, Rgetter rget, uvlong *foll) { int j; Inst i; + ulong l; Optable *op; mymap = map; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:2019,2026 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:2022,2030 foll[1] = pc+2+i.and[j].immediate; return 2; case STACK: /* RTR, RTS, RTD */ - if (get4(map, (*rget)(map, mach->sp), (long*) foll) < 0) + if (get4(map, (*rget)(map, mach->sp), &l) < 0) return -1; + *foll = l; return 1; default: break; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:2031,2037 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:2035,2041 } static int - m68020inst(Map *map, ulong pc, char modifier, char *buf, int n) + m68020inst(Map *map, uvlong pc, char modifier, char *buf, int n) { Inst i; Optable *op; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:2057,2063 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:2061,2067 } static int - m68020das(Map *map, ulong pc, char *buf, int n) + m68020das(Map *map, uvlong pc, char *buf, int n) { Inst i; Optable *op; [rsc] --rw-rw-r-- M 451989 glenda sys 1553 Nov 6 10:03 sys/src/libmach/5.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5.c:53,60 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5.c:53,61 "setR12", /* static base register name */ 0, /* static base register value */ 0x1000, /* page size */ - 0xC0000000, /* kernel base */ + 0xC0000000ULL, /* kernel base */ 0, /* kernel text mask */ + 0x7FFFFFFFULL, /* user stack top */ 4, /* quantization of pc */ 4, /* szaddr */ 4, /* szreg */ [rsc] --rw-rw-r-- M 451989 glenda sys 21545 Nov 6 10:03 sys/src/libmach/5db.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:18,24 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:18,24 { Map *map; ulong w; - ulong addr; + uvlong addr; uchar op; /* super opcode */ uchar cond; /* bits 28-31 */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:39,45 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:39,45 { char* o; void (*fmt)(Opcode*, Instr*); - ulong (*foll)(Map*, Rgetter, Instr*, ulong); + uvlong (*foll)(Map*, Rgetter, Instr*, uvlong); char* a; }; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:51,60 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:51,60 */ static char *armexcep(Map*, Rgetter); - static int armfoll(Map*, ulong, Rgetter, ulong*); - static int arminst(Map*, ulong, char, char*, int); - static int armdas(Map*, ulong, char*, int); - static int arminstlen(Map*, ulong); + static int armfoll(Map*, uvlong, Rgetter, uvlong*); + static int arminst(Map*, uvlong, char, char*, int); + static int armdas(Map*, uvlong, char*, int); + static int arminstlen(Map*, uvlong); /* * Debugger interface /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:82,91 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:82,91 static char* armexcep(Map *map, Rgetter rget) { - long c; + uvlong c; c = (*rget)(map, "TYPE"); - switch (c&0x1f) { + switch ((int)c&0x1f) { case 0x11: return "Fiq interrupt"; case 0x12: /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:196,204 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:196,204 } static int - decode(Map *map, ulong pc, Instr *i) + decode(Map *map, uvlong pc, Instr *i) { - long w; + ulong w; if(get4(map, pc, &w) < 0) { werrstr("can't read instruction: %r"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:232,238 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:232,238 int offset; if(!findsym(i->addr, CTEXT, &s)) { - if(debug)fprint(2,"fn not found @%lux: %r\n", i->addr); + if(debug)fprint(2,"fn not found @%llux: %r\n", i->addr); return 0; } fn = s.name; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:460,466 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:460,466 static int armcondpass(Map *map, Rgetter rget, uchar cond) { - ulong psr; + uvlong psr; uchar n; uchar z; uchar c; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:591,597 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:591,597 } } - static ulong + static uvlong armaddr(Map *map, Rgetter rget, Instr *i) { char buf[8]; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:637,644 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:637,644 } } - static ulong - armfadd(Map *map, Rgetter rget, Instr *i, ulong pc) + static uvlong + armfadd(Map *map, Rgetter rget, Instr *i, uvlong pc) { char buf[8]; int r; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:653,660 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:653,660 return rget(map, buf) + armshiftval(map, rget, i); } - static ulong - armfmovm(Map *map, Rgetter rget, Instr *i, ulong pc) + static uvlong + armfmovm(Map *map, Rgetter rget, Instr *i, uvlong pc) { ulong v; ulong addr; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:664,670 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:664,670 return pc+4; addr = armmaddr(map, rget, i) + nbits(i->w & BITS(0,15)); - if(get4(map, addr, (long*)&v) < 0) { + if(get4(map, addr, &v) < 0) { werrstr("can't read addr: %r"); return -1; } /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:671,678 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:671,678 return v; } - static ulong - armfbranch(Map *map, Rgetter rget, Instr *i, ulong pc) + static uvlong + armfbranch(Map *map, Rgetter rget, Instr *i, uvlong pc) { if(!armcondpass(map, rget, (i->w >> 28) & 0xf)) return pc+4; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:680,690 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:680,689 return pc + (((signed long)i->w << 8) >> 6) + 8; } - static ulong - armfmov(Map *map, Rgetter rget, Instr *i, ulong pc) + static uvlong + armfmov(Map *map, Rgetter rget, Instr *i, uvlong pc) { - ulong rd; - ulong v; + ulong rd, v; rd = (i->w >> 12) & 0xf; if(rd != 15 || !armcondpass(map, rget, (i->w>>28)&0xf)) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:693,699 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:692,698 /* LDR */ /* BUG: Needs LDH/B, too */ if((i->w>>26)&0x3 == 1) { - if(get4(map, armaddr(map, rget, i), (long*)&v) < 0) { + if(get4(map, armaddr(map, rget, i), &v) < 0) { werrstr("can't read instruction: %r"); return pc+4; } /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:910,916 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:909,915 fmt = "#%lx(R%d)"; if (i->rn == 15) { /* convert load of offset(PC) to a load immediate */ - if (get4(i->map, i->addr+i->imm+8, &i->imm) > 0) + if (get4(i->map, i->addr+i->imm+8, (ulong*)&i->imm) > 0) { g = 1; fmt = ""; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:921,927 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:920,926 if (i->rd == 11) { ulong nxti; - if (get4(i->map, i->addr+4, (long*)&nxti) > 0) { + if (get4(i->map, i->addr+4, &nxti) > 0) { if ((nxti & 0x0e0f0fff) == 0x060c000b) { i->imm += mach->sb; g = 1; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:1007,1013 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:1006,1012 } static int - printins(Map *map, ulong pc, char *buf, int n) + printins(Map *map, uvlong pc, char *buf, int n) { Instr i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:1021,1027 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:1020,1026 } static int - arminst(Map *map, ulong pc, char modifier, char *buf, int n) + arminst(Map *map, uvlong pc, char modifier, char *buf, int n) { USED(modifier); return printins(map, pc, buf, n); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:1028,1034 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:1027,1033 } static int - armdas(Map *map, ulong pc, char *buf, int n) + armdas(Map *map, uvlong pc, char *buf, int n) { Instr i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:1043,1049 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:1042,1048 } static int - arminstlen(Map *map, ulong pc) + arminstlen(Map *map, uvlong pc) { Instr i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:1053,1061 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:1052,1060 } static int - armfoll(Map *map, ulong pc, Rgetter rget, ulong *foll) + armfoll(Map *map, uvlong pc, Rgetter rget, uvlong *foll) { - ulong d; + uvlong d; Instr i; if(decode(map, pc, &i) < 0) [rsc] --rw-rw-r-- M 451989 jmk sys 3464 Nov 6 10:03 sys/src/libmach/6.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/6.c:2,17 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/6.c:2,14 * amd64 definition */ #include + #include #include #include "/amd64/include/ureg.h" #include - #define REGOFF(x) (uvlong)(&((struct Ureg *) 0)->x) + #define REGOFF(x) offsetof(struct Ureg, x) - #define PC REGOFF(ip) - #define SP REGOFF(sp) - #define AX REGOFF(ax) - #define REGSIZE sizeof(struct Ureg) #define FP_CTLS(x) (REGSIZE+2*(x)) #define FP_CTL(x) (REGSIZE+4*(x)) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/6.c:26,32 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/6.c:23,29 {"CX", REGOFF(cx), RINT, 'Y'}, {"DX", REGOFF(dx), RINT, 'Y'}, {"SI", REGOFF(si), RINT, 'Y'}, - {"DI", REGOFF(di), RINT, 'X'}, + {"DI", REGOFF(di), RINT, 'Y'}, {"BP", REGOFF(bp), RINT, 'Y'}, {"R8", REGOFF(r8), RINT, 'Y'}, {"R9", REGOFF(r9), RINT, 'Y'}, /n/sourcesdump/2005/1106/plan9/sys/src/libmach/6.c:41,61 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/6.c:38,60 {"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'}, - {"PC", PC, 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", SP, 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, 'x'}, + {"FTW", FP_CTLS(2), RFLT, 'b'}, {"FOP", FP_CTLS(3), RFLT, 'x'}, - {"FPC", FP_CTL(2), RFLT, 'Y'}, + {"RIP", FP_CTL(2), RFLT, 'Y'}, {"RDP", FP_CTL(4), RFLT, 'Y'}, {"MXCSR", FP_CTL(6), RFLT, 'X'}, - {"MXCSRMSK", FP_CTL(7), 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'}, /n/sourcesdump/2005/1106/plan9/sys/src/libmach/6.c:97,117 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/6.c:96,117 Mach mamd64= { "amd64", - MI386, /* machine type */ /* TO DO */ - amd64reglist, /* register list */ - REGSIZE, /* size of registers in bytes */ - FPREGSIZE, /* size of fp registers in bytes */ - "PC", /* name of PC */ - "SP", /* name of SP */ - 0, /* link register */ - "setSB", /* static base register name (bogus anyways) */ - 0, /* static base register value */ - 0x1000, /* page size */ - 0x80110000, /* kernel base */ /* TO DO: uvlong or vlong */ - 0, /* kernel text mask */ - 1, /* quantization of pc */ - 8, /* szaddr */ - 4, /* szreg */ - 4, /* szfloat */ - 8, /* szdouble */ + 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 */ + 0, /* link register */ + "setSB", /* static base register name (bogus anyways) */ + 0, /* static base register value */ + 0x1000, /* page size */ + 0xFFFFFFFF80110000ULL, /* kernel base */ + 0, /* kernel text mask */ + 0x00007FFFFFFFF000ULL, /* user stack top */ + 1, /* quantization of pc */ + 8, /* szaddr */ + 4, /* szreg */ + 4, /* szfloat */ + 8, /* szdouble */ }; [rsc] --rw-rw-r-- M 451989 glenda sys 3299 Nov 6 10:03 sys/src/libmach/7.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7.c:103,110 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7.c:103,111 "setSB", /* static base register name */ 0, /* static base register value */ 0x2000, /* page size */ - 0x80000000, /* kernel base */ - 0x00000000, /* kernel text mask */ + 0x80000000ULL, /* kernel base */ + 0, /* kernel text mask */ + 0x7FFFFFFFULL, /* user stack top */ 4, /* quantization of pc */ 4, /* szaddr */ 8, /* szreg (not used?) */ [rsc] --rw-rw-r-- M 451989 glenda sys 17330 Nov 6 10:03 sys/src/libmach/7db.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:7,16 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:7,16 */ static char *alphaexcep(Map*, Rgetter); - static int alphafoll(Map*, ulong, Rgetter, ulong*); - static int alphainst(Map*, ulong, char, char*, int); - static int alphadas(Map*, ulong, char*, int); - static int alphainstlen(Map*, ulong); + static int alphafoll(Map*, uvlong, Rgetter, uvlong*); + static int alphainst(Map*, uvlong, char, char*, int); + static int alphadas(Map*, uvlong, char*, int); + static int alphainstlen(Map*, uvlong); /* * Debugger interface */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:86,92 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:86,92 static char FRAMENAME[] = ".frame"; typedef struct { - ulong addr; + uvlong addr; uchar op; /* bits 31-26 */ uchar ra; /* bits 25-21 */ uchar rb; /* bits 20-16 */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:109,117 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:109,117 static Map *mymap; static int - decode(ulong pc, Instr *i) + decode(uvlong pc, Instr *i) { - long w; + ulong w; if (get4(mymap, pc, &w) < 0) { werrstr("can't read instruction: %r"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:140,146 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:140,146 } static int - mkinstr(ulong pc, Instr *i) + mkinstr(uvlong pc, Instr *i) { /* Instr x; */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:397,406 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:397,406 "OPC07", 0, alphaxxx, "MOVQA", load, alphaload, "MOVQAH", load, alphaload, - "MOVBU", load, alphaload, /* v 3 */ + "MOVBU", load, alphaload, /* v 3 */ "MOVQU", load, alphaload, "MOVWU", load, alphaload, /* v 3 */ - "MOVWU", store, alphastore, /* v 3 */ + "MOVWU", store, alphastore, /* v 3 */ "MOVBU", store, alphastore, /* v 3 */ "MOVQU", store, alphastore, 0, 0, 0, /* int arith */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:412,424 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:412,424 0, 0, 0, /* ieee */ 0, 0, 0, /* fp */ 0, misc, alphaxxx, - "PAL19 [HW_MFPR]", 0, alphaxxx, + "PAL19 [HW_MFPR]",0, alphaxxx, "JSR", jmp, 0, - "PAL1B [HW_LD]", 0, alphaxxx, + "PAL1B [HW_LD]",0, alphaxxx, "OPC1C", 0, alphaxxx, - "PAL1D [HW_MTPR]", 0, alphaxxx, - "PAL1E [HW_REI]", 0, alphaxxx, - "PAL1F [HW_ST]", 0, alphaxxx, + "PAL1D [HW_MTPR]",0, alphaxxx, + "PAL1E [HW_REI]",0, alphaxxx, + "PAL1F [HW_ST]",0, alphaxxx, "MOVF", loadf, alphafload, "MOVG", loadf, alphafload, "MOVS", loadf, alphafload, /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:804,810 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:804,810 } static int - printins(Map *map, ulong pc, char *buf, int n) + printins(Map *map, uvlong pc, char *buf, int n) { Instr i; Opcode *o; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:855,861 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:855,861 } static int - alphainst(Map *map, ulong pc, char modifier, char *buf, int n) + alphainst(Map *map, uvlong pc, char modifier, char *buf, int n) { USED(modifier); return printins(map, pc, buf, n); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:862,868 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:862,868 } static int - alphadas(Map *map, ulong pc, char *buf, int n) + alphadas(Map *map, uvlong pc, char *buf, int n) { Instr i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:882,888 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:882,888 } static int - alphainstlen(Map *map, ulong pc) + alphainstlen(Map *map, uvlong pc) { Instr i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:893,899 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:893,899 } static int - alphafoll(Map *map, ulong pc, Rgetter rget, ulong *foll) + alphafoll(Map *map, uvlong pc, Rgetter rget, uvlong *foll) { char buf[8]; Instr i; [rsc] --rw-rw-r-- M 451989 glenda sys 2060 Nov 6 10:03 sys/src/libmach/8.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8.c:68,75 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8.c:68,76 "setSB", /* static base register name (bogus anyways) */ 0, /* static base register value */ 0x1000, /* page size */ - 0x80100000, /* kernel base */ + 0x80100000ULL, /* kernel base */ 0, /* kernel text mask */ + 0x7FFFFFFFULL, /* user stack top */ 1, /* quantization of pc */ 4, /* szaddr */ 4, /* szreg */ [rsc] --rw-rw-r-- M 451989 glenda sys 50612 Nov 6 10:03 sys/src/libmach/8db.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:10,21 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:10,21 static char *i386excep(Map*, Rgetter); - static int i386trace(Map*, ulong, ulong, ulong, Tracer); - static ulong i386frame(Map*, ulong, ulong, ulong, ulong); - static int i386foll(Map*, ulong, Rgetter, ulong*); - static int i386inst(Map*, ulong, char, char*, int); - static int i386das(Map*, ulong, char*, int); - static int i386instlen(Map*, ulong); + static int i386trace(Map*, uvlong, uvlong, uvlong, Tracer); + static uvlong i386frame(Map*, uvlong, uvlong, uvlong, uvlong); + static int i386foll(Map*, uvlong, Rgetter, uvlong*); + static int i386inst(Map*, uvlong, char, char*, int); + static int i386das(Map*, uvlong, char*, int); + static int i386instlen(Map*, uvlong); static char STARTSYM[] = "_main"; static char PROFSYM[] = "_mainp"; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:74,80 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:74,80 i386excep(Map *map, Rgetter rget) { ulong c; - ulong pc; + uvlong pc; static char buf[16]; c = (*rget)(map, "TRAP"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:85,91 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:85,91 if (memcmp(buf, machdata->bpinst, machdata->bpsize) == 0) return "breakpoint"; } - sprint(buf, "exception %ld", c); + snprint(buf, sizeof(buf), "exception %ld", c); return buf; } else return excname[c]; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:92,101 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:92,101 } static int - i386trace(Map *map, ulong pc, ulong sp, ulong link, Tracer trace) + i386trace(Map *map, uvlong pc, uvlong sp, uvlong link, Tracer trace) { int i; - ulong osp; + uvlong osp; Symbol s, f; USED(link); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:115,121 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:115,121 sp += f.value-mach->szaddr; } - if (get4(map, sp, (long *) &pc) < 0) + if (geta(map, sp, &pc) < 0) break; if(pc == 0) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:130,137 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:130,137 return i; } - static ulong - i386frame(Map *map, ulong addr, ulong pc, ulong sp, ulong link) + static uvlong + i386frame(Map *map, uvlong addr, uvlong pc, uvlong sp, uvlong link) { Symbol s, f; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:149,155 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:149,155 if (s.value == addr) return sp; - if (get4(map, sp, (long *)&pc) < 0) + if (geta(map, sp, &pc) < 0) break; sp += mach->szaddr; } /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:165,177 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:165,177 struct Instr { uchar mem[1+1+1+1+2+1+1+4+4]; /* raw instruction */ - ulong addr; /* address of start of instruction */ + uvlong addr; /* address of start of instruction */ int n; /* number of bytes in instruction */ char *prefix; /* instr prefix */ char *segment; /* segment override */ uchar jumptype; /* set to the operand type for jump/ret/call */ uchar amd64; - uchar rex; /* REX prefix (or zero) */ + uchar rex; /* REX prefix (or zero) */ char osize; /* 'W' or 'L' (or 'Q' on amd64) */ char asize; /* address size 'W' or 'L' (or 'Q' or amd64) */ uchar mod; /* bits 6-7 of mod r/m field */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:179,191 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:179,191 char ss; /* bits 6-7 of SIB */ char index; /* bits 3-5 of SIB */ char base; /* bits 0-2 of SIB */ - char rip; /* RIP-relative in amd64 mode */ - uchar opre; /* f2/f3 could introduce media */ + char rip; /* RIP-relative in amd64 mode */ + uchar opre; /* f2/f3 could introduce media */ short seg; /* segment of far address */ ulong disp; /* displacement */ ulong imm; /* immediate */ ulong imm2; /* second immediate operand */ - uvlong imm64; /* big immediate */ + uvlong imm64; /* big immediate */ char *curr; /* fill level in output buffer */ char *end; /* end of output buffer */ char *err; /* error message */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:215,221 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:215,221 /* amd64 rex extension byte */ enum{ - REXW = 1<<3, /* =1, 64-bit operand size */ + REXW = 1<<3, /* =1, 64-bit operand size */ REXR = 1<<2, /* extend modrm reg */ REXX = 1<<1, /* extend sib index */ REXB = 1<<0 /* extend modrm r/m, sib base, or opcode reg */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:255,261 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:255,261 Iw, /* 16-bit immediate -> imm */ Iw2, /* 16-bit immediate -> imm2 */ Iwd, /* Operand-sized immediate (no sign extension)*/ - Iwdq, /* Operand-sized immediate, possibly 64 bits */ + Iwdq, /* Operand-sized immediate, possibly 64 bits */ Awd, /* Address offset */ Iwds, /* Operand-sized immediate (sign extended) */ RM, /* Word or long R/M field with register (/r) */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:273,281 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:273,281 OA, /* literal 0x0a byte */ PTR, /* Seg:Displacement addr (ptr16:16 or ptr16:32) */ AUX, /* Multi-byte op code - Auxiliary table */ - AUXMM, /* multi-byte op code - auxiliary table chosen by prefix */ + AUXMM, /* multi-byte op code - auxiliary table chosen by prefix */ PRE, /* Instr Prefix */ - OPRE, /* Instr Prefix or media op extension */ + OPRE, /* Instr Prefix or media op extension */ SEG, /* Segment Prefix */ OPOVER, /* Operand size override */ ADDOVER, /* Address size override */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:299,305 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:299,305 [0x03] 0,0, "MOVL %e,IDTR", [0x04] 0,0, "MOVW MSW,%e", /* word */ [0x06] 0,0, "MOVW %e,MSW", /* word */ - [0x07] 0,0, "INVLPG %e", /* TO DO: distinguish SWAPGS? */ + [0x07] 0,0, "INVLPG %e", /* TO DO: distinguish SWAPGS? */ }; /* 0F71 */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:330,358 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:330,358 static Optable optab0F0F[256]= { - [0x0c] 0,0, "PI2FW %m,%M", - [0x0d] 0,0, "PI2L %m,%M", - [0x1c] 0,0, "PF2IW %m,%M", - [0x1d] 0,0, "PF2IL %m,%M", - [0x8a] 0,0, "PFNACC %m,%M", - [0x8e] 0,0, "PFPNACC %m,%M", - [0x90] 0,0, "PFCMPGE %m,%M", - [0x94] 0,0, "PFMIN %m,%M", - [0x96] 0,0, "PFRCP %m,%M", - [0x97] 0,0, "PFRSQRT %m,%M", - [0x9a] 0,0, "PFSUB %m,%M", - [0x9e] 0,0, "PFADD %m,%M", - [0xa0] 0,0, "PFCMPGT %m,%M", - [0xa4] 0,0, "PFMAX %m,%M", - [0xa6] 0,0, "PFRCPIT1 %m,%M", - [0xa7] 0,0, "PFRSQIT1 %m,%M", - [0xaa] 0,0, "PFSUBR %m,%M", - [0xae] 0,0, "PFACC %m,%M", - [0xb0] 0,0, "PFCMPEQ %m,%M", - [0xb4] 0,0, "PFMUL %m,%M", - [0xb6] 0,0, "PFRCPI2T %m,%M", - [0xb7] 0,0, "PMULHRW %m,%M", - [0xbb] 0,0, "PSWAPL %m,%M", + [0x0c] 0,0, "PI2FW %m,%M", + [0x0d] 0,0, "PI2L %m,%M", + [0x1c] 0,0, "PF2IW %m,%M", + [0x1d] 0,0, "PF2IL %m,%M", + [0x8a] 0,0, "PFNACC %m,%M", + [0x8e] 0,0, "PFPNACC %m,%M", + [0x90] 0,0, "PFCMPGE %m,%M", + [0x94] 0,0, "PFMIN %m,%M", + [0x96] 0,0, "PFRCP %m,%M", + [0x97] 0,0, "PFRSQRT %m,%M", + [0x9a] 0,0, "PFSUB %m,%M", + [0x9e] 0,0, "PFADD %m,%M", + [0xa0] 0,0, "PFCMPGT %m,%M", + [0xa4] 0,0, "PFMAX %m,%M", + [0xa6] 0,0, "PFRCPIT1 %m,%M", + [0xa7] 0,0, "PFRSQIT1 %m,%M", + [0xaa] 0,0, "PFSUBR %m,%M", + [0xae] 0,0, "PFACC %m,%M", + [0xb0] 0,0, "PFCMPEQ %m,%M", + [0xb4] 0,0, "PFMUL %m,%M", + [0xb6] 0,0, "PFRCPI2T %m,%M", + [0xb7] 0,0, "PMULHRW %m,%M", + [0xbb] 0,0, "PSWAPL %m,%M", }; static Optable optab0FC7[8]= /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:385,392 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:385,392 static Optable optab660F[256]= { [0x2B] RM,0, "MOVNTPD %x,%e", - [0x2E] RM,0, "UCOMISD %x,%X", - [0x2F] RM,0, "COMISD %x,%X", + [0x2E] RM,0, "UCOMISD %x,%X", + [0x2F] RM,0, "COMISD %x,%X", [0x5A] RM,0, "CVTPD2PS %x,%X", [0x5B] RM,0, "CVTPS2PL %x,%X", [0x6A] RM,0, "PUNPCKHLQ %x,%X", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:394,400 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:394,400 [0x6C] RM,0, "PUNPCKLQDQ %x,%X", [0x6D] RM,0, "PUNPCKHQDQ %x,%X", [0x6E] RM,0, "MOV%S %e,%X", - [0x6F] RM,0, "MOVO %x,%X", /* MOVDQA */ + [0x6F] RM,0, "MOVO %x,%X", /* MOVDQA */ [0x70] RM,Ib, "PSHUFL %i,%x,%X", [0x71] RMOP,0, optab660F71, [0x72] RMOP,0, optab660F72, /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:413,420 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:413,420 static Optable optabF20F[256]= { - [0x10] RM,0, "MOVSD %x,%X", - [0x11] RM,0, "MOVSD %X,%x", + [0x10] RM,0, "MOVSD %x,%X", + [0x11] RM,0, "MOVSD %X,%x", [0x2A] RM,0, "CVTS%S2SD %e,%X", [0x2C] RM,0, "CVTTSD2S%S %x,%r", [0x2D] RM,0, "CVTSD2S%S %x,%r", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:428,435 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:428,435 static Optable optabF30F[256]= { - [0x10] RM,0, "MOVSS %x,%X", - [0x11] RM,0, "MOVSS %X,%x", + [0x10] RM,0, "MOVSS %x,%X", + [0x11] RM,0, "MOVSS %X,%x", [0x2A] RM,0, "CVTS%S2SS %e,%X", [0x2C] RM,0, "CVTTSS2S%S %x,%r", [0x2D] RM,0, "CVTSS2S%S %x,%r", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:449,467 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:449,469 [0x01] RMOP,0, optab0F01, [0x02] RM,0, "LAR %e,%r", [0x03] RM,0, "LSL %e,%r", + [0x05] 0,0, "SYSCALL", [0x06] 0,0, "CLTS", [0x07] 0,0, "SYSRET", [0x08] 0,0, "INVD", [0x09] 0,0, "WBINVD", - [0x0F] RM,AUX, optab0F0F, /* 3DNow! */ - [0x10] RM,0, "MOVU%s %x,%X", - [0x11] RM,0, "MOVU%s %X,%x", - [0x12] RM,0, "MOV[H]L%s %x,%X", /* TO DO: H if source is XMM */ - [0x13] RM,0, "MOVL%s %X,%e", - [0x14] RM,0, "UNPCKL%s %x,%X", - [0x15] RM,0, "UNPCKH%s %x,%X", - [0x16] RM,0, "MOV[L]H%s %x,%X", /* TO DO: L if source is XMM */ - [0x17] RM,0, "MOVH%s %X,%x", + [0x0B] 0,0, "UD2", + [0x0F] RM,AUX, optab0F0F, /* 3DNow! */ + [0x10] RM,0, "MOVU%s %x,%X", + [0x11] RM,0, "MOVU%s %X,%x", + [0x12] RM,0, "MOV[H]L%s %x,%X", /* TO DO: H if source is XMM */ + [0x13] RM,0, "MOVL%s %X,%e", + [0x14] RM,0, "UNPCKL%s %x,%X", + [0x15] RM,0, "UNPCKH%s %x,%X", + [0x16] RM,0, "MOV[L]H%s %x,%X", /* TO DO: L if source is XMM */ + [0x17] RM,0, "MOVH%s %X,%x", [0x20] RMR,0, "MOVL %C,%e", [0x21] RMR,0, "MOVL %D,%e", [0x22] RMR,0, "MOVL %e,%C", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:468,481 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:470,483 [0x23] RMR,0, "MOVL %e,%D", [0x24] RMR,0, "MOVL %T,%e", [0x26] RMR,0, "MOVL %e,%T", - [0x28] RM,0, "MOVA%s %x,%X", - [0x29] RM,0, "MOVA%s %X,%x", - [0x2A] RM,0, "CVTPL2%s %m*,%X", - [0x2B] RM,0, "MOVNT%s %X,%e", - [0x2C] RM,0, "CVTT%s2PL %x,%M", - [0x2D] RM,0, "CVT%s2PL %x,%M", - [0x2E] RM,0, "UCOMISS %x,%X", - [0x2F] RM,0, "COMISS %x,%X", + [0x28] RM,0, "MOVA%s %x,%X", + [0x29] RM,0, "MOVA%s %X,%x", + [0x2A] RM,0, "CVTPL2%s %m*,%X", + [0x2B] RM,0, "MOVNT%s %X,%e", + [0x2C] RM,0, "CVTT%s2PL %x,%M", + [0x2D] RM,0, "CVT%s2PL %x,%M", + [0x2E] RM,0, "UCOMISS %x,%X", + [0x2F] RM,0, "COMISS %x,%X", [0x30] 0,0, "WRMSR", [0x31] 0,0, "RDTSC", [0x32] 0,0, "RDMSR", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:500,514 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:502,516 [0x53] RM,0, "RCP%s %x,%X", [0x54] RM,0, "AND%s %x,%X", [0x55] RM,0, "ANDN%s %x,%X", - [0x56] RM,0, "OR%s %x,%X", /* TO DO: S/D */ - [0x57] RM,0, "XOR%s %x,%X", /* S/D */ - [0x58] RM,0, "ADD%s %x,%X", /* S/P S/D */ + [0x56] RM,0, "OR%s %x,%X", /* TO DO: S/D */ + [0x57] RM,0, "XOR%s %x,%X", /* S/D */ + [0x58] RM,0, "ADD%s %x,%X", /* S/P S/D */ [0x59] RM,0, "MUL%s %x,%X", [0x5A] RM,0, "CVTPS2PD %x,%X", [0x5B] RM,0, "CVTPL2PS %x,%X", [0x5C] RM,0, "SUB%s %x,%X", [0x5D] RM,0, "MIN%s %x,%X", - [0x5E] RM,0, "DIV%s %x,%X", /* TO DO: S/P S/D */ + [0x5E] RM,0, "DIV%s %x,%X", /* TO DO: S/P S/D */ [0x5F] RM,0, "MAX%s %x,%X", [0x60] RM,0, "PUNPCKLBW %m,%M", [0x61] RM,0, "PUNPCKLWL %m,%M", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:531,537 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:533,539 [0x7E] RM,0, "MOV%S %M,%e", [0x7F] RM,0, "MOVQ %M,%m", [0xAE] RMOP,0, optab0FAE, - [0xAA] 0,0, "RSM", + [0xAA] 0,0, "RSM", [0xB0] RM,0, "CMPXCHGB %r,%e", [0xB1] RM,0, "CMPXCHG%S %r,%e", [0xC0] RMB,0, "XADDB %r,%e", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:539,544 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:541,554 [0xC2] RM,Ib, "CMP%s %i,%x,%X", [0xC3] RM,0, "MOVNTI%S %r,%e", [0xC6] RM,Ib, "SHUF%s %i,%x,%X", + [0xC8] 0,0, "BSWAP AX", + [0xC9] 0,0, "BSWAP CX", + [0xCA] 0,0, "BSWAP DX", + [0xCB] 0,0, "BSWAP BX", + [0xCC] 0,0, "BSWAP SP", + [0xCD] 0,0, "BSWAP BP", + [0xCE] 0,0, "BSWAP SI", + [0xCF] 0,0, "BSWAP DI", [0xD1] RM,0, "PSRLW %m,%M", [0xD2] RM,0, "PSRLL %m,%M", [0xD3] RM,0, "PSRLQ %m,%M", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:969,975 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:979,985 [0x0c] Ib,0, "ORB %i,AL", [0x0d] Iwd,0, "OR%S %i,%OAX", [0x0e] 0,0, "PUSHL CS", - [0x0f] AUXMM,0, optab0F, + [0x0f] AUXMM,0, optab0F, [0x10] RMB,0, "ADCB %r,%e", [0x11] RM,0, "ADC%S %r,%e", [0x12] RMB,0, "ADCB %e,%r", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1094,1100 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1104,1110 [0x8a] RMB,0, "MOVB %e,%r", [0x8b] RM,0, "MOV%S %e,%r", [0x8c] RM,0, "MOVW %g,%e", - [0x8d] RM,0, "LEA %e,%r", + [0x8d] RM,0, "LEA%S %e,%r", [0x8e] RM,0, "MOVW %e,%g", [0x8f] RM,0, "POP%S %e", [0x90] 0,0, "NOP", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1214,1220 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1224,1230 * get a byte of the instruction */ static int - igetc(Map * map, Instr *ip, uchar *c) + igetc(Map *map, Instr *ip, uchar *c) { if(ip->n+1 > sizeof(ip->mem)){ werrstr("instruction too long"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1234,1240 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1244,1250 static int igets(Map *map, Instr *ip, ushort *sp) { - uchar c; + uchar c; ushort s; if (igetc(map, ip, &c) < 0) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1378,1384 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1388,1394 } static Optable * - mkinstr(Map *map, Instr *ip, ulong pc) + mkinstr(Map *map, Instr *ip, uvlong pc) { int i, n, norex; uchar c; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1451,1456 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1461,1467 ip->imm = c|0xff00; else ip->imm = c&0xff; + ip->imm64 = (long)ip->imm; break; case Iw: /* 16-bit immediate -> imm */ if (igets(map, ip, &s) < 0) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1819,1825 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1830,1836 Symbol s; long w; - if (findsym((long)val, CANY, &s)) { /* TO DO */ + if (findsym(val, CANY, &s)) { /* TO DO */ w = val - s.value; if (w < 0) w = -w; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1981,1987 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1992,2002 bprint(ip,"???"); break; case 'p': - immediate(ip, ip->imm+ip->addr+ip->n); + /* + * signed immediate in the ulong ip->imm. + */ + v = (long)ip->imm; + immediate(ip, v+ip->addr+ip->n); break; case 'r': if (ip->osize == 'B') /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2022,2030 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2037,2045 } static int - i386inst(Map *map, ulong pc, char modifier, char *buf, int n) + i386inst(Map *map, uvlong pc, char modifier, char *buf, int n) { - Instr instr; + Instr instr; Optable *op; USED(modifier); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2040,2048 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2055,2063 } static int - i386das(Map *map, ulong pc, char *buf, int n) + i386das(Map *map, uvlong pc, char *buf, int n) { - Instr instr; + Instr instr; int i; if (mkinstr(map, &instr, pc) == 0) { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2059,2065 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2074,2080 } static int - i386instlen(Map *map, ulong pc) + i386instlen(Map *map, uvlong pc) { Instr i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2069,2080 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2084,2096 } static int - i386foll(Map *map, ulong pc, Rgetter rget, ulong *foll) + i386foll(Map *map, uvlong pc, Rgetter rget, uvlong *foll) { Instr i; Optable *op; ushort s; - ulong l, addr; + uvlong l, addr; + vlong v; int n; op = mkinstr(map, &i, pc); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2087,2101 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2103,2118 case RET: /* RETURN or LEAVE */ case Iw: /* RETURN */ if (strcmp(op->proto, "LEAVE") == 0) { - if (get4(map, (*rget)(map, "BP"), (long*)&l) < 0) + if (geta(map, (*rget)(map, "BP"), &l) < 0) return -1; - } else if (get4(map, (*rget)(map, mach->sp), (long*)&l) < 0) + } else if (geta(map, (*rget)(map, mach->sp), &l) < 0) return -1; foll[0] = l; return 1; case Iwds: /* pc relative JUMP or CALL*/ case Jbs: /* pc relative JUMP or CALL */ - foll[0] = pc+i.imm+i.n; + v = (long)i.imm; + foll[0] = pc+v+i.n; n = 1; break; case PTR: /* seg:displacement JUMP or CALL */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2110,2131 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2127,2148 /* calculate the effective address */ addr = i.disp; if (i.base >= 0) { - if (get4(map, (*rget)(map, reg[i.rex&REXB? i.base+8: i.base]), (long*)&l) < 0) + if (geta(map, (*rget)(map, reg[i.rex&REXB? i.base+8: i.base]), &l) < 0) return -1; addr += l; } if (i.index >= 0) { - if (get4(map, (*rget)(map, reg[i.rex&REXX? i.index+8: i.index]), (long*)&l) < 0) + if (geta(map, (*rget)(map, reg[i.rex&REXX? i.index+8: i.index]), &l) < 0) return -1; addr += l*(1< #include - static int mget(Map*, ulong, char*, int); - static int mput(Map*, ulong, char*, int); - static struct segment* reloc(Map*, ulong, long*); + static int mget(Map*, uvlong, void*, int); + static int mput(Map*, uvlong, void*, int); + static struct segment* reloc(Map*, uvlong, vlong*); /* * routines to get/put various types */ + int + geta(Map *map, uvlong addr, uvlong *x) + { + ulong l; + uvlong vl; + if (mach->szaddr == 8){ + if (get8(map, addr, &vl) < 0) + return -1; + *x = vl; + return 1; + } + + if (get4(map, addr, &l) < 0) + return -1; + *x = l; + + return 1; + } + int - get8(Map *map, ulong addr, vlong *x) + get8(Map *map, uvlong addr, uvlong *x) { if (!map) { werrstr("get8: invalid map"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:24,40 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:43,59 } if (map->nsegs == 1 && map->seg[0].fd < 0) { - *x = (vlong)addr; + *x = addr; return 1; } - if (mget(map, addr, (char *)x, 8) < 0) + if (mget(map, addr, x, 8) < 0) return -1; *x = machdata->swav(*x); - return (1); + return 1; } int - get4(Map *map, ulong addr, long *x) + get4(Map *map, uvlong addr, ulong *x) { if (!map) { werrstr("get4: invalid map"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:45,58 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:64,77 *x = addr; return 1; } - if (mget(map, addr, (char *)x, 4) < 0) + if (mget(map, addr, x, 4) < 0) return -1; *x = machdata->swal(*x); - return (1); + return 1; } int - get2(Map *map, ulong addr, ushort *x) + get2(Map *map, uvlong addr, ushort *x) { if (!map) { werrstr("get2: invalid map"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:63,76 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:82,95 *x = addr; return 1; } - if (mget(map, addr, (char *)x, 2) < 0) + if (mget(map, addr, x, 2) < 0) return -1; *x = machdata->swab(*x); - return (1); + return 1; } int - get1(Map *map, ulong addr, uchar *x, int size) + get1(Map *map, uvlong addr, uchar *x, int size) { uchar *cp; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:86,108 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:105,136 while (size-- > 0) *x++ = 0; } else - return mget(map, addr, (char*)x, size); + return mget(map, addr, x, size); return 1; } int - put8(Map *map, ulong addr, vlong v) + puta(Map *map, uvlong addr, uvlong v) { + if (mach->szaddr == 8) + return put8(map, addr, v); + + return put4(map, addr, v); + } + + int + put8(Map *map, uvlong addr, uvlong v) + { if (!map) { werrstr("put8: invalid map"); return -1; } v = machdata->swav(v); - return mput(map, addr, (char *)&v, 8); + return mput(map, addr, &v, 8); } int - put4(Map *map, ulong addr, long v) + put4(Map *map, uvlong addr, ulong v) { if (!map) { werrstr("put4: invalid map"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:109,119 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:137,147 return -1; } v = machdata->swal(v); - return mput(map, addr, (char *)&v, 4); + return mput(map, addr, &v, 4); } int - put2(Map *map, ulong addr, ushort v) + put2(Map *map, uvlong addr, ushort v) { if (!map) { werrstr("put2: invalid map"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:120,147 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:148,175 return -1; } v = machdata->swab(v); - return mput(map, addr, (char *)&v, 2); + return mput(map, addr, &v, 2); } int - put1(Map *map, ulong addr, uchar *v, int size) + put1(Map *map, uvlong addr, uchar *v, int size) { if (!map) { werrstr("put1: invalid map"); return -1; } - return mput(map, addr, (char *)v, size); + return mput(map, addr, v, size); } static int - spread(struct segment *s, char *buf, int n, ulong off) + spread(struct segment *s, void *buf, int n, uvlong off) { - ulong base; + uvlong base; static struct { struct segment *s; char a[8192]; - ulong off; + uvlong off; } cache; if(s->cache){ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:167,180 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:195,207 } static int - mget(Map *map, ulong addr, char *buf, int size) + mget(Map *map, uvlong addr, void *buf, int size) { - long off; - uvlong voff; + uvlong off; int i, j, k; struct segment *s; - s = reloc(map, addr, &off); + s = reloc(map, addr, (vlong*)&off); if (!s) return -1; if (s->fd < 0) { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:181,191 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:208,217 werrstr("unreadable map"); return -1; } - voff = (ulong)off; for (i = j = 0; i < 2; i++) { /* in case read crosses page */ - k = spread(s, buf, size-j, voff+j); + k = spread(s, buf, size-j, off+j); if (k < 0) { - werrstr("can't read address %lux: %r", addr); + werrstr("can't read address %llux: %r", addr); return -1; } j += k; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:192,206 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:218,231 if (j == size) return j; } - werrstr("partial read at address %lux", addr); + werrstr("partial read at address %llux (size %d j %d)", addr, size, j); return -1; } static int - mput(Map *map, ulong addr, char *buf, int size) + mput(Map *map, uvlong addr, void *buf, int size) { - long off; - vlong voff; + vlong off; int i, j, k; struct segment *s; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:212,223 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:237,247 return -1; } - voff = (ulong)off; - seek(s->fd, voff, 0); + seek(s->fd, off, 0); for (i = j = 0; i < 2; i++) { /* in case read crosses page */ k = write(s->fd, buf, size-j); if (k < 0) { - werrstr("can't write address %lux: %r", addr); + werrstr("can't write address %llux: %r", addr); return -1; } j += k; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:224,230 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:248,254 if (j == size) return j; } - werrstr("partial write at address %lux", addr); + werrstr("partial write at address %llux", addr); return -1; } /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:232,238 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:256,262 * convert address to file offset; returns nonzero if ok */ static struct segment* - reloc(Map *map, ulong addr, long *offp) + reloc(Map *map, uvlong addr, vlong *offp) { int i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:243,248 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:267,272 return &map->seg[i]; } } - werrstr("can't translate address %lux", addr); + werrstr("can't translate address %llux", addr); return 0; } [rsc] --rw-rw-r-- M 451989 glenda sys 16128 Nov 6 10:02 sys/src/libmach/executable.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:12,25 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:12,28 typedef struct { union{ - Exec; /* in a.out.h */ - Ehdr; /* in elf.h */ - struct mipsexec; - struct mips4kexec; - struct sparcexec; - struct nextexec; + struct { + Exec; /* a.out.h */ + uvlong hdr[1]; + }; + Ehdr; /* elf.h */ + struct mipsexec; /* bootexec.h */ + struct mips4kexec; /* bootexec.h */ + struct sparcexec; /* bootexec.h */ + struct nextexec; /* bootexec.h */ } e; - long dummy; /* padding to ensure extra long */ + long dummy; /* padding to ensure extra long */ } ExecHdr; static int nextboot(int, Fhdr*, ExecHdr*); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:27,42 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:30,45 static int mipsboot(int, Fhdr*, ExecHdr*); static int mips4kboot(int, Fhdr*, ExecHdr*); static int common(int, Fhdr*, ExecHdr*); + static int commonllp64(int, Fhdr*, ExecHdr*); static int adotout(int, Fhdr*, ExecHdr*); static int elfdotout(int, Fhdr*, ExecHdr*); static int armdotout(int, Fhdr*, ExecHdr*); static int alphadotout(int, Fhdr*, ExecHdr*); - static void setsym(Fhdr*, long, long, long, long); - static void setdata(Fhdr*, long, long, long, long); - static void settext(Fhdr*, long, long, long, long); - static void hswal(long*, int, long(*)(long)); - static long noswal(long); - static ulong _round(ulong, ulong); + static void setsym(Fhdr*, long, long, long, vlong); + static void setdata(Fhdr*, uvlong, long, vlong, long); + static void settext(Fhdr*, uvlong, uvlong, long, vlong); + static void hswal(void*, int, ulong(*)(ulong)); + static uvlong _round(uvlong, ulong); /* * definition of per-executable file type structures /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:48,55 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:51,58 char *dlmname; /* dynamically loadable module identifier */ int type; /* Internal code */ Mach *mach; /* Per-machine data */ - ulong hsize; /* header size */ - long (*swal)(long); /* beswal or leswal */ + long hsize; /* header size */ + ulong (*swal)(ulong); /* beswal or leswal */ int (*hparse)(int, Fhdr*, ExecHdr*); } ExecTable; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:160,168 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:163,171 "amd64 plan 9 dlm", FAMD64, &mamd64, - sizeof(Exec), - beswal, - common }, + sizeof(Exec)+8, + nil, + commonllp64 }, { Q_MAGIC, /* PowerPC q.out & boot image */ "power plan 9 executable", "power plan 9 dlm", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:177,183 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:180,186 FNONE, &mi386, sizeof(Ehdr), - noswal, + nil, elfdotout }, { E_MAGIC, /* Arm 5.out */ "arm plan 9 executable", /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:242,248 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:245,252 { ExecTable *mp; ExecHdr d; - int nb, magic, ret; + int nb, ret; + ulong magic; fp->type = FNONE; nb = read(fd, (char *)&d.e, sizeof(d.e)); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:258,264 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:262,267 if(mp->magic == V_MAGIC) mp = couldbe4k(mp); - hswal((long *) &d, sizeof(d.e)/sizeof(long), mp->swal); fp->type = mp->type; if ((magic & DYN_MAGIC) && mp->dlmname != nil) fp->name = mp->dlmname; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:266,272 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:269,277 fp->name = mp->name; fp->hdrsz = mp->hsize; /* zero on bootables */ mach = mp->mach; - ret = mp->hparse(fd, fp, &d); + if(mp->swal != nil) + hswal(&d, sizeof(d.e)/sizeof(ulong), mp->swal); + ret = mp->hparse(fd, fp, &d); seek(fd, mp->hsize, 0); /* seek to end of header */ break; } /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:275,300 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:280,299 werrstr("unknown header type"); return ret; } + /* * Convert header to canonical form */ static void - hswal(long *lp, int n, long (*swap) (long)) + hswal(void *v, int n, ulong (*swap)(ulong)) { - while (n--) { - *lp = (*swap) (*lp); - lp++; - } + ulong *ulp; + + for(ulp = v; n--; ulp++) + *ulp = (*swap)(*ulp); } + /* - * noop - */ - static long - noswal(long x) - { - return x; - } - /* * Crack a normal a.out-type header */ static int /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:312,317 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:311,365 return 1; } + static void + commonboot(Fhdr *fp) + { + uvlong kbase; + + kbase = mach->kbase; + if ((fp->entry & kbase) != kbase) + return; + + switch(fp->type) { /* boot image */ + case F68020: + fp->type = F68020B; + fp->name = "68020 plan 9 boot image"; + break; + case FI386: + fp->type = FI386B; + fp->txtaddr = (u32int)fp->entry; + fp->name = "386 plan 9 boot image"; + fp->dataddr = _round(fp->txtaddr+fp->txtsz, mach->pgsize); + break; + case FARM: + fp->txtaddr = kbase+0x8010; + fp->name = "ARM plan 9 boot image"; + fp->dataddr = fp->txtaddr+fp->txtsz; + return; + case FALPHA: + fp->type = FALPHAB; + fp->txtaddr = (u32int)fp->entry; + fp->name = "alpha plan 9 boot image?"; + fp->dataddr = fp->txtaddr+fp->txtsz; + break; + case FPOWER: + fp->type = FPOWERB; + fp->txtaddr = (u32int)fp->entry; + fp->name = "power plan 9 boot image"; + fp->dataddr = fp->txtaddr+fp->txtsz; + break; + case FAMD64: + fp->type = FAMD64B; + fp->txtaddr = fp->entry; + fp->name = "amd64 plan 9 boot image"; + fp->dataddr = _round(fp->txtaddr+fp->txtsz, mach->pgsize); + break; + default: + return; + } + fp->hdrsz = 0; /* header stripped */ + } + /* * 68020 2.out and 68020 bootable images * 386I 8.out and 386I bootable images /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:321,328 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:369,374 static int common(int fd, Fhdr *fp, ExecHdr *hp) { - long kbase; - adotout(fd, fp, hp); if(hp->e.magic & DYN_MAGIC) { fp->txtaddr = 0; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:329,383 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:375,416 fp->dataddr = fp->txtsz; return 1; } - kbase = mach->kbase; - if ((fp->entry & kbase) == kbase) { /* Boot image */ - switch(fp->type) { - case F68020: - fp->type = F68020B; - fp->name = "68020 plan 9 boot image"; - fp->hdrsz = 0; /* header stripped */ - break; - case FI386: - fp->type = FI386B; - fp->txtaddr = sizeof(Exec); - fp->name = "386 plan 9 boot image"; - fp->hdrsz = 0; /* header stripped */ - fp->dataddr = _round(fp->txtaddr+fp->txtsz, mach->pgsize); - break; - case FARM: - fp->txtaddr = kbase+0x8010; - fp->name = "ARM plan 9 boot image"; - fp->hdrsz = 0; /* header stripped */ - fp->dataddr = fp->txtaddr+fp->txtsz; - return 1; - case FALPHA: - fp->type = FALPHAB; - fp->txtaddr = fp->entry; - fp->name = "alpha plan 9 boot image?"; - fp->hdrsz = 0; /* header stripped */ - fp->dataddr = fp->txtaddr+fp->txtsz; - break; - case FPOWER: - fp->type = FPOWERB; - fp->txtaddr = fp->entry; - fp->name = "power plan 9 boot image"; - fp->hdrsz = 0; /* header stripped */ - fp->dataddr = fp->txtaddr+fp->txtsz; - break; - case FAMD64: - fp->type = FAMD64B; - fp->txtaddr = sizeof(Exec); - fp->name = "amd64 plan 9 boot image"; - fp->hdrsz = 0; /* header stripped */ - fp->dataddr = _round(fp->txtaddr+fp->txtsz, mach->pgsize); - break; - default: - break; - } - fp->txtaddr |= kbase; - fp->entry |= kbase; - fp->dataddr |= kbase; + commonboot(fp); + return 1; + } + + static int + commonllp64(int, Fhdr *fp, ExecHdr *hp) + { + long pgsize; + uvlong entry; + + hswal(&hp->e, sizeof(Exec)/sizeof(long), beswal); + if(!(hp->e.magic & HDR_MAGIC)) + return 0; + + /* + * There can be more magic here if the + * header ever needs more expansion. + * For now just catch use of any of the + * unused bits. + */ + if((hp->e.magic & ~DYN_MAGIC)>>16) + return 0; + entry = beswav(hp->e.hdr[0]); + + pgsize = mach->pgsize; + settext(fp, entry, pgsize+fp->hdrsz, hp->e.text, fp->hdrsz); + setdata(fp, _round(pgsize+fp->txtsz+fp->hdrsz, pgsize), + hp->e.data, fp->txtsz+fp->hdrsz, hp->e.bss); + setsym(fp, hp->e.syms, hp->e.spsz, hp->e.pcsz, fp->datoff+fp->datsz); + + if(hp->e.magic & DYN_MAGIC) { + fp->txtaddr = 0; + fp->dataddr = fp->txtsz; + return 1; } + commonboot(fp); return 1; } /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:472,478 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:505,510 return 1; } - /* * Elf32 binaries. */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:480,486 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:512,518 elfdotout(int fd, Fhdr *fp, ExecHdr *hp) { - long (*swal)(long); + ulong (*swal)(ulong); ushort (*swab)(ushort); Ehdr *ep; Phdr *ph; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:560,574 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:592,606 free(ph); return 0; } - hswal((long*)ph, phsz/sizeof(long), swal); + hswal(ph, phsz/sizeof(ulong), swal); /* find text, data and symbols and install them */ it = id = is = -1; for(i = 0; i < ep->phnum; i++) { - if(ph[i].type == LOAD + if(ph[i].type == LOAD && (ph[i].flags & (R|X)) == (R|X) && it == -1) it = i; - else if(ph[i].type == LOAD + else if(ph[i].type == LOAD && (ph[i].flags & (R|W)) == (R|W) && id == -1) id = i; else if(ph[i].type == NOPTYPE && is == -1) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:575,587 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:607,619 is = i; } if(it == -1 || id == -1) { - /* + /* * The SPARC64 boot image is something of an ELF hack. * Text+Data+BSS are represented by ph[0]. Symbols * are represented by ph[1]: * * filesz, memsz, vaddr, paddr, off - * ph[0] : txtsz+datsz, txtsz+datsz+bsssz, txtaddr-KZERO, datasize, txtoff + * ph[0] : txtsz+datsz, txtsz+datsz+bsssz, txtaddr-KZERO, datasize, txtoff * ph[1] : symsz, lcsz, 0, 0, symoff */ if(ep->machine == SPARC64 && ep->phnum == 2) { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:617,623 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:649,655 static int alphadotout(int fd, Fhdr *fp, ExecHdr *hp) { - long kbase; + uvlong kbase; USED(fd); settext(fp, hp->e.entry, sizeof(Exec), hp->e.text, sizeof(Exec)); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:645,651 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:677,683 static int armdotout(int fd, Fhdr *fp, ExecHdr *hp) { - long kbase; + uvlong kbase; USED(fd); settext(fp, hp->e.entry, sizeof(Exec), hp->e.text, sizeof(Exec)); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:663,669 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:695,701 } static void - settext(Fhdr *fp, long e, long a, long s, long off) + settext(Fhdr *fp, uvlong e, uvlong a, long s, vlong off) { fp->txtaddr = a; fp->entry = e; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:670,677 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:702,710 fp->txtsz = s; fp->txtoff = off; } + static void - setdata(Fhdr *fp, long a, long s, long off, long bss) + setdata(Fhdr *fp, uvlong a, long s, vlong off, long bss) { fp->dataddr = a; fp->datsz = s; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:678,699 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:711,733 fp->datoff = off; fp->bsssz = bss; } + static void - setsym(Fhdr *fp, long sy, long sppc, long lnpc, long symoff) + setsym(Fhdr *fp, long symsz, long sppcsz, long lnpcsz, vlong symoff) { - fp->symsz = sy; + fp->symsz = symsz; fp->symoff = symoff; - fp->sppcsz = sppc; + fp->sppcsz = sppcsz; fp->sppcoff = fp->symoff+fp->symsz; - fp->lnpcsz = lnpc; + fp->lnpcsz = lnpcsz; fp->lnpcoff = fp->sppcoff+fp->sppcsz; } - static ulong - _round(ulong a, ulong b) + static uvlong + _round(uvlong a, ulong b) { - ulong w; + uvlong w; w = (a/b)*b; if (a!=w) [rsc] --rw-rw-r-- M 451989 glenda sys 3370 Nov 6 10:02 sys/src/libmach/k.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/k.c:107,114 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/k.c:107,115 "setSB", /* static base register name */ 0, /* value */ 0x1000, /* page size */ - 0xE0000000, /* kernel base */ + 0xE0000000ULL, /* kernel base */ 0, /* kernel text mask */ + 0x7FFFFFFFULL, /* user stack top */ 4, /* quantization of pc */ 4, /* szaddr */ 4, /* szreg */ [rsc] --rw-rw-r-- M 451989 glenda sys 21161 Nov 6 10:03 sys/src/libmach/kdb.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:8,17 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:8,17 */ static char *sparcexcep(Map*, Rgetter); - static int sparcfoll(Map*, ulong, Rgetter, ulong*); - static int sparcinst(Map*, ulong, char, char*, int); - static int sparcdas(Map*, ulong, char*, int); - static int sparcinstlen(Map*, ulong); + static int sparcfoll(Map*, uvlong, Rgetter, uvlong*); + static int sparcinst(Map*, uvlong, char, char*, int); + static int sparcdas(Map*, uvlong, char*, int); + static int sparcinstlen(Map*, uvlong); Machdata sparcmach = { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:116,122 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:116,122 int target; /* SETHI+ADD dest reg */ long w0; long w1; - ulong addr; /* pc of instruction */ + uvlong addr; /* pc of instruction */ char *curr; /* current fill level in output buffer */ char *end; /* end of buffer */ int size; /* number of longs in instr */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:126,132 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:126,132 static Map *mymap; /* disassembler context */ static int dascase; - static int mkinstr(ulong, Instr*); + static int mkinstr(uvlong, Instr*); static void bra1(Instr*, char*, char*[]); static void bra(Instr*, char*); static void fbra(Instr*, char*); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:288,296 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:288,296 } static int - decode(ulong pc, Instr *i) + decode(uvlong pc, Instr *i) { - long w; + ulong w; if (get4(mymap, pc, &w) < 0) { werrstr("can't read instruction: %r"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:323,329 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:323,329 } static int - mkinstr(ulong pc, Instr *i) + mkinstr(uvlong pc, Instr *i) { Instr xi; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:354,360 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:354,360 } static int - printins(Map *map, ulong pc, char *buf, int n) + printins(Map *map, uvlong pc, char *buf, int n) { Instr instr; void (*f)(Instr*, char*); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:424,430 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:424,430 } static int - sparcinst(Map *map, ulong pc, char modifier, char *buf, int n) + sparcinst(Map *map, uvlong pc, char modifier, char *buf, int n) { static int fmtinstalled = 0; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:442,448 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:442,448 } static int - sparcdas(Map *map, ulong pc, char *buf, int n) + sparcdas(Map *map, uvlong pc, char *buf, int n) { Instr instr; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:463,469 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:463,469 } static int - sparcinstlen(Map *map, ulong pc) + sparcinstlen(Map *map, uvlong pc) { Instr i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:500,506 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:500,506 address(Instr *i) { Symbol s, s2; - long off, off1; + uvlong off, off1; if (i->rs1 == 1 && plocal(i) >= 0) return; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:510,516 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:510,516 && (s.class == CDATA || s.class == CTEXT)) { if(off==s.value && s.name[0]=='$'){ off1 = 0; - get4(mymap, s.value, &off1); + geta(mymap, s.value, &off1); if(off1 && findsym(off1, CANY, &s2) && s2.value == off1){ bprint(i, "$%s(SB)", s2.name); return; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:878,885 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:878,885 bprint(i, ", R%d", i->rd); } - static - void storef(Instr *i, char *m) /* page 70 */ + static void + storef(Instr *i, char *m) /* page 70 */ { if(!dascase){ m = "FMOVD"; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:901,908 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:901,908 address(i); } - static - void loadc(Instr *i, char *m) /* page 72 */ + static void + loadc(Instr *i, char *m) /* page 72 */ { if(i->i == 0) bprint(i, "%s\t(R%d+R%d), C%d", m, i->rs1, i->rs2, i->rd); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:913,920 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:913,920 } } - static - void loadcsr(Instr *i, char *m) /* page 72 */ + static void + loadcsr(Instr *i, char *m) /* page 72 */ { if(i->i == 0) bprint(i, "%s\t(R%d+R%d), CSR", m, i->rs1, i->rs2); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:1007,1013 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:1007,1013 } static int - sparcfoll(Map *map, ulong pc, Rgetter rget, ulong *foll) + sparcfoll(Map *map, uvlong pc, Rgetter rget, uvlong *foll) { ulong w, r1, r2; char buf[8]; [rsc] --rw-rw-r-- M 451989 glenda sys 8799 Nov 6 10:02 sys/src/libmach/machdata.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:17,27 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:17,26 Machdata *machdata; /* machine-dependent functions */ int - localaddr(Map *map, char *fn, char *var, long *r, Rgetter rget) + localaddr(Map *map, char *fn, char *var, uvlong *r, Rgetter rget) { Symbol s; - ulong fp; - ulong pc, sp, link; + uvlong fp, pc, sp, link; if (!lookup(fn, 0, &s)) { werrstr("function not found"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:64,73 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:63,72 } /* - * Print value v as name[+offset] and then the string s. + * Print value v as s.name[+offset] if possible, or just v. */ int - symoff(char *buf, int n, long v, int space) + symoff(char *buf, int n, uvlong v, int space) { Symbol s; int r; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:82,95 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:81,95 delta = -delta; } if (v == 0 || r == 0) - return snprint(buf, n, "%lux", v); + return snprint(buf, n, "%llux", v); if (s.type != 't' && s.type != 'T' && delta >= 4096) - return snprint(buf, n, "%lux", v); + return snprint(buf, n, "%llux", v); else if (delta) return snprint(buf, n, "%s+%lux", s.name, delta); else return snprint(buf, n, "%s", s.name); } + /* * Format floating point registers * /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:104,110 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:104,110 fpformat(Map *map, Reglist *rp, char *buf, int n, int modif) { char reg[12]; - long r; + ulong r; switch(rp->rformat) { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:317,323 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:317,322 return beieeedftos(buf, n, (void*)ieee); } - int leieee80ftos(char *buf, int n, void *s) { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:332,350 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:331,348 } int - cisctrace(Map *map, ulong pc, ulong sp, ulong link, Tracer trace) + cisctrace(Map *map, uvlong pc, uvlong sp, uvlong link, Tracer trace) { Symbol s; - int found; - ulong opc; - long moved, j; + int found, i; + uvlong opc, moved; USED(link); - j = 0; + i = 0; opc = 0; while(pc && opc != pc) { moved = pc2sp(pc); - if (moved == -1) + if (moved == ~0) break; found = findsym(pc, CTEXT, &s); if (!found) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:354,375 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:352,373 sp += moved; opc = pc; - if (get4(map, sp, (long *)&pc) < 0) + if (geta(map, sp, &pc) < 0) break; (*trace)(map, pc, sp, &s); sp += mach->szaddr; /*assumes address size = stack width*/ - if(++j > 40) + if(++i > 40) break; } - return j; + return i; } int - risctrace(Map *map, ulong pc, ulong sp, ulong link, Tracer trace) + risctrace(Map *map, uvlong pc, uvlong sp, uvlong link, Tracer trace) { int i; Symbol s, f; - ulong oldpc; + uvlong oldpc; i = 0; while(findsym(pc, CTEXT, &s)) { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:385,391 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:383,389 if(s.type == 'L' || s.type == 'l' || pc <= s.value+mach->pcquant) pc = link; else - if (get4(map, sp, (long *) &pc) < 0) + if (geta(map, sp, &pc) < 0) break; if(pc == 0 || (pc == oldpc && f.value == 0)) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:400,421 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:398,419 return i; } - ulong - ciscframe(Map *map, ulong addr, ulong pc, ulong sp, ulong link) + uvlong + ciscframe(Map *map, uvlong addr, uvlong pc, uvlong sp, uvlong link) { Symbol s; - int moved; + uvlong moved; USED(link); for(;;) { moved = pc2sp(pc); - if (moved == -1) + if (moved == ~0) break; sp += moved; findsym(pc, CTEXT, &s); if (addr == s.value) return sp; - if (get4(map, sp, (long *) &pc) < 0) + if (geta(map, sp, &pc) < 0) break; sp += mach->szaddr; /*assumes sizeof(addr) = stack width*/ } /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:422,429 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:420,427 return 0; } - ulong - riscframe(Map *map, ulong addr, ulong pc, ulong sp, ulong link) + uvlong + riscframe(Map *map, uvlong addr, uvlong pc, uvlong sp, uvlong link) { Symbol s, f; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:444,450 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:442,448 if (s.type == 'L' || s.type == 'l' || pc-s.value <= mach->szaddr*2) pc = link; else - if (get4(map, sp-f.value, (long *)&pc) < 0) + if (geta(map, sp-f.value, &pc) < 0) break; } return 0; [rsc] --rw-rw-r-- M 451989 glenda sys 3056 Nov 6 10:02 sys/src/libmach/map.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:26,32 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:26,32 } int - setmap(Map *map, int fd, ulong b, ulong e, ulong f, char *name) + setmap(Map *map, int fd, uvlong b, uvlong e, vlong f, char *name) { int i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:46,52 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:46,52 return 1; } - static ulong + static uvlong stacktop(int pid) { char buf[64]; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:54,60 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:54,60 int n; char *cp; - sprint(buf, "/proc/%d/segment", pid); + snprint(buf, sizeof(buf), "/proc/%d/segment", pid); fd = open(buf, 0); if (fd < 0) return 0; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:74,80 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:74,80 cp++; if (!*cp) return 0; - return strtoul(cp, 0, 16); + return strtoull(cp, 0, 16); } Map* /n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:83,89 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:83,89 char buf[64], *regs; int fd; Map *map; - ulong n; + uvlong n; int mode; map = newmap(0, 4); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:116,128 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:116,128 setmap(map, fd, mach->regsize, mach->regsize+mach->fpregsize, 0, "fpregs"); } setmap(map, corefd, fp->txtaddr, fp->txtaddr+fp->txtsz, fp->txtaddr, "text"); - if(kflag || (ulong) fp->dataddr >= 0x7fffffff) { - setmap(map, corefd, fp->dataddr, 0xffffffff, fp->dataddr, "data"); + if(kflag || fp->dataddr >= mach->utop) { + setmap(map, corefd, fp->dataddr, ~0, fp->dataddr, "data"); return map; } n = stacktop(pid); if (n == 0) { - setmap(map, corefd, fp->dataddr, 0x7fffffff, fp->dataddr, "data"); + setmap(map, corefd, fp->dataddr, mach->utop, fp->dataddr, "data"); return map; } setmap(map, corefd, fp->dataddr, n, fp->dataddr, "data"); [rsc] --rw-rw-r-- M 451989 glenda sys 5929 Nov 6 10:02 sys/src/libmach/obj.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/obj.c:127,133 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/obj.c:127,133 } int - readar(Biobuf *bp, int objtype, int end, int doautos) + readar(Biobuf *bp, int objtype, vlong end, int doautos) { Prog p; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/obj.c:253,259 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/obj.c:253,259 * update the offset information for a 'a' or 'p' symbol in an intermediate file */ void - _offset(int id, long off) + _offset(int id, vlong off) { Sym *s; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/obj.c:299,305 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/obj.c:299,305 for(i=0; isymsz == 0) return 0; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:101,109 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:103,120 nsym = 0; size = 0; for(p = symbols; size < fp->symsz; p++, nsym++) { - if(Bread(&b, &p->value, sizeof(p->value)) != sizeof(p->value)) - return symerrmsg(sizeof(p->value), "symbol"); - p->value = beswal(p->value); + if(fp->magic & HDR_MAGIC){ + svalsz = 8; + if(Bread(&b, &vl, 8) != 8) + return symerrmsg(8, "symbol"); + p->value = beswav(vl); + } + else{ + svalsz = 4; + if(Bread(&b, &l, 4) != 4) + return symerrmsg(4, "symbol"); + p->value = (u32int)beswal(l); + } if(Bread(&b, &p->type, sizeof(p->type)) != sizeof(p->type)) return symerrmsg(sizeof(p->value), "symbol"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:110,116 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:121,127 i = decodename(&b, p); if(i < 0) return -1; - size += i+sizeof(p->value)+sizeof(p->type); + size += i+svalsz+sizeof(p->type); /* count global & auto vars, text symbols, and file names */ switch (p->type) { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:159,166 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:170,176 return -1; } Bseek(&b, fp->sppcoff, 0); - i = Bread(&b, spoff, fp->sppcsz); - if(i != fp->sppcsz){ + if(Bread(&b, spoff, fp->sppcsz) != fp->sppcsz){ spoff = 0; return symerrmsg(fp->sppcsz, "sp-pc"); } /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:173,180 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:183,189 return -1; } Bseek(&b, fp->lnpcoff, 0); - i = Bread(&b, pcline, fp->lnpcsz); - if(i != fp->lnpcsz){ + if(Bread(&b, pcline, fp->lnpcsz) != fp->lnpcsz){ pcline = 0; return symerrmsg(fp->lnpcsz, "pc-line"); } /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:190,201 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:199,211 return -1; } - static int + static long decodename(Biobuf *bp, Sym *p) { char *cp; int c1, c2; - int n; + long n; + vlong o; if((p->type & 0x80) == 0) { /* old-style, fixed length names */ p->name = malloc(NNAME); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:211,217 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:221,227 p->type &= ~0x80; if(p->type == 'z' || p->type == 'Z') { - n = Bseek(bp, 0, 1); + o = Bseek(bp, 0, 1); if(Bgetc(bp) < 0) { werrstr("can't read symbol name"); return -1; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:226,240 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:236,250 if(c1 == 0 && c2 == 0) break; } - n = Bseek(bp, 0, 1)-n; + n = Bseek(bp, 0, 1)-o; p->name = malloc(n); if(p->name == 0) { - werrstr("can't malloc %d bytes", n); + werrstr("can't malloc %ld bytes", n); return -1; } Bseek(bp, -n, 1); if(Bread(bp, p->name, n) != n) { - werrstr("can't read %d bytes of symbol name", n); + werrstr("can't read %ld bytes of symbol name", n); return -1; } } else { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:246,252 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:256,262 n = Blinelen(bp); p->name = malloc(n); if(p->name == 0) { - werrstr("can't malloc %d bytes", n); + werrstr("can't malloc %ld bytes", n); return -1; } strcpy(p->name, cp); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:253,258 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:263,269 } return n; } + /* * free any previously loaded symbol tables */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:296,310 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:307,323 free(pcline); pcline = 0; } + /* * delimit the text segment */ void - textseg(ulong base, Fhdr *fp) + textseg(uvlong base, Fhdr *fp) { txtstart = base; txtend = base+fp->txtsz; } + /* * symbase: return base and size of raw symbol table * (special hack for high access rate operations) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:315,320 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:328,334 *n = nsym; return symbols; } + /* * Get the ith symbol table entry */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:332,338 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:346,353 static int buildtbls(void) { - int i, j, nh, ng, nt; + long i; + int j, nh, ng, nt; File *f; Txtsym *tp; Hist *hp; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:391,397 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:406,412 case 'B': case 'b': if(debug) - print("Global: %s %lux\n", p->name, p->value); + print("Global: %s %llux\n", p->name, p->value); globals[ng++] = p; break; case 'z': /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:430,436 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:445,451 tp->sym = p; tp->locals = ap; if(debug) - print("TEXT: %s at %lux\n", p->name, p->value); + print("TEXT: %s at %llux\n", p->name, p->value); if(f && !f->sym) { /* first */ f->sym = p; f->addr = p->value; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:444,450 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:459,465 p->name); else { if(debug) - print("Local: %s %lux\n", p->name, p->value); + print("Local: %s %llux\n", p->name, p->value); tp->locals[tp->n] = p; tp->n++; ap++; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:468,474 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:483,489 for(j = 0; j < ntxt; j++) { if(f->sym == tp->sym) { if(debug) { - print("LINK: %s to at %lux", f->sym->name, f->addr); + print("LINK: %s to at %llux", f->sym->name, f->addr); printhist("... ", f->hist, 1); } f->txt = tp++; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:511,516 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:526,532 return findglobal(var, s); /* case 3: var not found */ } + /* * find a function by name */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:535,541 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:551,557 static int findglobal(char *name, Symbol *s) { - int i; + long i; for(i = 0; i < nglob; i++) { if(strcmp(globals[i]->name, name) == 0) { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:546,551 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:562,568 } return 0; } + /* * find the local variable by name within a given function */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:558,563 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:575,581 return 0; return findlocvar(s1, name, s2); } + /* * find the local variable by name within a given function * (internal function - does no parameter validation) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:580,585 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:598,604 } return 0; } + /* * Get ith text symbol */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:596,601 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:615,621 s->index = index; return 1; } + /* * Get ith file name */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:613,618 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:633,639 return 0; return fileelem(fnames, (uchar*)hp->name, buf, n); } + /* * Lookup name of local variable located at an offset into the frame. * The type selects either a parameter or automatic. /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:653,661 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:674,682 * Find text symbol containing addr; binary search assumes text array is sorted by addr */ static int - srchtext(long addr) + srchtext(uvlong addr) { - ulong val; + uvlong val; int top, bot, mid; Sym *sp; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:664,672 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:685,693 top = ntxt; for (mid = (bot+top)/2; mid < top; mid = (bot+top)/2) { sp = txt[mid].sym; - if(val < (ulong)sp->value) + if(val < sp->value) top = mid; - else if(mid != ntxt-1 && val >= (ulong)txt[mid+1].sym->value) + else if(mid != ntxt-1 && val >= txt[mid+1].sym->value) bot = mid; else return mid; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:677,686 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:698,707 /* * Find data symbol containing addr; binary search assumes data array is sorted by addr */ - static - int srchdata(long addr) + static int + srchdata(uvlong addr) { - ulong val; + uvlong val; int top, bot, mid; Sym *sp; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:689,697 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:710,718 val = addr; for(mid = (bot+top)/2; mid < top; mid = (bot+top)/2) { sp = globals[mid]; - if(val < (ulong)sp->value) + if(val < sp->value) top = mid; - else if(mid < nglob-1 && val >= (ulong)globals[mid+1]->value) + else if(mid < nglob-1 && val >= globals[mid+1]->value) bot = mid; else return mid; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:698,703 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:719,725 } return -1; } + /* * Find symbol containing val in specified search space * There is a special case when a value falls beyond the end /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:706,712 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:728,734 * data space are searched for a match. */ int - findsym(long w, int type, Symbol *s) + findsym(uvlong val, int type, Symbol *s) { int i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:714,720 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:736,742 return 0; if(type == CTEXT || type == CANY) { - i = srchtext(w); + i = srchtext(val); if(i >= 0) { if(type == CTEXT || i != ntxt-1) { fillsym(txt[i].sym, s); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:725,731 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:747,753 } } if(type == CDATA || type == CANY) { - i = srchdata(w); + i = srchdata(val); if(i >= 0) { fillsym(globals[i], s); s->index = i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:739,745 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:761,767 * Find the start and end address of the function containing addr */ int - fnbound(long addr, ulong *bounds) + fnbound(uvlong addr, uvlong *bounds) { int i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:779,784 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:801,807 } return 0; } + /* * get the ith global symbol */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:797,820 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:820,843 } return 0; } + /* * find the pc given a file name and line offset into it. */ - long - file2pc(char *file, ulong line) + uvlong + file2pc(char *file, long line) { File *fp; - int i; - long pc; - ulong start, end; + long i; + uvlong pc, start, end; short *name; if(buildtbls() == 0 || files == 0) - return -1; + return ~0; name = encfname(file); if(name == 0) { /* encode the file name */ werrstr("file %s not found", file); - return -1; + return ~0; } /* find this history stack */ for(i = 0, fp = files; i < nfiles; i++, fp++) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:823,829 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:846,852 free(name); if(i >= nfiles) { werrstr("line %ld in file %s not found", line, file); - return -1; + return ~0; } start = fp->addr; /* first text addr this file */ if(i < nfiles-1) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:835,848 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:858,872 * run the state machine to locate the pc closest to that value. */ if(debug) - print("find pc for %ld - between: %lux and %lux\n", line, start, end); + print("find pc for %ld - between: %llux and %llux\n", line, start, end); pc = line2addr(line, start, end); - if(pc == -1) { + if(pc == ~0) { werrstr("line %ld not in file %s", line, file); - return -1; + return ~0; } return pc; } + /* * search for a path component index */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:856,861 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:880,886 return i; return -1; } + /* * Encode a char file name as a sequence of short indices * into the file name dictionary. /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:893,904 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:918,930 dest[i] = 0; return dest; } + /* * Search a history stack for a matching file name accumulating * the size of intervening files in the stack. */ static int - hline(File *fp, short *name, ulong *line) + hline(File *fp, short *name, long *line) { Hist *hp; int offset, depth; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:942,947 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:968,974 *line = ln+offset; return 1; } + /* * compare two encoded file names */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:966,979 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:993,1006 } return *s == 0; } + /* * Convert a pc to a "file:line {file:line}" string. */ - int - fileline(char *str, int n, ulong dot) + long + fileline(char *str, int n, uvlong dot) { - long line; - int top, bot, mid; + long line, top, bot, mid; File *f; *str = 0; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1008,1014 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1035,1041 { Hist *start; /* start of current level */ Hist *h; /* current entry */ - int delta; /* sum of size of files this level */ + long delta; /* sum of size of files this level */ int k; start = base; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1067,1072 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1094,1100 ********************/ return 0; } + /* * convert an encoded file name to a string. */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1093,1098 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1121,1127 } return i; } + /* * compare the values of two symbol table entries. */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1106,1111 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1135,1141 return i; return strcmp((*(Sym**)a)->name, (*(Sym**)b)->name); } + /* * compare the values of the symbols referenced by two text table entries */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1114,1119 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1144,1150 { return ((Txtsym*)a)->sym->value - ((Txtsym*)b)->sym->value; } + /* * compare the values of the symbols referenced by two file table entries */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1122,1127 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1153,1159 { return ((File*)a)->addr - ((File*)b)->addr; } + /* * fill an interface Symbol structure from a symbol table entry */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1160,1183 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1192,1214 } s->handle = 0; } + /* * find the stack frame, given the pc */ - long - pc2sp(ulong pc) + uvlong + pc2sp(uvlong pc) { - uchar *c; - uchar u; - ulong currpc; - long currsp; + uchar *c, u; + uvlong currpc, currsp; if(spoff == 0) - return -1; + return ~0; currsp = 0; currpc = txtstart - mach->pcquant; if(pctxtend) - return -1; + return ~0; for(c = spoff; c < spoffend; c++) { if (currpc >= pc) return currsp; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1194,1210 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1225,1241 currpc += mach->pcquant*(u-129); currpc += mach->pcquant; } - return -1; + return ~0; } + /* * find the source file line number for a given value of the pc */ long - pc2line(ulong pc) + pc2line(uvlong pc) { - uchar *c; - uchar u; - ulong currpc; + uchar *c, u; + uvlong currpc; long currline; if(pcline == 0) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1212,1218 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1243,1249 currline = 0; currpc = txtstart-mach->pcquant; if(pctxtend) - return -1; + return ~0; for(c = pcline; c < pclineend; c++) { if(currpc >= pc) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1230,1237 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1261,1269 currpc += mach->pcquant*(u-129); currpc += mach->pcquant; } - return -1; + return ~0; } + /* * find the pc associated with a line number * basepc and endpc are text addresses bounding the search. /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1239,1260 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1271,1291 * usually, basepc and endpc contain the first text address in * a file and the first text address in the following file, respectively. */ - long - line2addr(ulong line, ulong basepc, ulong endpc) + uvlong + line2addr(long line, uvlong basepc, uvlong endpc) { - uchar *c; - uchar u; - ulong currpc; + uchar *c, u; + uvlong currpc, pc; long currline; long delta, d; - long pc, found; + int found; if(pcline == 0 || line == 0) - return -1; + return ~0; currline = 0; currpc = txtstart-mach->pcquant; - pc = -1; + pc = ~0; found = 0; delta = HUGEINT; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1287,1294 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1318,1326 } if(found) return pc; - return -1; + return ~0; } + /* * Print a history stack (debug). if count is 0, prints the whole stack */ [rsc] --rw-rw-r-- M 451989 jmk sys 3436 Nov 6 10:02 sys/src/libmach/u.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/u.c:108,115 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/u.c:108,116 "setSB", /* static base register name */ 0, /* value */ 0x2000, /* page size */ - 0x80000000, /* kernel base */ + 0x80000000ULL, /* kernel base */ 0, /* kernel text mask */ + 0x7FFFFFFFULL, /* user stack top */ 4, /* quantization of pc */ 4, /* szaddr */ 4, /* szreg */ [rsc] --rw-rw-r-- M 451989 jmk sys 21910 Nov 6 10:03 sys/src/libmach/udb.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:8,17 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:8,17 */ static char *sparc64excep(Map*, Rgetter); - static int sparc64foll(Map*, ulong, Rgetter, ulong*); - static int sparc64inst(Map*, ulong, char, char*, int); - static int sparc64das(Map*, ulong, char*, int); - static int sparc64instlen(Map*, ulong); + static int sparc64foll(Map*, uvlong, Rgetter, uvlong*); + static int sparc64inst(Map*, uvlong, char, char*, int); + static int sparc64das(Map*, uvlong, char*, int); + static int sparc64instlen(Map*, uvlong); Machdata sparc64mach = { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:143,149 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:143,149 int target; /* SETHI+ADD dest reg */ long w0; long w1; - ulong addr; /* pc of instruction */ + uvlong addr; /* pc of instruction */ char *curr; /* current fill level in output buffer */ char *end; /* end of buffer */ int size; /* number of longs in instr */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:153,159 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:153,159 static Map *mymap; /* disassembler context */ static int dascase; - static int mkinstr(ulong, Instr*); + static int mkinstr(uvlong, Instr*); static void bra1(Instr*, char*, char*[]); static void bra(Instr*, char*); static void fbra(Instr*, char*); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:317,323 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:317,323 static int decode(ulong pc, Instr *i) { - long w; + ulong w; if (get4(mymap, pc, &w) < 0) { werrstr("can't read instruction: %r"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:350,356 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:350,356 } static int - mkinstr(ulong pc, Instr *i) + mkinstr(uvlong pc, Instr *i) { Instr xi; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:381,387 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:381,387 } static int - printins(Map *map, ulong pc, char *buf, int n) + printins(Map *map, uvlong pc, char *buf, int n) { Instr instr; void (*f)(Instr*, char*); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:451,457 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:451,457 } static int - sparc64inst(Map *map, ulong pc, char modifier, char *buf, int n) + sparc64inst(Map *map, uvlong pc, char modifier, char *buf, int n) { static int fmtinstalled = 0; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:469,475 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:469,475 } static int - sparc64das(Map *map, ulong pc, char *buf, int n) + sparc64das(Map *map, uvlong pc, char *buf, int n) { Instr instr; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:490,496 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:490,496 } static int - sparc64instlen(Map *map, ulong pc) + sparc64instlen(Map *map, uvlong pc) { Instr i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:527,533 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:527,533 address(Instr *i) { Symbol s, s2; - long off, off1; + uvlong off, off1; if (i->rs1 == 1 && plocal(i) >= 0) return; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:537,543 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:537,543 && (s.class == CDATA || s.class == CTEXT)) { if(off==s.value && s.name[0]=='$'){ off1 = 0; - get4(mymap, s.value, &off1); + geta(mymap, s.value, &off1); if(off1 && findsym(off1, CANY, &s2) && s2.value == off1){ bprint(i, "$%s(SB)", s2.name); return; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:1034,1040 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:1034,1040 } static int - sparc64foll(Map *map, ulong pc, Rgetter rget, ulong *foll) + sparc64foll(Map *map, uvlong pc, Rgetter rget, uvlong *foll) { ulong w, r1, r2; char buf[8]; [rsc] --rw-rw-r-- M 451989 glenda sys 3446 Nov 6 10:02 sys/src/libmach/v.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/v.c:106,113 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/v.c:106,114 "setR30", /* static base register name */ 0, /* value */ 0x1000, /* page size */ - 0xC0000000, /* kernel base */ - 0x40000000, /* kernel text mask */ + 0xC0000000ULL, /* kernel base */ + 0x40000000ULL, /* kernel text mask */ + 0x7FFFFFFFULL, /* user stack top */ 4, /* quantization of pc */ 4, /* szaddr */ 4, /* szreg */ [rsc] --rw-rw-r-- M 451989 glenda sys 10258 Nov 6 10:03 sys/src/libmach/vcodas.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vcodas.c:6,12 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vcodas.c:6,12 /* mips native disassembler */ typedef struct { - long addr; /* pc of instr */ + uvlong addr; /* pc of instr */ uchar op; /* bits 31-26 */ uchar rs; /* bits 25-21 */ uchar rt; /* bits 20-16 */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vcodas.c:282,290 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vcodas.c:282,290 static int - mkinstr(Instr *i, Map *map, ulong pc) + mkinstr(Instr *i, Map *map, uvlong pc) { - long w; + ulong w; if (get4(map, pc, &w) < 0) { werrstr("can't read instruction: %r"); /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vcodas.c:506,512 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vcodas.c:506,512 } int - _mipscoinst(Map *map, ulong pc, char *buf, int n) + _mipscoinst(Map *map, uvlong pc, char *buf, int n) { Instr i; Opcode *o; [rsc] --rw-rw-r-- M 451989 glenda sys 22264 Nov 6 10:03 sys/src/libmach/vdb.c /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:7,16 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:7,16 */ static char *mipsexcep(Map*, Rgetter); - static int mipsfoll(Map*, ulong, Rgetter, ulong*); - static int mipsinst(Map*, ulong, char, char*, int); - static int mipsdas(Map*, ulong, char*, int); - static int mipsinstlen(Map*, ulong); + static int mipsfoll(Map*, uvlong, Rgetter, uvlong*); + static int mipsinst(Map*, uvlong, char, char*, int); + static int mipsdas(Map*, uvlong, char*, int); + static int mipsinstlen(Map*, uvlong); /* * Debugger interface /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:123,129 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:123,129 static char FRAMENAME[] = ".frame"; typedef struct { - ulong addr; + uvlong addr; uchar op; /* bits 31-26 */ uchar rs; /* bits 25-21 */ uchar rt; /* bits 20-16 */ /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:144,152 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:144,152 static Map *mymap; static int - decode(ulong pc, Instr *i) + decode(uvlong pc, Instr *i) { - long w; + ulong w; extern Mach mmips2le; if (get4(mymap, pc, &w) < 0) { /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:172,178 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:172,178 } static int - mkinstr(ulong pc, Instr *i) + mkinstr(uvlong pc, Instr *i) { Instr x; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:993,999 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:993,999 } static int - printins(Map *map, ulong pc, char *buf, int n) + printins(Map *map, uvlong pc, char *buf, int n) { Instr i; Opcode *o; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:1046,1056 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:1046,1056 return i.size*4; } - extern int _mipscoinst(Map *, ulong, char*, int); + extern int _mipscoinst(Map *, uvlong, char*, int); /* modifier 'I' toggles the default disassembler type */ static int - mipsinst(Map *map, ulong pc, char modifier, char *buf, int n) + mipsinst(Map *map, uvlong pc, char modifier, char *buf, int n) { if ((asstype == AMIPSCO && modifier == 'i') || (asstype == AMIPS && modifier == 'I')) /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:1060,1066 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:1060,1066 } static int - mipsdas(Map *map, ulong pc, char *buf, int n) + mipsdas(Map *map, uvlong pc, char *buf, int n) { Instr i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:1080,1086 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:1080,1086 } static int - mipsinstlen(Map *map, ulong pc) + mipsinstlen(Map *map, uvlong pc) { Instr i; /n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:1091,1097 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:1091,1097 } static int - mipsfoll(Map *map, ulong pc, Rgetter rget, ulong *foll) + mipsfoll(Map *map, uvlong pc, Rgetter rget, uvlong *foll) { ulong w, l; char buf[8]; [rsc] --rw-rw-r-- M 451989 glenda sys 2301 Nov 6 11:01 sys/src/libmach/elf.h /n/sourcesdump/2005/1106/plan9/sys/src/libmach/elf.h:1,22 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/elf.h:1,21 - /* * Definitions needed for accessing Irix ELF headers */ typedef struct { - unsigned char ident[16]; /* ident bytes */ - ushort type; /* file type */ - ushort machine; /* target machine */ - int version; /* file version */ - ulong elfentry; /* start address */ - ulong phoff; /* phdr file offset */ - ulong shoff; /* shdr file offset */ - int flags; /* file flags */ - ushort ehsize; /* sizeof ehdr */ - ushort phentsize; /* sizeof phdr */ - ushort phnum; /* number phdrs */ - ushort shentsize; /* sizeof shdr */ - ushort shnum; /* number shdrs */ - ushort shstrndx; /* shdr string index */ + uchar ident[16]; /* ident bytes */ + ushort type; /* file type */ + ushort machine; /* target machine */ + int version; /* file version */ + ulong elfentry; /* start address */ + ulong phoff; /* phdr file offset */ + ulong shoff; /* shdr file offset */ + int flags; /* file flags */ + ushort ehsize; /* sizeof ehdr */ + ushort phentsize; /* sizeof phdr */ + ushort phnum; /* number phdrs */ + ushort shentsize; /* sizeof shdr */ + ushort shnum; /* number shdrs */ + ushort shstrndx; /* shdr string index */ } Ehdr; typedef struct { [rsc] --rw-rw-r-- M 451989 glenda sys 604 Nov 6 11:01 sys/src/libmach/obj.h /n/sourcesdump/2005/1106/plan9/sys/src/libmach/obj.h:21,24 - /n/sourcesdump/2005/1107/plan9/sys/src/libmach/obj.h:21,24 }; #define UNKNOWN '?' - void _offset(int, long); + void _offset(int, vlong);