summaryrefslogtreecommitdiffstats
path: root/libexec/ld.so/resolve.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Convert the child_list member from a linked list to a vector.guenther2019-10-041-3/+2
| | | | ok mpi@
* Use a better algorithm for calculating the grpsym library order.guenther2019-10-031-13/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing code did a full recursive walk for O(horrible). Instead, keep a single list of nodes plus the index of the first node whose children haven't been scanned; lookup until that index catches the end, appending the unscanned children of the node at the index. This also makes the grpsym list order match that calculated by FreeBSD and glibc in dependency trees with inconsistent ordering of dependent libs. To make this easier and more cache friendly, convert grpsym_list to a vector: the size is bounded by the number of objects currently loaded. Other, related fixes: * increment the grpsym generation number _after_ pushing the loading object onto its grpsym list, to avoid double counting it * increment the grpsym generation number when building the grpsym list for an already loaded object that's being dlopen()ed, to avoid incomplete grpsym lists * use a more accurate test of whether an object already has a grpsym list Prompted by a diff from Nathanael Rensen (nathanael (at) list.polymorpheus.com) that pointed to _dl_cache_grpsym_list() as a performance bottleneck. Much proding from robert@, sthen@, aja@, jca@ no problem reports after being in snaps ok mpi@
* Simplify _dl_find_symbol(). Currently, it returns three values:guenther2019-08-041-54/+30
| | | | | | | | | | | | | - the symbol it found, returned via the second argument - the base offset of the the object it was found in, via the return value - optionally: the object it was found in, returned via the last argument Instead, return a struct with the symbol and object pointers and let the caller get the base offset from the object's obj_base member. On at least aarch64, amd64, mips64, powerpc, and sparc64, a two word struct like this is passed in registers. ok mpi@, kettenis@
* In 2004, we upgraded to binutils 2.14 with did -zcombreloc by default.guenther2019-07-211-45/+4
| | | | | | | | In 2013, I implemented the single-entry LRU cache that gets the maximal symbol reuse from combreloc. Since then, the ld.so generic relocation symcache has been a waste of CPU and memory with 0% hit-rate, so kill it. ok mpi@
* ld.so's $ORIGIN handling when argv[0] is a relative path was broken byguenther2019-07-141-2/+3
| | | | | | | | the change in __getcwd(2)'s return value. Fix it by switching to the __realpath(2) syscall, eliminating the ld.so copy of realpath(). problem caught by regress and noted by bluhm@ ok deraadt@
* Now that all Elf_foo types are correct, we don't need to use Elf32_Wordderaadt2019-04-211-9/+9
| | | | | anywhere and can use Elf_Word instead. ok guenther
* On alpha, the buckets of DT_HASH are 8 bytes instead of 4 bytes. This wasguenther2019-04-211-3/+3
| | | | | | | | previously 'implemented' by having the Elf_Word typedef in <sys/exec_elf.h> vary, but that doesn't match the spec and breaks libelf so it's gone away. Implement the variation here by defining our own type locally for this. ok deraadt@
* Implement support for DT_GNU_HASH, taking all the interesting bitsguenther2018-11-281-17/+107
| | | | | | | | | | from Matt Dillon's implementation in DragonFlyBSD commit 7629c631. One difference is that as long as DT_HASH is still present, ld.so will use that to get the total number of symbols rather than walking the GNU hash chains. Note that the GPLv2 binutils we have doesn't support DT_GNU_HASH, so this only helps archs were lld is used. ok kettenis@ mpi@
* Finish ld.so's transition to GNU_RELRO: eliminate support for usingguenther2018-11-161-69/+2
| | | | | | | | | | __got_{start,end} to find a region to mark read-only. It was only used for binaries that didn't have a GNU_RELRO segment, but all archs have been using that for over a year. Since support for insecure-PLT layouts on powerpc and alpha have been removed, all archs handle GNU_RELRO the same way and the support can be moved from the MD code to the MI code. ok mpi@
* Borrow an idea from DragonFly BSD: factor out the "does this symbol match whatguenther2018-11-161-38/+54
| | | | | | | | | | | | we're looking up?" logic from _dl_find_symbol_obj() into matched_symbol(), so that the former is just the "iterate across the hash" logic. matched_symbol() returns zero on "not found", one on "found strong symbol", and negative one on "found weak symbol". The last of those lets the caller give up on this object after finding a weak symbol, as there's no point in continuing to search for a strong symbol in the same object. ok mpi@
* Put all the symbol lookup parameters (except the object being searched) andguenther2018-11-151-72/+60
| | | | | | | | the return pointers into a structure and pass that to _dl_find_symbol_obj(). Set sl->sl_obj_out in _dl_find_symbol_obj() so that the callers don't need to each record the object. ok mpi@
* Use int, not char*, for booleansguenther2018-10-221-2/+2
| | | | ok millert@
* Add support for the DF_TEXTREL flag.kettenis2018-03-091-1/+3
| | | | ok patrick@, millert@
* On fatal errors, kill ourselves with thrkill(0,9,NULL) instead ofguenther2017-01-241-3/+3
| | | | | | | | simply exiting, via helper functions _dl_die(), _dl_diedie(), and _dl_oom(). prompted by a complaint from jsing@ ok jsing@ deraadt@
* Unbreak $ORIGIN support when only one of DT_RUNPATH and DT_RPATH is usedguenther2017-01-241-5/+7
|
* remove line that slipped in with rev 1.77 but doesn't belong there; ok sthen@naddy2017-01-231-2/+1
|
* Whoops, lost the adjustment of DT_RUNPATH value as a DT_STRTAB value.guenther2017-01-231-1/+3
| | | | problem reported by semarie@
* Mark a bunch of stuff staticguenther2017-01-231-2/+3
| | | | ok kettenis@
* Add support for DT_RUNPATH and DT_FLAGSguenther2017-01-221-13/+30
| | | | ok kettenis@
* Implement support for DT_INIT_ARRAY, DT_FINI_ARRAY and DT_PREINIT_ARRAY.kettenis2016-08-231-1/+8
| | | | | | | Don't skip DT_INIT and DT_FINI for the main executable. This matches what Linux and Solaris do. ok guenther@
* Look for a PT_GNU_RELRO section per object and, if present, mprotect thatguenther2016-08-081-14/+36
| | | | | | | | range instead of the [__got_start, __got_end) range. On many archs this will cover _DYNAMIC too, so move up the DT_DEBUG handling to before relocations and the mprotect are done. ok kettenis@
* Remove prebind support: binding to symbol table indices is too fragileguenther2016-07-041-4/+1
| | | | | | for our development process. ok kettenis@ deraadt@
* Export environ and __progname, making the latter a copy of just the filenameguenther2016-03-201-4/+3
| | | | | | | portion like crt0 does. This is prep for eliminating _dl_fixup_user_env() Mark almost everything in resolve.h as hidden, to improve code generation. ok kettenis@ mpi@ "good time" deraadt@
* Delete remnants of grpsym cache setting during symbol search: it's done atguenther2016-01-241-27/+2
| | | | | | | | load time only nwo. Rename _dl_searchnum and lastlookup to _dl_grpsym_gen and grpsym_gen as they are generation numbers. Merge _dl_newsymsearch() into _dl_cache_grpsym_list_setup(). ok millert@
* Lacking precise dependency-from-relocation tracking, a nodelete objectguenther2016-01-241-5/+11
| | | | | | | needs to lock down the entire load group, not just the specific object. problem report and ok sthen@ been in snaps for a week
* Factor out the logic for mprotecting the memory between two symbols intoguenther2015-11-021-1/+43
| | | | | | | | a new MI routine _dl_protect_segment(), and use that for protecting the GOT and--on some archs--the PLT. Amazing testing turnaround by miod@, who apparently violated relativity to get back results on some archs as fast as he did
* delete annoying white space that annoyderaadt2015-01-221-4/+4
|
* check all memory allocations; ok miod@ guenther@otto2014-07-101-2/+5
|
* Move to a non-zeroing _dl_malloc, a _dl_calloc and _dl_reallocarry andotto2014-06-211-2/+3
| | | | fix _dl_strdup to return NULL instead of crash; ok deraadt@
* unsigned char for ctypederaadt2013-11-271-2/+2
| | | | ok okan kettenis
* prototype & void * math cleanupderaadt2013-11-131-60/+54
| | | | ok guenther
* Introduce ltrace(1). This tool works with ld.so to inject utrace record formiod2013-06-011-1/+3
| | | | | | | | | | | | | | | | | each plt call, allowing to trace a binary linked against shared library at the public function call level. To do so, ltrace(1) sets up some environment variables to enable plt tracing in ld.so, and invokes ktrace(2) for utrace events. ld.so will force lazy binding and will send an utrace record in the plt resolver, without updating the plt. Minimal filtering capabilities are provided, inspired by Solaris' truss -u, to limit tracing to libraries and/or symbol names. Non-traced libraries and symbols will have the regular resolver processing, with the expected plt update. "Get it in" deraadt
* Implement symbol caching and RELACOUNT/RELCOUNT optimizations.guenther2013-05-081-1/+5
| | | | | | Much assistance and testing by miod ok miod@
* - Add ORIGIN, OSNAME, OSREL and PLATFORM substitution support for rpaths.kurt2013-04-051-3/+165
| | | | Improvements and okay matthew@, millert@, guenther@
* - Parse colon separated paths into NULL terminated arrays of stringkurt2013-03-201-1/+7
| | | | | pointers to prepare for adding rpath ORIGIN support. okay matthew@ millert@
* Fix LD_DEBUG=1 regression introduced by previous commit.matthew2012-07-061-2/+3
| | | | ok kurt
* Add support for DF_1_NOOPEN. Based on an origional diff from matthew@.kettenis2012-06-141-12/+20
| | | | ok matthew@
* Add support for getting some flags from DT_FLAGS_1: new flagsguenther2011-11-281-3/+13
| | | | | | DF_1_NODELETE and DF_1_INITFIRST, as well as DF_1_NOW and DF_1_GLOBAL. Committing for kurt@ who worked out the final version; ok guenther@ drahn@
* Backout the dynamic linker speed improvement diff for now, it stillsthen2011-06-271-123/+6
| | | | has some issues. Discussed with various, ok drahn@
* No need to call _dl_newsymsearch() twice; ok drahn@otto2011-05-261-4/+2
|
* Dynamic linker speed improvement diff. tested by several sinc k2k11.drahn2011-05-221-6/+125
| | | | get it in tree now deraadt@, ok by several ports folks. Thanks for the testing.
* Fix previous. On i386, library.c isn't compiledotto2011-05-101-1/+7
|
* Search loaded libs first and add support for SONAME matching. ok drahn@kurt2010-10-251-16/+4
|
* Make _dl_searchnum signed as originally intended.drahn2010-08-111-4/+5
| | | | Pointed out by patrick keshish.
* When generating grpsym lists, avoid duplicates without searching thedrahn2010-07-011-1/+26
| | | | | already generated list. Speeds up startup on deeply nested dlopen binaries. ok guenther@, tested by ckuethe@ and ajacoutot@
* Constantly fill in the program header pointer and count in elf_object_tkurt2008-05-051-9/+7
| | | | | for all objects which simplifies phdr usage in a few places. "go for it" drahn@
* Improve support for shared libs linked at non-zero addreses:kurt2008-04-091-18/+18
| | | | | | | | | | | | | | - rename private values in struct elf_object to better describe their meaning: s/load_offs/obj_base/ "object's address '0' base" s/load_addr/load_base/ "The base address of the loadable segments" - gdb needs the obj_base value so swap positions with load_base in struct elf_object - fix a few occurrences of where load_base was used instead of obj_base. With help and okay drahn@
* prebind - how to prelink a binary without throwing security out the windowdrahn2006-05-031-1/+14
| | | | | | | | Prelink fixes the address of libraries making 'return to libc' attacks trival, prebind uses a different method to achieve most of the same gains, however without adding any security conerns. Still under development, now in-tree.
* add RTLD_NOW support to dlopen and propogate -z now to dep libs.kurt2005-11-091-2/+2
| | | | ok drahn@
* using _dl_link_grpsym to increment refcounts made _dl_notify_unload_shlibkurt2005-10-211-2/+1
| | | | | | simpler, however it broke ldd refcount output. use _dl_link_child to increment refcounts and adjust _dl_notify_unload_shlib to match. work by drahn@ and myself. ok drahn@