C源代码反汇编(Centos7)

川长思鸟来 2022-02-02 10:49 469阅读 0赞

gcc

执行指令 gcc -v,如果发现找不到gcc 指令,则执行yum install gcc 进行安装.

objdump

执行指令 whereis objdump。就会看见objdump的路径,是Linux默认的指令。


C源代码文件(文件内容如下)

  1. #include <stdio.h>
  2. static int add(int a, int b)
  3. {
  4. return a + b;
  5. }
  6. int main(int argc, const char *argv[])
  7. {
  8. int a = 1;
  9. int b = 1;
  10. int c;
  11. c = add(a, b);
  12. printf(" %d + %d = %d\n", a, b, c);
  13. return c;
  14. }

编译C源代码和生产反汇编文件

编译:gcc -o gcc_objdump objdump.c

反汇编:objdump -l -x -d gcc_objdump > objdump.dmp
在这里插入图片描述

分析

  1. 执行gcc_objdump文件,会得到 1 + 1 = 2; 执行指令是 ./gcc_objdump
  2. gcc_objdump是一个可执行的elf文件。ELF文件由4部分组成,分别是ELF头(ELF header)程序头表(Program header table)节(Section)和节头表(Section header table)。实际上,一个文件中不一定包含全部内容,而且他们的位置也未必如同所示这样安排,只有ELF头的位置是固定的,其余各部分的位置、大小等信息由ELF头中的各项值来决定
  3. objdump.dmp文件可以由vim工具打开,也可以使用EditPlus打开。

