mawia
mawia

Reputation: 9349

Function pointer: physical or virtual address

When we get the address of a function (or any object, for that matter), is it the virtual address or physical address of that object??

Upvotes: 19

Views: 4949

Answers (2)

Tyler McHenry
Tyler McHenry

Reputation: 76660

Depends on the OS and at what level your code is running.

For a normal user-land program on a modern OS, you will get the virtual address.

Upvotes: 11

Uri
Uri

Reputation: 89749

Are you asking about pointers in general?

On most operating systems, they are logical addresses.

The operating system is responsible for translating them into physical addresses through the virtual memory and paging mechanism. This is transparent to the program. That's why a misguided program "hits the boundaries" and GPFs.

On some old systems (e.g., DOS), they would be physical, allowing you to overwrite stuff in other parts of memory.

Upvotes: 17

Related Questions