【发布时间】:2019-11-20 06:41:13
【问题描述】:
我试图理解一段反汇编代码中的行,如下所示。我想知道以下内容:
- dec %eax : 为什么 eax 寄存器被递减? eax寄存器的初始值是多少?
- movl $0x0,-0x8(%ebp) : 为什么我们要将值 0x0 移到堆栈上? movl 不存储 32 位值(4 个字节)吗?如果是这样,为什么将值存储在基指针下方 8 个字节而不是 4 个字节?
这是反汇编的二进制文件:
Contents of section .text:
0000 554889e5 48c745f8 00000000 905dc3 UH..H.E......].
Contents of section .rodata:
0000 48656c6c 6f00 Hello.
Contents of section .comment:
0000 00474343 3a202855 62756e74 7520352e .GCC: (Ubuntu 5.
0010 342e302d 36756275 6e747531 7e31362e 4.0-6ubuntu1~16.
0020 30342e31 30292035 2e342e30 20323031 04.10) 5.4.0 201
0030 36303630 3900 60609.
Contents of section .eh_frame:
0000 14000000 00000000 017a5200 01781001 .........zR..x..
0010 1b0c0708 90010000 1c000000 1c000000 ................
0020 00000000 0f000000 00410e10 8602430d .........A....C.
0030 064a0c07 08000000 .J......
Disassembly of section .text:
0000000000000000 <my_function>:
0: 55 push %ebp
1: 48 dec %eax
2: 89 e5 mov %esp,%ebp
4: 48 dec %eax
5: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp)
c: 90 nop
d: 5d pop %ebp
e: c3 ret
这是 C 代码:
void my_function () {
char* my_string = "Hello";
}
【问题讨论】:
-
你的函数没有效果。我发布版本可能会完全消除它。
标签: assembly x86 disassembly att