const
code
c code
int main()
{
const int ret = 0;
int *p = (int*)&ret;
*p = 4;
return ret + *p;
}
asm code
$ lldb const
(lldb) target create "const"
Current executable set to
(lldb) disassemble -name main
const`main:
const[0x100000f80] <+0>: pushq %rbp
const[0x100000f81] <+1>: movq %rsp, %rbp
const[0x100000f84] <+4>: leaq -0x8(%rbp), %rax
const[0x100000f88] <+8>: movl $0x0, -0x4(%rbp)
const[0x100000f8f] <+15>: movl $0x0, -0x8(%rbp)
const[0x100000f96] <+22>: movq %rax, -0x10(%rbp)
const[0x100000f9a] <+26>: movq -0x10(%rbp), %rax
const[0x100000f9e] <+30>: movl $0x4, (%rax)
const[0x100000fa4] <+36>: movq -0x10(%rbp), %rax
const[0x100000fa8] <+40>: movl (%rax), %ecx
const[0x100000faa] <+42>: addl $0x0, %ecx
const[0x100000fad] <+45>: movl %ecx, %eax
const[0x100000faf] <+47>: popq %rbp
const[0x100000fb0] <+48>: retq
lldb 用法
http://lldb.llvm.org/lldb-gdb.html