|
<div style="background-color: transparent; margin-top: 0px; margin-left: 0px; margin-bottom: 0px; margin-right: 0px;">一、socket()库函数到系统调用,再到内核
<div style="background-color: transparent; margin-top: 0px; margin-left: 0px; margin-bottom: 0px; margin-right: 0px;">1、Linux运行的C库是glibc;
2、socket()调用如下:
1) socket()->__socket():glibc-2.3.6/sysdept/generic/socket.c (weak_alias(name1, name2))
2) __socket():glibc-2.3.6/sysdept/unix/sysv/linux/i386/socket.S
3) ENTER_KERNEL:
movl $SYS_ify(socketcall), %eax/* System call number in %eax. *//* Use ## so `socket' is a separate token that might be #define'd. */movl $P(SOCKOP_,socket), %ebx/* Subcode is first arg to syscall. */lea 4(%esp), %ecx/* Address of args is 2nd arg. */ /* Do the system call trap. */ENTER_KERNEL这里,
SYS_ify宏定义为:glibc-2.3.6/sysdept/unix/sysv/linux/i386/Sysdept.h |
|