본문 바로가기

2018/03

Linux kernel debugging with qemu x86-64 리눅스 커널을 디버깅 하는 방법입니다.커널을 디버깅하기 위해 host-machine, target-machine이 필요한데 host-machine은 우분투 x86-64라고 가정하고 target-machine은 커널을 qemu에 올려서 vm으로 진행하겠습니다.먼저 디버깅할 버전의 커널을 컴파일 해야합니다.커널을 다운로드 받고 (http://kernel.org) 압축을 풀어서 커널 디렉토리로 이동한 후make defconfig make kvmconfig make menuconfig를 순서대로 실행해줍니다.make menuconfig를 하면 옵션을 선택할 수 있는 창들이 뜰 텐데 여기서 Kernel Hacking compile-time checks and compiler options compil.. 더보기
커널 컴파일 시 code model kernel does not support PIC mode 해결법 낮은 버전의 커널을 최신 혹은 높은 버전의 gcc로 컴파일 할 때 cc1: error: code model kernel does not support PIC mode 라는 에러를 볼 수 있다. gcc특정 버전 이상에서는 pie적용이 기본으로 설정되어있어서 나는 오류이다.1234567891011121314151617diff --git a/Makefile b/Makefileindex dda982c..f96b174 100644--- a/Makefile+++ b/Makefile@@ -608,6 +608,12 @@ endif # $(dot-config) # Defaults to vmlinux, but the arch makefile usually adds further targets all: vmlinux +# .. 더보기
커널 옛날 버전 컴파일 하다가 ____ilog2_nan 에러날 때 가끔씩 옛날 버전 컴파일 하다가 ____ilog2_nan 이거 없다고 에러날 때가 있다.12345678910111213141516171819202122232425262728293031323334353637diff --git a/include/linux/log2.h b/include/linux/log2.hindex ef3d4f67118c..07ef24eedf83 100644--- a/include/linux/log2.h+++ b/include/linux/log2.h@@ -16,12 +16,6 @@ #include /*- * deal with unrepresentable constant logarithms- */-extern __attribute__((const, noreturn))-int ____ilog2.. 더보기
리눅스 가상 시리얼 포트 열기 sudo socat PTY,link=/dev/ttyS10 PTY,link=/dev/ttyS08 하면 /dev/ttyS08 이 열림minicom -D /dev/ttyS08 해서 시리얼 열고 1234567891011121314151617181920212223242526272829303132333435363738394041424344#include #include #include #include #include #include #include int main( void){ int fd; struct termios newtio; fd = open( "/dev/ttyS8", O_RDWR | O_NOCTTY | O_NONBLOCK ); if (fd == -1) { puts("open error"); return 0.. 더보기