shithub: mc

Download patch

ref: 5e0ca55f184256a7a3868843bec2922b56a1126f
parent: 193c0a031b36a4d6d0ca90bb56d1427fd1b15bc0
author: Ori Bernstein <[email protected]>
date: Wed Dec 24 08:41:53 EST 2014

Get plan9 even closer to workingness.

    A few more oddities.

--- a/6/genp9.c
+++ b/6/genp9.c
@@ -246,7 +246,7 @@
     size_t i, len;
 
     for (i = 0; i < sz; i++) {
-        len = min(i, 8);
+        len = min(sz - i, 8);
         if (i % 8 == 0)
             fprintf(fd, "DATA %s+%zd(SB)/%zd,$\"", name, off + i, len);
         if (p[i] == '"' || p[i] == '\\')
@@ -426,6 +426,7 @@
     k = htkeys(strtab, &nk);
     for (i = 0; i < nk; i++) {
         s = k[i];
+		fprintf(fd, "GLOBL %s+0(SB),$%lld\n", htget(strtab, k[i]), (vlong)s->len);
         writebytes(fd, htget(strtab, k[i]), 0, s->buf, s->len);
     }
 }
@@ -436,7 +437,7 @@
     size_t i, j;
     char *hidden;
 
-    hidden = "<>";
+    hidden = "";
     if (fn->isexport || streq(fn->name, Symprefix "main"))
         hidden = "";
     fprintf(fd, "TEXT %s%s+0(SB),$%zd\n", fn->name, hidden, fn->stksz);
--- a/libstd/mkfile
+++ b/libstd/mkfile
@@ -92,10 +92,11 @@
 
 OBJ=${STDSRC:%.myr=%.o} ${SYSSRC:%.myr=%.o} ${STDASMSRC:%.s=%.o} ${SYSASMSRC:%.s=%.o}
 USE=${STDSRC:%.myr=%.use} ${SYSSRC:%.myr=%.use} ${STDLIB}
+LIBS=lib$STDLIB.a lib$SYSLIB.a
 .PHONY: clean
 clean:V:
 	rm -f $OBJ
 	rm -f $USE
-	rm -f lib${STDLIB}.a lib${SYSLIB}.a
+	rm -f $LIBS
 
 nuke:V: clean
--- a/libstd/util+plan9-x64.s
+++ b/libstd/util+plan9-x64.s
@@ -10,12 +10,13 @@
  */
 TEXT sys$cstring+0(SB),$0
 	/* save registers */
-	PUSHQ   BP
+	SUBQ	$48,SP
+	MOVQ	BP,40(SP)
 	MOVQ	SP,BP
-	PUSHQ	R15
-	PUSHQ	SI
-	PUSHQ	DI
-	PUSHQ	CX
+	MOVQ	R15,32(SP)
+	MOVQ	SI,24(SP)
+	MOVQ	DI,16(SP)
+	MOVQ	CX,8(SP)
 
 	MOVQ 	8(BP),R15	/* ret addr */
 	MOVQ	16(BP),SI	/* src */
@@ -30,9 +31,9 @@
 
 	CLD
 	REP; MOVSB
-	MOVB    $0,(DI)		/* terminate */
+	MOVB	$0,(DI)		/* terminate */
 
-	PUSHQ R15		/* ret addr */
+	MOVQ	R15,0(SP)		/* ret addr */
 
 	/* Restore registers */
 	MOVQ	-32(BP),CX
@@ -44,26 +45,27 @@
 
 TEXT sys$alloca+0(SB),$0
 	/* save registers */
-	PUSHQ   BP
-	MOVQ    SP,BP
-	PUSHQ   R15
-	PUSHQ   BX
+	SUBQ	$32,SP
+	MOVQ	BP,24(SP)
+	MOVQ	SP,BP
+	MOVQ	R15,16(SP)
+	MOVQ	BX,8(SP)
 
 	MOVQ	8(BP),R15	/* ret addr */
 	MOVQ	16(BP),BX	/* len */
 
 	/* get stack space */
-	SUBQ    BX,SP		/* get stack space */
-	MOVQ    SP,AX		/* top of stack (return value) */
-	SUBQ    $16,SP		/* "unpop" the args for return */
-	ANDQ    $(~15),SP	/* align */
+	SUBQ	BX,SP		/* get stack space */
+	MOVQ	SP,AX		/* top of stack (return value) */
+	SUBQ	$16,SP		/* "unpop" the args for return */
+	ANDQ	$(~15),SP	/* align */
 
-	PUSHQ R15		/* ret addr */
+	MOVQ	R15,0(SP)	/* ret addr */
 
 	/* restore registers */
-	MOVQ    -16(BP),BX
-	MOVQ    -8(BP),R15
-	MOVQ    (BP),BP
+	MOVQ	-16(BP),BX
+	MOVQ	-8(BP),R15
+	MOVQ	(BP),BP
 	RET
 
 TEXT sys$gettos+0(SB),$0
--- a/mkfile
+++ b/mkfile
@@ -44,6 +44,6 @@
 	echo '#define Instroot "'/'"' > config.h
 	echo '#define Asmcmd {"6a", "-o", NULL}' >> config.h
 	echo '#define Linkcmd {"ar", "ru", NULL}' >> config.h
-	echo '#define Symprefix "_"' >> config.h
+	echo '#define Symprefix ""' >> config.h
 	echo '#define Defaultasm Plan9' >> config.h
 
--- a/rt/_myrrt-plan9.s
+++ b/rt/_myrrt-plan9.s
@@ -9,11 +9,19 @@
 	LEAQ	inargv+0(FP), AX
 	MOVQ	AX, 8(SP)
 	CALL	main(SB)
+exitloop:
+	MOVQ	$0,estatus+0(FP)
+	MOVQ	$8,RARG
+	SYSCALL
+	JMP		exitloop
 
-loop:
-	MOVQ	$_exits<>(SB), RARG
-	CALL	exits(SB)
-	JMP	loop
+TEXT	_rt$abort_oob(SB),1,$0
+broke:
+	XORQ	AX,AX
+	MOVQ	$1234,(AX)
+	JMP		broke
 
-DATA	_exits<>+0(SB)/4, $"main"
-GLOBL	_exits<>+0(SB), $5
+GLOBL	argv0(SB), $8
+GLOBL	_tos(SB), $8
+GLOBL	_privates(SB), $8
+GLOBL	_nprivates(SB), $4