聘我网

新概念招聘3.0

如何查看可执行文件中的所有指令?

vote up0vote downstar
gdb a.exe 
(gdb) disassemble main 
Dump of assembler code for function main: 
0x004012d0 <main+0>:    push   %ebp 
0x004012d1 <main+1>:    mov    %esp,%ebp 
... 

上面的只能看某一部分,如何查看全部?

 

1 个答复

vote up0vote downcheck

Machine Code:

When two arguments are given, they should be separated by a comma, possibly surrounded by whitespace. The arguments specify a range of addresses (first inclusive, second exclusive) to dump.

 (gdb) disas 0x32c4, 0x32e4
 Dump of assembler code from 0x32c4 to 0x32e4:
    0x32c4 :      addil 0,dp
    0x32c8 :      ldw 0x22c(sr0,r1),r26
    0x32cc :      ldil 0x3000,r31
    0x32d0 :      ble 0x3f8(sr4,r31)
    0x32d4 :      ldo 0(r31),rp
    0x32d8 :      addil -0x800,dp
    0x32dc :      ldo 0x588(r1),r26
    0x32e0 :      ldil 0x3000,r31
 End of assembler dump.

或者:

objdump -d hw.o

hw.o:     file format pe-i386


Disassembly of section .text:

00000000 <__Z3badv>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 08                sub    $0x8,%esp
   6:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
   d:   e8 00 00 00 00          call   12 <__Z3badv+0x12>
  12:   c9                      leave
  13:   c3                      ret
  14:   8d b6 00 00 00 00       lea    0x0(%esi),%esi
  1a:   8d bf 00 00 00 00       lea    0x0(%edi),%edi

00000020 <__Z3foov>:
  20:   55                      push   %ebp
  21:   89 e5                   mov    %esp,%ebp
  23:   83 ec 04                sub    $0x4,%esp
  26:   89 ec                   mov    %ebp,%esp
  28:   5d                      pop    %ebp
  29:   c3                      ret
  2a:   8d b6 00 00 00 00       lea    0x0(%esi),%esi

00000030 <_main>:
  30:   55                      push   %ebp
  31:   b8 10 00 00 00          mov    $0x10,%eax
  36:   89 e5                   mov    %esp,%ebp
  38:   83 ec 08                sub    $0x8,%esp
  3b:   83 e4 f0                and    $0xfffffff0,%esp
  3e:   e8 00 00 00 00          call   43 <_main+0x13>
  43:   e8 00 00 00 00          call   48 <_main+0x18>
  48:   c9                      leave
  49:   31 c0                   xor    %eax,%eax
  4b:   c3                      ret
  4c:   90                      nop
  4d:   90                      nop
  4e:   90                      nop
  4f:   90                      nop
链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.