linux - 协助了解linux_start
问题描述
000003b0 <_start>:
3b0: 31 ed xor %ebp,%ebp
3b2: 5e pop %esi
3b3: 89 e1 mov %esp,%ecx
3b5: 83 e4 f0 and $0xfffffff0,%esp
3b8: 50 push %eax
3b9: 54 push %esp
3ba: 52 push %edx
3bb: e8 22 00 00 00 call 3e2 <_start+0x32>
3c0: 81 c3 1c 1c 00 00 add $0x1c1c,%ebx
3c6: 8d 83 94 e5 ff ff lea -0x1a6c(%ebx),%eax
3cc: 50 push %eax
3cd: 8d 83 34 e5 ff ff lea -0x1acc(%ebx),%eax
3d3: 50 push %eax
3d4: 51 push %ecx
3d5: 56 push %esi
3d6: ff b3 1c 00 00 00 pushl 0x1c(%ebx)
3dc: e8 af ff ff ff call 390 <__libc_start_main@plt>
3e1: f4 hlt
3e2: 8b 1c 24 mov (%esp),%ebx
3e5: c3 ret
3e6: 66 90 xchg %ax,%ax
3e8: 66 90 xchg %ax,%ax
3ea: 66 90 xchg %ax,%ax
3ec: 66 90 xchg %ax,%ax
3ee: 66 90 xchg %ax,%ax
嘿,伙计们,请帮我理解 addr 3b8 之后的这段代码片段。我可以猜到它在做什么,但不是很具体。
顺便说一句,如果你们有任何线索教我如何在特定代码上弄清楚 Linux 调用系统的实现,请告诉我。谢谢。
在检查了 ABI 文档后,仍然不太明白为什么它会跳转到 3e2,因为他们似乎什么也没做,只是跳了回来。
解决方案
查看 i386 System V ABI 文档。(https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI)。它还详细记录了函数调用约定。(它变得很激烈,有时只看 GCC 如何-O2
编译参数传递或按值返回结构会更容易。例如在https://godbolt.org/上)
它指定入口的用户空间堆栈布局_start
。例如,ESP 指向argc
,并且argv[]
在其上方(数组内容,而不是指针)。 envp[]
以上。另请注意,在动态链接的可执行文件中,_start
是从动态链接器自己的启动代码跳转到的。这就是 atexit 指针的来源。
另请注意,这是一个 PIE 可执行文件,因此它将返回地址转换为 EBX,以便使用call 3e2
.
推荐阅读
- excel - 使用vb6在ole中显示缩放Excel
- sql - 如何使用 value() 方法在没有 WITH XMLNAMESPACES 子句的情况下使用 SQL 获取 XML 节点值?
- xml - 更新 xml 文件中“url”标签的值时出错
- java - 如何使用 Selenium 和 Java 从自动建议中选择一个选项?
- java - 如何在单页应用程序中使用 keycloak
- javascript - Jquery - 获取单击的 DIV 元素的 ID
- c# - 我可以在.net core 中为每个区域设置一个默认页面吗?
- wait - 如何等待一组 slurm 工作中的一个工作完成
- html - 根据某些条件对齐按钮
- sql - 哪些表用于获取 OIM 中的编排信息?