Android arm linux 系統(tǒng)調(diào)用實現(xiàn)
Linux的應(yīng)用程序要想訪問內(nèi)核必須使用系統(tǒng)調(diào)用從而實現(xiàn)從usr模式轉(zhuǎn)到svc模式。在arm中,這個過程是通過swi(或者和它等價的指令)來實現(xiàn)模式轉(zhuǎn)換的。
本文引用地址:http://m.butianyuan.cn/article/201611/318011.htm從bionic libc中的open函數(shù)追溯系統(tǒng)調(diào)用實現(xiàn)
相關(guān)文件:
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
相關(guān)調(diào)用過程:
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系統(tǒng)調(diào)用跳轉(zhuǎn)表,里面保存了各個系統(tǒng)調(diào)用實現(xiàn)的地址。
.type sys_call_table, #object
ENTRY(sys_call_table)
#include "calls.S"
評論