objdump.dmp内容如下

  1. gcc_objdump: file format elf64-x86-64
  2. gcc_objdump
  3. architecture: i386:x86-64, flags 0x00000112:
  4. EXEC_P, HAS_SYMS, D_PAGED
  5. start address 0x0000000000400430
  6. Program Header:
  7. PHDR off 0x0000000000000040 vaddr 0x0000000000400040 paddr 0x0000000000400040 align 2**3
  8. filesz 0x00000000000001f8 memsz 0x00000000000001f8 flags r-x
  9. INTERP off 0x0000000000000238 vaddr 0x0000000000400238 paddr 0x0000000000400238 align 2**0
  10. filesz 0x000000000000001c memsz 0x000000000000001c flags r--
  11. LOAD off 0x0000000000000000 vaddr 0x0000000000400000 paddr 0x0000000000400000 align 2**21
  12. filesz 0x0000000000000774 memsz 0x0000000000000774 flags r-x
  13. LOAD off 0x0000000000000e10 vaddr 0x0000000000600e10 paddr 0x0000000000600e10 align 2**21
  14. filesz 0x000000000000021c memsz 0x0000000000000220 flags rw-
  15. DYNAMIC off 0x0000000000000e28 vaddr 0x0000000000600e28 paddr 0x0000000000600e28 align 2**3
  16. filesz 0x00000000000001d0 memsz 0x00000000000001d0 flags rw-
  17. NOTE off 0x0000000000000254 vaddr 0x0000000000400254 paddr 0x0000000000400254 align 2**2
  18. filesz 0x0000000000000044 memsz 0x0000000000000044 flags r--
  19. EH_FRAME off 0x0000000000000620 vaddr 0x0000000000400620 paddr 0x0000000000400620 align 2**2
  20. filesz 0x000000000000003c memsz 0x000000000000003c flags r--
  21. STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**4
  22. filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
  23. RELRO off 0x0000000000000e10 vaddr 0x0000000000600e10 paddr 0x0000000000600e10 align 2**0
  24. filesz 0x00000000000001f0 memsz 0x00000000000001f0 flags r--
  25. Dynamic Section:
  26. NEEDED libc.so.6
  27. INIT 0x00000000004003c8
  28. FINI 0x00000000004005f4
  29. INIT_ARRAY 0x0000000000600e10
  30. INIT_ARRAYSZ 0x0000000000000008
  31. FINI_ARRAY 0x0000000000600e18
  32. FINI_ARRAYSZ 0x0000000000000008
  33. GNU_HASH 0x0000000000400298
  34. STRTAB 0x0000000000400318
  35. SYMTAB 0x00000000004002b8
  36. STRSZ 0x000000000000003f
  37. SYMENT 0x0000000000000018
  38. DEBUG 0x0000000000000000
  39. PLTGOT 0x0000000000601000
  40. PLTRELSZ 0x0000000000000030
  41. PLTREL 0x0000000000000007
  42. JMPREL 0x0000000000400398
  43. RELA 0x0000000000400380
  44. RELASZ 0x0000000000000018
  45. RELAENT 0x0000000000000018
  46. VERNEED 0x0000000000400360
  47. VERNEEDNUM 0x0000000000000001
  48. VERSYM 0x0000000000400358
  49. Version References:
  50. required from libc.so.6:
  51. 0x09691a75 0x00 02 GLIBC_2.2.5
  52. Sections:
  53. Idx Name Size VMA LMA File off Algn
  54. 0 .interp 0000001c 0000000000400238 0000000000400238 00000238 2**0
  55. CONTENTS, ALLOC, LOAD, READONLY, DATA
  56. 1 .note.ABI-tag 00000020 0000000000400254 0000000000400254 00000254 2**2
  57. CONTENTS, ALLOC, LOAD, READONLY, DATA
  58. 2 .note.gnu.build-id 00000024 0000000000400274 0000000000400274 00000274 2**2
  59. CONTENTS, ALLOC, LOAD, READONLY, DATA
  60. 3 .gnu.hash 0000001c 0000000000400298 0000000000400298 00000298 2**3
  61. CONTENTS, ALLOC, LOAD, READONLY, DATA
  62. 4 .dynsym 00000060 00000000004002b8 00000000004002b8 000002b8 2**3
  63. CONTENTS, ALLOC, LOAD, READONLY, DATA
  64. 5 .dynstr 0000003f 0000000000400318 0000000000400318 00000318 2**0
  65. CONTENTS, ALLOC, LOAD, READONLY, DATA
  66. 6 .gnu.version 00000008 0000000000400358 0000000000400358 00000358 2**1
  67. CONTENTS, ALLOC, LOAD, READONLY, DATA
  68. 7 .gnu.version_r 00000020 0000000000400360 0000000000400360 00000360 2**3
  69. CONTENTS, ALLOC, LOAD, READONLY, DATA
  70. 8 .rela.dyn 00000018 0000000000400380 0000000000400380 00000380 2**3
  71. CONTENTS, ALLOC, LOAD, READONLY, DATA
  72. 9 .rela.plt 00000030 0000000000400398 0000000000400398 00000398 2**3
  73. CONTENTS, ALLOC, LOAD, READONLY, DATA
  74. 10 .init 0000001a 00000000004003c8 00000000004003c8 000003c8 2**2
  75. CONTENTS, ALLOC, LOAD, READONLY, CODE
  76. 11 .plt 00000030 00000000004003f0 00000000004003f0 000003f0 2**4
  77. CONTENTS, ALLOC, LOAD, READONLY, CODE
  78. 12 .plt.got 00000008 0000000000400420 0000000000400420 00000420 2**3
  79. CONTENTS, ALLOC, LOAD, READONLY, CODE
  80. 13 .text 000001c2 0000000000400430 0000000000400430 00000430 2**4
  81. CONTENTS, ALLOC, LOAD, READONLY, CODE
  82. 14 .fini 00000009 00000000004005f4 00000000004005f4 000005f4 2**2
  83. CONTENTS, ALLOC, LOAD, READONLY, CODE
  84. 15 .rodata 0000001f 0000000000400600 0000000000400600 00000600 2**3
  85. CONTENTS, ALLOC, LOAD, READONLY, DATA
  86. 16 .eh_frame_hdr 0000003c 0000000000400620 0000000000400620 00000620 2**2
  87. CONTENTS, ALLOC, LOAD, READONLY, DATA
  88. 17 .eh_frame 00000114 0000000000400660 0000000000400660 00000660 2**3
  89. CONTENTS, ALLOC, LOAD, READONLY, DATA
  90. 18 .init_array 00000008 0000000000600e10 0000000000600e10 00000e10 2**3
  91. CONTENTS, ALLOC, LOAD, DATA
  92. 19 .fini_array 00000008 0000000000600e18 0000000000600e18 00000e18 2**3
  93. CONTENTS, ALLOC, LOAD, DATA
  94. 20 .jcr 00000008 0000000000600e20 0000000000600e20 00000e20 2**3
  95. CONTENTS, ALLOC, LOAD, DATA
  96. 21 .dynamic 000001d0 0000000000600e28 0000000000600e28 00000e28 2**3
  97. CONTENTS, ALLOC, LOAD, DATA
  98. 22 .got 00000008 0000000000600ff8 0000000000600ff8 00000ff8 2**3
  99. CONTENTS, ALLOC, LOAD, DATA
  100. 23 .got.plt 00000028 0000000000601000 0000000000601000 00001000 2**3
  101. CONTENTS, ALLOC, LOAD, DATA
  102. 24 .data 00000004 0000000000601028 0000000000601028 00001028 2**0
  103. CONTENTS, ALLOC, LOAD, DATA
  104. 25 .bss 00000004 000000000060102c 000000000060102c 0000102c 2**0
  105. ALLOC
  106. 26 .comment 0000002d 0000000000000000 0000000000000000 0000102c 2**0
  107. CONTENTS, READONLY
  108. SYMBOL TABLE:
  109. 0000000000400238 l d .interp 0000000000000000 .interp
  110. 0000000000400254 l d .note.ABI-tag 0000000000000000 .note.ABI-tag
  111. 0000000000400274 l d .note.gnu.build-id 0000000000000000 .note.gnu.build-id
  112. 0000000000400298 l d .gnu.hash 0000000000000000 .gnu.hash
  113. 00000000004002b8 l d .dynsym 0000000000000000 .dynsym
  114. 0000000000400318 l d .dynstr 0000000000000000 .dynstr
  115. 0000000000400358 l d .gnu.version 0000000000000000 .gnu.version
  116. 0000000000400360 l d .gnu.version_r 0000000000000000 .gnu.version_r
  117. 0000000000400380 l d .rela.dyn 0000000000000000 .rela.dyn
  118. 0000000000400398 l d .rela.plt 0000000000000000 .rela.plt
  119. 00000000004003c8 l d .init 0000000000000000 .init
  120. 00000000004003f0 l d .plt 0000000000000000 .plt
  121. 0000000000400420 l d .plt.got 0000000000000000 .plt.got
  122. 0000000000400430 l d .text 0000000000000000 .text
  123. 00000000004005f4 l d .fini 0000000000000000 .fini
  124. 0000000000400600 l d .rodata 0000000000000000 .rodata
  125. 0000000000400620 l d .eh_frame_hdr 0000000000000000 .eh_frame_hdr
  126. 0000000000400660 l d .eh_frame 0000000000000000 .eh_frame
  127. 0000000000600e10 l d .init_array 0000000000000000 .init_array
  128. 0000000000600e18 l d .fini_array 0000000000000000 .fini_array
  129. 0000000000600e20 l d .jcr 0000000000000000 .jcr
  130. 0000000000600e28 l d .dynamic 0000000000000000 .dynamic
  131. 0000000000600ff8 l d .got 0000000000000000 .got
  132. 0000000000601000 l d .got.plt 0000000000000000 .got.plt
  133. 0000000000601028 l d .data 0000000000000000 .data
  134. 000000000060102c l d .bss 0000000000000000 .bss
  135. 0000000000000000 l d .comment 0000000000000000 .comment
  136. 0000000000000000 l df *ABS* 0000000000000000 crtstuff.c
  137. 0000000000600e20 l O .jcr 0000000000000000 __JCR_LIST__
  138. 0000000000400460 l F .text 0000000000000000 deregister_tm_clones
  139. 0000000000400490 l F .text 0000000000000000 register_tm_clones
  140. 00000000004004d0 l F .text 0000000000000000 __do_global_dtors_aux
  141. 000000000060102c l O .bss 0000000000000001 completed.6355
  142. 0000000000600e18 l O .fini_array 0000000000000000 __do_global_dtors_aux_fini_array_entry
  143. 00000000004004f0 l F .text 0000000000000000 frame_dummy
  144. 0000000000600e10 l O .init_array 0000000000000000 __frame_dummy_init_array_entry
  145. 0000000000000000 l df *ABS* 0000000000000000 objdump.c
  146. 000000000040051d l F .text 0000000000000014 add_a_and_b
  147. 0000000000000000 l df *ABS* 0000000000000000 crtstuff.c
  148. 0000000000400770 l O .eh_frame 0000000000000000 __FRAME_END__
  149. 0000000000600e20 l O .jcr 0000000000000000 __JCR_END__
  150. 0000000000000000 l df *ABS* 0000000000000000
  151. 0000000000600e18 l .init_array 0000000000000000 __init_array_end
  152. 0000000000600e28 l O .dynamic 0000000000000000 _DYNAMIC
  153. 0000000000600e10 l .init_array 0000000000000000 __init_array_start
  154. 0000000000400620 l .eh_frame_hdr 0000000000000000 __GNU_EH_FRAME_HDR
  155. 0000000000601000 l O .got.plt 0000000000000000 _GLOBAL_OFFSET_TABLE_
  156. 00000000004005f0 g F .text 0000000000000002 __libc_csu_fini
  157. 0000000000601028 w .data 0000000000000000 data_start
  158. 000000000060102c g .data 0000000000000000 _edata
  159. 00000000004005f4 g F .fini 0000000000000000 _fini
  160. 0000000000000000 F *UND* 0000000000000000 printf@@GLIBC_2.2.5
  161. 0000000000000000 F *UND* 0000000000000000 __libc_start_main@@GLIBC_2.2.5
  162. 0000000000601028 g .data 0000000000000000 __data_start
  163. 0000000000000000 w *UND* 0000000000000000 __gmon_start__
  164. 0000000000400608 g O .rodata 0000000000000000 .hidden __dso_handle
  165. 0000000000400600 g O .rodata 0000000000000004 _IO_stdin_used
  166. 0000000000400580 g F .text 0000000000000065 __libc_csu_init
  167. 0000000000601030 g .bss 0000000000000000 _end
  168. 0000000000400430 g F .text 0000000000000000 _start
  169. 000000000060102c g .bss 0000000000000000 __bss_start
  170. 0000000000400531 g F .text 000000000000004e main
  171. 0000000000601030 g O .data 0000000000000000 .hidden __TMC_END__
  172. 00000000004003c8 g F .init 0000000000000000 _init
  173. Disassembly of section .init:
  174. 00000000004003c8 <_init>:
  175. _init():
  176. 4003c8: 48 83 ec 08 sub $0x8,%rsp
  177. 4003cc: 48 8b 05 25 0c 20 00 mov 0x200c25(%rip),%rax # 600ff8 <__gmon_start__>
  178. 4003d3: 48 85 c0 test %rax,%rax
  179. 4003d6: 74 05 je 4003dd <_init+0x15>
  180. 4003d8: e8 43 00 00 00 callq 400420 <.plt.got>
  181. 4003dd: 48 83 c4 08 add $0x8,%rsp
  182. 4003e1: c3 retq
  183. Disassembly of section .plt:
  184. 00000000004003f0 <.plt>:
  185. 4003f0: ff 35 12 0c 20 00 pushq 0x200c12(%rip) # 601008 <_GLOBAL_OFFSET_TABLE_+0x8>
  186. 4003f6: ff 25 14 0c 20 00 jmpq *0x200c14(%rip) # 601010 <_GLOBAL_OFFSET_TABLE_+0x10>
  187. 4003fc: 0f 1f 40 00 nopl 0x0(%rax)
  188. 0000000000400400 <printf@plt>:
  189. 400400: ff 25 12 0c 20 00 jmpq *0x200c12(%rip) # 601018 <printf@GLIBC_2.2.5>
  190. 400406: 68 00 00 00 00 pushq $0x0
  191. 40040b: e9 e0 ff ff ff jmpq 4003f0 <.plt>
  192. 0000000000400410 <__libc_start_main@plt>:
  193. 400410: ff 25 0a 0c 20 00 jmpq *0x200c0a(%rip) # 601020 <__libc_start_main@GLIBC_2.2.5>
  194. 400416: 68 01 00 00 00 pushq $0x1
  195. 40041b: e9 d0 ff ff ff jmpq 4003f0 <.plt>
  196. Disassembly of section .plt.got:
  197. 0000000000400420 <.plt.got>:
  198. 400420: ff 25 d2 0b 20 00 jmpq *0x200bd2(%rip) # 600ff8 <__gmon_start__>
  199. 400426: 66 90 xchg %ax,%ax
  200. Disassembly of section .text:
  201. 0000000000400430 <_start>:
  202. _start():
  203. 400430: 31 ed xor %ebp,%ebp
  204. 400432: 49 89 d1 mov %rdx,%r9
  205. 400435: 5e pop %rsi
  206. 400436: 48 89 e2 mov %rsp,%rdx
  207. 400439: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp
  208. 40043d: 50 push %rax
  209. 40043e: 54 push %rsp
  210. 40043f: 49 c7 c0 f0 05 40 00 mov $0x4005f0,%r8
  211. 400446: 48 c7 c1 80 05 40 00 mov $0x400580,%rcx
  212. 40044d: 48 c7 c7 31 05 40 00 mov $0x400531,%rdi
  213. 400454: e8 b7 ff ff ff callq 400410 <__libc_start_main@plt>
  214. 400459: f4 hlt
  215. 40045a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
  216. 0000000000400460 <deregister_tm_clones>:
  217. deregister_tm_clones():
  218. 400460: b8 37 10 60 00 mov $0x601037,%eax
  219. 400465: 55 push %rbp
  220. 400466: 48 2d 30 10 60 00 sub $0x601030,%rax
  221. 40046c: 48 83 f8 0e cmp $0xe,%rax
  222. 400470: 48 89 e5 mov %rsp,%rbp
  223. 400473: 77 02 ja 400477 <deregister_tm_clones+0x17>
  224. 400475: 5d pop %rbp
  225. 400476: c3 retq
  226. 400477: b8 00 00 00 00 mov $0x0,%eax
  227. 40047c: 48 85 c0 test %rax,%rax
  228. 40047f: 74 f4 je 400475 <deregister_tm_clones+0x15>
  229. 400481: 5d pop %rbp
  230. 400482: bf 30 10 60 00 mov $0x601030,%edi
  231. 400487: ff e0 jmpq *%rax
  232. 400489: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
  233. 0000000000400490 <register_tm_clones>:
  234. register_tm_clones():
  235. 400490: b8 30 10 60 00 mov $0x601030,%eax
  236. 400495: 55 push %rbp
  237. 400496: 48 2d 30 10 60 00 sub $0x601030,%rax
  238. 40049c: 48 c1 f8 03 sar $0x3,%rax
  239. 4004a0: 48 89 e5 mov %rsp,%rbp
  240. 4004a3: 48 89 c2 mov %rax,%rdx
  241. 4004a6: 48 c1 ea 3f shr $0x3f,%rdx
  242. 4004aa: 48 01 d0 add %rdx,%rax
  243. 4004ad: 48 d1 f8 sar %rax
  244. 4004b0: 75 02 jne 4004b4 <register_tm_clones+0x24>
  245. 4004b2: 5d pop %rbp
  246. 4004b3: c3 retq
  247. 4004b4: ba 00 00 00 00 mov $0x0,%edx
  248. 4004b9: 48 85 d2 test %rdx,%rdx
  249. 4004bc: 74 f4 je 4004b2 <register_tm_clones+0x22>
  250. 4004be: 5d pop %rbp
  251. 4004bf: 48 89 c6 mov %rax,%rsi
  252. 4004c2: bf 30 10 60 00 mov $0x601030,%edi
  253. 4004c7: ff e2 jmpq *%rdx
  254. 4004c9: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
  255. 00000000004004d0 <__do_global_dtors_aux>:
  256. __do_global_dtors_aux():
  257. 4004d0: 80 3d 55 0b 20 00 00 cmpb $0x0,0x200b55(%rip) # 60102c <_edata>
  258. 4004d7: 75 11 jne 4004ea <__do_global_dtors_aux+0x1a>
  259. 4004d9: 55 push %rbp
  260. 4004da: 48 89 e5 mov %rsp,%rbp
  261. 4004dd: e8 7e ff ff ff callq 400460 <deregister_tm_clones>
  262. 4004e2: 5d pop %rbp
  263. 4004e3: c6 05 42 0b 20 00 01 movb $0x1,0x200b42(%rip) # 60102c <_edata>
  264. 4004ea: f3 c3 repz retq
  265. 4004ec: 0f 1f 40 00 nopl 0x0(%rax)
  266. 00000000004004f0 <frame_dummy>:
  267. frame_dummy():
  268. 4004f0: 48 83 3d 28 09 20 00 cmpq $0x0,0x200928(%rip) # 600e20 <__JCR_END__>
  269. 4004f7: 00
  270. 4004f8: 74 1e je 400518 <frame_dummy+0x28>
  271. 4004fa: b8 00 00 00 00 mov $0x0,%eax
  272. 4004ff: 48 85 c0 test %rax,%rax
  273. 400502: 74 14 je 400518 <frame_dummy+0x28>
  274. 400504: 55 push %rbp
  275. 400505: bf 20 0e 60 00 mov $0x600e20,%edi
  276. 40050a: 48 89 e5 mov %rsp,%rbp
  277. 40050d: ff d0 callq *%rax
  278. 40050f: 5d pop %rbp
  279. 400510: e9 7b ff ff ff jmpq 400490 <register_tm_clones>
  280. 400515: 0f 1f 00 nopl (%rax)
  281. 400518: e9 73 ff ff ff jmpq 400490 <register_tm_clones>
  282. 000000000040051d <add_a_and_b>:
  283. add_a_and_b():
  284. 40051d: 55 push %rbp
  285. 40051e: 48 89 e5 mov %rsp,%rbp
  286. 400521: 89 7d fc mov %edi,-0x4(%rbp)
  287. 400524: 89 75 f8 mov %esi,-0x8(%rbp)
  288. 400527: 8b 45 f8 mov -0x8(%rbp),%eax
  289. 40052a: 8b 55 fc mov -0x4(%rbp),%edx
  290. 40052d: 01 d0 add %edx,%eax
  291. 40052f: 5d pop %rbp
  292. 400530: c3 retq
  293. 0000000000400531 <main>:
  294. main():
  295. 400531: 55 push %rbp
  296. 400532: 48 89 e5 mov %rsp,%rbp
  297. 400535: 48 83 ec 20 sub $0x20,%rsp
  298. 400539: 89 7d ec mov %edi,-0x14(%rbp)
  299. 40053c: 48 89 75 e0 mov %rsi,-0x20(%rbp)
  300. 400540: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%rbp)
  301. 400547: c7 45 f8 02 00 00 00 movl $0x2,-0x8(%rbp)
  302. 40054e: 8b 55 f8 mov -0x8(%rbp),%edx
  303. 400551: 8b 45 fc mov -0x4(%rbp),%eax
  304. 400554: 89 d6 mov %edx,%esi
  305. 400556: 89 c7 mov %eax,%edi
  306. 400558: e8 c0 ff ff ff callq 40051d <add_a_and_b>
  307. 40055d: 89 45 f4 mov %eax,-0xc(%rbp)
  308. 400560: 8b 4d f4 mov -0xc(%rbp),%ecx
  309. 400563: 8b 55 f8 mov -0x8(%rbp),%edx
  310. 400566: 8b 45 fc mov -0x4(%rbp),%eax
  311. 400569: 89 c6 mov %eax,%esi
  312. 40056b: bf 10 06 40 00 mov $0x400610,%edi
  313. 400570: b8 00 00 00 00 mov $0x0,%eax
  314. 400575: e8 86 fe ff ff callq 400400 <printf@plt>
  315. 40057a: 8b 45 f4 mov -0xc(%rbp),%eax
  316. 40057d: c9 leaveq
  317. 40057e: c3 retq
  318. 40057f: 90 nop
  319. 0000000000400580 <__libc_csu_init>:
  320. __libc_csu_init():
  321. 400580: 41 57 push %r15
  322. 400582: 41 89 ff mov %edi,%r15d
  323. 400585: 41 56 push %r14
  324. 400587: 49 89 f6 mov %rsi,%r14
  325. 40058a: 41 55 push %r13
  326. 40058c: 49 89 d5 mov %rdx,%r13
  327. 40058f: 41 54 push %r12
  328. 400591: 4c 8d 25 78 08 20 00 lea 0x200878(%rip),%r12 # 600e10 <__frame_dummy_init_array_entry>
  329. 400598: 55 push %rbp
  330. 400599: 48 8d 2d 78 08 20 00 lea 0x200878(%rip),%rbp # 600e18 <__init_array_end>
  331. 4005a0: 53 push %rbx
  332. 4005a1: 4c 29 e5 sub %r12,%rbp
  333. 4005a4: 31 db xor %ebx,%ebx
  334. 4005a6: 48 c1 fd 03 sar $0x3,%rbp
  335. 4005aa: 48 83 ec 08 sub $0x8,%rsp
  336. 4005ae: e8 15 fe ff ff callq 4003c8 <_init>
  337. 4005b3: 48 85 ed test %rbp,%rbp
  338. 4005b6: 74 1e je 4005d6 <__libc_csu_init+0x56>
  339. 4005b8: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1)
  340. 4005bf: 00
  341. 4005c0: 4c 89 ea mov %r13,%rdx
  342. 4005c3: 4c 89 f6 mov %r14,%rsi
  343. 4005c6: 44 89 ff mov %r15d,%edi
  344. 4005c9: 41 ff 14 dc callq *(%r12,%rbx,8)
  345. 4005cd: 48 83 c3 01 add $0x1,%rbx
  346. 4005d1: 48 39 eb cmp %rbp,%rbx
  347. 4005d4: 75 ea jne 4005c0 <__libc_csu_init+0x40>
  348. 4005d6: 48 83 c4 08 add $0x8,%rsp
  349. 4005da: 5b pop %rbx
  350. 4005db: 5d pop %rbp
  351. 4005dc: 41 5c pop %r12
  352. 4005de: 41 5d pop %r13
  353. 4005e0: 41 5e pop %r14
  354. 4005e2: 41 5f pop %r15
  355. 4005e4: c3 retq
  356. 4005e5: 90 nop
  357. 4005e6: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
  358. 4005ed: 00 00 00
  359. 00000000004005f0 <__libc_csu_fini>:
  360. __libc_csu_fini():
  361. 4005f0: f3 c3 repz retq
  362. Disassembly of section .fini:
  363. 00000000004005f4 <_fini>:
  364. _fini():
  365. 4005f4: 48 83 ec 08 sub $0x8,%rsp
  366. 4005f8: 48 83 c4 08 add $0x8,%rsp
  367. 4005fc: c3 retq

