Date: Sun, 03 Aug 1997 17:53:33 -0700 From: Livio Ricciulli <livio@csl.sri.com> To: freebsd-questions@FreeBSD.ORG Subject: dynamic loading semantic difference Message-ID: <33E5280D.6672D029@csl.sri.com>
next in thread | raw e-mail | index | archive | help
I have noticed that there is a difference in the behavior of dynamically loaded objects between freebsd and (sunos, solaris and linux). When two shareable objects which contain a global variable with the same name are loaded, in freebsd the global variable is shared by the objects and in (sunos, solaris, linux) the variable is private for each separate object. for example, if the two following objects int global=0; try0() { int local=0; global++; local++; printf("try0 global=%d local=%d\n",global,local); } --------------------------------------------------- int global=0; try1() { int local=0; global++; local++; printf("try1 global=%d local=%d\n",global,local); } are loaded with dlopen and dlsym and called as: try0();try1(); their output is FreeBSD try0 global=0 local=0 try1 global=1 local=0 sunos,solaris,linux try0 global=0 local=0 try1 global=0 local=0 As I said before, in bsd the global variable is shared while in other OSs it is not. Can someone tell me why? Is there a way to get bsd to conform to the other OSs (because of inter-operability concerns)? Thanks in advance, Livio Ricciulli.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?33E5280D.6672D029>