我目前正在尝试了解 glibcsyscall
函数的内部代码。下面是代码(取自这里)。
/* In the EABI syscall interface, we don't need a special syscall to
implement syscall(). It won't work reliably with 64-bit arguments
(but that is true on many modern platforms). */
ENTRY (syscall)
mov ip, sp
push {r4, r5, r6, r7}
cfi_adjust_cfa_offset (16)
cfi_rel_offset (r4, 0)
cfi_rel_offset (r5, 4)
cfi_rel_offset (r6, 8)
cfi_rel_offset (r7, 12)
mov r7, r0
mov r0, r1
mov r1, r2
mov r2, r3
ldmfd ip, {r3, r4, r5, r6}
swi 0x0
pop {r4, r5, r6, r7}
cfi_adjust_cfa_offset (-16)
cfi_restore (r4)
cfi_restore (r5)
cfi_restore (r6)
cfi_restore (r7)
cmn r0, #4096
it cc
RETINSTR(cc, lr)
b PLTJMP(syscall_error)
PSEUDO_END (syscall)
我对传递系统调用号和参数的代码有一定的了解,这是函数的核心syscall
功能。但我不明白cfi_adjust_cfa_offset
指令、cfi_rel_offset
指令和cfi_restore
指令是做什么的。我知道这些说明与函数的功能关系不大syscall
。但是,我仍然想知道这些指令的作用。
谢谢你。