In this article, we will look into the x86 assembly code, analyze it and try to construct the corresponding C code. Let’s first look into the following piece of x86 assembly code:
0000000000400546 <main>: 400546: push rbp 400547: mov rbp,rsp 40054a: sub rsp,0x20 40054e: mov rax,QWORD PTR fs:0x28 400555: 00 00 400557: mov QWORD PTR [rbp-0x8],rax 40055b: xor eax,eax 40055d: mov BYTE PTR [rbp-0x15],0x61 400561: mov DWORD PTR [rbp-0x14],0x0 400568: jmp 40057b <main+0x35> 40056a: mov eax,DWORD PTR [rbp-0x14] 40056d: cdqe 40056f: movzx edx,BYTE PTR [rbp-0x15] 400573: mov BYTE PTR [rbp+rax*1-0x10],dl 400577: add DWORD PTR [rbp-0x14],0x1 40057b: cmp DWORD PTR [rbp-0x14],0x4 40057f: jle 40056a <main+0x24> 400581: mov eax,0x0 400586: mov rcx,QWORD PTR [rbp-0x8] 40058a: xor rcx,QWORD PTR fs:0x28 400591: 00 00 400593: je 40059a <main+0x54> 400595: call 400420 <__stack_chk_fail@plt> 40059a: leave 40059b: ret 40059c: nop DWORD PTR [rax+0x0]
0 Comments