[Kernel] 전처리 파일로 쉽게 Macro함수 분석

숲사람·2022년 6월 12일
0

Linux Kernel

목록 보기
6/10

LInux Kernel 소스 상단의 Makefile을 아래와 같이 수정하고 빌드하면 .i로 끝나는 전처리가 된 파일이 생성된다. 리눅스 커널 코드 분석할때 가장 고통스러운 부분은 끝없이 찾아서 따라가야 하는 매크로 함수및 정의들인데. 이렇게 빌드하면 전처리가 끝난 최종 c파일의 모습을 확인할 수 있다. 핵꿀팁ㅜ 진작 알았으면 시간을 많이 아꼈을것 같다.

diff --git a/Makefile b/Makefile
index 2d1e491f7737..19c0ee81f8d8 100644
--- a/Makefile
+++ b/Makefile
@@ -512,7 +512,7 @@ KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
 KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
                   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
                   -Werror=implicit-function-declaration -Werror=implicit-int \
-                  -Werror=return-type -Wno-format-security \
+                  -Werror=return-type -Wno-format-security -save-temps=obj \
                   -std=gnu89
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_AFLAGS_KERNEL :=

팁 출처:

profile
기록 & 정리 아카이브 용도 (보다 완성된 글은 http://soopsaram.com/documentudy)

0개의 댓글