--- /rc/bin/fshalt Thu Jun 13 23:27:53 2013 +++ /rc/bin/fshalt Fri Jul 19 21:55:08 2013 @@ -44,8 +44,8 @@ } fn isbootable { - # on mips (for example), kernels are now a.out format - test -e $1 && ~ `{file $1} *' plan 9 boot image' *' plan 9 executable'* + test -e $1 && ~ `{file $1} *' plan 9 boot image' \ + *' plan 9 executable'* *ELF*' executable' } fn usekernel { kerncopy=kern --- /sys/games/lib/fortunes Thu Jun 13 22:40:09 2013 +++ /sys/games/lib/fortunes Fri Jul 12 22:12:05 2013 @@ -4312,3 +4312,4 @@ qemu: could not open serial device 'dev': Success DSM Terminator [ ABORT ] Finished [ 0 request(s) + 0 call(s) distributed in 5ms] Microsoft Office PowerPoint has encountered a problem and cannot exit. We are sorry for the inconvenience. +dd: argument 18446744073709551615 out of range --- /sys/lib/backup/backup Mon Apr 16 21:45:48 2012 +++ /sys/lib/backup/backup Fri Jul 12 22:11:43 2013 @@ -1,9 +1,6 @@ #!/bin/rc # backup [-np] [-d dev] [-s set] - backup venti arenas to disc set using dev # and record that. also print recent fossil dump scores. -# -# it would be good to have some way to cope with truncated tracks left -# by write errors causing fewer tracks than expected to fit on a disc. rfork ne cd /sys/lib/backup --- /sys/lib/backup/mkfile Fri Nov 19 21:20:39 2010 +++ /sys/lib/backup/mkfile Fri Jul 12 22:10:45 2013 @@ -1,6 +1,6 @@ +backup:V: + ./backup clean:V: rm -f index setup:V: mkdir set1 -backup:V: - ./backup --- /sys/man/3/cons Tue Apr 30 22:05:23 2013 +++ /sys/man/3/cons Fri Jul 19 21:43:11 2013 @@ -207,6 +207,12 @@ .IR kernelpath . Only the host owner has the ability to open this file. +The named kernel may be a Plan 9 executable or +a 32-bit or 64-bit ELF executable. +On some architectures +(e.g., +.BR mips ), +it may also be a Plan 9 boot image. .PP .B Bintime is a binary interface that provides --- /sys/man/8/booting Thu Jun 13 22:42:28 2013 +++ /sys/man/8/booting Fri Jul 19 21:51:13 2013 @@ -70,8 +70,8 @@ . .SS MIPS Routerboard CPU Server Configure RouterBOOT via the serial port (115200 baud) -to always boot from Ethernet, and arrange to load -.B /mips/9rb.elf +to always boot from Ethernet, and arrange to load the ELF executable +.B /mips/9rb in .IR ndb (6). . --- /sys/src/9/pc/trap.c Thu Jun 13 23:00:46 2013 +++ /sys/src/9/pc/trap.c Fri Jul 12 01:35:25 2013 @@ -155,8 +155,7 @@ v->name[KNAMELEN-1] = 0; ilock(&vctllock); - if(vctl[vno]) - v->next = vctl[vno]->next; + v->next = vctl[vno]; vctl[vno] = v; iunlock(&vctllock); } --- /sys/src/9/pcboot/stub.c Mon May 7 21:02:20 2012 +++ /sys/src/9/pcboot/stub.c Fri Jul 19 02:06:42 2013 @@ -398,3 +398,12 @@ fpsserestore(FPsave *) { } + +ulong +l2be(long l) +{ + uchar *cp; + + cp = (uchar*)&l; + return (cp[0]<<24) | (cp[1]<<16) | (cp[2]<<8) | cp[3]; +} --- /sys/src/9/pcboot/trap.c Fri Jan 11 20:25:15 2013 +++ /sys/src/9/pcboot/trap.c Fri Jul 12 01:43:50 2013 @@ -157,8 +157,7 @@ v->name[KNAMELEN-1] = 0; ilock(&vctllock); - if(vctl[vno]) - v->next = vctl[vno]->next; + v->next = vctl[vno]; vctl[vno] = v; iunlock(&vctllock); } --- /sys/src/9/port/allocb.c Mon Oct 19 06:35:54 2009 +++ /sys/src/9/port/allocb.c Fri Jul 12 22:08:23 2013 @@ -65,9 +65,12 @@ if(up == nil) panic("allocb without up: %#p", getcallerpc(&size)); if((b = _allocb(size)) == nil){ + splhi(); xsummary(); mallocsummary(); - panic("allocb: no memory for %d bytes", size); + delay(500); + panic("allocb: no memory for %d bytes; caller %#p", size, + getcallerpc(&size)); } setmalloctag(b, getcallerpc(&size)); --- /sys/src/9/port/devaoe.c Fri Jun 28 23:35:19 2013 +++ /sys/src/9/port/devaoe.c Fri Jul 12 22:09:55 2013 @@ -2411,7 +2411,18 @@ break; qlock(d); d->flag &= ~Dup; - newvers(d); + + /* + * Changing the version number is, strictly speaking, correct, + * but doing so means that deleting a LUN that is not in use + * invalidates all other LUNs too. If your file server has + * venti arenas or fossil file systems on 1.0, and you delete 1.1, + * since you no longer need it, 1.0 will become inaccessible to your + * file server, which will eventually panic. Note that newdev() + * does not change the version number. + */ + // newvers(d); + d->ndl = 0; qunlock(d); for(i = 0; i < d->nframes; i++) --- /sys/src/9/port/devcons.c Mon Aug 8 22:47:55 2011 +++ /sys/src/9/port/devcons.c Fri Jul 19 08:22:41 2013 @@ -618,7 +618,7 @@ "pid", {Qpid}, NUMSIZE, 0444, "ppid", {Qppid}, NUMSIZE, 0444, "random", {Qrandom}, 0, 0444, - "reboot", {Qreboot}, 0, 0664, + "reboot", {Qreboot}, 0, 0660, "swap", {Qswap}, 0, 0664, "sysname", {Qsysname}, 0, 0664, "sysstat", {Qsysstat}, 0, 0666, --- /sys/src/9/port/devfs.c Tue Sep 28 06:53:26 2010 +++ /sys/src/9/port/devfs.c Fri Jul 12 22:10:22 2013 @@ -84,6 +84,7 @@ vlong size; /* min(inner[X].isize) */ vlong start; /* start address (for Fpart) */ uint ndevs; /* number of inner devices */ + int perm; /* minimum of inner device perms */ Inner *inner[Ndevs]; /* inner devices */ }; @@ -104,9 +105,11 @@ static Tree *trees[Ntrees]; /* internal representation of config */ static int ntrees; /* max number of trees */ static int qidvers; + static char *disk; /* default tree name used */ static char *source; /* default inner device used */ static int sectorsz = Sectorsz; /* default sector size */ + static char confstr[Maxconf]; /* textual configuration */ static int debug; @@ -502,16 +505,21 @@ validname(*dev, 0); } -static vlong -getlen(Chan *c) +static int +getattrs(Chan *c, vlong *lenp, int *permp) { uchar buf[128]; /* old DIRLEN plus a little should be plenty */ Dir d; long l; + *lenp = 0; + *permp = 0; l = devtab[c->type]->stat(c, buf, sizeof buf); - convM2D(buf, l, &d, nil); - return d.length; + if (l >= 0 && convM2D(buf, l, &d, nil) > 0) { + *lenp = d.length; + *permp = d.mode & 0777; + } + return l; } /* @@ -526,6 +534,7 @@ mconfig(char* a, long n) { int i; + int *iperm; vlong size, start; vlong *ilen; char *tname, *dname, *fakef[4]; @@ -547,6 +556,7 @@ cb = nil; idev = nil; ilen = nil; + iperm = nil; if(waserror()){ free(cb); @@ -622,14 +632,17 @@ mdeldev(mp); free(idev); free(ilen); + free(iperm); free(cb); nexterror(); } + /* record names, lengths and perms of all named files */ idev = smalloc(sizeof(Chan*) * Ndevs); ilen = smalloc(sizeof(vlong) * Ndevs); + iperm = smalloc(sizeof(int) * Ndevs); for(i = 1; i < cb->nf; i++){ idev[i-1] = namec(cb->f[i], Aopen, ORDWR, 0); - ilen[i-1] = getlen(idev[i-1]); + getattrs(idev[i-1], &ilen[i-1], &iperm[i-1]); } poperror(); runlock(&lck); @@ -657,11 +670,13 @@ error(Enomem); } + /* construct mp from iname, idev and iperm arrays */ mp->type = ct->index; if(mp->type == Fpart){ mp->start = start * sectorsz; mp->size = size * sectorsz; } + mp->perm = 0666; for(i = 1; i < cb->nf; i++){ inprv = mp->inner[i-1] = mallocz(sizeof(Inner), 1); if(inprv == nil) @@ -670,6 +685,8 @@ kstrdup(&inprv->iname, cb->f[i]); inprv->idev = idev[i-1]; idev[i-1] = nil; + /* use the most restrictive of the inner permissions */ + mp->perm &= iperm[i-1]; } setdsize(mp, ilen); @@ -677,6 +694,7 @@ wunlock(&lck); free(idev); free(ilen); + free(iperm); free(cb); } @@ -796,7 +814,7 @@ qid.type = QTFILE; qid.vers = mp->vers; qid.path = mkpath(treeno, Qfirst+i); - devdir(c, qid, mp->name, mp->size, eve, 0664, dp); + devdir(c, qid, mp->name, mp->size, eve, mp->perm, dp); return 1; } @@ -867,7 +885,7 @@ mp = getdev(t, path2devno(p) - Qfirst, Mustexist); q = c->qid; q.vers = mp->vers; - devdir(c, q, mp->name, mp->size, eve, 0664, &d); + devdir(c, q, mp->name, mp->size, eve, mp->perm, &d); } } n = convD2M(&d, db, n); @@ -897,6 +915,7 @@ mp = path2dev(q); if(mp->gone) error(Egone); + devpermcheck(eve, mp->perm, omode); incref(mp); poperror(); runlock(&lck); --- /sys/src/9/port/portdat.h Fri Apr 19 07:15:05 2013 +++ /sys/src/9/port/portdat.h Fri Jul 19 21:32:29 2013 @@ -9,6 +9,7 @@ typedef struct Edf Edf; typedef struct Egrp Egrp; typedef struct Evalue Evalue; +typedef struct Execvals Execvals; typedef struct Fgrp Fgrp; typedef struct DevConf DevConf; typedef struct Image Image; @@ -89,6 +90,9 @@ #ifndef STAGESIZE #define STAGESIZE 64 #endif +#ifndef MAXBY2PG +#define MAXBY2PG BY2PG /* rounding for UTZERO in executables */ +#endif struct Ref { @@ -794,6 +798,12 @@ READSTR = 4000, /* temporary buffer size for device reads */ }; +struct Execvals { + uvlong entry; + ulong textsize; + ulong datasize; +}; + extern Conf conf; extern char* conffile; extern int cpuserver; @@ -807,6 +817,7 @@ extern Ref noteidalloc; extern int nsyscall; extern Palloc palloc; + int (*parseboothdr)(Chan *, ulong, Execvals *); extern Queue* serialoq; extern char* statename[]; extern Image swapimage; --- /sys/src/9/port/portfns.h Wed Jun 16 21:27:30 2010 +++ /sys/src/9/port/portfns.h Thu Jul 18 02:36:52 2013 @@ -154,6 +154,7 @@ void ksetenv(char*, char*, int); void kstrcpy(char*, char*, int); void kstrdup(char**, char*); +ulong l2be(long); long latin1(Rune*, int); int lock(Lock*); void logopen(Log*); @@ -284,6 +285,7 @@ void randominit(void); ulong randomread(void*, ulong); void rdb(void); +void readn(Chan *, void *, long); int readnum(ulong, char*, ulong, ulong, int); int readstr(ulong, char*, ulong, char*); void ready(Proc*); --- /sys/src/9/port/proc.c Mon Apr 8 20:18:31 2013 +++ /sys/src/9/port/proc.c Fri Jul 12 22:09:33 2013 @@ -1378,13 +1378,6 @@ memset(p->time, 0, sizeof(p->time)); p->time[TReal] = MACHP(0)->ticks; ready(p); - /* - * since the bss/data segments are now shareable, - * any mmu info about this process is now stale - * and has to be discarded. - */ - p->newtlb = 1; - flushmmu(); } /* --- /sys/src/9/port/rebootcmd.c Thu Jun 13 23:27:17 2013 +++ /sys/src/9/port/rebootcmd.c Fri Jul 19 21:36:43 2013 @@ -4,19 +4,24 @@ #include "dat.h" #include "fns.h" #include "../port/error.h" -#include "a.out.h" - -static ulong -l2be(long l) -{ - uchar *cp; - - cp = (uchar*)&l; - return (cp[0]<<24) | (cp[1]<<16) | (cp[2]<<8) | cp[3]; -} +#include +#include "/sys/src/libmach/elf.h" +enum { + Ehdr32sz = 52, + Phdr32sz = 32, + Shdr32sz = 40, + + Ehdr64sz = 64, + Phdr64sz = 56, + Shdr64sz = 64, +}; + +static uchar elfident[] = { + '\177', 'E', 'L', 'F', +}; -static void +void readn(Chan *c, void *vp, long n) { char *p = vp; @@ -32,6 +37,49 @@ } } +/* assume the elf header is in the byte order of this machine */ +int +readelfhdr(Chan *c, ulong, Execvals *evp) +{ + Ehdr ehdr; + Phdr phdrs[3]; + + c->offset = 0; /* back up */ + readn(c, &ehdr, sizeof ehdr); + if(memcmp(&ehdr.ident[MAG0], elfident, sizeof elfident) != 0 || + ehdr.ident[CLASS] != ELFCLASS32) + return -1; + + /* get textsize and datasize from Phdrs */ + readn(c, phdrs, sizeof phdrs); + evp->entry = ehdr.elfentry; + evp->textsize = phdrs[0].filesz; + evp->datasize = phdrs[1].filesz; + c->offset = ROUNDUP(Ehdr32sz + 3*Phdr32sz, 16); /* position for text */ + return 0; +} + +static int +readelf64hdr(Chan *c, ulong, Execvals *evp) +{ + E64hdr ehdr; + P64hdr phdrs[3]; + + c->offset = 0; /* back up */ + readn(c, &ehdr, sizeof ehdr); + if(memcmp(&ehdr.ident[MAG0], elfident, sizeof elfident) != 0 || + ehdr.ident[CLASS] != ELFCLASS64) + return -1; + + /* get textsize and datasize from Phdrs */ + readn(c, phdrs, sizeof phdrs); + evp->entry = ehdr.elfentry; + evp->textsize = phdrs[0].filesz; + evp->datasize = phdrs[1].filesz; + c->offset = ROUNDUP(Ehdr64sz + 3*Phdr64sz, 16); /* position for text */ + return 0; +} + static void setbootcmd(int argc, char *argv[]) { @@ -55,6 +103,7 @@ { Chan *c; Exec exec; + Execvals ev; ulong magic, text, rtext, entry, data, size; uchar *p; @@ -69,20 +118,28 @@ readn(c, &exec, sizeof(Exec)); magic = l2be(exec.magic); - entry = l2be(exec.entry); - text = l2be(exec.text); - data = l2be(exec.data); /* * AOUT_MAGIC is sometimes defined like this: * #define AOUT_MAGIC V_MAGIC || magic==M_MAGIC * so we can only use it in a fairly stylized manner. */ if(magic == AOUT_MAGIC) { - } else + entry = l2be(exec.entry); + text = l2be(exec.text); + data = l2be(exec.data); + } else if(parseboothdr && (*parseboothdr)(c, magic, &ev) >= 0 || + readelfhdr(c, magic, &ev) >= 0 || + readelf64hdr(c, magic, &ev) >= 0){ + entry = ev.entry; + text = ev.textsize; + data = ev.datasize; + } else { error(Ebadexec); + return; /* for the compiler */ + } /* round text out to page boundary */ - rtext = PGROUND(entry+text)-entry; + rtext = ROUNDUP(entry+text, BY2PG) - entry; size = rtext + data; p = malloc(size); if(p == nil) --- /sys/src/9/port/sysproc.c Mon Apr 8 20:18:51 2013 +++ /sys/src/9/port/sysproc.c Thu Jul 18 00:23:14 2013 @@ -206,7 +206,7 @@ return pid; } -static ulong +ulong l2be(long l) { uchar *cp; --- /sys/src/cmd/vl/asm.c Sat Jun 29 01:25:22 2013 +++ /sys/src/cmd/vl/asm.c Fri Jul 19 05:33:59 2013 @@ -1,5 +1,12 @@ #include "l.h" +/* can't include a.out.h due to name clashes, but these are taken from it */ +#define _MAGIC(f, b) ((f)|((((4*(b))+0)*(b))+7)) +#define V_MAGIC _MAGIC(0, 16) /* mips 3000 BE */ +#define M_MAGIC _MAGIC(0, 18) /* mips 4000 BE */ +#define N_MAGIC _MAGIC(0, 22) /* mips 4000 LE */ +#define P_MAGIC _MAGIC(0, 24) /* mips 3000 LE */ + long OFFSET; /* long BADOFFSET = -1; @@ -168,10 +175,74 @@ return s->value; } +static void +plan9bootimage(ulong sects, ulong submagicvers, ulong tm, + ulong hdrtxtsz, ulong textsz, ulong textva, ulong lcsize) +{ + lput(0x160L<<16|sects); /* magic and sections */ + lput(tm); /* time and date */ + lput(hdrtxtsz+datsize); /* offset to symbol table */ + lput(symsize); /* size of symbol table */ + lput((0x38L<<16)|7L); /* size of optional hdr and flags */ + lput(submagicvers); /* magic and version */ + + lput(textsz); /* segment sizes */ + lput(datsize); + lput(bsssize); + + lput(entryvalue()); /* va of entry */ + lput(textva); /* va of base of text */ + lput(INITDAT); /* va of base of data */ + lput(INITDAT+datsize); /* va of base of bss */ + + lput(~0); /* gp reg mask */ + lput(lcsize); /* pcsize / cprmask[0] */ + lput(0); /* coproc reg masks[1⋯3] */ + lput(0); + lput(0); + lput(~0); /* gp value ?? */ +} + +static void +symhdrs(ulong hdrtxtsz) +{ + strnput(".text", 8); /* text segment */ + lput(INITTEXT); /* address */ + lput(INITTEXT); + lput(textsize); + lput(HEADR); + lput(0); + lput(HEADR+textsize+datsize+symsize); + lput(lcsize); /* line number size */ + lput(0x20); /* flags */ + + strnput(".data", 8); /* data segment */ + lput(INITDAT); /* address */ + lput(INITDAT); + lput(datsize); + lput(hdrtxtsz); + lput(0); + lput(0); + lput(0); + lput(0x40); /* flags */ + + strnput(".bss", 8); /* bss segment */ + lput(INITDAT+datsize); /* address */ + lput(INITDAT+datsize); + lput(bsssize); + lput(0); + lput(0); + lput(0); + lput(0); + lput(0x80); /* flags */ +} + void asmb(void) { Prog *p; + long tm; + ulong rndtxtsz; vlong t, etext; Optab *o; @@ -228,6 +299,7 @@ case 3: case 5: case 6: + case 7: OFFSET = HEADR+textsize; seek(cout, OFFSET, 0); break; @@ -256,6 +328,7 @@ case 1: case 5: case 6: + case 7: OFFSET = HEADR+textsize+datsize; seek(cout, OFFSET, 0); break; @@ -275,57 +348,26 @@ Bflush(&bso); OFFSET = 0; seek(cout, OFFSET, 0); + + rndtxtsz = rnd(HEADR+textsize, (INITRND > 0? INITRND: 4096)); + tm = time(0); switch(HEADTYPE) { case 0: - lput(0x160L<<16); /* magic and sections */ - lput(0L); /* time and date */ - lput(rnd(HEADR+textsize, 4096)+datsize); - lput(symsize); /* nsyms */ - lput((0x38L<<16)|7L); /* size of optional hdr and flags */ - lput((0413<<16)|0437L); /* magic and version */ - lput(rnd(HEADR+textsize, 4096)); /* sizes */ - lput(datsize); - lput(bsssize); - lput(entryvalue()); /* va of entry */ - lput(INITTEXT-HEADR); /* va of base of text */ - lput(INITDAT); /* va of base of data */ - lput(INITDAT+datsize); /* va of base of bss */ - lput(~0L); /* gp reg mask */ - lput(0L); - lput(0L); - lput(0L); - lput(0L); - lput(~0L); /* gp value ?? */ + /* 0413: plan 9 boot image, text segment rounded (to 4KB) */ + plan9bootimage(0, 0413<<16|0437, 0, rndtxtsz, rndtxtsz, + INITTEXT-HEADR, 0); break; case 1: - lput(0x160L<<16); /* magic and sections */ - lput(0L); /* time and date */ - lput(HEADR+textsize+datsize); - lput(symsize); /* nsyms */ - lput((0x38L<<16)|7L); /* size of optional hdr and flags */ - - lput((0407<<16)|0437L); /* magic and version */ - lput(textsize); /* sizes */ - lput(datsize); - lput(bsssize); - lput(entryvalue()); /* va of entry */ - lput(INITTEXT); /* va of base of text */ - lput(INITDAT); /* va of base of data */ - lput(INITDAT+datsize); /* va of base of bss */ - lput(~0L); /* gp reg mask */ - lput(lcsize); - lput(0L); - lput(0L); - lput(0L); - lput(~0L); /* gp value ?? */ - lput(0L); /* complete mystery */ + /* 0407: plan 9 boot image, extra word */ + plan9bootimage(0, 0407<<16|0437, 0, HEADR+textsize, textsize, + INITTEXT, lcsize); + lput(0); /* extra; complete mystery */ break; - case 2: + case 2: /* plan 9 format */ if (little) - t = 24; + lput(P_MAGIC); /* mips 3000 LE */ else - t = 16; - lput(((((4*t)+0)*t)+7)); /* magic */ + lput(V_MAGIC); /* mips 3000 BE */ lput(textsize); /* sizes */ lput(datsize); lput(bsssize); @@ -335,109 +377,16 @@ lput(lcsize); break; case 3: - lput((0x160L<<16)|3L); /* magic and sections */ - lput(time(0)); /* time and date */ - lput(HEADR+textsize+datsize); - lput(symsize); /* nsyms */ - lput((0x38L<<16)|7L); /* size of optional hdr and flags */ - - lput((0407<<16)|0437L); /* magic and version */ - lput(textsize); /* sizes */ - lput(datsize); - lput(bsssize); - lput(entryvalue()); /* va of entry */ - lput(INITTEXT); /* va of base of text */ - lput(INITDAT); /* va of base of data */ - lput(INITDAT+datsize); /* va of base of bss */ - lput(~0L); /* gp reg mask */ - lput(lcsize); - lput(0L); - lput(0L); - lput(0L); - lput(~0L); /* gp value ?? */ - - strnput(".text", 8); /* text segment */ - lput(INITTEXT); /* address */ - lput(INITTEXT); - lput(textsize); - lput(HEADR); - lput(0L); - lput(HEADR+textsize+datsize+symsize); - lput(lcsize); /* line number size */ - lput(0x20L); /* flags */ - - strnput(".data", 8); /* data segment */ - lput(INITDAT); /* address */ - lput(INITDAT); - lput(datsize); - lput(HEADR+textsize); - lput(0L); - lput(0L); - lput(0L); - lput(0x40L); /* flags */ - - strnput(".bss", 8); /* bss segment */ - lput(INITDAT+datsize); /* address */ - lput(INITDAT+datsize); - lput(bsssize); - lput(0L); - lput(0L); - lput(0L); - lput(0L); - lput(0x80L); /* flags */ + /* 0407: plan 9 mips 4k boot image with symbols */ + plan9bootimage(3, 0407<<16|0437, tm, HEADR+textsize, textsize, + INITTEXT, lcsize); + symhdrs(HEADR+textsize); break; case 4: - - lput((0x160L<<16)|3L); /* magic and sections */ - lput(time(0)); /* time and date */ - lput(rnd(HEADR+textsize, 4096)+datsize); - lput(symsize); /* nsyms */ - lput((0x38L<<16)|7L); /* size of optional hdr and flags */ - - lput((0413<<16)|01012L); /* magic and version */ - lput(textsize); /* sizes */ - lput(datsize); - lput(bsssize); - lput(entryvalue()); /* va of entry */ - lput(INITTEXT); /* va of base of text */ - lput(INITDAT); /* va of base of data */ - lput(INITDAT+datsize); /* va of base of bss */ - lput(~0L); /* gp reg mask */ - lput(lcsize); - lput(0L); - lput(0L); - lput(0L); - lput(~0L); /* gp value ?? */ - - strnput(".text", 8); /* text segment */ - lput(INITTEXT); /* address */ - lput(INITTEXT); - lput(textsize); - lput(HEADR); - lput(0L); - lput(HEADR+textsize+datsize+symsize); - lput(lcsize); /* line number size */ - lput(0x20L); /* flags */ - - strnput(".data", 8); /* data segment */ - lput(INITDAT); /* address */ - lput(INITDAT); - lput(datsize); - lput(rnd(HEADR+textsize, 4096)); /* sizes */ - lput(0L); - lput(0L); - lput(0L); - lput(0x40L); /* flags */ - - strnput(".bss", 8); /* bss segment */ - lput(INITDAT+datsize); /* address */ - lput(INITDAT+datsize); - lput(bsssize); - lput(0L); - lput(0L); - lput(0L); - lput(0L); - lput(0x80L); /* flags */ + /* 0413: plan 9 mips 4k boot image with symbols */ + plan9bootimage(3, 0413<<16|01012, tm, rndtxtsz, textsize, + INITTEXT, lcsize); + symhdrs(rndtxtsz); break; case 5: elf32(MIPS, little? ELFDATA2LSB: ELFDATA2MSB, 0, nil); --- /sys/src/cmd/vl/obj.c Sat Jun 29 01:26:18 2013 +++ /sys/src/cmd/vl/obj.c Thu Jul 18 01:42:34 2013 @@ -1,3 +1,4 @@ +/* vl - mips linker */ #define EXTERN #include "l.h" #include @@ -10,23 +11,22 @@ char symname[] = SYMDEF; char thechar = 'v'; char *thestring = "mips"; +int little; char** libdir; int nlibdir = 0; static int maxlibdir = 0; /* - * -H0 -T0x40004C -D0x10000000 is abbrev unix - * -H1 -T0x80020000 -R4 is bootp() format for 3k - * -H2 -T16416 -R16384 is plan9 format - * -H3 -T0x80020000 -R8 is bootp() format for 4k - * -H4 -T0x400000 -R4 is sgi unix coff executable - * -H5 -T0x4000A0 -R4 is sgi unix elf executable - * -H6 is headerless - * -H7 is 64-bit elf executable + * -H0 -T0x40004C -D0x10000000 is abbrev unix (boot image) + * -H1 -T0x80020000 -R4 is bootp() format for 3k (boot image) + * -H2 -T16416 -R16384 is plan9 format + * -H3 -T0x80020000 -R8 is bootp() format for 4k (4k boot image) + * -H4 -T0x400000 -R4 is sgi unix coff executable (4k boot image) + * -H5 -T0x4000A0 -R4 is sgi unix elf executable + * -H6 is headerless + * -H7 is 64-bit elf executable */ - -int little; void usage(void) --- /sys/src/libc/mips/main9p.s Sat Nov 1 21:37:09 2003 +++ /sys/src/libc/mips/main9p.s Fri Jul 12 00:07:36 2013 @@ -3,6 +3,7 @@ TEXT _mainp(SB), 1, $(16 + NPRIVATES*4) MOVW $setR30(SB), R30 + /* _tos = arg */ MOVW R1, _tos(SB) MOVW $p-64(SP), R1 @@ -10,9 +11,13 @@ MOVW $NPRIVATES, R1 MOVW R1, _nprivates(SB) + /* _profmain(); */ JAL _profmain(SB) - MOVW __prof+4(SB), R1 - MOVW R1, __prof+0(SB) + /* _tos->prof.pp = _tos->prof.next; */ + MOVW _tos(SB), R1 + MOVW 4(R1), R2 + MOVW R2, 0(R1) + /* main(argc, argv); */ MOVW inargc-4(FP), R1 MOVW $inargv+0(FP), R2 MOVW R1, 4(R29) --- /sys/src/libc/mips/vlrt.c Sat Nov 1 21:37:10 2003 +++ /sys/src/libc/mips/vlrt.c Fri Jul 12 01:19:36 2013 @@ -30,6 +30,7 @@ /* needed by profiler; can't be profiled. */ #pragma profile off + void _addv(Vlong *r, Vlong a, Vlong b) { @@ -55,8 +56,6 @@ r->lo = lo; r->hi = hi; } - -#pragma profile on void _d2v(Vlong *y, double d) --- /sys/src/libmach/sym.c Mon Apr 23 21:43:06 2012 +++ /sys/src/libmach/sym.c Thu Jul 18 01:43:02 2013 @@ -687,6 +687,8 @@ top = ntxt; for (mid = (bot+top)/2; mid < top; mid = (bot+top)/2) { sp = txt[mid].sym; + if(sp == nil) + return -1; if(val < sp->value) top = mid; else if(mid != ntxt-1 && val >= txt[mid+1].sym->value) @@ -712,6 +714,8 @@ val = addr; for(mid = (bot+top)/2; mid < top; mid = (bot+top)/2) { sp = globals[mid]; + if(sp == nil) + return -1; if(val < sp->value) top = mid; else if(mid < nglob-1 && val >= globals[mid+1]->value)