Commit Graph

58 Commits

Author SHA1 Message Date
Bruce Evans
87d0dcafca Use `install -C' instead of lots of shell commands to install ld.so
as atomically as possible.

(Immutable targets can't be renamed without opening a window when
neither the source nor the target is immutable.  Perhaps there
should be a rename_immutable syscall to do this if unsetting the
immutable flags would work.)
1996-09-12 03:42:54 +00:00
John Polstra
1dd43c183e When checking to see whether a needed shared library has already
been loaded, look for a match by device and inode number if the
traditional pathname comparisons don't find a match.  This detects
the case in which a library is requested using two different names
which are really links to the same file, and avoids loading it
twice.

Requested by:	peter@freebsd.org
Reviewed by:	peter@freebsd.org
1996-05-22 06:34:12 +00:00
Wolfram Schneider
9fb933075e `mv'' -> `mv -f''
``rm'' -> ``rm -f''
so mv/rm may not ask for confirmation if you are not root
1996-05-07 23:19:49 +00:00
John Polstra
dd2b076850 Implement support for LD_PRELOAD in the dynamic linker. Remove
descriptions of LD_NO_INTERN_SEARCH and LD_NOSTD_PATH from the manual
page, since they are not supported.

Submitted by:	Doug Ambrisko <ambrisko@ambrisko.roble.com>
1996-04-20 18:29:50 +00:00
John Polstra
c049096e82 Implement support for LD_PRELOAD in the dynamic linker.
Submitted by:	Doug Ambrisko <ambrisko@ambrisko.roble.com>
1996-04-20 18:27:56 +00:00
John Polstra
5a81ed9667 This release is a moderate restructuring of the dynamic linker.
It addresses a number of problems that were present in earlier
versions.

The calls to the "init" and "fini" functions of shared libraries
have been reordered, so that they are called in a strictly nested
fashion, as is required for C++ constructors and destructors.  In
addition, the "init" functions are called in better order relative
to each other.  That makes the system more tolerant of C++ programs
which depend on a library's being initialized before its clients.

The dynamic linker is now more tolerant of shared libraries in
which dependencies on other shared libraries are incompletely
recorded.

Cleanup in the event of errors has been improved throughout the
dynamic linker.  A number of memory leaks were eliminated.

The warning message for a shared library whose minor version number
is too old has been clarified.

The code dealing with the "ld.so.hints" file has been cleaned up.
A bug that caused the hints file to be unmapped incompletely has
been fixed.  A different bug that could potentially cause the hints
file to be mapped on top of a loaded object has been fixed.

The code that searches for shared libraries has been cleaned up.
The searching is now more compatible with that done by SunOS and
SVR4.  Also, some unnecessary and useless searches of both the
hints file and library directories have been eliminated.

Reviewed by:	nate@freebsd.org
1996-01-13 00:15:25 +00:00
John Polstra
eb4a4eeb45 Split up the code so that a single directory can be searched, to
support some changes in the dynamic linker.  (This code is shared
by the dynamic linker.)

Reviewed by:	nate@freebsd.org
1996-01-13 00:14:53 +00:00
Poul-Henning Kamp
bbb1dc53a4 Another '-' needed for make release. 1996-01-11 17:49:55 +00:00
Poul-Henning Kamp
5a39b83123 Make the new realinstall target a little less draconian so that make release
doesn't fall over.
1996-01-11 17:27:16 +00:00
John Polstra
b25d7c2bbc Install ld.so in a way that is safe even on a running system. 1996-01-11 03:45:55 +00:00
Nate Williams
1e37fc9d59 Changed the terminology for what used to be called the "memorizing"
vector.  Now it is called the "symbol caching" vector.  This was made
possible and unconfusing by other changes that allowed me to localize
everything having to do with the caching vector in the function
reloc_map().

Switched to alloca() for allocating the caching vector, and eliminated
the special mmap-based allocation routines.  Although this was motivated
by performance reasons, it led to significant simplification of the
code, and made it possible to confine the symbol caching code to the
single function reloc_map().

Got rid of the unnecessary and inefficient division loop at the
beginning of rtld().

Reduced the number of calls to getenv("LD_LIBRARY_PATH") to just 1, on
suggestion from <davidg@root.com>.

Added breaks out of the relocation loops when the relocation address is
found to be 0.  A relocation address of 0 is caused by an unused
relocation entry.  Unused relocation entries are caused by linking a
shared object with the "-Bsymbolic" switch.  The runtime linker itself
is linked that way, and the last 40% of its relocation entries are
unused.  Thus, breaking out of the loop on the first such entry is a
performance win when ld.so relocates itself.  As a side benefit, it
permits removing a test from md_relocate_simple() in
../i386/md-static-funcs.c.

Unused relocation entries in other shared objects (linked with
"-Bsymbolic") caused even bigger problems in previous versions of the
runtime linker. The runtime linker interpreted the unused entries as if
they were valid. That caused it to perform repeated relocations of the
first byte of the shared object.  In order to do that, it had to remap
the text segment writable.  Breaking out of the loop on the first unused
relocation entry solves that.

Submitted by:	John Polstra <jdp@polstra.com>
1995-11-02 18:48:15 +00:00
Nate Williams
468f82b316 Run-time linker speedups - Round One
Implemented symbol memorizing to reduce the number of calls to lookup(),
making relocation go faster.  While relocating a given shared object,
the dynamic linker maintains a memorizing vector that is directly
indexed by the symbol number in the relocation entry.  The first time a
given symbol is looked up, the memorizing vector is filled in with a
pointer to the symbol table entry, and a pointer to the so_map of the
shared object in which the symbol was defined.  On subsequent uses of
the same symbol, that information is retrieved directly from the
memorizing vector, without calling lookup() again.

A symbol that is referenced in a relocation entry is typically
referenced in many relocation entries, so this memorizing reduces the
number of calls to lookup() dramatically.  The overall improvement in
the speed of dynamic linking is also dramatic -- as much as a factor of
three for programs that use many shared libaries.

Submitted by:	jdp@polstra.com "John Polstra"
1995-10-25 16:16:35 +00:00
Andrey A. Chernov
a4057ed8d3 Remove LD_NOSTD_PATH implementation, it isn't works and
can cause some problems.
Suggested-by: davidg
1995-10-24 06:48:16 +00:00
Andrey A. Chernov
b2105a0990 if uid != euid or gid != egid unsetenv("LD_NOSTD_PATH") too 1995-10-21 14:52:48 +00:00
Nate Williams
c68c38c86b This is a FreeBSD manpage, not a NetBSD manpage. :) 1995-10-05 05:16:52 +00:00
Nate Williams
6f5457454c Make the error message more readable when 'ld.so' cannot locate a needed
shared library.  Formerly, the message looked like this:

    ld.so: run: libjdp1.so.1.0: Undefined error: 0

The new message looks like this:

    ld.so: run: Can't find shared library "libjdp1.so.1.0"

(Where "run" is the name of the program being executed.)

Submitted by:	jdp@polstra.com (John Polstra)
1995-09-27 23:17:33 +00:00
Nate Williams
e1ec3d8b3c Fixup the "ld.so failed" message for the case when ld.so finds undefined
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)
1995-09-27 23:14:08 +00:00
Joerg Wunsch
19d57e6d9d Import Paul Kranenburg's man page for ld.so (aka. rtld).
Obtained from:	NetBSD
1995-08-26 13:17:39 +00:00
Doug Rabson
82aaeb09ad Change ld.so to correctly load dependant libraries for dlopen and unload them
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>
1995-06-27 09:53:27 +00:00
Rodney W. Grimes
4399be3cbd Remove trailing whitespace. 1995-05-30 05:05:38 +00:00
Nate Williams
110aea11f2 Sync. up bits with Paul K. Cascade support plus some cosmetic changes.
Obtained from: NetBSD
1995-04-21 04:57:50 +00:00
Nate Williams
8af57ca9dd Removed /usr/local/lib from the standard library search path to be
consistant.  Programs shouldn't rely on non-standard paths for bringing
in default libraries.

Suggested by:	Andreas Schulz <ats@freebsd.first.gmd.de>
1995-03-19 21:20:09 +00:00
Nate Williams
c79eac4c4c Weak symbol support from NetBSD. This should bring us in sync with the
NetBSD ld code except for local changes for dlopen() and friends and
the hashing on the minor value of the shlibs.  We should be binary
compatible now with all their libraries.

Obtained from: NetBSD
1995-03-04 17:49:20 +00:00
Jordan K. Hubbard
19c408ae08 Support for more Sun compatible dlopen() and friends. Also added proper error
handling.
Reviewed by:	gj
Submitted by:	Mark Diekhans <markd@grizzly.com>
1995-02-07 13:33:42 +00:00
Joerg Wunsch
d5453ba5c4 Make ldconfig and ld.so not hashing the shared lib minor number. This
misfeature caused troubles when a program attempted to access a shlib
where one with a higher minor number has been hashed.  Ldconfig does
only include the highest-numbered shlib anyway, so this is in no way a
limitation of generality.

Caution: after installing the new programs, your /var/run/ld.so.hints
needs to be rebuiult; run ldconfig again as it's done from /etc/rc.
1995-01-12 19:12:29 +00:00
Steven Wallace
e86257e166 Change to
#define STANDARD_SEARCH_DIRS    "/usr/lib", "/usr/X11R6/lib", "/usr/local/lib"
Like in 2.0R, except without /usr/X386.
1995-01-05 02:36:29 +00:00
Nate Williams
61f9ce8d32 Updated to recent version of Paul K.'s shlib code. This code has better
warning handling and allows for link-time warnings with a modified
version of gas.

Note: Not all of the newer bits were updated such as some of the non-x86
machine-dependant code is relevant to FreeBSD right now.

Obtained from: NetBSD
1994-12-23 22:31:35 +00:00
Steven Wallace
504e8b978b Add LDDESTDIR to ld command.
Add -I${DESTDIR}/usr/include to cpp command.
1994-09-18 19:41:38 +00:00
Bruce Evans
dd8e0158cf Unmap hints file when finished with it, so that it can go away
completely when ldconfig unlinks it.  If init is shared, then the
referenced unlinked copy of the hints file created by running
ldconfig in /etc/rc caused the file system to be unclean after
every reboot.
1994-09-15 20:48:55 +00:00
Bruce Evans
2577a8acef Add dependencies on libraries to DPADD. Someday this should be done
automagically.  -lfoo has to be right to work, but ${LIBFO0} is too
easy to forget or misspell; nothing checks it and it should be
different for shared libraries.
1994-08-28 18:49:06 +00:00
Garrett Wollman
e410457b74 Install ld.so immutable. 1994-08-26 19:11:14 +00:00
Rich Murphey
699e1b82fb Changes from Paul Kranenburg which bring us into sync with his sources:
handling of errors through the standard err() and warn()
 more fixes for Geoff Rehmet's NULL pointer bug.
 fixes NULL pointer bugs when linking mono and nested X servers.
 supports a `-nostdlib' option.
 accept object files without a symbol table
 don't attempt dynamic linking when `-A' is given

