[EX] sample.c (C 언어 작성) --- 변환 --> sample.a (어셈블리어)
$ cd
$ cd tmp
$ vi sample.c
int function(int a, int b){
int main(void){ |
$ gcc -S -o sample.a sample.c
$ ls -l
-rw-rw-r-- 1 level1 level1 570 11월 25 12:17 sample.a -rw-rw-r-- 1 level1 level1 131 11월 25 12:16 sample.c |
$ file *
sample.a: ASCII assembler program text sample.c: ASCII C program text |
$ vi sample.a
.file "sample.c" subl %eax, %esp
|
[EX2] sample.c (C 언어) -----> sample (바이너리) -----> disassemble (어셈블리어)
$ gcc -o sample sample.c
$ file sample*
sample: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped sample.a: ASCII assembler program text sample.c: ASCII C program text |
$ gdb -q sample
(gdb) disassemble main Dump of assembler code for function main: 0x08048305 <main+0>: push %ebp 0x08048306 <main+1>: mov %esp,%ebp 0x08048308 <main+3>: sub $0x8,%esp 0x0804830b <main+6>: and $0xfffffff0,%esp 0x0804830e <main+9>: mov $0x0,%eax 0x08048313 <main+14>: sub %eax,%esp 0x08048315 <main+16>: sub $0x8,%esp 0x08048318 <main+19>: push $0x2 0x0804831a <main+21>: push $0x1 0x0804831c <main+23>: call 0x80482f4 <function> 0x08048321 <main+28>: add $0x10,%esp 0x08048324 <main+31>: mov %eax,0xfffffffc(%ebp) 0x08048327 <main+34>: mov $0x0,%eax 0x0804832c <main+39>: leave 0x0804832d <main+40>: ret 0x0804832e <main+41>: nop 0x0804832f <main+42>: nop End of assembler dump. |
(정리)
sample.c (C 언어) -----> sample.a (어셈블리어)
sample.c (C 언어) -----> sample (바이너리) ----- gdb ----> disassemble (어셈블리어)
'Learning > └◆Reversing' 카테고리의 다른 글
[실습] C언어 코드와 어셈블리 언어 코드 테이블 제작 (0) | 2017.01.19 |
---|---|
[과제] gdb(디버거) 사용법 (0) | 2017.01.19 |
[참고]어셈블리어의 기본 문법과 명령 (0) | 2017.01.19 |
[참고]어셈블리 언어에 대해서_2 (0) | 2017.01.19 |