Commit Graph

17 Commits

Author SHA1 Message Date
Rich Felker c7debe13ee make dynamic linker relocate the main program image last, after all libs
prior to this change, copy relocations for initialized pointer
variables would not reflect the relocated contents of the pointer.
2011-06-28 14:13:51 -04:00
Rich Felker 9e17b71fa6 fix stale pointer issue in dynamic linker with dlopen 2011-06-26 22:39:34 -04:00
Rich Felker 06933cc724 don't leave the lock held on dlopen failure.. 2011-06-26 22:09:32 -04:00
Rich Felker 97507bde47 add RTLD_DEFAULT support 2011-06-26 21:50:01 -04:00
Rich Felker 0e4dae3d77 in dlopen: don't use null pointer
deps can be null if a library has no dependencies (such as libc itself)
2011-06-26 21:36:44 -04:00
Rich Felker 92ab5d8d15 fix resolving symbols in objects loaded in RTLD_LOCAL mode
basically we temporarily make the library and all its dependencies
part of the global namespace but only for the duration of performing
relocations, then return them to their former state.
2011-06-26 21:21:04 -04:00
Rich Felker 59ab43f5f8 experimental dlopen/dlsym and dynlink changes needed to support them 2011-06-26 19:23:28 -04:00
Rich Felker 6b3d5e508f error handling in dynamic linking
some of the code is not yet used, and is in preparation for dlopen
which needs to be able to handle failure loading libraries without
terminating the program.
2011-06-26 17:39:17 -04:00
Rich Felker 32de61e81a fix some symbol resolution issues in dynamic linker
1. search was wrongly beginning with lib itself rather than dso head
2. inconsistent resolution of function pointers for functions in plt
2011-06-25 22:36:21 -04:00
Rich Felker 49388f3b7b handle library paths better (ignore empty path components, etc.) 2011-06-25 17:49:16 -04:00
Rich Felker 59633c736d fix possible (questionable) strict aliasing violations and ptr arith 2011-06-25 12:26:08 -04:00
Rich Felker 568b8075a4 proper path searching for dynamic linker
first, use $LD_LIBRARY_PATH unless suid. if that fails, read path from
/etc/ld-musl-$ARCH.path and fallback to a builtin default.
2011-06-25 01:56:34 -04:00
Rich Felker e8dbf00a78 discard dso descriptors after performing relocations
eventually (once dlopen exists) this behavior will be conditional on
dlopen/dlsym not being reachable.
2011-06-25 00:47:28 -04:00
Rich Felker 368ba4a0a9 keep track of which dsos have been relocated 2011-06-25 00:18:19 -04:00
Rich Felker b7f6e0c6f8 prepare support for LD_LIBRARY_PATH (checking suid/sgid safety)
the use of this test will be much stricter than glibc and other
typical implementations; the environment will not be honored
whatsoever unless the program is confirmed non-suid/sgid by the aux
vector the kernel passed in. no fallback to slow syscall-based
checking is used if the kernel fails to provide the information; we
simply assume the worst (suid) in this case and refuse to honor
environment.
2011-06-23 22:04:06 -04:00
Rich Felker 596d60c565 dynamic linker 64bit fix: hash table entries are always 32bit 2011-06-18 22:52:01 -04:00
Rich Felker 51e2d83102 experimental dynamic linker!
some notes:
- library search path is hard coded
- x86_64 code is untested and may not work
- dlopen/dlsym is not yet implemented
- relocations in read-only memory won't work
2011-06-18 19:48:42 -04:00