shithub: mc

Download patch

ref: 8fc0fa9c41c11af3443942bdf43c6f0146e19897
parent: f12188aeeb9d6cef0ce0c2a611b85e18a76eb672
author: Ori Bernstein <[email protected]>
date: Mon Jul 23 21:27:12 EDT 2012

Call mmap correctly.

--- a/sys-linux.myr
+++ b/sys-linux.myr
@@ -37,11 +37,11 @@
 	const Trunc   	: fdopt = 0x200
 
 	/* mmap protection */
-	const Mprotexec	: mprot = 0x1
-	const Mprotrd	: mprot = 0x2
-	const Mprotwr	: mprot = 0x4
-	const Mprotrw	: mprot = 0x6
 	const Mprotnone	: mprot = 0x0
+	const Mprotrd	: mprot = 0x1
+	const Mprotwr	: mprot = 0x2
+	const Mprotexec	: mprot = 0x4
+	const Mprotrw	: mprot = 0x3 /* convenience */
 	
 	/* mmap options */
 	const Mshared	: mopt = 0x1
@@ -65,6 +65,7 @@
 	const Sysfstat	: scno = 108
 	const Syskill	: scno = 37
 	const Sysgetpid	: scno = 20
+	const Sysmmap	: scno = 90
 	const Sysmmap2	: scno = 192
 	const Sysmunmap	: scno = 91
 
--- a/syscall-linux.s
+++ b/syscall-linux.s
@@ -1,9 +1,6 @@
 .globl std$syscall
 std$syscall:
 	pushl %ebp
-	movl %esp,%ebp
-	movl 12(%ebp),%eax #count
-        shl  $2,%eax
 	/*
 	   hack: 6 args uses %ebp, so we index
 	   relative to %esp.
@@ -14,14 +11,14 @@
            doesn't use them, it's going to be
            harmless.
 	 */
-	movl 32(%esp),%ebp
-	movl 28(%esp),%edi
-	movl 24(%esp),%esi
-	movl 20(%esp),%edx
-	movl 16(%esp),%ecx
-	movl 12(%esp),%ebx
 	movl 8(%esp),%eax
+	movl 12(%esp),%ebx
+	movl 16(%esp),%ecx
+	movl 20(%esp),%edx
+	movl 24(%esp),%esi
+	movl 28(%esp),%edi
+	movl 32(%esp),%ebp
+
         int $0x80
-	movl %ebp,%esp
 	popl %ebp
 	ret
--- a/syscall.s
+++ b/syscall.s
@@ -1,9 +1,6 @@
 .globl std$syscall
 std$syscall:
 	pushl %ebp
-	movl %esp,%ebp
-	movl 12(%ebp),%eax #count
-        shl  $2,%eax
 	/*
 	   hack: 6 args uses %ebp, so we index
 	   relative to %esp.
@@ -14,15 +11,14 @@
            doesn't use them, it's going to be
            harmless.
 	 */
-	movl 32(%esp),%ebp
-	movl 28(%esp),%edi
-	movl 24(%esp),%esi
-	movl 20(%esp),%edx
-	movl 16(%esp),%ecx
-	movl 12(%esp),%ebx
 	movl 8(%esp),%eax
+	movl 12(%esp),%ebx
+	movl 16(%esp),%ecx
+	movl 20(%esp),%edx
+	movl 24(%esp),%esi
+	movl 28(%esp),%edi
+	movl 32(%esp),%ebp
         int $0x80
-	movl %ebp,%esp
 	popl %ebp
 	ret