summaryrefslogtreecommitdiff
path: root/src/ldso
AgeCommit message (Collapse)AuthorLines
2012-05-04fix error reporting for dlsym with global symbolsRich Felker-1/+2
2012-05-03overhaul SSP support to use a real canaryRich Felker-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).
2012-04-25gdb shared library debugging supportRich Felker-5/+32
provide the minimal level of dynamic linker-to-debugger glue needed to let gdb find loaded libraries and load their symbols.
2012-04-24first attempt at enabling stack protector supportRich Felker-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.
2012-04-23make dlerror produce informative resultsRich Felker-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.
2012-03-23make dlerror conform to posixRich Felker-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.
2012-02-07protect against cancellation in dlopenRich Felker-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.
2012-02-07reduce some wasted space in dso structureRich Felker-3/+3
2012-02-06run ctors/dtors for shared objects loaded with dlopenRich Felker-0/+1
2012-02-06add support for init/finit (constructors and destructors)Rich Felker-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.
2012-02-03include dummied-out dlopen and dlsym functions for static binariesRich Felker-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...
2012-01-23fix broken copy relocations from dynamic linker cleanupRich Felker-1/+4
this issue affected programs which use global variables exported by non-libc libraries.
2012-01-23dynamic linker support for PIE binaries (position-independent main program)Rich Felker-3/+6
even with this change, PIE will not work yet due to deficiencies in the crt1.o startup code.
2012-01-23cleanup dynamic linker, removing some code duplicationRich Felker-80/+66
2012-01-20fix dynamic linker not to depend on DYNAMIC ptr in 0th entry of GOTRich Felker-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.
2012-01-17fix char signedness bug in dynlinker hash functionRich Felker-1/+2
this only affects non-ascii symbol names, which are probably not in use anyway..
2011-10-01dlsym entry point for armRich Felker-0/+6
2011-10-01dynamic linker entry point for armRich Felker-0/+14
mildly tested, seems to work
2011-09-18disable dynamic linking/loading code in static libc builds, for nowRich Felker-0/+2
it does not work, but some configure scripts will falsely detect support then generate programs that crash when they call dlopen.
2011-09-03fix RTLD_NEXT on x86_64Rich Felker-1/+1
the return address was being truncated to 32 bits, preventing the dlsym code from determining which module contains the calling code.
2011-08-16ldso: move the suid/secure check code closer to env/auxv processingRich Felker-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.
2011-08-16honor AT_SECURE aux vector flagRich Felker-2/+2
2011-08-16RTLD_NEXT supportRich Felker-3/+32
the asm wrapper is needed to get the return address without compiler-specific extensions.
2011-08-16LD_PRELOAD supportRich Felker-0/+20
2011-07-25when resolving symbols with only weak defs, use first def, not last defRich Felker-0/+1
2011-07-24fix resolution of weak symbols (hopefully right now) and vdsoRich Felker-3/+9
2011-07-24load vdso, if present, into the dso listRich Felker-2/+31
2011-07-24simplify dynamic linker startupRich Felker-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.
2011-07-01fix dlopen UB due to longjmp/volatile rules violationRich Felker-1/+1
2011-06-30simple rpath support (no token expansion yet) for dynamic linkerRich Felker-2/+8
2011-06-29textrel support, cheap and uglyRich Felker-0/+5
2011-06-28reclaim the memory wasted by dynamic linking for use by mallocRich Felker-0/+39
2011-06-28use load address from elf header if possibleRich Felker-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.
2011-06-28make dynamic linker relocate the main program image last, after all libsRich Felker-0/+1
prior to this change, copy relocations for initialized pointer variables would not reflect the relocated contents of the pointer.
2011-06-26fix stale pointer issue in dynamic linker with dlopenRich Felker-0/+1
2011-06-26don't leave the lock held on dlopen failure..Rich Felker-2/+2
2011-06-26add RTLD_DEFAULT supportRich Felker-1/+2
2011-06-26in dlopen: don't use null pointerRich Felker-3/+3
deps can be null if a library has no dependencies (such as libc itself)
2011-06-26fix resolving symbols in objects loaded in RTLD_LOCAL modeRich Felker-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.
2011-06-26experimental dlopen/dlsym and dynlink changes needed to support themRich Felker-8/+125
2011-06-26error handling in dynamic linkingRich Felker-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.
2011-06-25fix some symbol resolution issues in dynamic linkerRich Felker-4/+4
1. search was wrongly beginning with lib itself rather than dso head 2. inconsistent resolution of function pointers for functions in plt
2011-06-25handle library paths better (ignore empty path components, etc.)Rich Felker-3/+5
2011-06-25fix possible (questionable) strict aliasing violations and ptr arithRich Felker-3/+3
2011-06-25proper path searching for dynamic linkerRich Felker-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.
2011-06-25discard dso descriptors after performing relocationsRich Felker-0/+12
eventually (once dlopen exists) this behavior will be conditional on dlopen/dlsym not being reachable.
2011-06-25keep track of which dsos have been relocatedRich Felker-0/+1
2011-06-23prepare support for LD_LIBRARY_PATH (checking suid/sgid safety)Rich Felker-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.
2011-06-19make ldso asm more uniform with rest of codebase (no unnecessary suffixes)Rich Felker-12/+12
2011-06-19x86_64: ensure that dtor pointer passed to app is 0 so it won't be usedRich Felker-0/+1
leaving it uninitialized caused unpredictable crashes or worse due to calling an indeterminate function pointer.