2014-01-10 110 views
0

我想這個映射源文件和目標文件映射到目標文件

void main() 
{ 
    printf("Hello world !!\n"); 
} 

與目標文件之間如何做:

Disassembly of section .text: 

00000000 <main>: 

    0: 55      push %ebp 

    1: 89 e5     mov %esp,%ebp 

    3: 83 e4 f0    and $0xfffffff0,%esp 

    6: 83 ec 10    sub $0x10,%esp 

    9: b8 00 00 00 00   mov $0x0,%eax 

    e: 89 04 24    mov %eax,(%esp) 

    11: e8 fc ff ff ff   call 12 <main+0x12> 

    16: b8 00 00 00 00   mov $0x0,%eax 

    1b: c9      leave 

    1c: c3      ret 
+0

您是否嘗試添加'--source --line-numbers'選項? – Useless

回答

0

嘗試用gcc編譯的hello.c -g -o你好

選項。然後做ojbdump -S你好|少

1
objdump -d ./a.out --source --line-numbers 

工程就像一個魅力!

000000000040052c <main>: 
main(): 
/home/stdcall/temp/test.c:2 
void main() 
{ 
    40052c: 55      push %rbp 
    40052d: 48 89 e5    mov %rsp,%rbp 
/home/stdcall/temp/test.c:3 
    printf("Hello world !!\n"); 
    400530: bf e4 05 40 00   mov $0x4005e4,%edi 
    400535: e8 d6 fe ff ff   callq 400410 <[email protected]> 
/home/stdcall/temp/test.c:4 
} 
    40053a: 5d      pop %rbp 
    40053b: c3      retq 
    40053c: 0f 1f 40 00    nopl 0x0(%rax)