]> Cypherpunks repositories - gostls13.git/commitdiff
libmach: fix for Plan 9 build
authorLucio De Re <lucio.dere@gmail.com>
Sat, 19 Nov 2011 04:11:50 +0000 (23:11 -0500)
committerRuss Cox <rsc@golang.org>
Sat, 19 Nov 2011 04:11:50 +0000 (23:11 -0500)
R=rsc
CC=golang-dev
https://golang.org/cl/5316059

src/libmach/5db.c
src/libmach/8db.c
src/libmach/executable.c
src/libmach/machdata.c
src/libmach/sym.c

index aea391edfcd8b2b62c4c821e9700de0f8e20613b..ae71dd90dc83ed42e46b25253337cb1d3a709338 100644 (file)
@@ -307,7 +307,7 @@ gsymoff(char *buf, int n, long v, int space)
        if (!delta)
                return snprint(buf, n, "%s", s.name);
        if (s.type != 't' && s.type != 'T')
-               return snprint(buf, n, "%s+%lux", s.name, v-s.value);
+               return snprint(buf, n, "%s+%llux", s.name, v-s.value);
        else
                return snprint(buf, n, "#%lux", v);
 }
index 5b3de69a51702f3c0cf12232f569c6df9f13e21e..a5d147a8e2d23e30ff37d369ef11193b13c713d3 100644 (file)
@@ -125,7 +125,7 @@ i386excep(Map *map, Rgetter rget)
                        if (memcmp(buf, machdata->bpinst, machdata->bpsize) == 0)
                                return "breakpoint";
                }
-               snprint(buf, sizeof(buf), "exception %ld", c);
+               snprint(buf, sizeof(buf), "exception %d", c);
                return buf;
        } else
                return excname[c];
@@ -1971,7 +1971,7 @@ plocal(Instr *ip)
 
        offset = ip->disp;
        if (!findsym(ip->addr, CTEXT, &s) || !findlocal(&s, FRAMENAME, &s)) {
-               bprint(ip, "%lux(SP)", offset);
+               bprint(ip, "%ux(SP)", offset);
                return;
        }
 
@@ -1987,7 +1987,7 @@ plocal(Instr *ip)
                bprint(ip, "%s+", s.name);
        else
                offset = ip->disp;
-       bprint(ip, "%lux%s", offset, reg);
+       bprint(ip, "%ux%s", offset, reg);
 }
 
 static int
