GCC에서 C니모닉 코드는 어떻게 볼 수 있을까요?
조회수 2584회
제가 직접 짠 어셈블리랑 GCC가 C에서 변환한 어셈블리랑 비교해서 얼마나 최적화를 잘 해주는지 비교하려고 합니다.
자바에 니모닉으로 기계어를 보는 것처럼 C에서도 그런 기능이 있나요?
1 답변
-
디버그 심볼을 써서 컴파일하면 objdump에서 니모닉을 볼 수 있습니다
>objdump --help [...] -S, --source Intermix source code with disassembly -l, --line-numbers Include line numbers and filenames in output
예시 :
> gcc -g -c test.c > objdump -d -M intel -S test.o test.o: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include <stdio.h> int main(void) { 0: 55 push ebp 1: 89 e5 mov ebp,esp 3: 83 e4 f0 and esp,0xfffffff0 6: 83 ec 10 sub esp,0x10 puts("test"); 9: c7 04 24 00 00 00 00 mov DWORD PTR [esp],0x0 10: e8 fc ff ff ff call 11 <main+0x11> return 0; 15: b8 00 00 00 00 mov eax,0x0 } 1a: c9 leave 1b: c3 ret
댓글 입력