summaryrefslogtreecommitdiff
path: root/rt/abort-linux.s
blob: 8ac1c025bc4f0a3ef6ad87d0ce7377c5357b2a98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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"