arm linux syscall,你知道Arm Linux系统调用流程?

本文详细解析了Arm Linux系统调用的过程,包括如何获取线程对象基地址、系统调用表指针的获取、系统调用号的处理以及不同ABI下的系统调用表选择。通过对异常处理程序的分析,揭示了系统调用号作为索引查找系统调用表并执行相应处理例程的机制。此外,还探讨了与old ABI和EABI兼容性相关的配置选项及其影响。
摘要由CSDN通过智能技术生成

//tsk 是寄存器r9的别名,在arch/arm/kernel/entry-header.S中定义:// tsk .req   r9     @current thread_info

// 获得线程对象的基地址。

get_thread_info tsk

// tbl是r8寄存器的别名,在arch/arm/kernel/entry-header.S中定义:

// tbl  .req   r8     @syscall table pointer,

// 用来存放系统调用表的指针,系统调用表在后面调用

adr tbl, sys_call_table @ load syscall table pointer#if defined(CONFIG_OABI_COMPAT) /* * If the swi argument is zero, this is an EABI call and we do nothing. * * If this is an old ABI call, get the syscall number into scno and * get the old ABI syscall table address. */ bics r10, r10, #0xff000000 eorne scno, r10, #__NR_OABI_SYSCALL_BASE ldrne tbl, =sys_oabi_call_table#elif !defined(CONFIG_AEABI)   // scno是寄存器r7的别名 bic scno, scno, #0xff000000 @ mask off SWI op-code eor scno, scno, #__NR_SYSCALL_BASE @ check OS number#endif ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing stmdb sp!, {r4, r5} @ push fifth and sixth args#ifdef CONFIG_SECCOMP tst r10, #_TIF_SECCOMP beq 1f mov r0, scno bl __secure_computing add r0, sp, #S_R0 + S_OFF @ pointer to regs ldmia r0, {r0 - r3} @ have to reload r0 - r31:#endif tst r10, #_TIF_SYSCALL_TRACE @ are we tracing syscalls? bne __sys_trace 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 add r1, sp, #S_OFF

// why也是r8寄存器的别名

2: mov why, #0 @ no longer a real syscall

cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE) eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back bcs arm_syscall b sys_ni_syscall @ not private funcENDPROC(vector_swi) /* * This is the really slow path. We're going to be doing * context switches, and waiting for our parent to respond. */__sys_trace: mov r2, scno add r1, sp, #S_OFF mov r0, #0 @ trace entry [IP = 0] bl syscall_trace adr lr, BSYM(__sys_trace_return) @ return address mov scno, r0 @ syscall number (possibly new) add r1, sp, #S_R0 + S_OFF @ pointer to regs cmp scno, #NR_syscalls @ check upper syscall limit ldmccia r1, {r0 - r3} @ have to reload r0 - r3 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine b 2b__sys_trace_return: str r0, [sp,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值