summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf
Commit message (Collapse)AuthorAgeFilesLines
* mdoc(7) police: remove extraneous .Pp before and/or after .Sh.dd2001-07-091-2/+0
|
* mdoc(7) police: sort SEE ALSO xrefs (sort -b -f +2 -3 +1 -2).ru2001-07-061-1/+1
|
* Use new backup feature of install(1).ru2001-05-281-14/+1
|
* Performance improvements for the ELF dynamic linker. Thesejdp2001-05-055-18/+60
| | | | | | | | | | | | | | | | | | | | particularly help programs which load many shared libraries with a lot of relocations. Large C++ programs such as are found in KDE are a prime example. While relocating a shared object, maintain a vector of symbols which have already been looked up, directly indexed by symbol number. Typically, symbols which are referenced by a relocation entry are referenced by many of them. This is the same optimization I made to the a.out dynamic linker in 1995 (rtld.c revision 1.30). Also, compare the first character of a sought-after symbol with its symbol table entry before calling strcmp(). On a PII/400 these changes reduce the start-up time of a typical KDE program from 833 msec (elapsed) to 370 msec. MFC after: 5 days
* * include/elf.h has been repo copied to include/elf-hints.h, and it noobrien2001-05-021-1/+2
| | | | | | | | longer includes machine/elf.h. * consumers of elf.h now use the minimalist elf header possible. This change is motivated by Binutils 2.11.0 and too much clashing over our base elf headers and the Binutils elf headers.
* - Backout botched attempt to intoduce MANSECT feature.ru2001-03-261-1/+1
| | | | - MAN[1-9] -> MAN.
* Prepare for mdoc(7)NG.ru2001-01-161-1/+1
|
* Fix a bug in which a program called dlclose from a destructor andjdp2001-01-051-2/+43
| | | | got an assert failure in the dynamic linker.
* Prepare for mdoc(7)NG.ru2000-12-201-3/+5
|
* Add `_PATH_DEVZERO'.obrien2000-12-091-2/+3
| | | | Use _PATH_* where where possible.
* Remove the superfluous call to _rtld_error() in symlook_default().jdp2000-11-071-2/+0
| | | | | | | The function's callers generate the error message when appropriate. This eliminates the message ``Undefined symbol "__register_frame_info"'' which was bogusly returned by dlerror() in some cases.
* Add support for dlsym(RTLD_DEFAULT, ...).jdp2000-09-192-69/+97
|
* Pass two pointer parameters to the r_debug_state() hookjwd2000-08-261-8/+18
| | | | | | | | | | | | | | | function, thus allowing a debugger or other trace tool to easily grab the addresses of the needed structures off the stack. This change is transparent to gdb, which locates the link_map list and transfers it to debugger memory for comparison purposes. A sample program will be committed showing how this can be used. Reviewed by: John Polstra <jdp@FreeBSD.org>
* Revamp the code that calls shared libraries' init and fini functions.jdp2000-07-262-106/+185
| | | | | | | | | | | | | | | | | | | | | | Formerly the init functions were called in the opposite of the order in which libraries were loaded, and libraries were loaded according to a breadth-first traversal of the dependency graph. That ordering came from SVR4.0, and it was easy to implement but not always sensible. Now we do a depth-first walk over the dependency graph and call the init functions in an order such that each shared object's needed objects are initialized before the shared object itself. At the same time we build a list of finalization (fini) functions in the opposite order, to guarantee correct C++ destructor ordering whenever possible. (It may not be possible if dlopen and dlclose are used in strange ways, but we come as close as one can come.) The need for this renovation has become apparent as more programs have started using multithreading. The multithreaded C library libc_r requires initialization, whereas the standard libc does not. Since virtually every other object depends on the C library, it is important that it get initialized first.
* We shouldn't use cp to save the old ld-elf.so.1. Use the sanctioned toolgreen2000-07-201-1/+2
| | | | ${INSTALL} with -C -p instead.
* Fix a bug which could cause programs with user threads packages tojdp2000-07-173-5/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | lock against themselves, causing infinite spinning. Brian Feldman found this problem when testing with Mozilla and supplied the fix, which I have revised slightly. Here is the failure scenario. A thread calls dlopen() and acquires the writer lock. While the thread still holds the lock, a signal is delivered and caught. The signal handler tries to call a function which hasn't been bound yet. It thus enters the dynamic linker and tries to acquire the reader lock. Since the writer lock is already held, it will spin forever in the signal handler. The thread holding the lock won't be able to progress and release the lock. The solution is to block almost all signals while holding the exclusive lock. A similar problem could conceivably occur in the opposite order. Namely, a thread is holding the reader lock and then a signal handler calls dlopen() or dlclose() and spins waiting for the writer lock. We deal with this administratively by proclaiming that signal handlers aren't allowed to call dlopen() or dlclose(). Actually we don't have to proclaim a thing, since signal handlers aren't allowed to call any system functions except those which are explicitly permitted. Submitted by: Brian Fundakowski Feldman <green>
* Solve the dynamic linker's problems with multithreaded programs oncejdp2000-07-0810-334/+770
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and for all (I hope). Packages such as wine, JDK, and linuxthreads should no longer have any problems with re-entering the dynamic linker. This commit replaces the locking used in the dynamic linker with a new spinlock-based reader/writer lock implementation. Brian Fundakowski Feldman <green> argued for this from the very beginning, but it took me a long time to come around to his point of view. Spinlocks are the only kinds of locks that work with all thread packages. But on uniprocessor systems they can be inefficient, because while a contender for the lock is spinning the holder of the lock cannot make any progress toward releasing it. To alleviate this disadvantage I have borrowed a trick from Sleepycat's Berkeley DB implementation. When spinning for a lock, the requester does a nanosleep() call for 1 usec. each time around the loop. This will generally yield the CPU to other threads, allowing the lock holder to finish its business and release the lock. I chose 1 usec. as the minimum sleep which would with reasonable certainty not be rounded down to 0. The formerly machine-independent file "lockdflt.c" has been moved into the architecture-specific subdirectories by repository copy. It now contains the machine-dependent spinlocking code. For the spinlocks I used the very nifty "simple, non-scalable reader-preference lock" which I found at <http://www.cs.rochester.edu/u/scott/synchronization/pseudocode/rw.html> on all CPUs except the 80386 (the specific CPU model, not the architecture). The 80386 CPU doesn't support the necessary "cmpxchg" instruction, so on that CPU a simple exclusive test-and-set lock is used instead. 80386 CPUs are detected at initialization time by trying to execute "cmpxchg" and catching the resulting SIGILL signal. To reduce contention for the locks, I have revamped a couple of key data structures, permitting all common operations to be done under non-exclusive (reader) locking. The only operations that require exclusive locking now are the rare intrusive operations such as dlopen() and dlclose(). The dllockinit() interface is now deprecated. It still exists, but only as a do-nothing stub. I plan to remove it as soon as is reasonably possible. (From the very beginning it was clearly labeled as experimental and subject to change.) As far as I know, only the linuxthreads port uses dllockinit(). This interface turned out to have several problems. As one example, when the dynamic linker called a client-supplied locking function, that function sometimes needed lazy binding, causing re-entry into the dynamic linker and a big looping mess. And in any case, it turned out to be too burdensome to require threads packages to register themselves with the dynamic linker.
* When installing the dynamic linker, save the previous version injdp2000-07-081-0/+12
| | | | | | | | | "ld-elf.so.1.old". The dynamic linker is a critical component of the system, and it is difficult to recover if it is damaged and there isn't a working backup available. For instance, parts of the toolchain such as the assembler are dynamically linked, making it impossible to build a new dynamic linker if the installed one doesn't work.
* Only punctuation is an allowed argument type for open-close macrossheldonh2000-06-301-1/+2
| | | | | | such as Po/Pc, as explained by phantom. Reported by: billf
* Back out the previous change to the queue(3) interface.jake2000-05-262-5/+5
| | | | | | It was not discussed and should probably not happen. Requested by: msmith and others
* Change the way that the queue(3) structures are declared; don't assume thatjake2000-05-232-5/+5
| | | | | | | | the type argument to *_HEAD and *_ENTRY is a struct. Suggested by: phk Reviewed by: phk Approved by: mdodd
* Eliminate unaligned accesses that occurred when relocating thejdp2000-05-221-12/+27
| | | | | | DWARF2 exception tables emitted by the compiler for C++ sources. These tables are tightly packed, and they contain some relocated addresses which are not well-aligned.
* Cross-reference ldd(1) in rtld(1) and vice versa.sheldonh2000-03-281-0/+1
|
* Fixed missing DPADDs.bde2000-03-271-4/+5
| | | | | Fixed some style bugs (some usual ones for LDADD, and misformatting of $FreeBSD$).
* Add a manual page for the ELF dynamic linker. I initially createdjdp2000-01-292-99/+22
| | | | | | rtld.1 by means of a repository copy from "src/libexec/rtld-aout/rtld.1". Then I edited it to make it (more) accurate for the ELF dynamic linker.
* When a threads package registers locking methods with dllockinit(),jdp2000-01-295-50/+137
| | | | | | | | | | figure out which shared object(s) contain the the locking methods and fully bind those objects as if they had been loaded with LD_BIND_NOW=1. The goal is to keep the locking methods from requiring any lazy binding. Otherwise infinite recursion occurs in _rtld_bind. This fixes the infinite recursion problem in the linuxthreads port.
* Block almost all signals in the default locking method instead ofjdp2000-01-254-32/+40
| | | | | | | | just a few of them. This looks like it solves the recent ld-elf.so.1: assert failed: /usr/src/libexec/rtld-elf/lockdflt.c:55 failures seen by some applications such as JDK.
* Allow files in LD_PRELOAD to be separated by white space, like Solarisjdp2000-01-221-3/+4
| | | | and Linux.
* Revamp the mechanism for enumerating and calling shared objects'jdp2000-01-096-139/+187
| | | | | | | | | | | | init and fini functions. Now the code is very careful to hold no locks when calling these functions. Thus the dynamic linker cannot be re-entered with a lock already held. Remove the tolerance for recursive locking that I added in revision 1.2 of dllockinit.c. Recursive locking shouldn't happen any more. Mozilla and JDK users: I'd appreciate confirmation that things still work right (or at least the same) with these changes.
* Work around an assert failure in the dynamic linker's default threadjdp1999-12-284-16/+32
| | | | | | | | | | | | | | | | locking functions. If an application loads a shared object with dlopen() and the shared object has an init function which requires lazy binding, then _rtld_bind is called when the thread is already inside the dynamic linker. This leads to a recursive acquisition of the lock, which I was not expecting -- hence the assert failure. This work-around makes the default locking functions handle recursive locking. It is NOT the correct fix -- that should be implemented at the generic locking level rather than in the default locking functions. I will implement the correct fix in a future commit. Since the dllockinit() interface will likely need to change, warn about that in both the man page and the header file.
* Add a new function dllockinit() for registering thread lockingjdp1999-12-2711-45/+509
| | | | | | | | | | | | | | | | | | | functions to be used by the dynamic linker. This can be called by threads packages at start-up time. I will add the call to libc_r soon. Also add a default locking method that is used up until dllockinit() is called. The default method works by blocking SIGVTALRM, SIGPROF, and SIGALRM in critical sections. It is based on the observation that most user-space threads packages implement thread preemption with one of these signals (usually SIGVTALRM). The dynamic linker has never been reentrant, but it became less reentrant in revision 1.34 of "src/libexec/rtld-elf/rtld.c". Starting with that revision, multiple threads each doing lazy binding could interfere with each other. The usual symptom was that a symbol was falsely reported as undefined at start-up time. It was rare but not unseen. This commit fixes it.
* In revision 1.21 I changed the search order for shared libraries,jdp1999-11-191-1/+1
| | | | | | | but I forgot to make the corresponding fix to the comment. Rectify that. Submitted by: Tony Finch <fanf@demon.net>
* .Nm += "rtld"phantom1999-09-281-1/+2
| | | | apropos(1) now knows about rtld(1) manpage.
* Make jdk-1.1.8 work again. It turns out that some code insidejdp1999-09-051-5/+9
| | | | | | | | | | | | | | | libjava peeks into the dynamic linker's private Obj_Entry structures. My recent changes introduced some new members near the front of the structures, causing libjava to get the wrong fields. This commit moves the new members toward the end of the structure so that the layout of the portion that is relevant to JDK remains the same as before. I will work with the JDK porting team to see if we can come up with a less fragile way for them to do what they need to do. I understand the current approach was necessary in order to work around some limitations of the dynamic linker. Maybe it's not necessary any more.
* Enable -Wformat checking for debug_printf().jdp1999-09-041-1/+3
|
* Change the warning about unrecognized entries in the dynamic tablejdp1999-09-041-2/+2
| | | | | | | to a debug message which is disabled in production builds of the dynamic linker. The condition warned about is normally harmless. PR: bin/12849
* When looking up symbols, search the objects loaded at program startjdp1999-09-041-8/+8
| | | | | | | up first -- before the dlopened DAGs containing the referencing object. This makes dynamically loaded perl modules work properly again.
* Get the actual pathname of the dynamic linker from the executable'sjdp1999-08-303-12/+31
| | | | | | | 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.
* When checking to see if a shared object is already loaded, look forjdp1999-08-303-7/+38
| | | | a device/inode match if no pathname match is found.
* Revamp the symbol lookup algorithm to cope better with objectsjdp1999-08-304-82/+245
| | | | | | | | | | | | | | | | | | | | | | 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
* When honoring -Bsymbolic, still keep searching if only a weakjdp1999-08-301-4/+8
| | | | definition was found in the referencing object.
* Simplify the logic in find_symdef().jdp1999-08-301-45/+41
|
* $Id$ -> $FreeBSD$peter1999-08-2818-18/+18
|
* Add a NULL pointer check whose absence could cause segmentationjdp1999-08-201-6/+6
| | | | | | | 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.
* Change many asserts into normal errors. They were all for conditionsjdp1999-07-183-39/+65
| | | | | | caused by invalid shared objects rather than by internal errors. Enable format string mismatch checking for _rtld_error().
* Change the symbol used to find the end of an object's address spacejdp1999-07-141-2/+2
| | | | | from "end" to "_end". The former does not exist in most shared libraries. This fixes problems in dladdr() and dlsym(RTLD_NEXT, ...).
* Add code to 'handle' R_ALPHA_NONE relocations by ignoring them.dfr1999-07-121-1/+4
|
* Add a MAINTAINER line naming myself. We control the vertical. Wejdp1999-07-091-1/+2
| | | | control the horizontal.
* Fix bug: if a dlopen() failed (e.g., because of undefined symbols),jdp1999-07-091-38/+44
| | | | | | | | | | 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>
* Shake hands with GDB a little bit earlier so that it is possible tojdp1999-07-031-3/+3
| | | | | | debug the init functions. Submitted by: dfr
OpenPOWER on IntegriCloud