我很难跟踪这个程序集错误,非常感谢一些帮助。
我已将这个漏洞追踪到一个地方,这让我感到困惑:
not_object:
movq _stanza_header(%rip), %rbp
movq c_rsp_offset(%rbp), %rsp
andq $-16, %rsp
addq $0, %rsp // Code does not work without this line
call _gc_failure
由于某种原因,添加虚拟语句(addq $ 0,%rsp)会使代码工作,没有它,它就不会。
有谁知道这种行为可能会如何产生?我不动态地将代码加载到堆中,所以我不相信我会在没有段错误的情况下以某种方式覆盖代码。
我正在使用Apple的i686-apple-darwin10-gcc-4.2.1在64位Intel机器上组装代码。
非常感谢你的帮助! -Patrick
生成的机器代码(由gdb反汇编)与我写的相符:
not_object:
0x000000010001060e <not_object+0>: mov 0xabb(%rip),%rbp # 0x1000110d0 <stanza_header>
0x0000000100010615 <not_object+7>: mov 0x58(%rbp),%rsp
0x0000000100010619 <not_object+11>: and $0xfffffffffffffff0,%rsp
0x000000010001061d <not_object+15>: add $0x0,%rsp
0x0000000100010621 <not_object+19>: callq 0x10000173f <gc_failure>
所以我想我应该排除一个错误的汇编程序作为原因。