On linux, I use objdump -dS file
to display disassemble with c source.
On mac OSX I use otool
instead, but man otool
didn't mention corresponding option.
Is there any solution for my problem?
Here is my c source:
➜ test cat b.c
#include <stdio.h>
int main(){
int i = 0;
return i+1;
}
➜ test gcc b.c -o b.out
I want to display b.out
's disassemble with source:
b.out:
(__TEXT,__text) section
_main:
0000000100000f80 pushq %rbp
0000000100000f81 movq %rsp, %rbp
0000000100000f84 movl $0x0, -0x4(%rbp)
source: i = 0;
0000000100000f8b movl $0x0, -0x8(%rbp)
source: return i+1;
0000000100000f92 movl -0x8(%rbp), %eax
0000000100000f95 addl $0x1, %eax
Unfortunately I only get disassemble.
➜ test otool -tV b.out
b.out:
(__TEXT,__text) section
_main:
0000000100000f80 pushq %rbp
0000000100000f81 movq %rsp, %rbp
0000000100000f84 movl $0x0, -0x4(%rbp)
0000000100000f8b movl $0x0, -0x8(%rbp)
0000000100000f92 movl -0x8(%rbp), %eax
0000000100000f95 addl $0x1, %eax
0000000100000f9a popq %rbp
0000000100000f9b ret