如何将小精灵中的地址转换为物理地址 [英] How convert address in elf to physical address

查看:82
本文介绍了如何将小精灵中的地址转换为物理地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道os会将elf加载到物理内存中.当执行jmp elf-address时,系统将检查tlb并将elf-address转换为物理地址.我感到困惑的是,elf-address没有段num和页num?操作系统如何将elf-address转换为MMU所需.

I know os will load elf in physical memory. When execute jmp elf-address,system will check tlb and convert the elf-address to physical address. I am confused that elf-address does not have segment num and page num? How os convert elf-address to what MMU need.

我真的很困惑. 我知道linux将读取elf的标头和map elf. 当发生页面错误时,内核会将elf加载到内存中并刷新页面表. 但是您知道的小精灵地址就像0x0804900. 如果要执行jmp elf-address,内核如何将elf-address映射到MMU可以使用的地址. 您知道MMU地址是基于段num和页num的.

I'm really confused that. I know linux will read header of elf and map elf. When page fault happened,kernel will load elf in memory and refresh page table. But you konw elf address is like 0x0804900. If we want to exe jmp elf-address ,how kernel map the elf-address to address which MMU can use. You know MMU address is based on segment num and page num.

是否有操作系统要查找的映射表?而当exec jmp elf-address时,os首先会将elf-address映射到MMU地址吗? 例如: elf-address <==> MMU-address

Is there a map table which os will look for? And when exec jmp elf-address, will os first map elf-address to MMU address? eg: elf-address <==> MMU-address

推荐答案

I don't really think that a Linux kernel, when execve(2) some binary ELF executable, is loading that file into physical RAM.

它只是将文件的某些ELF段映射到进程的地址空间.您可以通过阅读例如以下内容来了解​​进程1234的地址空间.使用cat命令,伪文件/proc/1234/maps;尝试使用命令cat /proc/self/maps,该命令显示正在运行该cat的进程的内存映射.

It is just mapping some ELF segments of the file into the process' address space. You can get an idea of the address space of process 1234 by reading, e.g. with cat command, the pseudo file /proc/1234/maps; Try the command cat /proc/self/maps which shows the memory map of the process running that cat.

所以基本上execve(2)所做的是某种内存映射,例如 MMU ,因此,任何对某项内容的初始访问都会导致虚拟内存& 内存管理.

So basically what execve(2) does is some sort of memory mapping, like mmap(2) does. It sets the MMU so any initial access to something would fault the memory address, and then the kernel would load (page-in in demand paging) some pages from the file. Read about virtual memory & memory management.

您确实应该阅读高级Linux编程

正如FGE所说,存在 ASLR 的问题.

As FGE commented, there is the issue of ASLR.

这篇关于如何将小精灵中的地址转换为物理地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