In this article we will dive into system call interface implementation in arm linux(with gnu eabi).咱们将从bionic中的open函数开端追溯arm linux的体系调用完成(运用gnu eabi)。
Linux的应用程序要想拜访内核有必要运用体系调用然后完成从usr形式转到svc形式。在arm中,这个进程是经过swi(或许和它等价的指令)来完成形式转化的。
从bionic libc中的open函数追溯体系调用完成
相关文件:
-
bionic/libc/unistd/open.c
-
bionic/libc/arch-arm/syscalls/__open.S
-
linux/arch/arm/kernel/entry-common.S
-
linux/arch/arm/kernel/entry-armv.S
-
linux/arch/arm/kernel/entry-header.S
相关调用进程:
-
int open(const char *pathname, int flags, …);bionic/libc/unistd/open.c
-
__openbionic/libc/arch-arm/syscalls/__open.S
__open:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_open
swi #0
ldmfd sp!, {r4, r7}
movs r0, r0
bxpl lr
b __set_syscall_errno
-
vector_swilinux/arch/arm/kernel/entry-common.S
adr tbl, sys_call_table @ load syscall table pointer
cmp scno, #NR_syscalls @ check upper syscall limit
adr lr, BSYM(ret_fast_syscall) @ return address
ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
-
sys_call_table体系调用跳转表,里边保存了各个体系调用完成的地址。
.type sys_call_table, #object
ENTRY(sys_call_table)
#include “calls.S”
资源和链接
- eabi
- ARM linux体系调用的完成原理
- SWI : SoftWare Interrupt
TODOS
- 找出eabi中寄存器运用和参数传递的规矩
- 了解swi跳转的更多具体常识,比方怎么跳转到一个固定方位的
- arm体系的中止体系
- 了解常用的arm指令和gnu 汇编器指令