Date: Sat, 8 Feb 1997 11:40:15 -0500 (EST) From: "John S. Dyson" <toor@dyson.iquest.net> To: witr@rwwa.com (Robert Withrow) Cc: freebsd-hackers@freebsd.org Subject: Re: In what way are shared libs ``shared''? Message-ID: <199702081640.LAA03138@dyson.iquest.net> In-Reply-To: <199702081502.KAA29141@spooky.rwwa.com> from "Robert Withrow" at Feb 8, 97 10:02:48 am
next in thread | previous in thread | raw e-mail | index | archive | help
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702081640.LAA03138>