Are the load address is common for all the C programs in linux?

后端 未结 3 1719
[愿得一人]
[愿得一人] 2021-01-07 12:55

Let\'s say I have a prog1.c which is build as prog1.out. In prog1.out there is a linker information that will tell where the elf will be loaded. These addresses will be a vi

3条回答
  •  情深已故
    2021-01-07 13:13

    Each process "thinks" it runs alone on the computer and only knows about it's virtual addresses. The memory management unit (MMU) then translates the virtual address to a physical address. The MMU must of course make sure that two virtual addresses are not mapped to same physical address. The mapping is super fast because the CPU has (most of the time) dedicated hardware support for the MMU.

    The MMU has to also figure out where exactly to fetch the data e.g. Main Memory (maybe the typical case), level 1 cache, level 2 cache, a swap file from disk, etc. And as I said, the process itself is oblivious to that, it "thinks" it works on one flat memory file and doesn't have to worry about any collisions.

提交回复
热议问题