How to convert an address from an elf to a physical address

I know that os will load the elf into physical memory. When jmp elf-address is executed, the system will check tlb and translate the elven address into a physical address. Am I confused that the elf address does not have a segment and page number? How os convert elf address to what MMU needs.

I really confused this. I know that linux will read the elf and card elf header. When a page error occurs, the kernel loads the elf into memory and updates the page table. But your elf elf address is similar to 0x0804900. If we want exe jmp elf-address , how does the kernel display the el-address for an address that the MMU can use. You know that the MMU address is based on the number number and page number.

Is there a map table that os will look for? And when exec jmp elf-address , will there be a first card email address to the MMU address? for example: elf-address <==> MMU-address

+4
source share
1 answer

I really do not think that the Linux kernel, when execve (2) executes some kind of binary ELF file, loads this file into physical RAM.

It is simply mapping some segments of an ELF file into a process address space . You can get an idea of ​​the address space of process 1234 by reading, for example. with the cat , the pseudo file /proc/1234/maps ; Try running the command cat /proc/self/maps , which displays the memory card of the process that runs this cat .

So basically what execve(2) does is some kind of memory mapping, like mmap (2) . It sets the MMU , so any initial access to something would result in a memory address error, and then the kernel would load (page-in into the swap request ) some pages from the file. Read about virtual memory and memory management .

You really need to read books such as Linux Advanced Programming

As FGE commented, there is an ASLR problem.

+1
source

All Articles