summaryrefslogtreecommitdiff
path: root/rt
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-12-06 04:25:11 -0800
committerOri Bernstein <ori@eigenstate.org>2015-12-06 04:25:11 -0800
commitc5a41d7c6bb10c1f384cce78953355b1c0c1e6f2 (patch)
tree903bc4efc49192847b3f8d7789f9c38f4dc9326c /rt
parent0f8acbf5559d4710faa41fdb81a5bc892f1a753f (diff)
downloadmc-c5a41d7c6bb10c1f384cce78953355b1c0c1e6f2.tar.gz
Add missing files.
Fixes FreeBSD support.
Diffstat (limited to 'rt')
-rw-r--r--rt/abort-freebsd.s42
1 files changed, 42 insertions, 0 deletions
diff --git a/rt/abort-freebsd.s b/rt/abort-freebsd.s
new file mode 100644
index 0000000..09297a7
--- /dev/null
+++ b/rt/abort-freebsd.s
@@ -0,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 $4, %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 $20,%rax /* getpid */
+ syscall
+ movq %rax, %rdi /* save pid */
+ movq $37, %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"