Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22015

Confusion about virtual address space and position indepedent code (PIC)

$
0
0

While reading this blogpost, I came across the following while the author tries to justify the need of PIC for shared libraries.

If your shared library is built to only work when loaded at one particular address everything may be fine — until another library comes along that was built also using that address.

If the start address of the library determines where the library goes into memory, what is virtual memory management doing here? I mean memory mapping should be able to determine that something is already in this physical address space, so we could possibly place the next shared library elsewhere.

Moreover the loading address that the library specifies is the virtual address space right? so why does it even create a problem if both of the libraries have the same virtual address space load address.

So I have basically this question:

  1. When using non-PIC, the problem of two libraries having something in the same address makes less sense to me currently. Does this have to do with the first library overlapping with addresses of the second library? but again the OS memory management should be able to put things into spaces where physical memory is free then where is even the conflict?

Viewing all articles
Browse latest Browse all 22015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>