about summary refs log tree commit diff
path: root/src/ldso
Commit message (Collapse)AuthorAgeFilesLines
* fix bug caused by main app & libc having map set; cannot free themRich Felker2012-08-271-1/+1
|
* dladdr support for dynamic linker (nonstandard extension)Rich Felker2012-08-262-0/+95
| | | | | | | | | based on patches submitted by boris brezillon. this commit also fixes the issue whereby the main application and libc don't have the address ranges of their mappings stored, which was theoretically a problem for RTLD_NEXT support in dlsym; it didn't actually matter because libc never calls dlsym, and it seemed to be doing the right thing (by chance) for symbols in the main program as well.
* fix bug in gnu hash lookup on dlsym(handle, name) lookupsRich Felker2012-08-251-1/+1
| | | | | | wrong hash was being passed; just a copy/paste error. did not affect lookups in the global namespace; this is probably why it was not caught in testing.
* clean up search_vec usage for vdsoRich Felker2012-08-251-2/+2
|
* use new search_vec function to find vdso in dynamic linkerRich Felker2012-08-251-4/+2
|
* ensure canary is setup if stack-prot libs are dlopen'd into non-ssp appRich Felker2012-08-251-1/+4
| | | | | | previously, this usage could lead to a crash if the thread pointer was still uninitialized, and otherwise would just cause the canary to be zero (less secure).
* add gnu hash support in the dynamic linkerRich Felker2012-08-251-12/+85
| | | | based on the patches contributed by boris brezillon.
* make dynamic linker report all failures before exitingRich Felker2012-08-181-2/+6
| | | | | | | | | before, only the first library that failed to load or symbol that failed to resolve was reported, and then the dynamic linker immediately exited. when attempting to fix a library compatibility issue, this is about the worst possible behavior. now we print all errors as they occur and exit at the very end if errors were encountered.
* fix bug computing argc when invoking ld-musl-mips.so.1 progname ...Rich Felker2012-08-171-3/+3
|
* fix bug dlsym bug that slipped in during dynamic linker cleanupRich Felker2012-08-071-1/+1
|
* dlsym RTLD_NEXT support for mipsRich Felker2012-08-051-0/+15
| | | | untested
* more changes that were lost when committing mips dynamic linkerRich Felker2012-08-051-0/+4
|
* fix change lost in the process of integrating mips dynamic linkerRich Felker2012-08-051-2/+2
|
* mips dynamic linker supportRich Felker2012-08-052-0/+49
| | | | | | | | | | | | | | | | | | not heavily tested, but the basics are working. the basic concept is that the dynamic linker entry point code invokes a pure-PIC (no global accesses) C function in reloc.h to perform the early GOT relocations needed to make the dynamic linker itself functional, then invokes __dynlink like on other archs. since mips uses some ugly arch-specific hacks to optimize relocating the GOT (rather than just using the normal DT_REL[A] tables like on other archs), the dynamic linker has been modified slightly to support calling arch-specific relocation code in reloc.h. most of the actual mips-specific behavior was developed by reading the output of readelf on libc.so and simple executable files. i could not find good reference information on which relocation types need to be supported or their semantics, so it's possible that some legitimate usage cases will not work yet.
* more cleanup of dynamic linker internalsRich Felker2012-08-051-8/+9
|
* more dynamic linker internals cleanupRich Felker2012-08-051-6/+6
| | | | | | changing the string printed for the dso name is not a regression; the old code was simply using the wrong dso name (head rather than the dso currently being relocated). this will be fixed in a later commit.
* dynamic linker internals cleanupRich Felker2012-08-051-5/+7
|
* make dynamic linker tell the debugger its own pathnameRich Felker2012-07-131-0/+5
| | | | | use the main program's PT_INTERP header if possible, since this is sure to be a correct (and hopefully absolute) pathname.
* make dynamic linker depend on -DSHARED not -fPICRich Felker2012-07-111-1/+1
| | | | | | if libc.a is compiled PIC for use in static PIE code, this should not cause the dynamic linker (which still does not support static-linked main program) to be built into libc.a.
* fix lots of breakage on dlopen, mostly with explicit pathnamesRich Felker2012-07-111-14/+21
| | | | | | | | | | | | | | | | | | most importantly, the name for such libs was being set from an uninitialized buffer. also, shortname always had an initial '/' character, making it useless for looking up already-loaded libraries by name, and thus causing repeated searches through the library path. major changes now: - shortname is the base name for library lookups with no explicit pathname. it's initially clear for libraries loaded with an explicit pathname (and for the main program), but will be set if the same library (detected via inodes match) is later found by a search. - exact name match is never used to identify libraries loaded with an explicit pathname. in this case, there's no explicit search, so we can just stat the file and check for inode match.
* fix dlsym RTLD_NEXT supportRich Felker2012-07-071-1/+3
| | | | | | | | previously this was being handled the same as a library-specific, dependency-order lookup on the next library in the global chain, which is likely to be utterly meaningless. instead the lookup needs to be in the global namespace, but omitting the initial portion of the global library chain up through the calling library.
* fix char signedness bug (arm-specific) in dynamic linkerRich Felker2012-06-091-1/+1
|
* treat failure of mprotect in map_library as a fatal load failureRich Felker2012-06-061-9/+9
| | | | | | | | | | | | | | | | | | | | the error will propagate up and be printed to the user at program start time; at runtime, dlopen will just fail and leave a message for dlerror. previously, if mprotect failed, subsequent attempts to perform relocations would crash the program. this was resulting in an increasing number of false bug reports on grsec systems where rwx permission is not possible in cases where users were wrongly attempting to use non-PIC code in shared libraries. supporting that usage is in theory possible, but the x86_64 toolchain does not even support textrels, and the cost of keeping around the necessary information to handle textrels without rwx permissions is disproportionate to the benefit (which is essentially just supporting broken library setups on grsec machines). also, i unified the error-out code in map_library now that there are 3 places from which munmap might have to be called.
* add ldd and main program loading support to dynamic linkerRich Felker2012-05-274-21/+89
|
* cleanup dynamic linker start code cruftRich Felker2012-05-273-13/+6
| | | | | | | | | | | | | two actual issues: one is that __dynlink no longer wants/needs a GOT pointer argument, so the code to generate that argument can be removed. the other issue was that in the i386 code, argc/argv were being loaded into registers that would be call-clobbered, then copied to preserved registers, rather than just being loaded into the proper call-preserved registers to begin with. this cleanup is in preparation for adding new dynamic linker functionality (ability to explicitly invoke the dynamic linker to run a program).
* 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
|