about summary refs log tree commit diff
path: root/src/ldso
Commit message (Collapse)AuthorAgeFilesLines
* fix error reporting for dlsym with global symbolsRich Felker2012-05-041-1/+2
|
* overhaul SSP support to use a real canaryRich Felker2012-05-031-4/+3
| | | | | | | | | | | | | pthread structure has been adjusted to match the glibc/GCC abi for where the canary is stored on i386 and x86_64. it will need variants for other archs to provide the added security of the canary's entropy, but even without that it still works as well as the old "minimal" ssp support. eventually such changes will be made anyway, since they are also needed for GCC/C11 thread-local storage support (not yet implemented). care is taken not to attempt initializing the thread pointer unless the program actually uses SSP (by reference to __stack_chk_fail).
* gdb shared library debugging supportRich Felker2012-04-251-5/+32
| | | | | provide the minimal level of dynamic linker-to-debugger glue needed to let gdb find loaded libraries and load their symbols.
* first attempt at enabling stack protector supportRich Felker2012-04-241-0/+7
| | | | | | | | the code is written to pre-init the thread pointer in static linked programs that pull in __stack_chk_fail or dynamic-linked programs that lookup the symbol. no explicit canary is set; the canary will be whatever happens to be in the thread structure at the offset gcc hard-coded. this can be improved later.
* make dlerror produce informative resultsRich Felker2012-04-231-4/+15
| | | | | | | | | | note that dlerror is specified to be non-thread-safe, so no locking is performed on the error flag or message aside from the rwlock already held by dlopen or dlsym. if 2 invocations of dlsym are generating errors at the same time, they could clobber each other's results, but the resulting string, albeit corrupt, will still be null-terminated. any use of dlerror in such a situation could not be expected to give meaningful results anyway.
* make dlerror conform to posixRich Felker2012-03-231-6/+16
| | | | | | | the error status is required to be sticky after failure of dlopen or dlsym until cleared by dlerror. applications and especially libraries should never rely on this since it is not thread-safe and subject to race conditions, but glib does anyway.
* protect against cancellation in dlopenRich Felker2012-02-071-2/+5
| | | | | | | i'm not sure that it's "correct" for dlopen to block cancellation when calling constructors for libraries it loads, but it sure seems like the right thing. in any case, dlopen itself needs cancellation blocked.
* reduce some wasted space in dso structureRich Felker2012-02-071-3/+3
|
* run ctors/dtors for shared objects loaded with dlopenRich Felker2012-02-061-0/+1
|
* add support for init/finit (constructors and destructors)Rich Felker2012-02-061-0/+19
| | | | | | | | | | this is mainly in hopes of supporting c++ (not yet possible for other reasons) but will also help applications/libraries which use (and more often, abuse) the gcc __attribute__((__constructor__)) feature in "C" code. x86_64 and arm versions of the new startup asm are untested and may have minor problems.
* include dummied-out dlopen and dlsym functions for static binariesRich Felker2012-02-031-1/+10
| | | | | | | | | these don't work (or do anything at all) but at least make it possible to static link programs that insist on "having" dynamic loading support...as long as they don't actually need to use it. adding real support for dlopen/dlsym with static linking is going to be significantly more difficult...
* fix broken copy relocations from dynamic linker cleanupRich Felker2012-01-231-1/+4
| | | | | this issue affected programs which use global variables exported by non-libc libraries.
* dynamic linker support for PIE binaries (position-independent main program)Rich Felker2012-01-231-3/+6
| | | | | even with this change, PIE will not work yet due to deficiencies in the crt1.o startup code.
* cleanup dynamic linker, removing some code duplicationRich Felker2012-01-231-80/+66
|
* fix dynamic linker not to depend on DYNAMIC ptr in 0th entry of GOTRich Felker2012-01-201-3/+12
| | | | | | | | | | this fixes an issue using gold instead of gnu ld for linking. it also should eliminate the need of the startup code to even load/pass the got address to the dynamic linker. based on patch submitted by sh4rm4 with minor cosmetic changes. further cleanup will follow.
* fix char signedness bug in dynlinker hash functionRich Felker2012-01-171-1/+2
| | | | | this only affects non-ascii symbol names, which are probably not in use anyway..
* dlsym entry point for armRich Felker2011-10-011-0/+6
|
* dynamic linker entry point for armRich Felker2011-10-011-0/+14
| | | | mildly tested, seems to work
* disable dynamic linking/loading code in static libc builds, for nowRich Felker2011-09-181-0/+2
| | | | | it does not work, but some configure scripts will falsely detect support then generate programs that crash when they call dlopen.
* fix RTLD_NEXT on x86_64Rich Felker2011-09-031-1/+1
| | | | | the return address was being truncated to 32 bits, preventing the dlsym code from determining which module contains the calling code.
* ldso: move the suid/secure check code closer to env/auxv processingRich Felker2011-08-161-7/+7
| | | | | | this does not change behavior, but the idea is to avoid letting other code build up between these two points, whereby the environment variables might get used before security it checked.
* honor AT_SECURE aux vector flagRich Felker2011-08-161-2/+2
|
* RTLD_NEXT supportRich Felker2011-08-164-3/+32
| | | | | the asm wrapper is needed to get the return address without compiler-specific extensions.
* LD_PRELOAD supportRich Felker2011-08-161-0/+20
|
* when resolving symbols with only weak defs, use first def, not last defRich Felker2011-07-251-0/+1
|
* fix resolution of weak symbols (hopefully right now) and vdsoRich Felker2011-07-241-3/+9
|
* load vdso, if present, into the dso listRich Felker2011-07-241-2/+31
|
* simplify dynamic linker startupRich Felker2011-07-241-23/+17
| | | | | | instead of creating temp dso objects on the stack and moving them to the heap if dlopen/dlsym are used, use static objects to begin with, and just donate them to malloc if we no longer need them.
* fix dlopen UB due to longjmp/volatile rules violationRich Felker2011-07-011-1/+1
|
* simple rpath support (no token expansion yet) for dynamic linkerRich Felker2011-06-301-2/+8
|
* textrel support, cheap and uglyRich Felker2011-06-291-0/+5
|
* reclaim the memory wasted by dynamic linking for use by mallocRich Felker2011-06-281-0/+39
|
* use load address from elf header if possibleRich Felker2011-06-281-1/+1
| | | | | | | | | this is mostly useless for shared libs (though it could help for prelink-like purposes); the intended use case is for adding support for calling the dynamic linker directly to run a program, as in: ./libc.so ./a.out foo this usage is not yet supported.
* make dynamic linker relocate the main program image last, after all libsRich Felker2011-06-281-0/+1
| | | | | prior to this change, copy relocations for initialized pointer variables would not reflect the relocated contents of the pointer.
* fix stale pointer issue in dynamic linker with dlopenRich Felker2011-06-261-0/+1
|
* don't leave the lock held on dlopen failure..Rich Felker2011-06-261-2/+2
|
* add RTLD_DEFAULT supportRich Felker2011-06-261-1/+2
|
* in dlopen: don't use null pointerRich Felker2011-06-261-3/+3
| | | | deps can be null if a library has no dependencies (such as libc itself)
* fix resolving symbols in objects loaded in RTLD_LOCAL modeRich Felker2011-06-261-0/+11
| | | | | | 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.
* experimental dlopen/dlsym and dynlink changes needed to support themRich Felker2011-06-261-8/+125
|
* error handling in dynamic linkingRich Felker2011-06-261-2/+19
| | | | | | 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.
* fix some symbol resolution issues in dynamic linkerRich Felker2011-06-251-4/+4
| | | | | 1. search was wrongly beginning with lib itself rather than dso head 2. inconsistent resolution of function pointers for functions in plt
* handle library paths better (ignore empty path components, etc.)Rich Felker2011-06-251-3/+5
|
* fix possible (questionable) strict aliasing violations and ptr arithRich Felker2011-06-251-3/+3
|
* proper path searching for dynamic linkerRich Felker2011-06-251-14/+38
| | | | | first, use $LD_LIBRARY_PATH unless suid. if that fails, read path from /etc/ld-musl-$ARCH.path and fallback to a builtin default.
* discard dso descriptors after performing relocationsRich Felker2011-06-251-0/+12
| | | | | eventually (once dlopen exists) this behavior will be conditional on dlopen/dlsym not being reachable.
* keep track of which dsos have been relocatedRich Felker2011-06-251-0/+1
|
* prepare support for LD_LIBRARY_PATH (checking suid/sgid safety)Rich Felker2011-06-231-0/+6
| | | | | | | | | | 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.
* make ldso asm more uniform with rest of codebase (no unnecessary suffixes)Rich Felker2011-06-191-12/+12
|
* x86_64: ensure that dtor pointer passed to app is 0 so it won't be usedRich Felker2011-06-191-0/+1
| | | | | leaving it uninitialized caused unpredictable crashes or worse due to calling an indeterminate function pointer.