我使用自定义内核模块编译内核,该内核模块打印出内核的代码开始和结束(物理)地址。它从0x8000开始,到0xefe6d8结束。通过生成的System.map,我看到内核中的几乎所有函数都位于物理内存中的0x10000(1Mb)以及之后。但代码从0x8000开始。我无法弄清楚这两个地址之间的内容。任何人都可以对此有所了解吗?
来自System.map的片段(虚拟映射从0xc0000000开始):
c0008000 T _text
c0008000 T stext
c000804c t __create_page_tables
c000814c t __turn_mmu_on_loc
c0008158 t __vet_atags
c0100000 T __exception_text_start
__create_page_tables
函数表示页面表位于__vet_atags
代码之后。但为什么他们会成为可执行内存的一部分?
答案 0 :(得分:1)
从kernel boot procotol开始,内核内存布局如下:
~ ~
| Protected-mode kernel |
100000 +------------------------+
| I/O memory hole |
0A0000 +------------------------+
| Reserved for BIOS | Leave as much as possible unused
~ ~
| Command line | (Can also be below the X+10000 mark)
X+10000 +------------------------+
| Stack/heap | For use by the kernel real-mode code.
X+08000 +------------------------+
| Kernel setup | The kernel real-mode code.
| Kernel boot sector | The kernel legacy boot sector.
X +------------------------+
| Boot loader | <- Boot sector entry point 0000:7C00
001000 +------------------------+
| Reserved for MBR/BIOS |
000800 +------------------------+
| Typically used by MBR |
000600 +------------------------+
| BIOS use only |
000000 +------------------------+