From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25016 invoked from network); 19 Jan 2004 07:36:06 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 19 Jan 2004 07:36:06 -0000 Received: (qmail 21015 invoked by alias); 19 Jan 2004 07:35:50 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7006 Received: (qmail 21001 invoked from network); 19 Jan 2004 07:35:50 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 19 Jan 2004 07:35:50 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [199.67.51.101] by sunsite.dk (MessageWall 1.0.8) with SMTP; 19 Jan 2004 7:35:50 -0000 Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id i0J7ZUcJ097051; Mon, 19 Jan 2004 01:35:30 -0600 (CST) (envelope-from dan) Date: Mon, 19 Jan 2004 01:35:30 -0600 From: Dan Nelson To: Vincent Cc: Dominic Mitchell , zsh-users@sunsite.dk Subject: Re: loading dynamic modules in a static shell Message-ID: <20040119073529.GB76639@dan.emsphone.com> References: <20040118121441.GA29157@quark.localdomain> <20040118153107.GA55970@ppe.happygiraffe.net> <20040119052552.GA32753@quark.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040119052552.GA32753@quark.localdomain> X-OS: FreeBSD 5.2-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.5.1i In the last episode (Jan 18), Vincent said: > On Sun, Jan 18, 2004 at 03:31:07PM +0000, Dominic Mitchell wrote: > > On Sun, Jan 18, 2004 at 06:14:42AM -0600, Vincent wrote: > > > Is it supposed to be possible to compile a static shell with part > > > of the modules built in and to be able to load the remaining > > > modules with zmodload? > > > > I think it depends upon the capabilities of the platform's dynamic > > loader. Certainly for FreeBSD you won't be able to do this. This > > is because all dynamic loading is disabled when a static binary is > > used. For the current release (5.2) the root filesystem has been > > made dynamic in order to get this working (for the nsswitch stuff > > to work correctly). > > Thanks for the reply. I did not realize that. I could have sworn I > remembered compiling programs before with mixed linking, where some > libs I specified as "/usr/lib/xxx.a" while others were dynamic, > specified with "-lxxx". Perhaps that was when I was running Linux. You can do this, but note that this isn't a static binary; it's a dynamic binary with some libraries loaded statically. You'll still have a dependency on ld.so, and depending on which libraries you pulled in statically, you may have issues dlopen'ing shared objects that also depend on those libraries. Statically-linking a library only pulls in the object files required for the link to complete, so if you link with libc.a, you won't have all of libc in your executable. If your shared object also depends on libc (most would, I guess), it will dlopen libc.so, but now you will have two copies of some functions and structures in libc, and constructors may fire twice. I did some googling, and I don't think Linux or Solaris like dlopening from static binaries, either. -- Dan Nelson dnelson@allantgroup.com