1. 创建一个vm_area_struct;
2. 圈定一个虚用户空间,将其起始结束地址(elf段中已设置好)保存到vm_start和vm_end中;
3. 将磁盘file句柄保存在vm_file中;
4. 将对应段在磁盘file中的偏移值(elf段中已设置好)保存在vm_pgoff中;
5. 将操作该磁盘file的磁盘操作函数保存在vm_ops中;
6. 注意这里没有为对应的页目录表项创建页表,更不存在设置页表项了;
§ §
§ +------§->+--------------+
§ | § | Disk file |
§ | § | |
§ +----------------+ | +---§->|--------------|
§ | vm_area_struct | | | § | Seg Content |
§ |----------------| | | § |--------------|
+----------------+<-§-------- vm_start | | | § | |
| 圈定了一个未映 | § +----- vm_end | | | § | |
| 射到物理内存的 | § | | vm_file--------+ | § +--------------+
| vm_area_struct | § | | vm_pgoff ---------+ §
+----------------+<-§--+ | vm_ops --------+ §
§ | | | §
§ +----------------+ | §
§ | §
§ +----------------------+ §
§ | §
§ +->+-----------------------+ §
§ | file_private_map | §
§ |-----------------------| §
§ | nopage:filemap_nopage | §
§ | ..... | §
§ +-----------------------+ §
user space § kernel § disk
文章来源CU社区:Linux sys_exec中可执行文件映射的建立及读取