-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrappers.S
More file actions
60 lines (50 loc) · 1.38 KB
/
Copy pathwrappers.S
File metadata and controls
60 lines (50 loc) · 1.38 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <asm.h>
ENTRY(write)
pushl %ebp
mov %esp, %ebp
pushl %ecx # Needed so 'sysexit' runs with success
pushl %edx # Same as above
mov 0x08(%ebp), %ebx # fd
mov 0x0c(%ebp), %ecx # buffer
mov 0x10(%ebp), %edx # size
mov $0x04, %eax # Tells that we will access the 4th position in the sys_call_table
pushl $write_return # Fake dyn. link for the handler
pushl %ebp # Same as above
mov %esp, %ebp # Same as above
sysenter
write_return:
cmpl $0x0, %eax
jg write_continue
neg %eax
mov %eax, errno
mov $-1, %eax
write_continue:
popl %ebp
add $0x4, %esp # Handles the return addres in the stack. We could use a 'pop' instruction too
popl %edx
popl %ecx
popl %ebp
ret
ENTRY(gettime)
pushl %ebp
mov %esp, %ebp
pushl %ecx # Needed so 'sysexit' runs with success
pushl %edx # Same as above
mov $0x0a, %eax # Tells that we will access the 10th position in the sys_call_table
pushl $gettime_return # Fake dyn. link for the handler
pushl %ebp # Same as above
mov %esp, %ebp # Same as above
sysenter
gettime_return:
cmpl $0x0, %eax
jg gettime_continue
neg %eax
mov %eax, errno
mov $-1, %eax
gettime_continue:
popl %ebp
add $0x4, %esp # Handles the return addres in the stack. We could use a 'pop' instruction too
popl %edx
popl %ecx
popl %ebp
ret