This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I know that when I compile a program and then I inspect with objdump, I have addresses. These are relative addresses.
But if it's a C program and I printf with %p a pointer, that is a virtual/logical address. Who generates this? Is that the loader?
If yes, why do I need that a loader does this? Isn't it sufficient a relative address (generated by compiler) and then MMU hw unit just adds the program base offset in real memory to reach the physical address? Why a virtual address is needed and a relative insufficient?
Also, virtual addresses should serve to create an illusion to process to be the only one in memory and to be contiguously allocated. I can imagine this with relative (generated by compiler) addresses, but I can't imagine with virtual/logical (generated by loader) addresses... How can loader achieve to put program code in contiguous portion of virtual memory? Isn't virtual memory used by other programs in separate portions? Or can it happen that two completely different programs have same virtual/logical addresses ?
Also, last doubt: why in lot of places online it's written that "virtual/logical address are generated by CPU"..... it's not true..... it's done by the OS, so why it's written everywhere? am I missing something?
Subreddit
Post Details
- Posted
- 9 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/AskComputer...