zsh-users
 help / color / mirror / code / Atom feed
From: Dan Nelson <dnelson@allantgroup.com>
To: Vincent <zsh@hightek.org>
Cc: Dominic Mitchell <dom@happygiraffe.net>, zsh-users@sunsite.dk
Subject: Re: loading dynamic modules in a static shell
Date: Mon, 19 Jan 2004 01:35:30 -0600	[thread overview]
Message-ID: <20040119073529.GB76639@dan.emsphone.com> (raw)
In-Reply-To: <20040119052552.GA32753@quark.localdomain>

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


  reply	other threads:[~2004-01-19  7:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-18 12:14 Vincent
2004-01-18 15:31 ` Dominic Mitchell
2004-01-19  5:25   ` Vincent
2004-01-19  7:35     ` Dan Nelson [this message]
2004-01-18 18:39 ` Bart Schaefer
2004-01-19  5:37   ` Vincent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040119073529.GB76639@dan.emsphone.com \
    --to=dnelson@allantgroup.com \
    --cc=dom@happygiraffe.net \
    --cc=zsh-users@sunsite.dk \
    --cc=zsh@hightek.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).