shithub: mc

Download patch

ref: 2c27f80bb5f4d8084f1d8cf9d01c4377dba92c2f
parent: 216975cab68aaa631ae92b467614465cb42bca10
author: Ori Bernstein <[email protected]>
date: Mon Sep 15 16:37:50 EDT 2014

Split abort-linux.s, abort-osx.s

    Syscall numbers are different. What was I smoking, and where
    can I get some?

--- /dev/null
+++ b/rt/abort-linux.s
@@ -1,0 +1,41 @@
+.text
+
+.globl _rt$abort_oob
+.globl __rt$abort_oob
+_rt$abort_oob:
+__rt$abort_oob:
+	/* format pc */
+	movq	(%rsp),%rax
+	movq	$15,%rdx
+.loop:
+	movq	%rax, %rcx
+	andq	$0xf, %rcx
+	movb	.digitchars(%rcx),%r8b
+	movb	%r8b,.pcstr(%rdx)
+	subq	$1, %rdx
+	shrq	$4, %rax
+	jnz .loop
+	/* write abort message */
+	movq	$1, %rax 	/* write(fd=%rdi, msg=%rsi, len=%rdx) */
+	movq	$2, %rdi		/* fd */
+	movq	$.msg, %rsi	/* msg */
+	movq	$(.msgend-.msg), %rdx	/* length */
+	syscall
+	/* kill self */
+	movq	$39,%rax 	/* getpid */
+	syscall	
+	movq	%rax, %rdi	/* save pid */
+	movq	$62, %rax	/* kill(pid=%rdi, sig=%rsi) */
+	movq	$6, %rsi	/* kill(pid=%rdi, sig=%rsi) */
+	syscall
+.data
+.msg: 	/* pc name:  */
+	.byte '0','x'
+.pcstr:
+	.byte '0','0','0','0','0','0','0','0'
+	.byte '0','0','0','0','0','0','0','0'
+	.ascii ": out of bounds access\n"
+.msgend:
+
+.digitchars:
+	.ascii "0123456789abcdef"
--- /dev/null
+++ b/rt/abort-osx.s
@@ -1,0 +1,42 @@
+.text
+
+.globl _rt$abort_oob
+.globl __rt$abort_oob
+_rt$abort_oob:
+__rt$abort_oob:
+	/* format pc */
+	movq	(%rsp),%rax
+	movq	$15,%rdx
+	leaq	.digitchars(%rip),%r8
+        leaq    .pcstr(%rip),%r9
+.loop:
+	movq	%rax, %rcx
+	andq	$0xf, %rcx
+        movb    (%r8,%rcx),%r10b
+	movb	%r10b,(%r9,%rdx)
+	subq	$1, %rdx
+	shrq	$4, %rax
+	jnz .loop
+	/* write abort message */
+	movq	$0x2000004, %rax 	/* write(fd=%rdi, msg=%rsi, len=%rdx) */
+	movq	$2, %rdi		/* fd */
+	leaq	.msg(%rip), %rsi	/* msg */
+	movq	$(.msgend-.msg), %rdx	/* length */
+	syscall
+	/* kill self */
+	movq	$0x2000014,%rax 	/* getpid */
+	syscall	
+	movq	%rax, %rdi	/* save pid */
+	movq	$0x2000025, %rax	/* kill(pid=%rdi, sig=%rsi) */
+	movq	$6, %rsi
+	syscall
+.data
+.msg: 	/* pc name:  */
+	.ascii "0x"
+.pcstr:
+	.ascii "0000000000000000"
+	.ascii ": out of bounds access\n"
+.msgend:
+
+.digitchars:
+	.ascii "0123456789abcdef"
--- a/rt/abort.s
+++ /dev/null
@@ -1,42 +1,0 @@
-.text
-
-.globl _rt$abort_oob
-.globl __rt$abort_oob
-_rt$abort_oob:
-__rt$abort_oob:
-	/* format pc */
-	movq	(%rsp),%rax
-	movq	$15,%rdx
-	leaq	.digitchars(%rip),%r8
-        leaq    .pcstr(%rip),%r9
-.loop:
-	movq	%rax, %rcx
-	andq	$0xf, %rcx
-        movb    (%r8,%rcx),%r10b
-	movb	%r10b,(%r9,%rdx)
-	subq	$1, %rdx
-	shrq	$4, %rax
-	jnz .loop
-	/* write abort message */
-	movq	$1, %rax 	/* write(fd=%rdi, msg=%rsi, len=%rdx) */
-	movq	$2, %rdi		/* fd */
-	leaq	.msg(%rip), %rsi	/* msg */
-	movq	$(.msgend-.msg), %rdx	/* length */
-	syscall
-	/* kill self */
-	movq	$39,%rax 	/* getpid */
-	syscall	
-	movq	%rax, %rdi	/* save pid */
-	movq	$62, %rax	/* kill(pid=%rdi, sig=%rsi) */
-	movq	$6, %rsi	/* kill(pid=%rdi, sig=%rsi) */
-	syscall
-.data
-.msg: 	/* pc name:  */
-	.ascii "0x"
-.pcstr:
-	.ascii "0000000000000000"
-	.ascii ": out of bounds access\n"
-.msgend:
-
-.digitchars:
-	.ascii "0123456789abcdef"