flat assembler
Message board for the users of flat assembler.

Index > Linux > DSO global data not static between programs

Author
Thread Post new topic Reply to topic
eilenbeb



Joined: 17 Feb 2010
Posts: 21
eilenbeb
I have several 64bit shared libs up, running, and in use; however I just discovered something unexpected.
Global data set within a shared lib is only available to the program that set it.
It's as if each program is getting it's own, unique copy of the lib's process, as if the lib isn't actually shared at all.

I've been carefull to make my exported functions re-entrant and non-clobbering, but now that seems irrelevant.
Is something wrong? Is this normal behavior? Anyone have any thoughts on this?
Post 09 Feb 2015, 02:33
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 357
Location: Australia
redsock
my understanding is that this is quite by design, imagine the case scenario where libc functions for example use a static library space to do their thing (inet_ntoa comes to mind), if this were actually global or system-wide, then the library would have to do some pretty crazy locking, whereas the much more elegant occurs, each process that uses it needs to figure out how to deal with its static space on its own...

Please correct me if I'm wrong about this, but I am pretty sure that is the way it is meant to work.
Post 09 Feb 2015, 04:28
View user's profile Send private message Reply with quote
eilenbeb



Joined: 17 Feb 2010
Posts: 21
eilenbeb
I hear ya. Makes my life a lot simpler....
I was mostly double checking just to make sure I wasn't doing anything wrong when creating my libs.

Thanks for the reply, I'm gonna go back to coding assuming that's the way it's supposed to be.
Post 09 Feb 2015, 04:58
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
It is normal. Similar technique is used in Windows as well. The memory page is common across the processes only while read-only. On the first write, the page is cloned and becomes different for the application that wrote the data.
Post 09 Feb 2015, 05:44
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
eilenbeb



Joined: 17 Feb 2010
Posts: 21
eilenbeb
Thanks for the details. Know any way to bypass this for select data?
See, I've been thinking that it would be of use to me to be able to share -settable- data between my libs clients.

Hmm... Should I start a new topic for this?
Post 09 Feb 2015, 06:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17255
Location: In your JS exploiting you and your system
revolution
You can use a file for global shared data. A file is semanticly the same as system wide data. The file doesn't have to be instantiated on to a physical disk, it can be virtual in memory only.
Post 09 Feb 2015, 08:38
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.