diff options
author | Ori Bernstein <ori@eigenstate.org> | 2014-09-15 02:28:27 -0400 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2014-09-15 02:28:27 -0400 |
commit | b24267e29842d9f8fd513af63176fd099d1ef204 (patch) | |
tree | 5b3f5f51c1a12c93363f3c358a1e55a34314e22d /rt | |
parent | cec4decf37b8eab103846cc90cdb3dddd45c71ca (diff) | |
download | mc-b24267e29842d9f8fd513af63176fd099d1ef204.tar.gz |
Add missing file abort.s
This contains the code for dying out of memory. W00t string
formatting in assembly!
Diffstat (limited to 'rt')
-rw-r--r-- | rt/abort.s | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/rt/abort.s b/rt/abort.s new file mode 100644 index 0000000..8ac1c02 --- /dev/null +++ b/rt/abort.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" |