Skip to content

커널 컴파일

Steve edited this page Jul 13, 2019 · 2 revisions

[HOME]

1. 커널소스 다운로드

커널소스는 www.kernel.org 에서 다운로드 받는다.
현재(2019년 6월 27일) 최종 소스는 5.1.15 이다.

** 커널 컴파일은 Ubuntu linux 에서 진행 한다. **

2. 커널 압축 해제

다운로드한 최종 소스는 이름은 linux-5.1.15.tar.xz 이다.
아래 명령어로 압축을 해제 한다.

$sudo xz -d linux-5.1.15.tar.xz   
$sudo tar xf linux-5.1.15.tar

3. 커널 빌드 환경 구축하기

3.1 64bit AArch64 툴체인 설치

ARM Cross compiler 설치 아래와 같이 64bit AArch64 툴체인을 설치 한다.

sudo apt install binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

3.2 커널 컴파일을 위한 패키지 설치

필요 패키지 설치
아래 명령어로 패키지를 설치 한다.

sudo apt-get update  
sudo apt-get install build-essential libncurses5 libncurses5-dev bin86 kernel-package libssl-dev bison flex libelf-dev

3.3 커널 makefile 수정 크로스 컴파일 설정 수정

#3. 크로스 컴파일 설정 수정
크로스 컴파일 환경을 위한 커널 makefile 의 346 라인을 아래와 같이 수정한다.

#ARCH		?= $(SUBARCH)
ARCH		?= arm64
CROSS_COMPILE	?= aarch64-linux-gnu-

4. 커널 환경 설정

linux-5.1.15/arch/arm64/configs/defconfig 를 이용하여 커널 환경을 설정 한.

4.1 '.config' 파일로 복사

linux-5-1.15$ sudo cp arch/arm64/configs/defconfig .config  

4.2 menuconfig

ref : 6. make menuconfig 아래와 같이 입력하여 커널 설정을 시작 한다.
위의 참조 링크와 같이 커널을 설정 한다.

linux-5-1.15$ sudo make menuconfig

5. 커널 빌딩

5.1 vmlinux 이미지 빌딩

아래와 같이 커널 빌딩을 시작한다.

linux-5-1.15$ sudo make all  

5.2 Section 정보 추출

vmlinux 에 있는 section 정보를 아래와 같이 추출한다.

linux-5-1.15$ aarch64-linux-gnu-objdump -h vmlinux > vmlinux_section

5.3 aarch64-linux-gnu-objdump 의 optinos

linux-5-1.15$ aarch64-linux-gnu-objdump
Usage: ./aarch64-linux-gnu-objdump <option(s)> <file(s)>
Display information from object <file(s)>.
At least one of the following switches must be given:
  -a, --archive-headers    Display archive header information
  -f, --file-headers       Display the contents of the overall file header
  -p, --private-headers    Display object format specific file header contents
  -P, --private=OPT,OPT... Display object format specific contents
  -h, --[section-]headers  Display the contents of the section headers
  -x, --all-headers        Display the contents of all headers
  -d, --disassemble        Display assembler contents of executable sections
  -D, --disassemble-all    Display assembler contents of all sections
  -S, --source             Intermix source code with disassembly
  -s, --full-contents      Display the full contents of all sections requested
  -g, --debugging          Display debug information in object file
  -e, --debugging-tags     Display debug information using ctags style
  -G, --stabs              Display (in raw form) any STABS info in the file
  -W[lLiaprmfFsoRt] or
  --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,
          =frames-interp,=str,=loc,=Ranges,=pubtypes,
          =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,
          =addr,=cu_index]
                           Display DWARF info in the file
  -t, --syms               Display the contents of the symbol table(s)
  -T, --dynamic-syms       Display the contents of the dynamic symbol table
  -r, --reloc              Display the relocation entries in the file
  -R, --dynamic-reloc      Display the dynamic relocation entries in the file
  @<file>                  Read options from <file>
  -v, --version            Display this program's version number
  -i, --info               List object formats and architectures supported
  -H, --help               Display this information