linux - 基于 libc 程序集的 32 位 socketcall 系统调用如何工作?
问题描述
我试图通过阅读套接字 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 系统调用的呢?
解决方案
推荐阅读
- oauth-2.0 - IdentityServer4授权代码流同意页面的最佳实践?
- javascript - 使用 Javascript 按 ID 查找两个元素
- cypress - 赛普拉斯获取元素长度返回双倍
- entity-framework - 每次我在数据库中进行更改时是否需要更新代码/应用程序?
- sql - 删除 Oracle SQL 中的重复行
- xamarin.android - 预加载 DialogFragment
- python - 来自 Amazon.com ( & Amazon.in ) 的程序化结账
- javascript - 复选框 onchanged 未在反应中更新
- shell - Bash 将内容插入到第 n 个 html 标记中
- node.js - 如何从firebase函数获得对firebase静态index.html的响应