main函数

  1. 0000000000400531 <main>:
  2. main():
  3. 400531: 55 push %rbp
  4. 400532: 48 89 e5 mov %rsp,%rbp
  5. 400535: 48 83 ec 20 sub $0x20,%rsp
  6. 400539: 89 7d ec mov %edi,-0x14(%rbp)
  7. 40053c: 48 89 75 e0 mov %rsi,-0x20(%rbp)
  8. 400540: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%rbp)
  9. 400547: c7 45 f8 02 00 00 00 movl $0x2,-0x8(%rbp)
  10. 40054e: 8b 55 f8 mov -0x8(%rbp),%edx
  11. 400551: 8b 45 fc mov -0x4(%rbp),%eax
  12. 400554: 89 d6 mov %edx,%esi
  13. 400556: 89 c7 mov %eax,%edi
  14. 400558: e8 c0 ff ff ff callq 40051d <add_a_and_b>
  15. 40055d: 89 45 f4 mov %eax,-0xc(%rbp)
  16. 400560: 8b 4d f4 mov -0xc(%rbp),%ecx
  17. 400563: 8b 55 f8 mov -0x8(%rbp),%edx
  18. 400566: 8b 45 fc mov -0x4(%rbp),%eax
  19. 400569: 89 c6 mov %eax,%esi
  20. 40056b: bf 10 06 40 00 mov $0x400610,%edi
  21. 400570: b8 00 00 00 00 mov $0x0,%eax
  22. 400575: e8 86 fe ff ff callq 400400 <printf@plt>
  23. 40057a: 8b 45 f4 mov -0xc(%rbp),%eax
  24. 40057d: c9 leaveq
  25. 40057e: c3 retq
  26. 40057f: 90 nop

