Date: Thu, 23 Nov 2000 14:38:24 -0800 (PST) From: John Polstra <jdp@polstra.com> To: hackers@freebsd.org Cc: Konstantin.Chuguev@dante.org.uk Subject: Re: dlopen() Message-ID: <200011232238.eANMcOf81020@vashon.polstra.com> In-Reply-To: <3A1D2BC7.65AB61AA@dante.org.uk> References: <001001c05552$45913f80$0e61bec3@dima> <3A1D1E52.95A9E626@dante.org.uk> <20001123154748.C7746@ringworld.oblivion.bg> <3A1D2BC7.65AB61AA@dante.org.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <3A1D2BC7.65AB61AA@dante.org.uk>, Konstantin Chuguev <Konstantin.Chuguev@dante.org.uk> wrote: > Peter Pentchev wrote: > > > So the original poster's question is better translated as 'does the dynamic > > loader ever close and reopen a file after the initial loading, so it could > > accidentally open the new version of the library and use the old addresses'? > > > > I'd guess the answer is 'no' - the dynamic loader most probably opens > > the file once, and mmap()'s the needed functions; I might very well be wrong > > though. > > > > This is how I think it works (don't have any FreeBSD box nearby): > For all dynamically loaded modules: > dlopen() opens the file (gets a file descriptor) and mmaps it (possibly > excluding the debug and some other sections). dlclose() unmaps and closes it. Not quite. The dynamic linker opens the file, mmaps it, and closes it immediately. A mapping created by mmap endures even after you close the underlying file. I assume (but have not tested) that it is OK to remove the file after the dlopen call. The file is still mmapped, so I don't think the underlying storage will go away. John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011232238.eANMcOf81020>