stub.S 1.1 KB
Newer Older
J
Jeff Dike 已提交
1
#include "as-layout.h"
2 3 4 5 6 7 8 9

	.globl syscall_stub
.section .__syscall_stub, "x"
syscall_stub:
	syscall
	/* We don't have 64-bit constants, so this constructs the address
	 * we need.
	 */
J
Jeff Dike 已提交
10
	movq	$(STUB_DATA >> 32), %rbx
11
	salq	$32, %rbx
J
Jeff Dike 已提交
12
	movq	$(STUB_DATA & 0xffffffff), %rcx
13 14 15
	or	%rcx, %rbx
	movq	%rax, (%rbx)
	int3
J
Jeff Dike 已提交
16 17 18

	.globl batch_syscall_stub
batch_syscall_stub:
J
Jeff Dike 已提交
19
	mov	$(STUB_DATA >> 32), %rbx
20
	sal	$32, %rbx
J
Jeff Dike 已提交
21
	mov	$(STUB_DATA & 0xffffffff), %rax
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
	or	%rax, %rbx
	/* load pointer to first operation */
	mov	%rbx, %rsp
	add	$0x10, %rsp
again:
	/* load length of additional data */
	mov	0x0(%rsp), %rax

	/* if(length == 0) : end of list */
	/* write possible 0 to header */
	mov	%rax, 8(%rbx)
	cmp	$0, %rax
	jz	done

	/* save current pointer */
	mov	%rsp, 8(%rbx)

	/* skip additional data */
	add	%rax, %rsp

	/* load syscall-# */
	pop	%rax

	/* load syscall params */
J
Jeff Dike 已提交
46 47 48 49 50 51
	pop	%rdi
	pop	%rsi
	pop	%rdx
	pop	%r10
 	pop	%r8
	pop	%r9
52 53

	/* execute syscall */
J
Jeff Dike 已提交
54
	syscall
55 56 57 58 59 60 61 62

	/* check return value */
	pop	%rcx
	cmp	%rcx, %rax
	je	again

done:
	/* save return value */
J
Jeff Dike 已提交
63
	mov	%rax, (%rbx)
64 65 66

	/* stop */
	int3