[TriLUG] shared libraries aren't shared

Rodney Radford rradford at mindspring.com
Wed Nov 11 16:52:09 EST 2009


>> That is not how shared libraries work (thank goodness).
>did they used to work this way?

Nope, they have always had private data spaces

> Is the static int j stored in its own data segment too?

Yes.

The only thing 'shared' in a 'shared library' is the code space.  The loader simply maps the code space (TEXT segment) into your address space, directly from the file, and then allocates memory for the data area (DATA and BSS segments). 

If you are trying to create a shared memory area where more than one process can share data, take a look at the info here: http://fscked.org/writings/SHM/shm.html





More information about the TriLUG mailing list