Commit Graph

16 Commits

Author SHA1 Message Date
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 d19adeec52 make ldso asm more uniform with rest of codebase (no unnecessary suffixes) 2011-06-19 22:42:10 -04:00
Rich Felker 779165e6d4 x86_64: ensure that dtor pointer passed to app is 0 so it won't be used
leaving it uninitialized caused unpredictable crashes or worse due to
calling an indeterminate function pointer.
2011-06-19 08:33:27 -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
Rich Felker 41d518360f various changes in preparation for dynamic linking support
prefer using visibility=hidden for __libc internal data, rather than
an accessor function, if the compiler has visibility.

optimize with -O3 for PIC targets (shared library). without heavy
inlining, reloading the GOT register in small functions kills
performance. 20-30% size increase for a single libc.so is not a big
deal, compared to comparaible size increase in every static binaries.

use -Bsymbolic-functions, not -Bsymbolic. global variables are subject
to COPY relocations, and thus binding their addresses in the library
at link time will cause library functions to read the wrong (original)
copies instead of the copies made in the main program's bss section.

add entry point, _start, for dynamic linker.
2011-02-24 16:37:21 -05:00