Subject: Re: dlopen() twists
To: Kevin P. Neal <>
From: Todd Vierling <>
List: tech-userlevel
Date: 12/28/2000 10:22:45
On Wed, 27 Dec 2000, Kevin P. Neal wrote:

: > 	it seems to me that there are a couple of twists in dlopen() handling
: > 	in NetBSD.
: > 	1. static linked binaries cannot use dlopen().
: I think this is a mistake.

This is an artifact of the design of the [particularly ELF] dynamic loader.
For ELF, the kernel loads the ld.elf_so as the program interpreter *BEFORE*
the main program is completely set up to run.

: If HP-UX had been able to compile a true static binary that could do
: dynamic linking anyway then I could have simplified that gunk a bit. (I
: don't remember what specialness Solaris had).

Solaris doesn't do truly "static" linking for most programs.  If you look
closely, you'll see that there are no .a counterparts to many of the .so
libraries -- among them, libdl (for dlopen()!).  Do a "ldd /sbin/something"
sometime and you'll note that the program is, indeed, a dynamic executable.
The only programs that are truly static in Solaris are in /sbin/static/.

: Does anyone actually think of linking a program dynamically so they can
: use dlopen()? I didn't, and was irritated when I had to link dynamically.

Welcome to the world of shared objects.  At least you get a link failure
that dlopen() is not defined....

-- Todd Vierling <>  *  Wasabi NetBSD:  Run with it.
-- NetBSD 1.5 now available on CD-ROM  --