add函数

  1. 000000000040051d <add_a_and_b>:
  2. add_a_and_b():
  3. 40051d: 55 push %rbp
  4. 40051e: 48 89 e5 mov %rsp,%rbp
  5. 400521: 89 7d fc mov %edi,-0x4(%rbp)
  6. 400524: 89 75 f8 mov %esi,-0x8(%rbp)
  7. 400527: 8b 45 f8 mov -0x8(%rbp),%eax
  8. 40052a: 8b 55 fc mov -0x4(%rbp),%edx
  9. 40052d: 01 d0 add %edx,%eax
  10. 40052f: 5d pop %rbp
  11. 400530: c3 retq

发表评论

表情:
评论列表 (有 0 条评论,469人围观)

还没有评论,来说两句吧...

相关阅读

    相关 C基础汇编

    switch switch性能高于if语句的原因在于在case值较为连续的时候会生成值连续的大表,用switch的参数减去第一个最小的case值,和最大值进行比较,小于等

    相关 汇编-objdump

    windows下完成objdump需要用到:反汇编的目标镜像、镜像生成的本地编译器(.exe),相关指令如下。 > 反汇编命令: > > 1. 编译器路径,例:D:\

    相关 汇编

    从代码到最终可执行文件,要经过预处理、编译、汇编、链接四个过程: 1.预处理:对程序进行简单的处理,比如头文件包含展开 2.编译:汇编语言编译器用汇编语言来翻译文件

    相关 汇编工具

    最近上网络编程这门课,孙老师给我们介绍了下反汇编相关工具,让我对反汇编有了一个基本的认识,算是增长见识了。大概介绍了三个工具: 1.source insight 此工具为查