[ARM중] 1차 분석 복습

홍문화 2011.08.08 20:44 조회 수 : 33707

출처 : http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html

오래된 자료라 3.0 버전과는 차이가 있을 수 있음을 염두해 두고 읽어 주세요.

5. Loading the kernel image

Kernel images generated by the kernel build process are either uncompressed "Image" files or compressed zImage files.

The uncompressed Image files are generally not used, as they do not contain a readily identifiable magic number. The compressed zImage format is almost universally used in preference.

The zImage has several benefits in addition to the magic number. Typically, the decompression of the image is faster than reading from some external media. The integrity of the image can be assured, as any errors will result in a failed decompress. The kernel has knowledge of its internal structure and state, which allows for better results than a generic external compression method.


=> 커널은 압축이 안된 Image 또는 압축이 된 zImage로 빌드 됩니다.

    아래 제 빌드 트리 확인 결과 두배 이상 차이가 납니다.



The zImage has a magic number and some useful information near its beginning.

Table 2. Useful fields in zImage head code

Offset into zImageValueDescription
0x240x016F2818Magic number used to identify this is an ARM Linux zImage
0x28start addressThe address the zImage starts at
0x2Cend addressThe address the zImage ends at

The start and end offsets can be used to determine the length of the compressed image (size = end - start). This is used by several bootloaders to determine if any data is appended to the kernel image. This data is typically used for an initial RAM disk (initrd). The start address is usually 0 as the zImage code is position independent.

The zImage code is Position Independent Code (PIC) so may be loaded anywhere within the available address space. The maximum kernel size after decompression is 4Megabytes. This is a hard limit and would include the initrd if a bootpImage target was used.


=> 매직넘버, start 주소, end 주소의 용도에 대한 설명입니다.

    0x24 주소를 보면 매직 넘버가(0x016F2818) 보입니다. 그런데 0x28, 0x2C가 ...으로 되어있네요.


(objdump 확인 결과)

(readelf 확인 결과)

0x28, 0x2C가 보입니다. 값이 둘다 0이군요.


=> zImage 는 position independent code라고 합니다. 공유 라이브러리 만들때 -fPIC 옵션 준다고 알고 있었는데

   PIC의 뜻이 이거였군요. zImage는 어느 주소에도 로드가 될 수 있다고 하네요. (잘 이해가 안가네요.)

Note

Although the zImage may be located anywhere, care should be taken. Starting a compressed kernel requires additional memory for the image to be uncompressed into. This space has certain constraints.

The zImage decompression code will ensure it is not going to overwrite the compressed data. If the kernel detects such a conflict it will uncompress the image immediately after the compressed zImage data and relocate the kernel after decompression. This obviously has the impact that the memory region the zImage is loaded into must have up to 4Megabytes of space after it (the maximum uncompressed kernel size), i.e. placing the zImage in the same 4Megabyte bank as its ZRELADDR would probably not work as expected.

Despite the ability to place zImage anywhere within memory, convention has it that it is loaded at the base of physical RAM plus an offset of 0x8000 (32K). This leaves space for the parameter block usually placed at offset 0x100, zero page exception vectors and page tables. This convention is very common.


=> 관습적으로 커널은 베이스 주소 + 0x8000에 로드를 한다고 합니다.

    초록색 글 부분 해석좀 해주세요. 정확히 해석을 못하겠네요. ㅋ


.section ".start", #alloc, #execinstr

위 코드에 의해 [5].start 섹션이 만들어 졌습니다. A(alloc), X(execinstr) 속성이 보이네요.


.type   start,#function

위 코드에 의해 start 심볼의 타입이 FUNC가 되었습니다.



objdump, readelf 파일 첨부 하였습니다.

공부하다보니 ELF 포맷에 완전 무지 하다는 사실을 깨달았습니다.

공부해야지. ㅋ

번호 제목 글쓴이 날짜 조회 수
공지 [공지] 커널 스터디 관련 Q&A 게시판 입니다. [5] woos 2016.04.09 2194
1745 setup.c 파일의 cacheid_init 함수 [1] file HyunGyu 2013.11.05 72265
1744 Vol.1의 CMPS ~ CVTPD2PS 입니다. 늦어서 죄송합니다. file 지현구 2007.03.10 64199
1743 as86(1) - Linux man page 입니다. 김민석 2010.04.30 36679
1742 lilo.c에서 !! 관한 토론? [6] 오시리스 2011.07.25 34354
» [ARM중] 1차 분석 복습 [5] file 홍문화 2011.08.08 33707
1740 ZONE_DMA, ZONE_NORMAL, ZONE_HIGHMEM (미완성) 구본규 2013.10.15 32767
1739 fork() 함수가 리턴을 두번하는 이유 설명 [2] 커널B조 2016.05.07 30223
1738 task_struct 구조체입니다. [1] file 아폴로 2013.04.30 29853
1737 ARM 프로세서 모드 [7] 홍문화 2011.06.08 26499
1736 BIOS 를 통하여 PCI configuration space를 액세스하는 방법 지현구 2007.08.12 22864
1735 파이프라인과 익셉션의 관계 관련 블로그 주소입니다. 이한울 2012.05.26 22081
1734 buildroot 사용법 [1] 구본규 2012.07.20 20240
1733 [x86] 스터디때 나왔던 cpu_dev 문제 [2] file pororo 2012.02.19 18429
1732 페이지 테이블에 주소 변환 정보가 채워지는 원리 [16] 홍문화 2011.07.12 16325
1731 odroid bootlog 입니다 박장운 2010.08.14 15560
1730 명령어 정리 - 늦어서 죄송.. 송형주 2007.03.09 14524
1729 Linux booting 과정 (start_kernel() 함수 전까지) 관련 참고자료들 모음 file 지현구 2007.04.27 14328
1728 분석 환경 구축 실습 [11] file 권석민 2013.05.19 14204
1727 [x86] 가족번호 [2] pororo 2012.02.27 13912
1726 LVM에 대해 간략하게 정리했습니다. [2] file 조성진 2013.05.07 13825
XE Login