32位套接字调用系统调用如何基于libc程序集工作?

时间:2019-03-01 05:46:29

标签: linux assembly system-calls libc

我试图通过阅读套接字API和Libc库中的其他一些代码来了解32位套接字调用的工作原理。

   000ed9f0 <socket>:
   ed9f0: 89 da                 mov    %ebx,%edx
   ed9f2: b8 66 00 00 00        mov    $0x66,%eax   # socketcall syscall number
   ed9f7: bb 01 00 00 00        mov    $0x1,%ebx    # SYS_SOCKET value
   ed9fc: 8d 4c 24 04           lea    0x4(%esp),%ecx # pointer to the *arg structure
   eda00: 65 ff 15 10 00 00 00  call   *%gs:0x10  # invokes syscall? but this is not sysenter or int 0x80
   eda07: 89 d3                 mov    %edx,%ebx
   eda09: 83 f8 83              cmp    $0xffffff83,%eax
   eda0c: 73 01                 jae    eda0f <socket+0x1f>
   eda0e: c3                    ret
   eda0f: e8 cb 8d 03 00        call   1267df <__frame_state_for+0x35f>
   eda14: 81 c1 ec d5 0b 00     add    $0xbd5ec,%ecx
   eda1a: 8b 89 24 ff ff ff     mov    -0xdc(%ecx),%ecx
   eda20: f7 d8                 neg    %eax
   eda22: 65 03 0d 00 00 00 00  add    %gs:0x0,%ecx
   eda29: 89 01                 mov    %eax,(%ecx)
   eda2b: 83 c8 ff              or     $0xffffffff,%eax
   eda2e: c3                    ret
   eda2f: 90                    nop

请参阅上面的代码注释(#)。在这一行之前,对我来说很有意义:

   eda00: 65 ff 15 10 00 00 00  call   *%gs:0x10  # invokes syscall? but this is not Sysenter or int 0x80

我认为我们使用int 0x80或Sysenter调用syscall。但是,使用段寄存器进行的调用如何调用socketcall syscall?

0 个答案:

没有答案