I learn that system call number is passed as the immediate operand of "svc (or swi)" instruction on ARM OABI (Old Application Binary Interface). The immediate operand is "0x900000+(Number of system call)" For example, the EXIT system call is issued as follows.
svc #0x900001 @ sys_exit
I become curious about the implementation of syscall() function because sycall() gets the system call number as its argument. I guess the binary code of syscall() cannot create easily, if the argument value is created dynamically. However, the binary code of syscall() of glibc is simple. It sets the number of system call to "register r0" and the arguements to "register r1-r6". After then, execute "svc #0x900071".
The test environment is Debian lenny ARM OABI, Linux 2.6.26, gcc 4.2, glibc 2.7.18. The binary code of syscall() is as follows.
00012560 <syscall>:
12560: e1a0c00d mov ip, sp
12564: e92d0070 push {r4, r5, r6}
12568: e89c0070 ldm ip, {r4, r5, r6}
1256c: ef900071 svc 0x00900071
12570: e8bd0070 pop {r4, r5, r6}
12574: e3700a01 cmn r0, #4096 ; 0x1000
12578: 31a0f00e movcc pc, lr
1257c: ea000547 b 13aa0 <__syscall_error>
The syscall is called as follows. This is sample of "syscall(SYS_getuid)".
8270: e3a00609 mov r0, #9437184 ; 0x900000
8274: e2800018 add r0, r0, #24 ; 0x18
8278: eb0028b8 bl 12560 <syscall>
What is "svc #0x900071"? It works as super system call.