diff options
| author | forsyth <forsyth@lavoro.terzarima.net> | 2013-06-03 21:01:14 +0000 |
|---|---|---|
| committer | forsyth <forsyth@lavoro.terzarima.net> | 2013-06-03 21:01:14 +0000 |
| commit | 45a20ab721a513710138340faff3d59a31c3e01e (patch) | |
| tree | eea29d2684c51cc73725b8992a2125bede48e118 /utils/6l | |
| parent | cd8e99851af33e52bcdf8faf34f9d4e62fa0cbaf (diff) | |
sync compilers with Plan 9
remove 1[acl] 2[acl]
Diffstat (limited to 'utils/6l')
| -rw-r--r-- | utils/6l/Nt.c | 77 | ||||
| -rw-r--r-- | utils/6l/Plan9.c | 57 | ||||
| -rw-r--r-- | utils/6l/Posix.c | 80 | ||||
| -rw-r--r-- | utils/6l/README | 1 | ||||
| -rw-r--r-- | utils/6l/asm.c | 79 | ||||
| -rw-r--r-- | utils/6l/l.h | 26 | ||||
| -rw-r--r-- | utils/6l/mkfile | 8 | ||||
| -rw-r--r-- | utils/6l/obj.c | 207 | ||||
| -rw-r--r-- | utils/6l/optab.c | 10 | ||||
| -rw-r--r-- | utils/6l/span.c | 30 |
10 files changed, 225 insertions, 350 deletions
diff --git a/utils/6l/Nt.c b/utils/6l/Nt.c deleted file mode 100644 index 73c6f795..00000000 --- a/utils/6l/Nt.c +++ /dev/null @@ -1,77 +0,0 @@ -#include <windows.h> -#include "l.h" - -/* - * fake malloc - */ -void* -malloc(uint n) -{ - void *p; - - while(n & 7) - n++; - while(nhunk < n) - gethunk(); - p = hunk; - nhunk -= n; - hunk += n; - return p; -} - -void -free(void *p) -{ - USED(p); -} - -void* -calloc(uint m, uint n) -{ - void *p; - - n *= m; - p = malloc(n); - memset(p, 0, n); - return p; -} - -void* -realloc(void *p, uint n) -{ - void *new; - - new = malloc(n); - if(new && p) - memmove(new, p, n); - return new; -} - -#define Chunk (1*1024*1024) - -void* -mysbrk(ulong size) -{ - void *v; - static int chunk; - static uchar *brk; - - if(chunk < size) { - chunk = Chunk; - if(chunk < size) - chunk = Chunk + size; - brk = VirtualAlloc(NULL, chunk, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - if(brk == 0) - return (void*)-1; - } - v = brk; - chunk -= size; - brk += size; - return v; -} - -double -cputime(void) -{ - return ((double)0); -} diff --git a/utils/6l/Plan9.c b/utils/6l/Plan9.c deleted file mode 100644 index f4cf23f4..00000000 --- a/utils/6l/Plan9.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "l.h" - -/* - * fake malloc - */ -void* -malloc(ulong n) -{ - void *p; - - while(n & 7) - n++; - while(nhunk < n) - gethunk(); - p = hunk; - nhunk -= n; - hunk += n; - return p; -} - -void -free(void *p) -{ - USED(p); -} - -void* -calloc(ulong m, ulong n) -{ - void *p; - - n *= m; - p = malloc(n); - memset(p, 0, n); - return p; -} - -void* -realloc(void *p, ulong n) -{ - USED(p); - USED(n); - fprint(2, "realloc called\n"); - abort(); - return 0; -} - -void* -mysbrk(ulong size) -{ - return sbrk(size); -} - -void -setmalloctag(void*, ulong) -{ -} diff --git a/utils/6l/Posix.c b/utils/6l/Posix.c deleted file mode 100644 index 7c3a661f..00000000 --- a/utils/6l/Posix.c +++ /dev/null @@ -1,80 +0,0 @@ -#include "l.h" -#include <sys/types.h> -#include <sys/times.h> -#undef getwd -#include <unistd.h> /* For sysconf() and _SC_CLK_TCK */ - -/* - * fake malloc - */ -void* -malloc(size_t n) -{ - void *p; - - while(n & 7) - n++; - while(nhunk < n) - gethunk(); - p = hunk; - nhunk -= n; - hunk += n; - return p; -} - -void -free(void *p) -{ - USED(p); -} - -void* -calloc(size_t m, size_t n) -{ - void *p; - - n *= m; - p = malloc(n); - memset(p, 0, n); - return p; -} - -void* -realloc(void *p, size_t n) -{ - fprint(2, "realloc called\n", p, n); - abort(); - return 0; -} - -void* -mysbrk(ulong size) -{ - return (void*)sbrk(size); -} - -double -cputime(void) -{ - - struct tms tmbuf; - double ret_val; - - /* - * times() only fials if &tmbuf is invalid. - */ - (void)times(&tmbuf); - /* - * Return the total time (in system clock ticks) - * spent in user code and system - * calls by both the calling process and its children. - */ - ret_val = (double)(tmbuf.tms_utime + tmbuf.tms_stime + - tmbuf.tms_cutime + tmbuf.tms_cstime); - /* - * Convert to seconds. - */ - ret_val *= sysconf(_SC_CLK_TCK); - return ret_val; - -} diff --git a/utils/6l/README b/utils/6l/README deleted file mode 100644 index 602f5378..00000000 --- a/utils/6l/README +++ /dev/null @@ -1 +0,0 @@ -this is an intermediate version not yet ready for use diff --git a/utils/6l/asm.c b/utils/6l/asm.c index c4d46633..a4afaa2a 100644 --- a/utils/6l/asm.c +++ b/utils/6l/asm.c @@ -2,7 +2,7 @@ #define Dbufslop 100 -#define PADDR(a) ((ulong)(a) & ~0x80000000) +#define PADDR(a) ((a) & ~0xfffffffff0000000ull) vlong entryvalue(void) @@ -28,15 +28,15 @@ entryvalue(void) return s->value; } -void -wputl(ushort w) +/* these need to take long arguments to be compatible with elf.c */void +wputl(long w) { cput(w); cput(w>>8); } void -wput(ushort w) +wput(long w) { cput(w>>8); cput(w); @@ -68,6 +68,13 @@ lputl(long l) } void +llputl(vlong v) +{ + lputl(v); + lputl(v>>32); +} + +void strnput(char *s, int n) { for(; *s && n > 0; s++){ @@ -133,6 +140,7 @@ asmb(void) diag("unknown header type %ld", HEADTYPE); case 2: case 5: + case 6: seek(cout, HEADR+textsize, 0); break; } @@ -166,6 +174,7 @@ asmb(void) default: case 2: case 5: + case 6: seek(cout, HEADR+textsize+datsize, 0); break; } @@ -210,65 +219,11 @@ asmb(void) lput(lcsize); /* line offsets */ llput(vl); /* va of entry */ break; - case 3: /* plan9 */ - magic = 4*26*26+7; - if(dlm) - magic |= 0x80000000; - lput(magic); /* magic */ - lput(textsize); /* sizes */ - lput(datsize); - lput(bsssize); - lput(symsize); /* nsyms */ - lput(entryvalue()); /* va of entry */ - lput(spsize); /* sp offsets */ - lput(lcsize); /* line offsets */ - break; case 5: - strnput("\177ELF", 4); /* e_ident */ - cput(1); /* class = 32 bit */ - cput(1); /* data = LSB */ - cput(1); /* version = CURRENT */ - strnput("", 9); - wputl(2); /* type = EXEC */ - wputl(62); /* machine = AMD64 */ - lputl(1L); /* version = CURRENT */ - lputl(PADDR(entryvalue())); /* entry vaddr */ - lputl(52L); /* offset to first phdr */ - lputl(0L); /* offset to first shdr */ - lputl(0L); /* processor specific flags */ - wputl(52); /* Ehdr size */ - wputl(32); /* Phdr size */ - wputl(3); /* # of Phdrs */ - wputl(0); /* Shdr size */ - wputl(0); /* # of Shdrs */ - wputl(0); /* Shdr string size */ - - lputl(1L); /* text - type = PT_LOAD */ - lputl(HEADR); /* file offset */ - lputl(INITTEXT); /* vaddr */ - lputl(PADDR(INITTEXT)); /* paddr */ - lputl(textsize); /* file size */ - lputl(textsize); /* memory size */ - lputl(0x05L); /* protections = RX */ - lputl(INITRND); /* alignment */ - - lputl(1L); /* data - type = PT_LOAD */ - lputl(HEADR+textsize); /* file offset */ - lputl(INITDAT); /* vaddr */ - lputl(PADDR(INITDAT)); /* paddr */ - lputl(datsize); /* file size */ - lputl(datsize+bsssize); /* memory size */ - lputl(0x06L); /* protections = RW */ - lputl(INITRND); /* alignment */ - - lputl(0L); /* data - type = PT_NULL */ - lputl(HEADR+textsize+datsize); /* file offset */ - lputl(0L); - lputl(0L); - lputl(symsize); /* symbol table size */ - lputl(lcsize); /* line number size */ - lputl(0x04L); /* protections = R */ - lputl(0x04L); /* alignment */ + elf32(debug['8']? I386: AMD64, ELFDATA2LSB, 0, nil); + break; + case 6: + elf64(AMD64, ELFDATA2LSB, 0, nil); break; } cflush(); diff --git a/utils/6l/l.h b/utils/6l/l.h index 115aa69d..5a1c6b95 100644 --- a/utils/6l/l.h +++ b/utils/6l/l.h @@ -1,6 +1,7 @@ #include <lib9.h> #include <bio.h> #include "../6c/6.out.h" +#include "../8l/elf.h" #ifndef EXTERN #define EXTERN extern @@ -14,6 +15,8 @@ if(--cbc <= 0)\ cflush(); } +#define LIBNAMELEN 300 + typedef struct Adr Adr; typedef struct Prog Prog; typedef struct Sym Sym; @@ -226,7 +229,7 @@ EXTERN union { struct { - char obuf[MAXIO]; /* output buffer */ + uchar obuf[MAXIO]; /* output buffer */ uchar ibuf[MAXIO]; /* input buffer */ } u; char dbuf[1]; @@ -235,22 +238,26 @@ EXTERN union #define cbuf u.obuf #define xbuf u.ibuf +#pragma varargck type "A" int #pragma varargck type "A" uint #pragma varargck type "D" Adr* #pragma varargck type "P" Prog* #pragma varargck type "R" int #pragma varargck type "S" char* +#pragma varargck argpos diag 1 + EXTERN long HEADR; EXTERN long HEADTYPE; EXTERN vlong INITDAT; EXTERN long INITRND; EXTERN vlong INITTEXT; +EXTERN vlong INITTEXTP; EXTERN char* INITENTRY; /* entry point */ EXTERN Biobuf bso; EXTERN long bsssize; EXTERN int cbc; -EXTERN char* cbp; +EXTERN uchar* cbp; EXTERN char* pcstr; EXTERN int cout; EXTERN Auto* curauto; @@ -323,6 +330,7 @@ int Pconv(Fmt*); int Rconv(Fmt*); int Sconv(Fmt*); void addhist(long, int); +void addlibpath(char*); Prog* appendp(Prog*); void asmb(void); void asmdyn(void); @@ -349,8 +357,10 @@ void dynreloc(Sym*, ulong, int); vlong entryvalue(void); void errorexit(void); void export(void); +int fileexists(char*); int find1(long, int); int find2(long, int); +char* findlib(char*); void follow(void); void gethunk(void); void histtoauto(void); @@ -361,6 +371,8 @@ void ldobj(int, long, char*); void loadlib(void); void listinit(void); Sym* lookup(char*, int); +void llput(vlong v); +void llputl(vlong v); void lput(long); void lputl(long); void main(int, char*[]); @@ -376,17 +388,13 @@ int relinv(int); long reuse(Prog*, Sym*); vlong rnd(vlong, vlong); void span(void); +void strnput(char*, int); void undef(void); void undefsym(Sym*); vlong vaddr(Adr*); -void wput(ushort); +void wput(long); +void wputl(long); void xdefine(char*, int, vlong); void xfol(Prog*); int zaddr(uchar*, Adr*, Sym*[]); void zerosig(char*); - -#pragma varargck type "D" Adr* -#pragma varargck type "P" Prog* -#pragma varargck type "R" int -#pragma varargck type "A" int -#pragma varargck argpos diag 1 diff --git a/utils/6l/mkfile b/utils/6l/mkfile index 19a65c8b..e0bb5f7c 100644 --- a/utils/6l/mkfile +++ b/utils/6l/mkfile @@ -11,6 +11,7 @@ OFILES=\ list.$O\ enam.$O\ $TARGMODEL.$O\ + elf.$O\ HFILES=\ l.h\ @@ -23,7 +24,12 @@ BIN=$ROOT/$OBJDIR/bin <$ROOT/mkfiles/mkone-$SHELLTYPE -CFLAGS= $CFLAGS -I../include +CFLAGS= $CFLAGS -I../include -I. enam.$O: ../6c/enam.c $CC $CFLAGS ../6c/enam.c +elf.$O: ../ld/elf.c + $CC $CFLAGS ../ld/elf.c + +$TARGMODEL.$O: ../ld/$TARGMODEL.c + $CC $CFLAGS ../ld/$TARGMODEL.c diff --git a/utils/6l/obj.c b/utils/6l/obj.c index 9f57d612..ed52ec2b 100644 --- a/utils/6l/obj.c +++ b/utils/6l/obj.c @@ -12,14 +12,25 @@ char thechar = '6'; char *thestring = "amd64"; char *paramspace = "FP"; +char** libdir; +int nlibdir = 0; +static int maxlibdir = 0; + /* - * -H2 -T4136 -R4096 is plan9 64-bit format - * -H3 -T4128 -R4096 is plan9 32-bit format + * -H2 -T0x200028 -R0x200000 is plan9 format (was -T4136 -R4096) * -H5 -T0x80110000 -R4096 is ELF32 + * -H6 -T0x2000e8 -R0x200000 is ELF64 * - * options used: 189BLQSWabcjlnpsvz + * options used: 189BLPQSVWabcjlnpsvz */ +void +usage(void) +{ + diag("usage: %s [-options] objects", argv0); + errorexit(); +} + static int isobjfile(char *f) { @@ -47,6 +58,7 @@ main(int argc, char *argv[]) { int i, c; char *a; + char name[LIBNAMELEN]; Binit(&bso, 1, OWRITE); cout = -1; @@ -56,6 +68,7 @@ main(int argc, char *argv[]) outfile = "6.out"; HEADTYPE = -1; INITTEXT = -1; + INITTEXTP = -1; INITDAT = -1; INITRND = -1; INITENTRY = 0; @@ -78,11 +91,19 @@ main(int argc, char *argv[]) if(a) HEADTYPE = atolwhex(a); break; + case 'L': + addlibpath(EARGF(usage())); + break; case 'T': a = ARGF(); if(a) INITTEXT = atolwhex(a); break; + case 'P': + a = ARGF(); + if(a) + INITTEXTP = atolwhex(a); + break; case 'D': a = ARGF(); if(a) @@ -106,12 +127,20 @@ main(int argc, char *argv[]) break; } ARGEND USED(argc); - if(*argv == 0) { - diag("usage: 6l [-options] objects"); - errorexit(); - } + if(*argv == 0) + usage(); if(!debug['9'] && !debug['U'] && !debug['B']) debug[DEFAULT] = 1; + a = getenv("ccroot"); + if(a != nil && *a != '\0') { + if(!fileexists(a)) { + diag("nonexistent $ccroot: %s", a); + errorexit(); + } + }else + a = ""; + snprint(name, sizeof(name), "%s/%s/lib", a, thestring); + addlibpath(name); if(HEADTYPE == -1) { if(debug['B']) HEADTYPE = 2; @@ -125,31 +154,33 @@ main(int argc, char *argv[]) case 2: /* plan 9 */ HEADR = 32L+8L; if(INITTEXT == -1) - INITTEXT = 4096+HEADR; + INITTEXT = 0x200000+HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) - INITRND = 4096; + INITRND = 0x200000; break; - case 3: /* plan 9 */ - HEADR = 32L; + case 5: /* elf32 executable */ + HEADR = rnd(Ehdr32sz+3*Phdr32sz, 16); if(INITTEXT == -1) - INITTEXT = 4096+32; + INITTEXT = 0xf0110000L; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; - case 5: /* elf32 executable */ - HEADR = rnd(52L+3*32L, 16); + case 6: /* ELF64 executable */ + HEADR = rnd(Ehdr64sz+3*Phdr64sz, 16); if(INITTEXT == -1) - INITTEXT = 0x80110000L; + INITTEXT = 0x200000+HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) - INITRND = 4096; + INITRND = 0x200000; break; } + if (INITTEXTP == -1) + INITTEXTP = INITTEXT; if(INITDAT != 0 && INITRND != 0) print("warning: -D0x%llux is ignored because of -R0x%lux\n", INITDAT, INITRND); @@ -283,7 +314,7 @@ main(int argc, char *argv[]) dtype = 4; cout = create(outfile, 1, 0775); if(cout < 0) { - diag("cannot create %s", outfile); + diag("cannot create %s: %r", outfile); errorexit(); } version = 0; @@ -351,6 +382,42 @@ main(int argc, char *argv[]) } void +addlibpath(char *arg) +{ + char **p; + + if(nlibdir >= maxlibdir) { + if(maxlibdir == 0) + maxlibdir = 8; + else + maxlibdir *= 2; + p = malloc(maxlibdir*sizeof(*p)); + if(p == nil) { + diag("out of memory"); + errorexit(); + } + memmove(p, libdir, nlibdir*sizeof(*p)); + free(libdir); + libdir = p; + } + libdir[nlibdir++] = strdup(arg); +} + +char* +findlib(char *file) +{ + int i; + char name[LIBNAMELEN]; + + for(i = 0; i < nlibdir; i++) { + snprint(name, sizeof(name), "%s/%s", libdir[i], file); + if(fileexists(name)) + return libdir[i]; + } + return nil; +} + +void loadlib(void) { int i; @@ -390,25 +457,26 @@ objfile(char *file) int f, work; Sym *s; char magbuf[SARMAG]; - char name[100], pname[150]; + char name[LIBNAMELEN], pname[LIBNAMELEN]; struct ar_hdr arhdr; char *e, *start, *stop; - if(file[0] == '-' && file[1] == 'l') { - if(debug['9']) - sprint(name, "/%s/lib/lib", thestring); - else - sprint(name, "/usr/%clib/lib", thechar); - strcat(name, file+2); - strcat(name, ".a"); - file = name; - } if(debug['v']) Bprint(&bso, "%5.2f ldobj: %s\n", cputime(), file); Bflush(&bso); + if(file[0] == '-' && file[1] == 'l') { + snprint(pname, sizeof(pname), "lib%s.a", file+2); + e = findlib(pname); + if(e == nil) { + diag("cannot find library: %s", file); + errorexit(); + } + snprint(name, sizeof(name), "%s/%s", e, pname); + file = name; + } f = open(file, 0); if(f < 0) { - diag("cannot open file: %s", file); + diag("cannot open %s: %r", file); errorexit(); } l = read(f, magbuf, SARMAG); @@ -467,7 +535,8 @@ objfile(char *file) l |= (e[3] & 0xff) << 16; l |= (e[4] & 0xff) << 24; seek(f, l, 0); - l = read(f, &arhdr, SAR_HDR); + /* need readn to read the dumps (at least) */ + l = readn(f, &arhdr, SAR_HDR); if(l != SAR_HDR) goto bad; if(strncmp(arhdr.fmag, ARFMAG, sizeof(arhdr.fmag))) @@ -494,7 +563,7 @@ int zaddr(uchar *p, Adr *a, Sym *h[]) { int c, t, i; - long l; + int l; Sym *s; Auto *u; @@ -579,25 +648,24 @@ zaddr(uchar *p, Adr *a, Sym *h[]) void addlib(char *obj) { - char name[1024], comp[256], *p; - int i; + char fn1[LIBNAMELEN], fn2[LIBNAMELEN], comp[LIBNAMELEN], *p, *name; + int i, search; if(histfrogp <= 0) return; + name = fn1; + search = 0; if(histfrog[0]->name[1] == '/') { sprint(name, ""); i = 1; - } else - if(histfrog[0]->name[1] == '.') { + } else if(histfrog[0]->name[1] == '.') { sprint(name, "."); i = 0; } else { - if(debug['9']) - sprint(name, "/%s/lib", thestring); - else - sprint(name, "/usr/%clib", thechar); + sprint(name, ""); i = 0; + search = 1; } for(; i<histfrogp; i++) { @@ -620,13 +688,25 @@ addlib(char *obj) memmove(p+strlen(thestring), p+2, strlen(p+2)+1); memmove(p, thestring, strlen(thestring)); } - if(strlen(name) + strlen(comp) + 3 >= sizeof(name)) { + if(strlen(fn1) + strlen(comp) + 3 >= sizeof(fn1)) { diag("library component too long"); return; } - strcat(name, "/"); - strcat(name, comp); + if(i > 0 || !search) + strcat(fn1, "/"); + strcat(fn1, comp); + } + + cleanname(name); + + if(search){ + p = findlib(name); + if(p != nil){ + snprint(fn2, sizeof(fn2), "%s/%s", p, name); + name = fn2; + } } + for(i=0; i<libraryp; i++) if(strcmp(name, library[i]) == 0) return; @@ -1138,8 +1218,7 @@ lookup(char *symb, int v) for(p=symb; c = *p; p++) h = h+h+h + c; l = (p - symb) + 1; - if(h < 0) - h = ~h; + h &= 0xffffff; h %= NHASH; for(s = hash[h]; s != S; s = s->link) if(s->version == v) @@ -1288,16 +1367,24 @@ void doprof2(void) { Sym *s2, *s4; - Prog *p, *q, *ps2, *ps4; + Prog *p, *q, *q2, *ps2, *ps4; if(debug['v']) Bprint(&bso, "%5.2f profile 2\n", cputime()); Bflush(&bso); - s2 = lookup("_profin", 0); - s4 = lookup("_profout", 0); + if(debug['e']){ + s2 = lookup("_tracein", 0); + s4 = lookup("_traceout", 0); + }else{ + s2 = lookup("_profin", 0); + s4 = lookup("_profout", 0); + } if(s2->type != STEXT || s4->type != STEXT) { - diag("_profin/_profout not defined"); + if(debug['e']) + diag("_tracein/_traceout not defined %d %d", s2->type, s4->type); + else + diag("_profin/_profout not defined"); return; } @@ -1338,7 +1425,20 @@ doprof2(void) q->line = p->line; q->pc = p->pc; q->link = p->link; - p->link = q; + if(debug['e']){ /* embedded tracing */ + q2 = prg(); + p->link = q2; + q2->link = q; + + q2->line = p->line; + q2->pc = p->pc; + + q2->as = AJMP; + q2->to.type = D_BRANCH; + q2->to.sym = p->to.sym; + q2->pcond = q->link; + }else + p->link = q; p = q; p->as = ACALL; p->to.type = D_BRANCH; @@ -1349,6 +1449,17 @@ doprof2(void) } if(p->as == ARET) { /* + * RET (default) + */ + if(debug['e']){ /* embedded tracing */ + q = prg(); + q->line = p->line; + q->pc = p->pc; + q->link = p->link; + p->link = q; + p = q; + } + /* * RET */ q = prg(); diff --git a/utils/6l/optab.c b/utils/6l/optab.c index db22ca67..133bb1d2 100644 --- a/utils/6l/optab.c +++ b/utils/6l/optab.c @@ -15,8 +15,10 @@ uchar ynop[] = Ynone, Ynone, Zpseudo,1, Ynone, Yml, Zpseudo,1, Ynone, Yrf, Zpseudo,1, + Ynone, Yxr, Zpseudo,1, Yml, Ynone, Zpseudo,1, Yrf, Ynone, Zpseudo,1, + Yxr, Ynone, Zpseudo,1, 0 }; uchar yxorb[] = @@ -753,7 +755,7 @@ Optab optab[] = { AMOVBWSX, ymb_rl, Pq, 0xbe }, { AMOVBWZX, ymb_rl, Pq, 0xb6 }, { AMOVO, yxmov, Pe, 0x6f,0x7f }, - { AMOVOU, yxmov, Pf2, 0x6f,0x7f }, + { AMOVOU, yxmov, Pf3, 0x6f,0x7f }, { AMOVHLPS, yxr, Pm, 0x12 }, { AMOVHPD, yxmov, Pe, 0x16,0x17 }, { AMOVHPS, yxmov, Pm, 0x16,0x17 }, @@ -762,7 +764,7 @@ Optab optab[] = { AMOVLPD, yxmov, Pe, 0x12,0x13 }, { AMOVLPS, yxmov, Pm, 0x12,0x13 }, { AMOVLQSX, yml_rl, Pw, 0x63 }, - { AMOVLQZX, yml_rl, Px, 0x63 }, + { AMOVLQZX, yml_rl, Px, 0x8b }, { AMOVMSKPD, yxrrl, Pq, 0x50 }, { AMOVMSKPS, yxrrl, Pm, 0x50 }, { AMOVNTO, yxr_ml, Pe, 0xe7 }, @@ -877,9 +879,9 @@ Optab optab[] = { APOPQ, ypopl, Py, 0x58,0x8f,(00) }, { APOPW, ypopl, Pe, 0x58,0x8f,(00) }, { APOR, ymm, Py, 0xeb,Pe,0xeb }, - { APSADBW, yxm, Pw, Pe,0xf6 }, + { APSADBW, yxm, Pq, 0xf6 }, { APSHUFHW, yxshuf, Pf3, 0x70 }, - { APSHUFL, yxm, Pw, Pe,0x70 }, + { APSHUFL, yxshuf, Pq, 0x70 }, { APSHUFLW, yxshuf, Pf2, 0x70 }, { APSHUFW, ymshuf, Pm, 0x70 }, { APSLLO, ypsdq, Pq, 0x73,(07) }, diff --git a/utils/6l/span.c b/utils/6l/span.c index 1ce533d0..e49d873f 100644 --- a/utils/6l/span.c +++ b/utils/6l/span.c @@ -127,9 +127,17 @@ putsymb(char *s, int t, vlong v, int ver) if(t == 'f') s++; l = 4; - if(!debug['8']){ + switch(HEADTYPE){ + default: + break; + case 5: + if(debug['8']) + break; + case 2: + case 6: lput(v>>32); l = 8; + break; } lput(v); if(ver) @@ -245,12 +253,12 @@ asmlc(void) if(p->line == oldlc || p->as == ATEXT || p->as == ANOP) { if(p->as == ATEXT) curtext = p; - if(debug['L']) + if(debug['V']) Bprint(&bso, "%6llux %P\n", p->pc, p); continue; } - if(debug['L']) + if(debug['V']) Bprint(&bso, "\t\t%6ld", lcsize); v = (p->pc - oldpc) / MINLC; while(v) { @@ -258,7 +266,7 @@ asmlc(void) if(v < 127) s = v; cput(s+128); /* 129-255 +pc */ - if(debug['L']) + if(debug['V']) Bprint(&bso, " pc+%ld*%d(%ld)", s, MINLC, s+128); v -= s; lcsize++; @@ -272,7 +280,7 @@ asmlc(void) cput(s>>16); cput(s>>8); cput(s); - if(debug['L']) { + if(debug['V']) { if(s > 0) Bprint(&bso, " lc+%ld(%d,%ld)\n", s, 0, s); @@ -287,14 +295,14 @@ asmlc(void) } if(s > 0) { cput(0+s); /* 1-64 +lc */ - if(debug['L']) { + if(debug['V']) { Bprint(&bso, " lc+%ld(%ld)\n", s, 0+s); Bprint(&bso, "%6llux %P\n", p->pc, p); } } else { cput(64-s); /* 65-128 -lc */ - if(debug['L']) { + if(debug['V']) { Bprint(&bso, " lc%ld(%ld)\n", s, 64-s); Bprint(&bso, "%6llux %P\n", p->pc, p); @@ -307,7 +315,7 @@ asmlc(void) cput(s); lcsize++; } - if(debug['v'] || debug['L']) + if(debug['v'] || debug['V']) Bprint(&bso, "lcsize = %ld\n", lcsize); Bflush(&bso); } @@ -1385,7 +1393,7 @@ found: q = p->pcond; if(q) { v = q->pc - p->pc - 2; - if(v < -128 && v > 127) + if(v < -128 || v > 127) diag("loop too far: %P", p); *andptr++ = op; *andptr++ = v; @@ -1574,7 +1582,7 @@ asmins(Prog *p) /* * as befits the whole approach of the architecture, * the rex prefix must appear before the first opcode byte - * (and thus after any 66/67/f2/f3 prefix bytes, but + * (and thus after any 66/67/f2/f3/26/2e/3e prefix bytes, but * before the 0f opcode escape!), or it might be ignored. * note that the handbook often misleadingly shows 66/f2/f3 in `opcode'. */ @@ -1583,7 +1591,7 @@ asmins(Prog *p) n = andptr - and; for(np = 0; np < n; np++) { c = and[np]; - if(c != 0x66 && c != 0xf2 && c != 0xf3 && c != 0x67) + if(c != 0xf2 && c != 0xf3 && (c < 0x64 || c > 0x67) && c != 0x2e && c != 0x3e && c != 0x26) break; } memmove(and+np+1, and+np, n-np); |
