2012年5月3日 星期四

objdump vs bochs 反組譯

bochs 的反組譯可以秀出 %ss, %ds 這些預設的 segment register, objdump 就不行了, 但是 objdump 可以和 c code 一起對照著看。

objdump.disasm
 1 void proc_a(void)
 2 {
 3     64e1: 55                    push   %ebp
 4     64e2: 89 e5                 mov    %esp,%ebp
 5     64e4: 83 ec 28              sub    $0x28,%esp
11   int i = 0;
12     64e7: c7 45 f4 00 00 00 00  movl   $0x0,-0xc(%ebp)
13   int get_ticks(void);
14 
15   while(1)
16   {
17     //int r = sys_get_ticks();
18     int r = get_ticks();
19     64ee: e8 4d 03 00 00        call   6840 <get_ticks>
20     64f3: 89 45 f0              mov    %eax,-0x10(%ebp)
21     s32_print("A", cur_vb);
22     64f6: a1 cc 77 00 00        mov    0x77cc,%eax
23     64fb: 89 44 24 04           mov    %eax,0x4(%esp)
24     64ff: c7 04 24 2f 6b 00 00  movl   $0x6b2f,(%esp)
25     6506: e8 e3 f0 ff ff        call   55ee <s32_print>
26     //s32_print_int(i++, cur_vb, 10);
27     s32_print(".", cur_vb);
28     650b: a1 cc 77 00 00        mov    0x77cc,%eax
29     6510: 89 44 24 04           mov    %eax,0x4(%esp)
30     6514: c7 04 24 31 6b 00 00  movl   $0x6b31,(%esp)
31     651b: e8 ce f0 ff ff        call   55ee <s32_print>
32     s32_print_int(r, cur_vb, 10);
33     6520: a1 cc 77 00 00        mov    0x77cc,%eax
34     6525: c7 44 24 08 0a 00 00  movl   $0xa,0x8(%esp)
35     652c: 00 
36     652d: 89 44 24 04           mov    %eax,0x4(%esp)
37     6531: 8b 45 f0              mov    -0x10(%ebp),%eax
38     6534: 89 04 24              mov    %eax,(%esp)
39     6537: e8 0c f2 ff ff        call   5748 <s32_print_int>
40     //loop_delay(100);
41     milli_delay(1000);
42     653c: c7 04 24 64 00 00 00  movl   $0x64,(%esp)
43     6543: e8 49 fd ff ff        call   6291 <milli_delay>
44   }
45     6548: eb a4                 jmp    64ee <proc_a+0xd>
49 }





bochs.disasm
 1 
 2 <bochs:16> u 0x64e1 0x654b
 3 000064e1: (                    ): pushl %ebp                ; 55
 4 000064e2: (                    ): movl %esp, %ebp           ; 89e5
 5 000064e4: (                    ): subl $0x00000028, %esp    ; 83ec28
 6 000064e7: (                    ): movl $0x00000000, %ss:-12(%ebp) ; c745f400000000
 7 000064ee: (                    ): call .+845                ; e84d030000
 8 000064f3: (                    ): movl %eax, %ss:-16(%ebp)  ; 8945f0
 9 000064f6: (                    ): movl %ds:0x77cc, %eax     ; a1cc770000
10 000064fb: (                    ): movl %eax, %ss:4(%esp)    ; 89442404
11 000064ff: (                    ): movl $0x00006b2f, %ss:(%esp) ; c704242f6b0000
12 00006506: (                    ): call .-3869               ; e8e3f0ffff
13 0000650b: (                    ): movl %ds:0x77cc, %eax     ; a1cc770000
14 00006510: (                    ): movl %eax, %ss:4(%esp)    ; 89442404
15 00006514: (                    ): movl $0x00006b31, %ss:(%esp) ; c70424316b0000
16 0000651b: (                    ): call .-3890               ; e8cef0ffff
17 00006520: (                    ): movl %ds:0x77cc, %eax     ; a1cc770000
18 00006525: (                    ): movl $0x0000000a, %ss:8(%esp) ; c74424080a000000
19 0000652d: (                    ): movl %eax, %ss:4(%esp)    ; 89442404
20 00006531: (                    ): movl %ss:-16(%ebp), %eax  ; 8b45f0
21 00006534: (                    ): movl %eax, %ss:(%esp)     ; 890424
22 00006537: (                    ): call .-3572               ; e80cf2ffff
23 0000653c: (                    ): movl $0x00000064, %ss:(%esp) ; c7042464000000
24 00006543: (                    ): call .-695                ; e849fdffff
25 00006548: (                    ): jmp .-92                  ; eba4


沒有留言:

張貼留言

使用 google 的 reCAPTCHA 驗證碼, 總算可以輕鬆留言了。

我實在受不了 spam 了, 又不想讓大家的眼睛花掉, 只好放棄匿名留言。這是沒辦法中的辦法了。留言的朋友需要有 google 帳號。