shithub: mc

Download patch

ref: 8f0a2b6431382733d8289d2571a8735ea9d7213a
parent: 9168c60d542e2ee877a7d9ccfaf88593b936bd3f
author: Ori Bernstein <[email protected]>
date: Fri Dec 26 20:19:39 EST 2014

Fix the register saving dance.

    Bah, ?l on plan9 want balanced push/pop, so we have to
    fool it with add/sub. This is ugly.

--- a/libstd/util+plan9-x64.s
+++ b/libstd/util+plan9-x64.s
@@ -10,13 +10,14 @@
  */
 TEXT sys$cstring+0(SB),$0
 	/* save registers */
-	MOVQ	SP,BP
+	MOVQ	SP,AX
 	SUBQ	$40,SP
-	MOVQ	BP,-8(BP)
-	MOVQ	R15,-16(BP)
-	MOVQ	SI,-24(BP)
-	MOVQ	DI,-32(BP)
-	MOVQ	CX,-40(BP)
+	MOVQ	BP,-8(AX)
+	MOVQ	R15,-16(AX)
+	MOVQ	SI,-24(AX)
+	MOVQ	DI,-32(AX)
+	MOVQ	CX,-40(AX)
+	MOVQ	AX,BP
 
 	MOVQ 	(BP),R15	/* ret addr */
 	MOVQ	8(BP),SI	/* src */
@@ -26,8 +27,8 @@
 	SUBQ	$1,SP		/* +1 for nul */
 	MOVQ	SP,DI		/* dest */
 	MOVQ	SP,AX		/* ret val */
-	SUBQ	$24,SP		/* "unpop" the args and make room for return addr */
 	ANDQ	$(~15),SP	/* align */
+	SUBQ	$24,SP		/* "unpop" the args and make room for return addr */
 
 	CLD
 	REP
@@ -45,11 +46,12 @@
 
 TEXT sys$alloca+0(SB),$0
 	/* save registers */
-        MOVQ    SP,BP
+	MOVQ    SP,AX
 	SUBQ	$32,SP
-	MOVQ	BP,-8(BP)
-	MOVQ	R15,-16(BP)
-	MOVQ	BX,-24(SP)
+	MOVQ	BP,-8(AX)
+	MOVQ	R15,-16(AX)
+	MOVQ	BX,-24(AX)
+	MOVQ	AX,BP
 
 	MOVQ	(BP),R15	/* ret addr */
 	MOVQ	8(BP),BX	/* len */
@@ -57,7 +59,7 @@
 	/* get stack space */
 	SUBQ	BX,SP		/* get stack space */
 	MOVQ	SP,AX		/* top of stack (return value) */
-	SUBQ	$24,SP		/* "unpop" the args for return, and reserve ret addr */
+	SUBQ	$24,SP		/* "unpop" the args, and make room for ret addr */
 	ANDQ	$(~15),SP	/* align */
 
 	MOVQ	R15,0(SP)	/* place ret addr */