@@ -2061,7 +2061,7 @@ immediate(Instr *ip, vlong val)
                        w = -w;
                if (issymref(ip, &s, w, val)) {
                        if (w)
-                               bprint(ip, "%s+%#lux(SB)", s.name, w);
+                               bprint(ip, "%s+%#ux(SB)", s.name, w);
                        else
                                bprint(ip, "%s(SB)", s.name);
                        return;
@@ -2104,7 +2104,7 @@ pea(Instr *ip)
                if (ip->base < 0)
                        immediate(ip, ip->disp);
                else {
-                       bprint(ip, "%lux", ip->disp);
+                       bprint(ip, "%ux", ip->disp);
                        if(ip->rip)
                                bprint(ip, "(RIP)");
                        bprint(ip,"(%s%s)", ANAME(ip), reg[ip->rex&REXB? ip->base+8: ip->base]);
@@ -2197,7 +2197,7 @@ prinstr(Instr *ip, char *fmt)
                                bprint(ip, "CBW");
                        break;
                case 'd':
-                       bprint(ip,"%ux:%lux",ip->seg,ip->disp);
+                       bprint(ip,"%ux:%ux", ip->seg, ip->disp);
                        break;
                case 'm':
                        if (ip->mod == 3 && ip->osize != 'B') {
index 9d45323021347483d8ae780b8f3dde68f378b917..3db3e7da4d98ae20eabb435dfa943048a26b28a6 100644 (file)
@@ -677,7 +677,7 @@ elf64dotout(int fd, Fhdr *fp, ExecHdr *hp)
        uint32 (*swal)(uint32);
        ushort (*swab)(ushort);
        Ehdr64 *ep;
-       Phdr64 *ph;
+       Phdr64 *ph, *pph;
        Shdr64 *sh;
        int i, it, id, is, phsz, shsz;
 
@@ -797,7 +797,8 @@ elf64dotout(int fd, Fhdr *fp, ExecHdr *hp)
        }
 
        settext(fp, ep->elfentry, ph[it].vaddr, ph[it].memsz, ph[it].offset);
-       setdata(fp, ph[id].vaddr, ph[id].filesz, ph[id].offset, ph[id].memsz - ph[id].filesz);
+       pph = ph + id;
+       setdata(fp, pph->vaddr, pph->filesz, pph->offset, pph->memsz - pph->filesz);
        if(is != -1)
                setsym(fp, ph[is].offset, ph[is].filesz, 0, 0, 0, ph[is].memsz);
        else if(sh != 0){
@@ -1049,7 +1050,6 @@ machdotout(int fd, Fhdr *fp, ExecHdr *hp)
        mp->sizeofcmds = swal(mp->sizeofcmds);
        mp->flags = swal(mp->flags);
        mp->reserved = swal(mp->reserved);
-       hdrsize = 0;
 
        switch(mp->magic) {
        case 0xFEEDFACE:        // 32-bit mach
@@ -1104,7 +1104,9 @@ machdotout(int fd, Fhdr *fp, ExecHdr *hp)
        datava = 0;
        symtab = 0;
        pclntab = 0;
-       textsize = datasize = bsssize = 0;
+       textsize = 0;
+       datasize = 0;
+       bsssize = 0;
        for (i = 0; i < mp->ncmds; i++) {
                MachCmd *c;
 
@@ -1379,7 +1381,8 @@ pedotout(int fd, Fhdr *fp, ExecHdr *hp)
        }
 
        seek(fd, start+sizeof(magic)+sizeof(fh)+leswab(fh.SizeOfOptionalHeader), 0);
-       fp->txtaddr = fp->dataddr = 0;
+       fp->txtaddr = 0;
+       fp->dataddr = 0;
        for (i=0; i<leswab(fh.NumberOfSections); i++) {
                if (readn(fd, &sh, sizeof(sh)) != sizeof(sh)) {
                        werrstr("could not read Section Header %d", i+1);
@@ -1398,7 +1401,7 @@ pedotout(int fd, Fhdr *fp, ExecHdr *hp)
        seek(fd, leswal(fh.PointerToSymbolTable), 0);
        symtab = esymtab = 0;
        for (i=0; i<leswal(fh.NumberOfSymbols); i++) {
-               if (readn(fd, &sym, sizeof(sym)) != sizeof(sym)) {
+               if (readn(fd, sym, sizeof(sym)) != sizeof(sym)) {
                        werrstr("crippled COFF symbol %d", i);
                        return 0;
                }
@@ -1452,7 +1455,6 @@ setsym(Fhdr *fp, vlong symoff, int32 symsz, vlong sppcoff, int32 sppcsz, vlong l
        fp->lnpcsz = lnpcsz;
 }
 
-
 static uvlong
 _round(uvlong a, uint32 b)
 {
index 425a9217946ca1db5ebd9d74c665a466933315e2..66c19f9537612803b802eb0dfd748712b08cd433 100644 (file)
@@ -113,7 +113,7 @@ symoff(char *buf, int n, uvlong v, int space)
        if (s.type != 't' && s.type != 'T' && delta >= 4096)
                return snprint(buf, n, "%llux", v);
        else if (delta)
-               return snprint(buf, n, "%s+%#lux", s.name, delta);
+               return snprint(buf, n, "%s+%#ux", s.name, delta);
        else
                return snprint(buf, n, "%s", s.name);
 }
@@ -139,7 +139,7 @@ fpformat(Map *map, Reglist *rp, char *buf, int n, int modif)
        case 'X':
                if (get4(map, rp->roffs, &r) < 0)
                        return -1;
-               snprint(buf, n, "%lux", r);
+               snprint(buf, n, "%ux", r);
                break;
        case 'F':       /* first reg of double reg pair */
                if (modif == 'F')
@@ -219,12 +219,12 @@ ieeedftos(char *buf, int n, uint32 h, uint32 l)
                return snprint(buf, n, "0.");
        exp = (h>>20) & ((1L<<11)-1L);
        if(exp == 0)
-               return snprint(buf, n, "DeN(%.8lux%.8lux)", h, l);
+               return snprint(buf, n, "DeN(%.8ux%.8ux)", h, l);
        if(exp == ((1L<<11)-1L)){
                if(l==0 && (h&((1L<<20)-1L)) == 0)
                        return snprint(buf, n, "Inf");
                else
-                       return snprint(buf, n, "NaN(%.8lux%.8lux)", h&((1L<<20)-1L), l);
+                       return snprint(buf, n, "NaN(%.8ux%.8ux)", h&((1<<20)-1), l);
        }
        exp -= (1L<<10) - 2L;
        fr = l & ((1L<<16)-1L);
@@ -256,7 +256,7 @@ ieeesftos(char *buf, int n, uint32 h)
                return snprint(buf, n, "0.");
        exp = (h>>23) & ((1L<<8)-1L);
        if(exp == 0)
-               return snprint(buf, n, "DeN(%.8lux)", h);
+               return snprint(buf, n, "DeN(%.8ux)", h);
        if(exp == ((1L<<8)-1L)){
                if((h&((1L<<23)-1L)) == 0)
                        return snprint(buf, n, "Inf");
index 5e4fdd86738acd15f44fcb4743d7ff53db1a9397..1512d7a4fe8a68290e186e64aa8ebf32747a68a8 100644 (file)
@@ -124,7 +124,7 @@ syminit(int fd, Fhdr *fp)
                /* minimum symbol record size = 4+1+2 bytes */
        symbols = malloc((fp->symsz/(4+1+2)+1)*sizeof(Sym));
        if(symbols == 0) {
-               werrstr("can't malloc %ld bytes", fp->symsz);
+               werrstr("can't malloc %d bytes", fp->symsz);
                return -1;
        }
        Binit(&b, fd, OREAD);
@@ -203,11 +203,11 @@ syminit(int fd, Fhdr *fp)
                }
        }
        if (debug)
-               print("NG: %ld NT: %d NF: %d\n", nglob, ntxt, fmaxi);
+               print("NG: %d NT: %d NF: %d\n", nglob, ntxt, fmaxi);
        if (fp->sppcsz) {                       /* pc-sp offset table */
                spoff = (uchar *)malloc(fp->sppcsz);
                if(spoff == 0) {
-                       werrstr("can't malloc %ld bytes", fp->sppcsz);
+                       werrstr("can't malloc %d bytes", fp->sppcsz);
                        return -1;
                }
                Bseek(&b, fp->sppcoff, 0);
@@ -220,7 +220,7 @@ syminit(int fd, Fhdr *fp)
        if (fp->lnpcsz) {                       /* pc-line number table */
                pcline = (uchar *)malloc(fp->lnpcsz);
                if(pcline == 0) {
-                       werrstr("can't malloc %ld bytes", fp->lnpcsz);
+                       werrstr("can't malloc %d bytes", fp->lnpcsz);
                        return -1;
                }
                Bseek(&b, fp->lnpcoff, 0);
@@ -280,12 +280,12 @@ decodename(Biobuf *bp, Sym *p)
                n = Bseek(bp, 0, 1)-o;
                p->name = malloc(n);
                if(p->name == 0) {
-                       werrstr("can't malloc %ld bytes", n);
+                       werrstr("can't malloc %d bytes", n);
                        return -1;
                }
                Bseek(bp, -n, 1);
                if(Bread(bp, p->name, n) != n) {
-                       werrstr("can't read %ld bytes of symbol name", n);
+                       werrstr("can't read %d bytes of symbol name", n);
                        return -1;
                }
        } else {
@@ -297,7 +297,7 @@ decodename(Biobuf *bp, Sym *p)
                n = Blinelen(bp);
                p->name = malloc(n);
                if(p->name == 0) {
-                       werrstr("can't malloc %ld bytes", n);
+                       werrstr("can't malloc %d bytes", n);
                        return -1;
                }
                strcpy(p->name, cp);
@@ -913,7 +913,7 @@ file2pc(char *file, int32 line)
                        break;
        free(name);
        if(i >= nfiles) {
-               werrstr("line %ld in file %s not found", line, file);
+               werrstr("line %d in file %s not found", line, file);
                return ~0;
        }
        start = fp->addr;               /* first text addr this file */
@@ -926,10 +926,10 @@ file2pc(char *file, int32 line)
         * run the state machine to locate the pc closest to that value.
         */
        if(debug)
-               print("find pc for %ld - between: %llux and %llux\n", line, start, end);
+               print("find pc for %d - between: %llux and %llux\n", line, start, end);
        pc = line2addr(line, start, end);
        if(pc == ~0) {
-               werrstr("line %ld not in file %s", line, file);
+               werrstr("line %d not in file %s", line, file);
                return ~0;
        }
        return pc;
@@ -1146,7 +1146,7 @@ fline(char *str, int n, int32 line, Hist *base, Hist **ret)
        else {
                k = fileelem(fnames, (uchar*)start->name, str, n);
                if(k+8 < n)
-                       sprint(str+k, ":%ld", line);
+                       sprint(str+k, ":%d", line);
        }
 /**********Remove comments for complete back-trace of include sequence
  *     if(start != base) {
@@ -1404,7 +1404,7 @@ printhist(char *msg, Hist *hp, int count)
        while(hp->name) {
                if(count && ++i > count)
                        break;
-               print("%s Line: %lx (%ld)  Offset: %lx (%ld)  Name: ", msg,
+               print("%s Line: %x (%d)  Offset: %x (%d)  Name: ", msg,
                        hp->line, hp->line, hp->offset, hp->offset);
                for(cp = (uchar *)hp->name+1; (*cp<<8)|cp[1]; cp += 2) {
                        if (cp != (uchar *)hp->name+1)