From owner-freebsd-questions Mon Aug 4 01:01:43 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id BAA20951 for questions-outgoing; Mon, 4 Aug 1997 01:01:43 -0700 (PDT) Received: from capri.sri.brainstorm.net (capri.sri.brainstorm.net [205.178.57.130]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id BAA20938 for ; Mon, 4 Aug 1997 01:01:38 -0700 (PDT) Received: from capri.sri.brainstorm.net (localhost [127.0.0.1]) by capri.sri.brainstorm.net (8.8.5/8.8.5) with SMTP id RAA29417 for ; Sun, 3 Aug 1997 17:53:33 -0700 Message-ID: <33E5280D.6672D029@csl.sri.com> Date: Sun, 03 Aug 1997 17:53:33 -0700 From: Livio Ricciulli Organization: SRI International X-Mailer: Mozilla 3.01Gold (X11; U; Linux 2.0.30 i686) MIME-Version: 1.0 To: freebsd-questions@FreeBSD.ORG Subject: dynamic loading semantic difference Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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.