[pso] Surse glibc sub LXR
Octavian Voicu
octavian.voicu at gmail.com
Wed May 27 16:54:41 EEST 2009
2009/5/27 Bogdan Tenea <tenea.bogdan at gmail.com>
> Am si eu intrebare legata de glibc. Vroiam sa fac o prezentare maine cu
> titlu "De la sendto la fir", am luat sursele glibc, am gasit sendto la
> http://koala.cs.pub.ro/lxr/glibc/sysdeps/mach/hurd/sendto.c si am gasit ca
> in spate apeleaza un __socket_send catre care nu mai gasesc referinte nici
> macar ca freetext. Unde gresesc?
>
Functia este generata de fisierul
sendto.S<http://koala.cs.pub.ro/lxr/glibc/sysdeps/unix/sysv/linux/sendto.S>,
intr-un mod mai indirect:
#define socket sendto
/* ... */
#include <socket.S>
In socket.S<http://koala.cs.pub.ro/lxr/glibc/sysdeps/unix/sysv/linux/i386/socket.S>se
implementeaza functia apeland syscall-ul socketcall cu argumentul
SOCKOP_sendto<http://koala.cs.pub.ro/lxr/glibc/sysdeps/unix/sysv/linux/socketcall.h#L39>
.
In codul de mai jos (vezi socket.S) `socket' are valoarea definita mai sus:
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
Toate chestiile astea sunt doar detalii de implementare, raspunsul scurt e
ca se apeleaza syscall-ul
socketcall<http://lxr.linux.no/linux+v2.6.29/net/socket.c#L2049>care e
de fapt un mare switch care face dispatch la functia corespunzatoare
codului primit, adica
sendto<http://lxr.linux.no/linux+v2.6.29/net/socket.c#L1618>(care e de
fapt un alt syscall, probabil in alte implementari se apeleaza
acest syscall direct).
--
Octavian Voicu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cursuri.cs.pub.ro/pipermail/pso/attachments/20090527/af43284b/attachment.htm>
More information about the pso
mailing list