summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/rtld.c
Commit message (Collapse)AuthorAgeFilesLines
* Make our ELF64 type definitions match standards. In particular thismarcel2005-12-181-1/+1
| | | | | | | | | | | | | means: o Remove Elf64_Quarter, o Redefine Elf64_Half to be 16-bit, o Redefine Elf64_Word to be 32-bit, o Add Elf64_Xword and Elf64_Sxword for 64-bit entities, o Use Elf_Size in MI code to abstract the difference between Elf32_Word and Elf64_Word. o Add Elf_Ssize as the signed counterpart of Elf_Size. MFC after: 2 weeks
* Fix a bug in dlinfo(RTLD_DI_SERINFOSIZE) requests. For each search pathjhb2005-11-111-1/+1
| | | | | | | | | | | | we included the length of the path in the returned size but not the length of the associated Dl_serpath structure. Without this fix, programs attempting to allocate a structure to hold the search path information would allocate too small of a buffer and rtld would overrun the buffer while filling it via a subsequent RTLD_DI_SERINFO request. Submitted by: "William K. Josephson" wkj at morphisms dot net Reviewed by: jdp MFC after: 2 weeks
* When allocating TLS and DTV, make sure that any unused slots in the DTVdfr2005-03-301-8/+4
| | | | | | | | are initialised to zero. When freeing TLS, don't attempt to free DTV slots which were not used. Pointed out by: Joerg Sonnenberger X-MFC-After: After the branch, probably
* If "dangerous" environment variables (LD_PRELOAD, LD_LIBMAP,cperciva2005-03-241-1/+24
| | | | | | | | | | | | | LD_LIBMAP_DISABLE, LD_LIBRARY_PATH) are used, then make sure the libraries being loaded aren't on a noexec-mounted filesystem. This is a compromise position: I'm assuming that nobody will be silly enough to set the noexec mount flag on part of the default library path, in order to avoid adding extra overhead into the common case (where those environment variables aren't used). Discussed with: csjp, secteam MFC after: 1 week
* Add locking code for tls routines.davidxu2005-03-201-4/+21
|
* Attempt to free any static TLS space used by a shared library when itdfr2005-02-271-0/+20
| | | | | | | is unloaded. This allows applications which load and unload libraries like libGL.so.1 several times to work properly. MFC after: 2 days
* Description from Dan:mdodd2005-02-041-1/+3
| | | | | | | | | | | | | | | Another handy libmap patch. Lets you do stuff like this: LD_LIBMAP="libpthread.so.1=libthr.so.1" mythreadedapp If you already have a program-specific override in libmap.conf, note that you must use a program-specific override in LD_LIBMAP: LD_LIBMAP="[mythreadedapp],libpthread.so.1=libthr.so.1" mythreadedapp PR: bin/74471 Submitted by: Dan Nelson <dnelson AT allantgroup.com> MFC after: 2 weeks
* Do the TLS offset allocations before relocations, as otherwise theressouhlal2004-11-021-11/+11
| | | | | | | can be overlap in the TLS offsets, if the relocations are done in a certain order. Approved by: dfr, grehan (mentor)
* Add stubs for TLS.cognet2004-09-231-1/+2
| | | | Arbitraly choose the 2nd variant until I figure out which one I should use.
* Add stubs for powerpc TLS.dfr2004-08-041-5/+2
| | | | Submitted by: ssouhlal
* Add support for Thread Local Storage.dfr2004-08-031-0/+342
|
* Fix the problem that surfaced with the new binutils import on sparc64tmm2004-06-181-1/+4
| | | | | | | | | | | | | | | | | | | | | | (and that is for now being worked around by a binutils patch). The rtld code tested &_DYNAMIC against 0 to see whether rtld itself was built as PIC or not. While the sparc64 MD code did not rely on the preset value of the GOT slot for _DYNAMIC any more due to previous binutils changes, it still used to not be 0, so that this check did work. The new binutils do however initialize this slot with 0. As a consequence, rtld would not properly initialize itself and crash. Fix that by introducing a new macro, RTLD_IS_DYNAMIC, to take the role of this test. For sparc64, it is implemented using the rtld_dynamic() code that was already there. If an architecture does not provide its own implementation, we default to the old check. While being there, mark _DYNAMIC as a weak symbol in the sparc64 rtld_start.S. This is needed in the LDSCRIPT case, which is however not currently supported for want of an actual ldscript. Sanity checked with md5 on alpha, amd64, i386 and ia64.
* give out a little more information in case of a missing dependencyeik2004-05-281-1/+6
| | | | | | | | PR: 56549 Submitted by: edwin Reviewed by: joerg, ru Approved by: joerg MFC after: 2 weeks
* If we change obj_rtld.path after initialising __progname, make sure wedfr2004-03-291-0/+1
| | | | | change __progname to point at the new storage otherwise it ends up pointing at freed memory which leads to confusing garbled error messages.
* Add initial support for compiling a special 32 bit version ofpeter2004-03-211-12/+25
| | | | | | | ld-elf.so.1 on 64 bit systems. Most of this involves using alternate paths, environment variables and diagnostic messages. The build glue is seperate.
* Make NULL a (void*)0 whereever possible, and fix the warnings(-Werror)markm2004-03-051-4/+4
| | | | | | | | | | | | | | | that this provokes. "Wherever possible" means "In the kernel OR NOT C++" (implying C). There are places where (void *) pointers are not valid, such as for function pointers, but in the special case of (void *)0, agreement settles on it being OK. Most of the fixes were NULL where an integer zero was needed; many of the fixes were NULL where ascii <nul> ('\0') was needed, and a few were just "other". Tested on: i386 sparc64
* Do not depend on existence of _end symbol in obj_from_addr, usekan2004-02-251-8/+1
| | | | | | obj->mapbase and obj->mapsize instead. Prompted by: OpenOffice debugging session at last BSDCon.
* Initialise some uninitialised variables.dfr2003-12-311-0/+2
| | | | Thanks to: valgrind
* Sync comment with code's reality.tobez2003-11-141-1/+1
| | | | MFC after: 1 week
* Retire the WITH_LIBMAP compile knob; libmap is now a standard feature.mdodd2003-09-131-8/+0
|
* Change libmap.c:lm_init() to return a status value; 0 for successmdodd2003-09-131-1/+1
| | | | | | | | (libmap available) and 1 for failure. Assign this return to the global 'libmap_disable' variable in rtld.c. This totally prevents any libmap functions from being called after lm_init() if no config file is present.
* As long threatened, stage 2 of making a dynamically-linked root a reality.gordon2003-08-171-1/+1
| | | | Install rtld into /libexec.
* Prepend /lib to the builtin library search path in rtld.gordon2003-08-171-1/+1
|
* Provide a mechanism for dumping relocation information.mdodd2003-06-191-0/+10
| | | | | | | Setting the LD_DUMP_REL_PRE or LD_DUMP_REL_POST environment variables cause rtld-elf to output a table of all relocations. This is useful for debugging.
* Avoid a NULL pointer dereference.mdodd2003-06-181-1/+2
|
* - Add support for DT_FLAGS.mdodd2003-06-181-1/+18
| | | | - Define various things from the most recent ELF spec.
* - use issetugid()mdodd2003-05-311-3/+2
| | | | | | - be paranoid about honoring LD_LIBMAP_DISABLE. Suggested by: rwatson
* Use the environment variable LD_LIBMAP_DISABLE to disablemdodd2003-05-311-3/+8
| | | | libmap.conf(5) functionality.
* Allow threading libraries to register their own lockingkan2003-05-291-85/+39
| | | | | | | | | | implementation in case default one provided by rtld is not suitable. Consolidate various identical MD lock implementation into a single file using appropriate machine/atomic.h. Approved by: re (scottl)
* Rethink the way we count module references. Simply followingkan2003-05-081-18/+30
| | | | | | | | | DT_NEEDED links is not flexible enough for cases where dynamically loaded modules form a dependency cycle. This should fix an infinite recursion problem encountered by Yahoo. Approved by: re (jhb)
* Fix signed/unsigned comparison warnings.obrien2003-05-041-1/+1
|
* Dynamic object dependency mapping: libmap.mdodd2003-04-071-5/+21
| | | | | | | This is an optional feature, disabled by default. This will be useful to people testing the various POSIX threading libraries under -CURRENT but can easily serve other needs.
* Do not remove object from the lists at the unref_dag() stage.kan2003-02-171-8/+26
| | | | | | | Introduce a new unlink_object() function and call it in unload_object() instead. Removing the object in unref_dag() is too early, rtld calls _fini() function after that and shared objects might fail resolve their own symbols.
* Fix a typo in rtld_dirname.kan2003-02-131-1/+1
|
* Implement dlinfo() function.kan2003-02-131-31/+261
| | | | | | | | | | Introdice RTLD_SELF special handle and properly process it within dlsym() and dlinfo() functions. The intention is to improve our compatibility with Solaris and to make a Java port easier. Partially submitted by: phantom
* Remove /usr/lib/elf from a default search path.kan2003-02-131-17/+0
| | | | | | Move xprintf to malloc.c, it is only used there. Make static. Submitted by: phantom
* When unloading dependencies make sure they are removed from all thekan2003-02-101-9/+10
| | | | | | | | | | | | associated lists: remove RTLD_GLOBAL objects from global objects list; remove the parent object from dldags list of its children. Previosly we were doing that only to the top-level object OF the DAG being unloaded and all its dependencies were ignored, leading to mysterious crashes later. Submitted by: peter (partially)
* Put back a test for binaries with no PT_LOAD entries I over-jealoslykan2002-11-291-0/+4
| | | | | | removed in r1.69. Apploved by: re (rwatson)
* Fix the handling of high PLT entries (> 32764) on sparc64. This requirestmm2002-11-181-1/+1
| | | | | | | | additional arguments to reloc_jmpslot(), which is why MI code and MD code of other platforms had to be changed. Reviewed by: jake Approved by: re
* Add support for binaries with arbitrary number of PT_LOAD sections.kan2002-10-231-8/+0
| | | | Reviewed by: peter
* Change the symbol lookup order to search RTLD_GLOBAL objectskan2002-10-191-12/+12
| | | | | | | | | | before referencing object's DAG. This makes it possible for C++ exceptions to work across shared libraries and brings us closer to the search order used by Solaris/Linux. Reviewed by: jdp Approved by: obrien MFC after: 1 month
* Fix a problem with RTLD_TRACE flag to dlopen(3), which sometimes can returnsobomax2002-10-191-6/+8
| | | | | | | | | | | | | even if there was no error occured (when trying to dlopen(3) object that already linked into executable which does dlopen(3) call). This is more proper fix for `ldd /usr/lib/libc.so' problem, because the new behaviour conforms to documentation. Remove workaround from ldd.c (rev.1.32). PR: 35099 Submitted by: Nathan Hawkins <utsl@quic.net> MFC after: 1 week
* Don't acquire the writer lock in rtld_exit when clearing the sharedjdp2002-08-081-2/+0
| | | | | | | | objects' reference counts. This function is called by the atexit mechanism at program shutdown. I don't think the locking is necessary here. It caused OpenOffice builds to hang more often than not. Credit to Martin Blapp and Matt Dillon for helping to diagnose this problem and for testing the fix.
* Fix handling of weak references to undefined symbols on ia64:marcel2002-04-271-1/+1
| | | | | | | | | | | | | | | | 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
* 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
* Minor changes to make this work on sparc64.jake2002-04-021-33/+46
| | | | | Approved by: jdp Tested on: alpha, i386, sparc64
* 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
* Add support such that if LD_TRACE_LOADED_OBJECTS_ALL is defined to aobrien2002-02-171-2/+6
| | | | | | | | 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
OpenPOWER on IntegriCloud