Commit Graph

64 Commits

Author SHA1 Message Date
jdp
bc43c4e07b Enable -Wformat checking for debug_printf(). 1999-09-04 20:36:27 +00:00
jdp
74f0e38f17 Change the warning about unrecognized entries in the dynamic table
to a debug message which is disabled in production builds of the
dynamic linker.  The condition warned about is normally harmless.

PR:		bin/12849
1999-09-04 20:14:48 +00:00
jdp
72d7b993cf When looking up symbols, search the objects loaded at program start
up first -- before the dlopened DAGs containing the referencing
object.

This makes dynamically loaded perl modules work properly again.
1999-09-04 04:00:09 +00:00
jdp
848a374d79 Get the actual pathname of the dynamic linker from the executable's
PT_INTERP program header entry, to ensure that gdb always finds
the right dynamic linker.

Use obj->relocbase to simplify a few calculations where appropriate.
1999-08-30 01:54:13 +00:00
jdp
b4e6b734d3 When checking to see if a shared object is already loaded, look for
a device/inode match if no pathname match is found.
1999-08-30 01:50:41 +00:00
jdp
18f468e8be Revamp the symbol lookup algorithm to cope better with objects
loaded separately by dlopen that have global symbols with identical
names.  Viewing each dlopened object as a DAG which is linked by its
DT_NEEDED entries in the dynamic table, the search order is as
follows:

  * If the referencing object was linked with -Bsymbolic, search it
    internally.
  * Search all dlopened DAGs containing the referencing object.
  * Search all objects loaded at program start up.
  * Search all objects which were dlopened() using the RTLD_GLOBAL
    flag (which is now supported too).

The search terminates as soon as a strong definition is found.
Lacking that, the first weak definition is used.

These rules match those of Solaris, as best I could determine them
from its vague manual pages and the results of experiments I performed.

PR:		misc/12438
1999-08-30 01:48:19 +00:00
jdp
042137c9ea When honoring -Bsymbolic, still keep searching if only a weak
definition was found in the referencing object.
1999-08-30 01:25:38 +00:00
jdp
1dfbc06c79 Simplify the logic in find_symdef(). 1999-08-30 01:24:08 +00:00
peter
e226894fa0 $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
jdp
1323dfb72b Add a NULL pointer check whose absence could cause segmentation
violations in certain obscure cases involving failed dlopens.  Many
thanks to Archie Cobbs for providing me with a good test case.

Eliminate a block that existed only to localize a declaration.
1999-08-20 22:33:44 +00:00
jdp
ab1b9caa66 Change many asserts into normal errors. They were all for conditions
caused by invalid shared objects rather than by internal errors.

Enable format string mismatch checking for _rtld_error().
1999-07-18 00:02:19 +00:00
jdp
83b97458dd Change the symbol used to find the end of an object's address space
from "end" to "_end".  The former does not exist in most shared
libraries.  This fixes problems in dladdr() and dlsym(RTLD_NEXT, ...).
1999-07-14 04:09:11 +00:00
dfr
a5b5a62db4 Add code to 'handle' R_ALPHA_NONE relocations by ignoring them. 1999-07-12 07:54:45 +00:00
jdp
f1d6b4fb32 Add a MAINTAINER line naming myself. We control the vertical. We
control the horizontal.
1999-07-09 16:27:43 +00:00
jdp
2e4c2d155e Fix bug: if a dlopen() failed (e.g., because of undefined symbols),
the dynamic linker didn't clean up properly.  A subsequent dlopen()
of the same object would appear to succeed.

Another excellent fix from Max Khon.

PR:		bin/12471
Submitted by:	Max Khon <fjoe@iclub.nsu.ru>
1999-07-09 16:22:55 +00:00
jdp
eccca16b3f Shake hands with GDB a little bit earlier so that it is possible to
debug the init functions.

Submitted by:	dfr
1999-07-03 23:54:02 +00:00
jdp
86ed7099cb Fix a reference counting problem when using dlopen(NULL, ...).
PR:		bin/12129
1999-06-25 04:50:06 +00:00
jdp
5ab77d8d27 Fix a serious performance bug for large programs on the Alpha,
discovered by Hidetoshi Shimokawa.  Large programs need multiple
GOTs.  The lazy binding stub in the PLT can be reached from any of
these GOTs, but the dynamic linker only has enough information to
fix up the first GOT entry.  Thus calls through the other GOTs went
through the time-consuming lazy binding process on every call.

