我正在尝试将x86_64汇编代码中的double转换为堆栈中的字符串:
bs.code += isa.movsd(registers.xmm0, MemRef(registers.rsp))
bs.code += isa.pop(registers.rax)
bs.code += isa.push(registers.rbp)
bs.code += isa.mov(registers.rbp, registers.rsp)
bs.code += isa.sub(registers.rsp, 100)
bs.code += isa.and_(registers.rsp, -16)
bs.code += isa.mov(registers.rdi, registers.rsp)
bs.code += isa.mov(registers.rsi, <address of "%i\0">)
bs.code += isa.mov(registers.rax, <address of sprintf in libc>)
bs.code += isa.call(registers.rax)
程序在call(rax)
与
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6a2919b in *__GI___overflow (f=0x7fffffffb5d0, ch=9698128) at genops.c:248
warning: Source file is more recent than executable.
248 return _IO_OVERFLOW (f, ch);
我认为必须特别调用sprintf
,因为它使用变量参数,所以有人可以通过汇编来建议正确的方法吗?
答案 0 :(得分:1)
如果你在C中编写一个简单的sprintf调用并使用gcc -s foo.c会有帮助吗?