前言
在main.c函数中,存在两个函数 fork.c pause.c,当我们尝试单步跟进去之后,却发现失败了,我们来分析其原因。
void main(void) /* This really IS void, no error here. */
{
....
if (!fork()) { /* we count on this going ok */
init();
}
for(;;) pause();
}
_syscall0(type,name) 宏的实现
我们在main函数中存在下面这些定义,我们现在尝试分析一下。
static inline _syscall0(int,fork)
static inline _syscall0(int,pause)
static inline _syscall1(int,setup,void *,BIOS)
static inline _syscall0(int,sync)
其_syscall0(type,name)定义如下,我们尝试对此展开一下。
#define _syscall0(type,name) \
type name(void) \
{ \
long __res; \
__asm__ volatile ("int $0x80" \
: "=a" (__res) \
: "0" (__NR_##name)); \
if (__res >= 0) \
return (type) __res; \
errno = -__res; \
return -1; \
}
我们现在对pause( )展开,内容如下,就是调用 int 0x80,然后eax来