summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf
Commit message (Collapse)AuthorAgeFilesLines
* MFC r266411:kib2014-05-251-3/+3
| | | | Fix LD_LIBMAP.
* MFC r264481:kib2014-04-211-0/+43
| | | | | Add dwarf annotations to the amd64 _rtld_bind_start to allow debuggers to unwind around the calls from PLT to binder.
* MFC r262277:davidxu2014-02-271-7/+5
| | | | | | | | | | | | | | | | | | malloc_aligned() may not leave enough space for pointer to allocated memory, saving the pointer will overwrite bytes belongs to another memory block unexpectly, to fix the problem, use (allocated address + sizeof(void *)) as initial value, and slip to next aligned address, so maximum extra bytes is sizeof(void *) + align - 1. Tested by: Andre Albsmeier < mail at ma17 dot ata dot myota dot orgndre > MFC r262334: Increase alignment to size of pointer if the alignment is too small. Some modules do not align data at least to size of pointer, they uses a smaller alignment, but our pointer should be aligned to its native boundary, otherwise on some platforms, hardware alignment checking will cause bus error.
* MFC: r262136brueffer2014-02-241-5/+1
| | | | | | | Remove the 3rd clause ("advertising clause") of the BSD license as permitted by the University of Berkeley on July 22, 1999. Reviewed by: imp
* MFC r259044:kib2013-12-131-15/+20
| | | | | | | For variant II static TLS, properly align tls segments. MFC r259072: Cast Elf_Addr to void * to match the free_aligned() argument type.
* MFC r259043:kib2013-12-132-0/+32
| | | | | Build an allocator for the aligned memory on top of the rtld-private malloc.
* Implement support for the interpose dso flag.kib2013-10-072-2/+33
| | | | | | | | Requested by: bf Reviewed by: kan Sponsored by: The FreeBSD Foundation MFC after: 1 week Approved by: re (glebius)
* Populate .rld_map on MIPS for debuggersemaste2013-10-021-5/+1
| | | | | | | | | On MIPS the .dynamic section is read-only, so the pointer to rtld information for debuggers cannot be stored there (in DT_DEBUG). Instead, a special section .rld_map is used. Sponsored by: DARPA, AFRL Approved by: re (delphij)
* Make the directory mapping functionality, which was previously onlydes2013-09-213-9/+5
| | | | | | | | | available in 32-bit compatibility mode, unconditional. Overhaul the man page, which had evolved more by accretion than by design. Approved by: re (gjb) MFC after: 3 weeks
* Revert r253748,253749avg2013-07-282-0/+2
| | | | | | This WIP should not have been committed yet. Pointyhat to: avg
* remove needless inclusion of machine/cpu.h in userlandavg2013-07-282-2/+0
| | | | MFC after: 21 days
* Properly terminate the result string for intermediate results, tokib2013-04-291-1/+2
| | | | | | | | allow the final strcpy() to start at the intended place. Reported and tested by: pgj Pointy hat to: kib MFC after: 3 days
* The origin_subst_one() function limits the length of the string tokib2013-04-151-73/+75
| | | | | | | | | | | | | | | | | | PATH_MAX after the token substitution. This is wrong, because origin_subst_one() performs the substitution on the whole rpath and similar strings, which contain several pathes separated by colon. As result, long (but correct) rpath consisting of many path elements is rejected by the function. Correct the problem by rewriting the origin_subst_one() to perform two passes, first pass to calculate the number of substitutions to be performed, and second pass to generate the resulting string. Second pass allocates the memory for the result based on the count from the first pass, without enforcing a limit. Reported and tested by: pgj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Map libraries linked with -Ttext-segment=base_addr at base_addr.tijl2013-02-271-1/+1
| | | | | | | | | Normal libraries have base address 0 and are unaffected by this change. PR: 176216 Submitted by: Damjan Jovanovic <damjan.jov@gmail.com> Reviewed by: kib MFC after: 1 week
* Avoid use of register variables, which some compilers (e.g. clang)nwhitehorn2013-02-081-9/+5
| | | | | | don't like. It makes the code a little clearer as well. MFC after: 1 week
* When building for ARM EABI link against libgcc for the __aeabi_* functions.andrew2013-01-191-0/+10
|
* Use absolute path for /usr/libexec/ld-elf.so.1 symlink.pjd2012-12-041-2/+2
| | | | | | | | | Requested by: kan, kib Use -h flags for chflags, so we won't remove 'schg' flag from system's /libexec/ld-elf.so.1. MFC after: 2 weeks
* Do not change entire BINDIR, it might be needed later, just changepjd2012-12-041-2/+2
| | | | | | symlink target. MFC after: 2 weeks
* Change /usr/libexec/ld-elf.so.1 to point at ../../libexec/ld-elf.so.1pjd2012-12-041-1/+1
| | | | | | | | | | | instead of /libexec/ld-elf.so.1. Below in the Makefile we execute 'chflags noschg ${DESTDIR}/usr/libexec/ld-elf.so.1', which follows symlink and removes 'schg' flag from system's /libexec/ld-elf.so.1 instead of the one in DESTDIR. It is also more friendly to use replative paths in symlink in case of jail/chroot environments. Obtained from: WHEEL Systems MFC after: 2 weeks
* rtld: Fix fd leak with parallel dlopen and fork/exec.jilles2012-11-042-4/+4
| | | | | | | | | | | | | | | | Rtld did not set FD_CLOEXEC on its internal file descriptors; therefore, such a file descriptor may be passed to a process created by another thread running in parallel to dlopen() or fdlopen(). No other threads are expected to be running during parsing of the hints and libmap files but the file descriptors need not be passed to child processes so add O_CLOEXEC there as well. This change will break fdlopen() (as used by OpenPAM) on kernels without F_DUPFD_CLOEXEC (added in July). Note that running new userland on old kernels is not supported. Reviewed by: kib
* Do not reference z_nodeflib for !objgiven case, thus fixing LD_PRELOADkib2012-09-191-4/+4
| | | | | | | for a non-absolute path. PR: bin/171604 MFC after: 3 days
* Do not call process_nodelete with NULL object pointer.kan2012-08-201-1/+2
| | | | | | | | The place where the function is called can be reached if object loading and relocation fails too, in which case obj pointer will be NULL. Do not call process_nodelete then, or crash will follow. Pointy hat to: kan
* Merging of projects/armv6, part 2gonzo2012-08-151-1/+14
| | | | Handle TLS for ARMv6 and ARMv7
* Pospone the DF_1_NODELETE processing until object DAG is fully loaded.kan2012-08-141-7/+27
| | | | | | | | | Trying to up the reference from the load loop risks missing dependencies that have not been loaded yet. MFC afer: 1 week Reported by: nox Reviewd by: kib
* Ensure we align the stack to 8 bytes in rtld.andrew2012-08-041-2/+4
| | | | | | | This is not strictly required with the current ABI but will be when we switch to the ARM EABI. The aapcs requires the stack to be 4 byte aligned at all times and 8 byte aligned when calling a public subroutine where the current ABI only requires sp to be a multiple of 4.
* Parse notes only after object structure had been allocated.kan2012-08-031-2/+2
| | | | | Reported by: kargl Reviewed by: kib (sans whitespace)
* Import the DragonFly BSD commit 4f0bc915b65fcf5a23214f6d221d65c80be68ad4kib2012-07-153-72/+276
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | by John Marino <draco@marino.st>, with the following (edited) commit message Date: Sat, 24 Mar 2012 06:40:50 +0100 Subject: [PATCH 1/1] rtld: Implement DT_RUNPATH and -z nodefaultlib DT_RUNPATH is incorrectly being considered as an alias of DT_RPATH. The purpose of DT_RUNPATH is to have two different types of rpath: one that can be overridden by the environment variable LD_LIBRARY_PATH and one that can't. With the currently implementation, LD_LIBRARY_PATH will always trump any embedded rpath or runpath tags. Current path search order by rtld: ================================== LD_LIBRARY_PATH DT_RPATH / DT_RUNPATH (always the same) ldconfig hints file (default: /var/run/ld-elf.so.hints) /usr/lib New path search order by rtld: ============================== DT_RPATH of the calling object if no DT_RUNPATH DT_RPATH of the main binary if no DT_RUNPATH and binary isn't calling obj LD_LIBRARY_PATH DT_RUNPATH ldconfig hints file /usr/lib The new path search matches how the linux runtime loader works. The other major added feature is support for linker flag "-z nodefaultlib". When this flag is passed to the linker, rtld will skip all references to the standard library search path ("/usr/lib" in this case but it could handle more color delimited paths) except in DT_RPATH and DT_RUNPATH. New path search order by rtld with -z nodefaultlib flag set: ============================================================ DT_RPATH of the calling object if no DT_RUNPATH DT_RPATH of the main binary if no DT_RUNPATH and binary isn't calling obj LD_LIBRARY_PATH DT_RUNPATH ldconfig hints file (skips all references to /usr/lib) FreeBSD notes: - we fixed some bugs which were submitted to DragonFly and merged there as commit 1ff8a2bd3eb6e5587174c6a983303ea3a79e0002; - we added LD_LIBRARY_PATH_RPATH environment variable to switch to the previous behaviour of considering DT_RPATH a synonym for DT_RUNPATH; - the FreeBSD default search path is /lib:/usr/lib and not /usr/lib. Reviewed by: kan MFC after: 1 month MFC note: flip the ld_library_path_rpath default value for stable/9
* Ensure that for the object which is a dependency for some filtee,kib2012-06-271-40/+84
| | | | | | | | | | | | | | | | relocations are performed before the object's initializer is called. When dlopen()ing an object, relocate the whole DAG rooted in the object instead of only relocating the object itself and list of newly loaded dependencies. Reversed sequence currently can occur if the same object is a dependency for both filtee and filter, since filtees are loaded typically during the relocation processing, when some filter dependencies might be already loaded but not relocated yet. Reported and tested by: swills Reviewed by: kan MFC after: 1 week
* Eliminate the static buffer used to read the first page of the mappedkib2012-06-141-62/+70
| | | | | | | | | | | | | | | object, and eliminate the pread(2) call as well [1]. Mmap the first page of the object temporaly, and unmap it on error or last use. Potentially, this leaves one-page gap between succeeding dlopen(3), but there are other mmap(2) consumers as well. Fix several cases were the whole mapping of the object leaked on error. Use MAP_PREFAULT_READ for mmap(2) calls which map real object pages [2]. Insipired by the patch by: Ian Lepore <freebsd damnhippie dyndns org> [1] Suggested by: alc [2] MFC after: 2 weeks
* open the resolved pathbapt2012-05-051-4/+4
| | | | | | | fix debug message Submitted by: John Marino <draco@marino.st> Approved by: des (mentor)
* Work around a situation where symlook_obj() could be called for thekib2012-05-051-3/+5
| | | | | | | | | | | | | object for which digest_dynamic1() was not done yet. Just return EINVAL and do not try to dereference NULL buckets hash array. This seems to happen on ia64 for rtld object itself, where the R_IA_64_FPTR64LSB relocations require symbol lookup. The dynamic linker itself does not rely on identity of the C-level function pointers (i.e. function descriptors). Reported and reviewed by: marcel MFC after: 8 days
* Add two special directives to libmap.conf:bapt2012-04-301-30/+132
| | | | | | | | | | | | | | | include <file>: Parse the contents of file before continuing with the current file. includedir <dir>: Parse the contents of every file in dir that ends in .conf before continuing with the current file. Any file or directory encountered while processing include or includedir directives will be parsed exactly once, even if it is encountered multiple times. Reviewed by: kib, des Approved by: des (mentor) MFC after: 1 month
* Add GNU hash support for rtld.kib2012-04-309-19/+163
| | | | | | | Based on dragonflybsd support for GNU hash by John Marino <draco marino st> Reviewed by: kan Tested by: bapt MFC after: 2 weeks
* Split the symlook_obj1 into a loop iterating over the ELF object symbolkib2012-04-302-95/+116
| | | | | | | | | | hash elements, and a helper matched_symbol() which match the given hash entry and request, performing needed type and version checks. Based on dragonflybsd support for GNU hash by John Marino <draco marino st> Reviewed by: kan Tested by: bapt MFC after: 2 weeks
* Fix a missed file in r234580: replace the now-obsolete powerpc_mb() withnwhitehorn2012-04-231-2/+2
| | | | regular mb().
* Propagate the current state of rtld_bind_lock to dlopen_object() callskib2012-04-121-16/+23
| | | | | | | | | through the filter loading call chain. This fixes attempts to write-lock the already locked rtld_bind_lock when filter loading is initiated by relocation of dlopening dso. Reported and tested by: Taku YAMAMOTO <taku tackymt homeip net> MFC after: 1 week
* Properly handle absent AT_CANARY aux entry.kib2012-04-051-1/+2
| | | | | Submitted by: Andrey Zonov <andrey zonov org> MFC after: 3 days
* Remove extra blank line from revious commit.kan2012-04-021-1/+0
| | | | Submitted by: trema
* Do not try to adjust stacks if dlopen_object is called too early.kan2012-04-021-1/+4
| | | | | | | | This is a follow-up to r233231, which fixed similar issue with object initialization code. Reviewed by: kib MFC after: 1 week (with 233231)
* Fix ia64 build after r233655.kib2012-03-291-0/+6
| | | | MFC after: 1 week
* Import DragonFly BSD commitkib2012-03-291-1/+6
| | | | | | | | | | | | | | From: Sascha Wildner <saw@online.de> Date: Fri, 2 Mar 2012 09:15:56 +0000 (+0100) Subject: rtld: Add a special case in do_dlsym() for TLS stored symbols. X-Git-Url: http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/1388aaafe730c85693936aaf9bc6d83fc2d981be?hp=bca4412595a8979ab9f1bf36068c806ce88a667a rtld: Add a special case in do_dlsym() for TLS stored symbols. Submitted-by: Markus Pfeiffer <markus.pfeiffer@morphism.de> Discussed with: kan MFC after: 1 week
* Prevent rtld_verify_object_versions() from being called several timeskib2012-03-272-0/+5
| | | | | | | | | | for the same object. This can happen when object is a dependency of the dlopen()ed dso. When called several times, we waste time due to unneeded processing, and memory, because obj->vertab is allocated anew on each iteration. Reviewed by: kan MFC after: 2 weeks
* Remove libssp_nonshared from the rtld linking set. The only use for thekib2012-03-242-1/+2
| | | | | | | library was definition for the weak alias of __stack_chk_fail. No objections from: kan MFC after: 2 weeks
* Provide short-circuit exit(3) implementation for rtld.kib2012-03-241-0/+11
| | | | | | | | There is no atexit finalizers in rtld to call on rtld exiting (due to errors). Submitted by: bde No objections from: kan MFC after: 2 weeks
* Before jumping to application's entry point set ra == pc in ordergonzo2012-03-231-1/+2
| | | | to let backtracing routine know to go no further.
* Remove superfluous extern keywords.kib2012-03-231-10/+10
| | | | MFC after: 2 weeks
* Centralize the calculation of the top source directory. Thiskib2012-03-231-2/+3
| | | | | | | | simplifies the build of rtld with partial checkout, allowing to override only one place to reference other tree. Submitted by: bde MFC after: 2 weeks
* Implement xstrdup() using strlen()/xmalloc()/memcpy() alreadykib2012-03-231-7/+8
| | | | | | | presented in rtld, instead of pulling in libc strdup(). Submitted by: bde MFC after: 2 weeks
* Use xmalloc() instead of malloc() in the places where malloc() callskib2012-03-225-19/+20
| | | | | | | | | | | | | | | are assumed to not fail. Make the xcalloc() calling conventions follow the calloc(3) calling conventions and replace unchecked calls to calloc() with calls to xcalloc(). Remove redundand declarations from xmalloc.c, which are already present in rtld.h. Reviewed by: kan Discussed with: bde MFC after: 2 weeks
* Remove the fragments which are not needed on FreeBSD. The caltechkib2012-03-221-18/+0
| | | | | | | malloc hardly would ever be updated. Reviewed by: bde, kan MFC after: 2 weeks
OpenPOWER on IntegriCloud