我反汇编了用C++编写的简单程序,其中有一个函数:
080486a8 <_GLOBAL__I_main>:
80486a8: 55 push %ebp
80486a9: 89 e5 mov %esp,%ebp
80486ab: 83 ec 18 sub $0x18,%esp
80486ae: c7 44 24 04 ff ff 00 movl $0xffff,0x4(%esp)
80486b5: 00
80486b6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
80486bd: e8 a6 ff ff ff call 8048668 <_Z41__static_initialization_and_destruction_0ii>
80486c2: c9 leave
80486c3: c3 ret
80486c4: 90 nop
80486c5: 90 nop
80486c6: 90 nop
80486c7: 90 nop
80486c8: 90 nop
80486c9: 90 nop
80486ca: 90 nop
80486cb: 90 nop
80486cc: 90 nop
80486cd: 90 nop
80486ce: 90 nop
80486cf: 90 nop 这个功能是什么?为什么在RET指令之后会有这么多NOP操作?
发布于 2011-06-25 22:52:23
正如netrom提到的,__static_initialization_and_destruction_0(int, int)安排调用全局构造函数和析构函数。
许多编译器在函数后添加nop指令以启用增量重新链接。如果稍微更改一下函数,它就会增长,链接器就不必移动后面的所有函数了。相反,这种增长覆盖了以前的一些nop。
发布于 2011-06-25 22:22:59
如果你拆分__Z41__static_initialization_and_destruction_0ii,那么你就会得到__static_initialization_and_destruction_0(int, int)。
看看this answer,甚至this file。
https://stackoverflow.com/questions/6478306
复制相似问题