summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf
Commit message (Collapse)AuthorAgeFilesLines
* Add END markers to asm functions so that debuggers can find their size.jake2002-07-171-1/+3
|
* Remove the nanosleep calls from the spin loops in the locking code.jdp2002-07-065-42/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | They provided little benefit (if any) and they caused some problems in OpenOffice, at least in post-KSE -current and perhaps in other environments too. The nanosleep calls prevented the profiling timer from advancing during the spinloops, thereby preventing the thread scheduler from ever pre-empting the spinning thread. Alexander Kabaev diagnosed this problem, Martin Blapp helped with testing, and Matt Dillon provided some helpful suggestions. This is a short-term fix for a larger problem. The use of spinlocking isn't guaranteed to work in all cases. For example, if the spinning thread has higher priority than all other threads, it may never be pre-empted, and the thread holding the lock may never progress far enough to release the lock. On the other hand, spinlocking is the only locking that can work with an arbitrary unknown threads package. I have some ideas for a much better fix in the longer term. It would eliminate all locking inside the dynamic linker by making it safe for symbol lookups and lazy binding to proceed in parallel with a call to dlopen or dlclose. This means that the only mutual exclusion needed would be to prevent multiple simultaneous calls to dlopen and/or dlclose. That mutual exclusion could be put into the native pthreads library. Applications using foreign threads packages would have to make their own arrangements to ensure that they did not have multiple threads in dlopen and/or dlclose -- a reasonable requirement in my opinion. MFC after: 3 days
* The .Nm utilitycharnier2002-07-061-2/+6
|
* Update the asm statements to use the "+" modifier instead ofjdp2002-06-244-16/+16
| | | | | | | | | | matching constraints where appropriate. This makes the dynamic linker buildable at -O0 again. Thanks to Bruce Evans for identifying the cause of the build problem. MFC after: 1 week
* Add needed include of mman.h to fix sparc64 buildworld.jake2002-06-241-1/+3
|
* The last bits of the alloca -> mmap fix. IA64 and SPARC64 (current only).dillon2002-06-222-21/+58
| | | | | | | | Untested (testing request went unanswered), but sparc64 is not expected to cause problems. IA64 is not expected to cause problems but the patch was slightly more complex so the possibility exists. Approved by: jdp
* This is the same alloca() fix as was committed for i386. David O'Briendillon2002-06-181-5/+17
| | | | | | | | tested the patch on -stable. Reviewed by: obrien Approved by: jdp MFC after: 3 days
* Dillon's recent commits to the dynamic linker without running themjdp2002-06-101-1/+0
| | | | | | by me first have given me a good excuse to drop my MAINTAINERship. MFC after: 1 week
* Correct a bug in the last commit. The whole point of creating a 'done:'dillon2002-06-102-6/+6
| | | | | | | goto target was so the cache could be freed. So free the cache after done: rather then before done: (!) Submitted by: Gavin Atkinson <gavin@ury.york.ac.uk>
* In tracking down an installation seg fault with then openoffice portdillon2002-06-102-18/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | Martin Blapp determined that the elf dynamic loader was at fault. In particular, the loader uses alloca() to allocate a symbol cache on the stack. Normally this would work just fine, but if the loader is called from a threaded program and the object being loaded is fairly large the alloca() can blow away the thread stack and effect other nearby thread stacks as well. My testing showed that the symbol cache can be as large as 250KBytes during the openoffice port build and install sequence. Martin was able to work around the problem by disabling the symbol cache (cache = NULL;). However, this solution is not adequate for commit because it can cause an enormous cpu burden for applications which do a lot of dynamic loading (e.g. like konqueror). The solution is to use anonymous mmap() to temporarily allocate space to hold the symbol cache. In testing I found that replacing the alloca() with mmap() has no observable degredation in performance. It should be noted that this bug does not necessarily cause an immediate crash but can instead result in long term corruption and instability in applications that load modules from threads. The bug is almost certainly responsible for some of the instabilities found in konqueror, for example, and possibly netscape too. Sleuthing work by: Martin Blapp <mb@imp.ch> X-MFC after: Before or after the 4.6 release depending on the release engineers
* Include machine/ia64_cpu.h because we use ia64_mf().marcel2002-05-211-0/+1
| | | | Submitted by: ru
* Fix handling of weak references to undefined symbols on ia64:marcel2002-04-272-29/+21
| | | | | | | | | | | | | | | | o Set st_shndx for sym_zero to SHN_UNDEF instead of SHN_ABS. This gives us something to reliably test against. o For weak references to undefined sysmbols (as indicated by having st_shndx equals SHN_UNDEF) in the context of OPDs, the address of the OPD is to be zero, not the address of the function it contains. o For weak references to undefined symbols in all other cases (only DIR64LSB at this time), the actual relocated value is to be zero, not the value prior to relocating. Roughly speaking, weak references to undefined symbols are no-ops. Tested on: i386, ia64
* Now that local symbols aren't looked up with the symbol hash table,marcel2002-04-271-10/+3
| | | | binding works for local symbols. Remove the workaround...
* Don't do symbol lookups for local symbols. The symbol index in themarcel2002-04-271-7/+14
| | | | | | | | relocation identifies the symbol to which we need to bind. This solves a problem seen on ia64 where the symbol hash table does not contain local symbols and thus resulted in unresolved symbols. Tested on: alpha, i386, ia64
* Fix a relocation bug in the ia64 ld.so. Weak function pointers in sharedpeter2002-04-071-3/+16
| | | | | | | | | | | objects were not being correctly set to zero. Instead, the function descriptor pointer was set to the load address of the .so object. This caused gcc generated binaries to segfault on exit when crtbegin.asm's _fini code tested the __cxa_finalize() function pointer for zero. This is a bit of a hack because of a problem nearby workaround for find_symdef and its quirks (failures) for local symbols. This still needs to be fixed.
* Minor changes to make this work on sparc64.jake2002-04-021-33/+46
| | | | | Approved by: jdp Tested on: alpha, i386, sparc64
* rtld support for sparc64.jake2002-03-135-0/+1073
| | | | | Largely obtained from: netbsd Submitted by: jake, tmm
* When searching an object that was opened with RTLD_GLOBAL, search its DAG too.des2002-02-271-3/+6
| | | | | | PR: bin/25059 Approved by: jdp MFC after: 3 weeks
* ld-elf.so.1 assumed a few too many things about the ordering of sectionspeter2002-02-185-72/+265
| | | | | | | | | | | | | | produced by ld(8) (ie: that _DYNAMIC immediately follows the _GOT). The new binutils import changed that, and the intial GOT relocation broke. Use a custom linker script to provide a real end-of-GOT symbol. Update ld.so to deal with the new (faster) PLT format that gcc-3.1 and binutils can produce. This is probably incomplete, but appears to be working again. Obtained from: NetBSD (And a fix to a silly mistake that I made by: gallatin)
* Add support such that if LD_TRACE_LOADED_OBJECTS_ALL is defined to aobrien2002-02-172-2/+11
| | | | | | | | non-empty string in the environment; we indicate which objects caused each object to be loaded. PR: 30908 Submitted-by: Mike Meyer <mwm@mired.org>
* Allow ldd(1) be used on shared libraries in addition to executables.sobomax2002-02-041-9/+35
|
* Mark a function as __printflike()kris2002-02-041-1/+1
| | | | MFC after: 1 week
* Change the library search order so that LD_LIBRARY_PATH overridesjdp2002-01-251-2/+2
| | | | | | | all others. PR: bin/28191 MFC after: 2 weeks
* Change brk's prototype from char *brk(const char *) to int brk(const void *)dwmalone2002-01-241-1/+0
| | | | | | | | | | | | | | | and sbrk's prototype from char *sbrk(int) to void *sbrk(intptr_t). This makes us more consistant with NetBSD and standards which include these functions. Bruce pointed out that ptrdiff_t would probably have been better than intptr_t, but this doesn't match other implimentations. Also remove local declarations of sbrk and unnecessary casting. PR: 32296 Tested by: Harti Brandt <brandt@fokus.gmd.de> MFC after: 1 month
* mdoc(7) police: tidy up.ru2002-01-101-17/+25
|
* Update rtld for the "new" ia64 ABI. In the old toolchain, thepeter2001-10-297-9/+34
| | | | | | | | | | | | | | | DT_INIT and DT_FINI tags pointed to fptr records. In 2.11.2, it points to the actuall address of the function. On IA64 you cannot just take an address of a function, store it in a function pointer variable and call it.. the function pointers point to a fptr data block that has the target gp and address in it. This is absolutely necessary for using the in-tree binutils toolchain, but (unfortunately) will not work with old shared libraries. Save your old ld-elf.so.1 if you want to use old ones still. Do not mix-and-match. This is a no-op change for i386 and alpha. Reviewed by: dfr
* Fix a dependency violation (branch after alloc)peter2001-10-291-1/+1
|
* Add ia64 support. Various adjustments were made to existing targets todfr2001-10-1514-33/+1069
| | | | | cope with a few interface changes required by the ia64. In particular, function pointers on ia64 need special treatment in rtld.
* The support for accelerating find_symdef() with a cache was broken. Thisdfr2001-10-101-8/+9
| | | | | | | | fixes the problem and improves startup times for large applications such as KDE2 considerably. Reviewed by: jdp MFC after: 1 week
* mdoc(7) police:ru2001-08-071-4/+2
| | | | | | | Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text. Not only this slows down the mdoc(7) processing significantly, but it also has an undesired (in this case) effect of disabling hyphenation within the entire enclosed block.
* Use STD{ERR,IN,OUT}_FILENO instead of their numeric values. Thesheldonh2001-07-262-2/+2
| | | | | | | definitions are more readable, and it's possible that they're more portable to pathalogical platforms. Submitted by: David Hill <david@phobia.ms>
* mdoc(7) police: removed HISTORY info from the .Os call.ru2001-07-101-1/+1
|
* 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.
OpenPOWER on IntegriCloud