From owner-freebsd-hackers Sat Feb 8 08:41:35 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id IAA19111 for hackers-outgoing; Sat, 8 Feb 1997 08:41:35 -0800 (PST) Received: from dyson.iquest.net (dyson.iquest.net [198.70.144.127]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id IAA19104 for ; Sat, 8 Feb 1997 08:41:31 -0800 (PST) Received: (from root@localhost) by dyson.iquest.net (8.8.4/8.6.9) id LAA03138; Sat, 8 Feb 1997 11:40:15 -0500 (EST) From: "John S. Dyson" Message-Id: <199702081640.LAA03138@dyson.iquest.net> Subject: Re: In what way are shared libs ``shared''? To: witr@rwwa.com (Robert Withrow) Date: Sat, 8 Feb 1997 11:40:15 -0500 (EST) Cc: freebsd-hackers@freebsd.org In-Reply-To: <199702081502.KAA29141@spooky.rwwa.com> from "Robert Withrow" at Feb 8, 97 10:02:48 am X-Mailer: ELM [version 2.4 PL24 ME8] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > Looking at rtld.c I see: > > addr = mmap(0, hdr.a_text + hdr.a_data + hdr.a_bss, > PROT_READ|PROT_EXEC, MAP_COPY, fd, 0) > > >From my understanding of MAP_COPY semantics, this is *not* > a shared mapping. If I am right about this, then how > are shared libs shared? > The initial mapping is copy-on-write, subsequently, the mapping is changed for .data to be writeable, and bss is remapped to be read/write. The reason for the initial mapping to include the bss is so that enough space is reserved for the contiguous allocation. The reason that the MAP_COPY (in -current MAP_PRIVATE is technically more appropriate), is so that when debuggers are run, and changes are made by the debugger, that a COW operation will occur (as opposed to modifying the binary, if MAP_SHARED was used.) MAP_COPY doesn't really mean much at execution time (except for data structure set-up) in FreeBSD unless a write operation occurs. Until the write operation, there is full sharing. John