Add a bootstrap mode so that non-rtld versions of these objects can
be built when bootstrapping the system with NetBSD tools, headers
and libraries. Once the FreeBSD tools are built, the FreeBSD headers
are installed and *then* these objects can be recompiled with the
rtld references. Phew.
asm code didn't link the way it was supposed to and the calling convention
for the entry "function" turned out to be very different. On alpha
it's a true function, but on i386 it's a fudge. Blech.
So jdp suggested keeping separate sets of source and avoiding lots
of #ifdefs. These files are based on his i386-elf code, with crt1.c
borrowing code from NetBSD's crt0. The copyright reflects that.
Complicating matters, the code turned out to be difficult to bootstrap
build using NetBSD tools. To compile against the FreeBSD rtld header
requires FreeBSD specific headers, but these can't be installed until
the tools are built, and they can't be built without the FreeBSD crt
objects. Anal retentive. So I introduced a HAVE_RTLD #define that isn't
set during the build process until all the tools are built and the
headers installed.
now that has been committed.
The makefile is derived from the i386-elf version, modified to pick
up most of the source (except crt1.c) from i386-elf. With minor changes
to i386-elf/crt1.c, this directory can be combined with i386-elf to
be a single csu/elf directory for all seasons.
the rtld code pending implementation on the alpha.
The csu/i386-elf should be renamed as csu/elf and this directory
trashed. Consider this a temporary implementation.
into libc. This reduces the size of every dynamically linked
executable by 248 bytes, and it reduces the size of static executables
by a lesser amount. It also eliminates some global namespace
pollution.
With this change in place, the source for dlfcn.h should probably
be moved to "/usr/src/include". I'll save that for another day.
Compatibility note: Programs which use dlopen, if compiled on
systems with this change, will not run on systems with a libc from
prior to this change. Very few programs use dlopen, so I think
that is OK.
common. Add one do-nothing element to each set. This ensures that
the linker realizes that they are linker sets rather than simple
commons, and makes it possible to link c++rt0.o into every shared
library regardless of whether it is a C++ library or not. Without
this change, the constructors and destructors in the main program
could be executed multiple times.
This change is going to make it possible to get rid of the
CPLUSPLUSLIB makefile variable once and for all. It is a piece of
the solution to PR gnu/3505 (gcc -shared). Finally, it fixes a
heretofore unreported bug: If CPLUSPLUSLIB was set in a makefile
for a C++ shared library that had no static constructors or
destructors in it, then the main program's constructors and
destructors would be executed multiple times.
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.
Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.
Add descriptions of RTLD_LAZY and RTLD_NOW.
Correct the synopsis to agree with the actual function prototypes.
Add clarifications of a few things.
Clean up the wording in a few places.
was apparently overlooked at the time the member was added. Its absence
causes some error messages from the dynamic linker to begin with
"(null):" instead of with the pathname of the dynamic linker as they
should.
I am also adding a work-around to the dynamic linker, to cope with
legacy binaries that were built with older versions of crt0.
just return errors. This removes the need for awful hacks like that in
our build of libtcl which would get link errors when linked static.
John Polstra once mentioned that this was on his "todo" list.
Note that one can use:
cc -Wl,-Bstatic -o foo foo.o
and get an executable that has it's libraries statically linked, but has
a fully functional runtime linker so the executable can call dlopen() and
have it work. (I've tested this)
and forwards compatable with version 3. This is needed to enable storing
a run-time library path in the dynamic linking headers. The crt startup
tries version 4 first, and falls back to version 3, so an executable that
is linked on -current will work with the ld.so on 2.1.x and less.
Reviewed by: nate, jdp
Obtained from: NetBSD
to 2. This makes them agree with the declarations in libgcc, and
clears the way once again for linking c++rt0.o into all libraries,
and eliminating CPLUSPLUSLIB from <bsd.lib.mk>. (I have not made
that change yet, because there is still a bootstrapping problem
for "make world".)
Also, removed a check which ensured that the constructor count in
the first word of __CTOR_LIST__ was greater than zero before
traversing the list. I had added that check earlier, but it is no
longer necessary, now that there is guaranteed to be at least 2
words in __CTOR_LIST__.
the loop that invokes the static constructors. That makes it safe
to link c++rt0.o into any shared library, even one that does not
have any static constructors. Formerly, doing that would cause a
bus error. If the library has no static constructors, __CTOR_LIST__
comes out as a simple 4-byte COMMON region, and it does not have
the usual NULL word that terminates the list of constructors. This
caused the old code to "call" a garbage address via the non-existent
entry __CTOR_LIST__[1].
The analogous code that invokes the static destructors was already safe.
This change is fully backward-compatible.
Reviewed by: dfr@render.com (Doug Rabson)
symbols.
An easy example to see this is to develop an X program which links
against Xt, but doesn't add -lX11 to the link line. It will link fine,
but cause run-time errors by ld.so because of missing symbols used by Xt
defined in X11. This patch makes the errors more readable.
Submitted by: jdp@polstra.com (John Polstra)
specified in the top level Makefiles.
Previously I missed dozens of Makefiles that skip the install after
using `cmp -s' to decide that the install isn't necessary.
1) Do dependencies.
2) Install all appropriate links to manual pages.
3) Install header file in `beforeinstall' like all the rest.
4) Install header file only if changed.
5) Install object files only if changed.
on dlclose. Also correctly call constructors and destructors for libraries
linked with /usr/lib/c++rt0.o.
Change interpretation of dlopen manpage to call _init() rather than init()
for dlopened objects.
Change c++rt0.o to avoid using atexit to call destructors, allowing dlclose to
call destructors when an object is unloaded.
Change interface between crt0 and ld.so to allow crt0 to call a function on
exit to call destructors for shared libraries explicitly.
These changes are backwards compatible. Old binaries will work with the new
ld.so and new binaries will work with the old ld.so. A version number has
been introduced in the crt0-ld.so interface to allow for future changes.
Reviewed by: GAWollman, Craig Struble <cstruble@singularity.bevc.blacksburg.va.us>