-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenmacro.sh
executable file
·56 lines (48 loc) · 1020 Bytes
/
genmacro.sh
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
#!/bin/bash
unistd=/usr/include/asm/unistd.h
date=`date`
cat <<EOF
;;;; -*- Mode: asm; asm-indent-level: 2; -*-
;;;; $date
;;;; Linux System call interrupt numbers
%ifndef SYSCALL_MAC
%define SYSCALL_MAC
EOF
# The second `y' is a y/tab/space/.
cat $unistd | \
sed -n '/^#define __NR/ {
y/#/%/
y/ / /
s/__NR//g
s/\/\\*.*\\*\///
p
}' | \
awk '{ printf ("%s %-26s %3d\n", $1,$2,$3) }'
cat <<'EOF'
%imacro syscall 0-6 nil
%ifidn %1, nil
%error "syscall needs at least one parameter"
%elifid %1
%error "Undefined system call `%1'"
%else
mov eax, dword %1
%if %0 > 1
mov ebx, %2
%if %0 > 2
mov ecx, %3
%if %0 > 3
mov edx, %4
%if %0 > 4
mov esi, %5
%if %0 > 5
mov edi, %6
%endif
%endif
%endif
%endif
%endif
int 0x80
%endif
%endmacro
%endif ; SYSCALL_MAC
EOF