summaryrefslogtreecommitdiff
path: root/rt
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-09-15 20:37:50 -0400
committerOri Bernstein <ori@eigenstate.org>2014-09-15 20:37:50 -0400
commitdd97266db3c7c7a663c3654dbc843242b8cb7b80 (patch)
tree44644d23c91c628e6489b36b6091fc990457a999 /rt
parent2281d457448549cf86ae9475627c0c12a8c4843f (diff)
downloadmc-dd97266db3c7c7a663c3654dbc843242b8cb7b80.tar.gz
Split abort-linux.s, abort-osx.s
Syscall numbers are different. What was I smoking, and where can I get some?
Diffstat (limited to 'rt')
-rw-r--r--rt/abort-linux.s41
-rw-r--r--rt/abort-osx.s (renamed from rt/abort.s)8
2 files changed, 45 insertions, 4 deletions
diff --git a/rt/abort-linux.s b/rt/abort-linux.s
new file mode 100644
index 0000000..8ac1c02
--- /dev/null
+++ b/rt/abort-linux.s
@@ -0,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"
diff --git a/rt/abort.s b/rt/abort-osx.s
index 9c44ec7..188fda5 100644
--- a/rt/abort.s
+++ b/rt/abort-osx.s
@@ -18,17 +18,17 @@ __rt$abort_oob:
shrq $4, %rax
jnz .loop
/* write abort message */
- movq $1, %rax /* write(fd=%rdi, msg=%rsi, len=%rdx) */
+ 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 $39,%rax /* getpid */
+ movq $0x2000014,%rax /* getpid */
syscall
movq %rax, %rdi /* save pid */
- movq $62, %rax /* kill(pid=%rdi, sig=%rsi) */
- movq $6, %rsi /* kill(pid=%rdi, sig=%rsi) */
+ movq $0x2000025, %rax /* kill(pid=%rdi, sig=%rsi) */
+ movq $6, %rsi
syscall
.data
.msg: /* pc name: */