2

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
ahuigo
  • 2,929
  • 2
  • 25
  • 45
  • The `man` page doesn't mention it. Are you asking if it's available as some sort of hidden easter egg? – Jongware Sep 21 '14 at 12:30
  • @Jongware So, if there is a hidden easter egg that I want? – ahuigo Sep 21 '14 at 12:33
  • 1
    Not that I know of. This specific functionality of `objdump` is not replicated in `otool`. Have you read [Disassemble the executable created by g++ in mac osx](http://stackoverflow.com/questions/9510074/disassemble-the-executable-created-by-g-in-mac-osx)? – Jongware Sep 21 '14 at 23:00

0 Answers0