a few variable names have chaged (desc -> fd), and the formatting has
changed which should make it much easier to track his sources.

I tested 'make world' for /usr/src and X twice with these changes.
1994-06-15 22:41:19 +00:00
Andreas Schulz
e7ae632e5a Change the private declarations from dlopen,dlclose,dlsym,dlctl
to public. These functions are also used in /usr/include/link.h,
so it looks, like they shouldn't be private.
I will ask Paul about that, if this is correct.
1994-04-13 20:52:40 +00:00
Andreas Schulz
3507018b5b Due to the deletion of the gcc support from libc we need again the
-lgcc_pic library. rtld uses the udivd3 routine from it.
Repeat the bug by simply compiling ld on current.
1994-03-10 23:19:54 +00:00
Jordan K. Hubbard
09e3d49d92 This is Paul K's latest set of ld changes. A commit was necessary at this
late stage due to the fact that link.h was copyright Sun Microsystems.

This version of ld sync's us up with NetBSD's ld and supports compatablily
with NetBSD's -[zZ] flags (which we had reversed).  Compiling with this
new ld will give you RRS warnings for libraries which do not contain .type
infomation - these wsarnings are harmless and will go away as soon as you
recompile your libraries (cd /usr/src; make libraries).
1994-02-13 20:43:13 +00:00
Rodney W. Grimes
825079654d Remove /usr/X386/lib and /usr/local/lib from the default locations,
these are handled by /etc/rc and this was causing errors on a new
install as these places do NOT exsist by default!
1994-02-09 02:29:31 +00:00
David Greenman
84462ab47a Removed dependance on EX_DYNAMIC in making decisions on the magic number. 1994-01-19 15:00:37 +00:00
Jordan K. Hubbard
9d4389fddc More proper fix for for shared lib debugging support. 1994-01-14 11:47:00 +00:00
Jordan K. Hubbard
5b3dd4f53e 1. Fix bug where duplicate symbol warnings were suppressed. This often
caued ld to `exit silently', to general confusion.

2. Add Gary Jennejohn's fix to support debugging of shared libraries.
1994-01-12 23:16:19 +00:00
David Greenman
1799d2585e Implemented 'QMAGIC' a.out format correctly, and changed the default
output to be QMAGIC.
1994-01-03 18:35:54 +00:00
Jordan K. Hubbard
f7122c559f C++ support changes (+misc fixes) from Paul K. 1993-12-22 23:28:35 +00:00
Jordan K. Hubbard
8b6ddcb0a3 Broke sbrk() out of rtld as part of general cleanup. 1993-12-11 21:06:00 +00:00
Jordan K. Hubbard
c9cb3c7ea5 Omitted 4th argument to findshlib() [thanks Rich!]. Our ld is a bit
different from NetBSD's here and it squeaked through the update.
1993-12-11 20:08:39 +00:00
Jordan K. Hubbard
b640de6119 Sync up with Paul K's latest ld from cesium. 1993-12-11 12:02:10 +00:00
Jordan K. Hubbard
127447df73 makedepend fails for ld. I think it because the .S files are
preprocessed the same as when they are compiled.  I just remove the
single-quotes from the offending comments.  Rich
1993-12-10 10:16:00 +00:00
Jordan K. Hubbard
a0b8281d40 David Greenman's latest changes to eliminate much stack-walking jazz
(no more sbrk_init()!).
1993-12-09 17:45:43 +00:00
Jordan K. Hubbard
230d2c5ff9 More changes to bring FreeBSD in sync with Paul K's latest. 1993-12-04 00:53:16 +00:00
Jordan K. Hubbard
2e21ebe5ce More changes to bring FreBSD in sync with Paul K's latest. 1993-12-04 00:53:02 +00:00
Jordan K. Hubbard
1e503f71fb Second attempt to integrate Paul K's changes. 1993-12-02 01:03:47 +00:00
Andrey A. Chernov
730a80c44c Remove hanging #else part (with second sbrk()) without #if & #endif
Add missing argument to findshlib, I am not shure,
but it seems that it is 1.
!!! Does anybody compile it before commit?
1993-12-01 15:05:31 +00:00