接上篇,文件跳转到了entry.S里面,这是kernel的入口。首先面临这么一个问题,kernel被加载到了什么地方?
回想上篇elf文件的加载机制,以及objdump里打印出的kernel信息,可以看到,kernel的代码段(text段)被加载到了0x100000的位置,也就是1m的位置,所以内存布局如下:
+------------------+ <- 0xFFFFFFFF (4GB) | 32-bit | | memory mapped | | devices | | | /\/\/\/\/\/\/\/\/\/\ /\/\/\/\/\/\/\/\/\/\ | | | Unused | | | +------------------+ <- depends on amount of RAM | | | | | Extended Memory | |------------------| | kernnel | +------------------+ <- 0x00100000 (1MB) | BIOS ROM | +------------------+ <- 0x000F0000 (960KB) | 16-bit devices, | | expansion ROMs | +------------------+ <- 0x000C0000 (768KB) | VGA Display | +------------------+ <- 0x000A0000 (640KB) | | | Lo