Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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.

1
Who and how generate the virtual/logical addresses? Confusion if it's the compiler, the linker, the loader.
Post Body

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?

Author
Account Strength
70%
Account Age
1 year
Verified Email
Yes
Verified Flair
No
Total Karma
6,622
Link Karma
6,131
Comment Karma
491
Profile updated: 1 week ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
9 months ago