stub_32.S 764 字节
Newer Older
1
#include <as-layout.h>
2 3

	.globl syscall_stub
A
Amerigo Wang 已提交
4
.section .__syscall_stub, "ax"
J
Jeff Dike 已提交
5 6 7

	.globl batch_syscall_stub
batch_syscall_stub:
8
	/* load pointer to first operation */
J
Jeff Dike 已提交
9
	mov	$(STUB_DATA+8), %esp
10 11 12 13 14 15 16

again:
	/* load length of additional data */
	mov	0x0(%esp), %eax

	/* if(length == 0) : end of list */
	/* write possible 0 to header */
J
Jeff Dike 已提交
17
	mov	%eax, STUB_DATA+4
J
Jeff Dike 已提交
18 19
	cmpl	$0, %eax
	jz	done
20 21

	/* save current pointer */
J
Jeff Dike 已提交
22
	mov	%esp, STUB_DATA+4
23 24 25 26 27 28 29 30

	/* skip additional data */
	add	%eax, %esp

	/* load syscall-# */
	pop	%eax

	/* load syscall params */
J
Jeff Dike 已提交
31 32 33 34 35 36
	pop	%ebx
	pop	%ecx
	pop	%edx
	pop	%esi
 	pop	%edi
	pop	%ebp
37 38

	/* execute syscall */
J
Jeff Dike 已提交
39
	int	$0x80
40 41 42 43 44 45 46 47

	/* check return value */
	pop	%ebx
	cmp	%ebx, %eax
	je	again

done:
	/* save return value */
J
Jeff Dike 已提交
48
	mov	%eax, STUB_DATA
49 50 51

	/* stop */
	int3