This fix rewrites the PLT entries themselves to bypass the lazy
binding.

Tested by Hidetoshi Shimokawa and Steve Price.

Reviewed by:	Doug Rabson <dfr@freebsd.org>
1999-06-25 02:53:59 +00:00
jdp
072c9803b2 Back out my change from 6 April PDT that added a new dlversion()
function.  It was an ill-considered feature.  It didn't solve the
problem I wanted it to solve.   And it added Yet Another Version
Number that would have to be maintained at every release point.
I'm nuking it now before anybody grows too fond of it.
1999-04-22 01:54:38 +00:00
jdp
e2d9e4f987 After relocating the main program, but before calling any of the
_init() functions, initialize the global variables "__progname" and
"environ".  This makes it possible for the _init() functions to call
things like getenv() and err().
1999-04-21 04:06:57 +00:00
jdp
1723187361 The ELF specification says that the RPATH in the executable or
shared object takes precedence over LD_LIBRARY_PATH.  Make the
dynamic linker do it that way.
1999-04-09 06:42:00 +00:00
jdp
3ca4129b7d Eliminate all machine-dependent code from the main source body and
the Makefile, and move it down into the architecture-specific
subdirectories.

Eliminate an asm() statement for the i386.

Make the dynamic linker work if it is built as an executable instead
of as a shared library.  See i386/Makefile.inc to find out how to
do it.  Note, this change is not enabled and it might never be
enabled.  But it might be useful in the future.  Building the
dynamic linker as an executable should make it start up faster,
because it won't have any relocations.  But in practice I suspect
the difference is negligible.
1999-04-09 00:28:43 +00:00
jdp
14c2ca1dbb Fix a couple of typos in comments. 1999-04-07 02:48:43 +00:00
jdp
fed809049f Add a new function dlversion() which returns the version number of
the dynamic linker in the same form as __FreeBSD_version.  This is
mainly intended for checking the dynamic linker version during a make
world.
1999-04-07 02:43:11 +00:00
jdp
d0e7d2aafe Resolve undefined weak references to a value of 0. This solves the
"__deregister_frame_info" problem that was seen when combining a
program linked using the old gcc with shared libraries that were
built using egcs.
1999-04-05 02:36:40 +00:00
peter
5d5c9b046d If somebody does an execv("foo", NULL) (which theoretically is an error),
avoid crashing inside rtld (since it's easy) since everything else handles
it.  Of course, if the target program checks argv[], it'll fall over.

Reviewed by:	jdp
1999-04-04 06:01:09 +00:00
nate
5b778b1b78 - Commit the correct dladdr() implementation.
Reviewed by:	jdp@FreeBSD.org <This is the version he reviewed!>
1999-03-24 23:47:29 +00:00
nate
0879092ae7 - Added dladdr(3) support.
Reviewed by:	jdp@FreeBSD.org
1999-03-24 23:37:35 +00:00
nate
46834a8536 - Set the system immutable flag when installing ld.so to avoid people
accidentally clobbering it.

Submitted by:	numberous people on -current
1999-02-15 05:02:54 +00:00
dfr
d494c31af1 Use the runpath of the main program for locating libraries loaded by
dlopen().

Reviewed by: jdp
1998-11-27 21:19:52 +00:00
jdp
db2840b038 Fix a bug in dlclose that broke the apache13 port. The list of
loaded objects wasn't being maintained properly.
1998-10-13 03:31:59 +00:00
jdp
eeb13953e9 Make LD_PRELOAD work for ELF. 1998-09-22 02:09:56 +00:00
jdp
39ca3db720 Fix a bug that showed up when debugging dynamically linked programs.
References from GDB to "printf" and various other functions would
find the versions in the dynamic linker itself, rather than the
versions in the program's libc.  This fix moves the GDB link map
entry for the dynamic linker to the end of the search list, where
its symbols will be found only if they are not found anywhere else.
It was suggested by Doug Rabson, though I implemented it a little
differently.

I personally would prefer to leave the dynamic linker's entry out
of the GDB search list altogether.  But Doug argues that it is
handy there for such things as setting breakpoints on dlopen().
So it stays for now, at least.

Note, if we ever integrate the dynamic linker with libc (which has
several important benefits to recommend it), this whole problem
goes away.
1998-09-16 02:54:08 +00:00
jdp
04cd93fac8 Make the pathname pointed to by the Obj_Entry structure for the
dynamic linker itself dynamically allocated.  All of them are
supposed to be dynamically allocated, but we cheated before.  It
made gdb unhappy under some circumstances.
1998-09-15 21:07:52 +00:00
dfr
f6827e3b6c Update to the binutils-2.9.1 PLT format. 1998-09-11 18:31:55 +00:00
dfr
6612fb5072 Add the r_addend of the relocation when processing GLOB_DAT relocations. 1998-09-11 18:30:55 +00:00
dfr
e4d9383fcc Fix a cut&paste error which prevented LD_BIND_NOW from working. 1998-09-08 09:47:35 +00:00
jdp
223720d306 Implement ldconfig functionality for ELF. The hints are stored in
a different file than the a.out hints, namely, "/var/run/ld-elf.so.hints".
These hints consist only of the directory search path.  There is
no hash table as in the a.out hints, because ELF doesn't have to
search for the file with the highest minor version number.  (It
doesn't have minor version numbers at all.)

A single run of ldconfig updates either the a.out hints or the ELF
hints, but not both.  The set of hints to process is selected in
the usual way, via /etc/objformat, or ${OBJFORMAT}, or the "-aout"
or "-elf" command line option.  The rationale is that you probably
want to search different directories for ELF than for a.out.

"ldconfig -r" is faked up to produce output like we are used to,
except that for ELF there are no minor version numbers.  This should
enable "ldconfig -r" to be used for checking LIB_DEPENDS in ports
even for ELF.

I implemented the ELF functionality in a new source file, with an
eye toward eliminating the a.out code entirely at some point in
the future.
1998-09-05 03:31:00 +00:00
dfr
61d8f0b0b1 Add alpha support.
Submitted by: John Birrell <jb@cimlogic.com.au> (with extra hacks by me)
Obtained from: Probably NetBSD
1998-09-04 19:03:57 +00:00
jdp
bb404e6bbf Suppress duplicate entries in ldd output. 1998-09-02 02:51:12 +00:00
jdp
9bf76278fc Style fixes. If it seems like a lot of lines of changes, it's
because I moved some functions.  Mr. Tidy likes them to be in
alphabetical order.
1998-09-02 02:00:20 +00:00
jdp
649f889aaf Handle dlsym(NULL, ...) properly, by searching in the caller's
shared object.  Note, this searches _only_ that object, and not its
needed objects, in accordance with the documentation.

Also fix dlopen(NULL, ...) so that the executable's needed objects
are searched as well as the executable itself.
1998-09-02 01:09:34 +00:00
jb
eb522a9455 Update this header to use the revamped elf headers which select Elf32
or Elf64 based on the inclusion of the machine dependent header.

I've left the addition of the extra fields to handle the relocation
structures with addend for a separate commit after jdp has had a chance
to review what I've done. The current change is needed to compile
csu/alpha/crt1.c
1998-08-21 03:29:40 +00:00
jdp
ba5269475b Add "-C" to INSTALLFLAGS to install atomically. An elf->elf
installworld dies at this point otherwise, leaving the system
without a dynamic linker.
1998-08-17 04:59:15 +00:00
dfr
c97988bb9c Add support for ldd. 1998-05-01 08:39:27 +00:00
dfr
fb4b627fd3 Add GDB support. The method and some of the code came from NetBSD's elf
runtime linker.
1998-04-30 07:48:02 +00:00
jdp
80858b4054 This commit was generated by cvs2svn to compensate for changes in r34192,
which included commits to RCS files with non-trunk default branches.
1998-03-07 19:24:35 +00:00
jdp
d75383fd3d Import the ELF dynamic linker. This is the ElfKit version with
quite a few enhancements and bug fixes.  There are still some known
deficiencies, but it should be adequate to get us started with ELF.

Submitted by:	John Polstra <jdp@polstra.com>
1998-03-07 19:24:35 +00:00
jdp
350f58aa8f Import the ELF dynamic linker. This is the ElfKit version with
quite a few enhancements and bug fixes.  There are still some known
deficiencies, but it should be adequate to get us started with ELF.

Submitted by:	John Polstra <jdp@polstra.com>
1998-03-07 19:24:35 +00:00
wosch
07b6e5147d spelling corrections.
PR: docs/4450
Submitted by: josh@quick.net
1997-09-13 16:01:53 +00:00