I have read about system calls in Linux, and everywhere description is given regarding x86 architecture (ox80 interrupt and SYSENTER). But I am not able to track down the files and process for a system call in ARM achitecture. Can anyone please help.
Few relevant files which I got to know are:
\arch\arm\kernel\calls.S
\arch\arm\kernel\entry-common.S (explanation needed)
In ARM world, you do a
software interrupt
(mechanism to signal the kernel) bysupervisor call / svc
(previously called SWI).ARM assembly (UAL) syntax looks like this:
(In Linux you need to pass #0)
You should cheat from other projects like bionic/write or uClibc boilerplate.
The disassembly of hello world in n900 shows
svc #0
http://brnz.org/hbr/?m=201102
If you're looking for syscall number in Linux system, take a look at w3challs.
That site helps finding out which syscall number and which registers used for passing arguments. It supports many architectures listed below:
More generic answer than what you asked.
On Linux the
man syscall (2)
is a good start to find out how to make a system call in various architectures.Copied from that manpage:
So it depends whether the system uses OABI or EABI.
So in EABI you use
r7
to pass the system call number, user0-r6
to pass the arguments, useSWI 0
to make the system call, expect the result inr0
.In OABI everything is the same except you use
SWI <number>
to make a system call.arm system call numbers
v4.19 defines them at
arch/arm/tools/syscall.tbl
: https://github.com/torvalds/linux/blob/v4.19/arch/arm/tools/syscall.tblExcerpt:
I have tested that
exit
andwrite
have those exact numbers on this Linux assembly hello world on QEMU user mode.arm64 system call numbers
aarch64 uses a new mechanism, see: https://reverseengineering.stackexchange.com/questions/16917/arm64-syscalls-table/18834#18834