Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!ux1.cso.uiuc.edu!midway!msuinfo!rang From: rang@cs.wisc.edu (Anton Rang) Newsgroups: comp.unix.internals Subject: Re: Shared libraries Summary: Fixups aren't always easy.... Message-ID: Date: 3 May 91 01:53:08 GMT References: <5152f9e6.20b6d@apollo.HP.COM> <1991May2.172740.11422@mp.cs.niu.edu> Sender: news@msuinfo.cl.msu.edu Organization: UW-Madison CS department Lines: 27 In-Reply-To: rickert@mp.cs.niu.edu's message of 2 May 91 17:27:40 GMT In article <1991May2.172740.11422@mp.cs.niu.edu> rickert@mp.cs.niu.edu (Neil Rickert) writes: > Unfortunately it is not that simple. The trouble is that the text segment >of the module contains references to the data and bss, which will be different >for each use of the shared routines. This is true; also, on some architectures, it's difficult or impossible to generate fully position-independent code. (If you map the library into a different spot in your address space, you may need to "patch up" some references it makes, which suddenly makes some pages shared and some pages not, or else forces you to make the entire text segment non-shared.) Hopefully these architectures are few.... Another point which shouldn't be too hard to get right, but does require some thought, is that one shared library may refer to routines from another one. > The proper way to do this is to design the shared library so that >all modules in it have only text segments, and zero-length bss and >data segments. Given an architecture with a shared data and instruction memory, a C compiler which puts 'const' variables into the text segment would make this fairly painless, I think. (Personally, I don't like variables which are initialized at compile time but aren't constants--they offend my sense that everything should be re-entrant. :-) Anton +---------------------------+------------------+-------------+----------------+ | Anton Rang (grad student) | rang@cs.wisc.edu | UW--Madison | "VMS Forever!" | +---------------------------+------------------+-------------+----------------+