summaryrefslogtreecommitdiff
path: root/ldso/ldso/dl-elf.c
AgeCommit message (Collapse)Author
2019-04-14Fix build with SUPPORT_LD_DEBUG_EARLY enabledKonstantin Vasin
2018-08-10TLS: fix relocation computationChristophe Lyon
* ldso/ldso/dl-elf.c (_dl_load_elf_shared_library): Fix l_tls_initimage computation. * ldso/ldso/ldso.c (_dl_get_ready_to_run): Likewise. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-08-10rtld: Do not protect RELRO segments when we don't use an MMU.Christophe Lyon
Without MMU, we cannot mark memory regions as read-only. * ldso/ldso/dl-elf.c (_dl_protect_relro): Do nothing if __ARCH_USE_MMU__ is defined. Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
2018-02-03bits/mman.h: consolidate header fileWaldemar Brodkorb
Sync with GNU C library and consolidate duplicate non architecture specific defines. MAP_UNINITIALIZED is only defined to 0x4000000 and used by the Linux kernel when CONFIG_MMAP_ALLOW_UNINITIALIZED is enabled. CONFIG_MMAP_ALLOW_UNINITIALIZED is only available for nommu. See Documentation/nommu-mmap.txt.
2017-11-03fix multilib dirWaldemar Brodkorb
Signed-off-by: Alex Potapenko <opotapenko@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2017-06-21remove editor hints for viWaldemar Brodkorb
2017-03-17Search the configured multilibAlexey Neyman
... before falling back to ld.so installation path (it is not the same - gcc uses /lib/ld-uClibc-x86-64.so.0 for uClibc) or default /lib:/usr/lib. This matches glibc behavior (see trusted-dirs.h generated during glibc build). Signed-off-by: Alexey Neyman <stilor@att.net>
2016-06-22ldso: fix dlsym hang when reloading DSOsLeonid Lisovskiy
It can happen under certain cases that the DSO had refcount 0, but was already loaded. (NODELETE flag is set, or it is pulled in via both NEEDED dependency and explicit dlopen()). Add extra reference count for NODELETE objects, this will ensure that the reference count never drops below one. It is improved version of http://lists.busybox.net/pipermail/uclibc/2013-June/047826.html Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
2016-06-22ldso: Consistently set & use DL_OPENED flag in both ld.so and libdlLeonid Lisovskiy
Previously, DL_OPENED flag was set in libdl only and never used. Set it centralized in _dl_load_elf_shared_library() & use it in both ld.so and libdl. Additionally, rename it to DL_OPENED2 for clarity. Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
2016-01-31ldso: Use single rtld_flags interpretation through all the callsLeonid Lisovskiy
Implement single rtld_flags interpretation through all the do_dlopen()/_dl_load_shared_library()/_dl_load_elf_shared_library() calls chain. This adds the ability to use the flags, passed to dlopen(), in all underlaying functions and implement rtld_flags inheritance. Saves a few bytes code. Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2016-01-31ldso: Fix fail of $ORIGIN expansion in case of RTLD_NOLOADLeonid Lisovskiy
$ORIGIN expansion in search_for_named_library() wrongly takes into account all bits of rflags. Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-04-13fix compile error when LDSO_RUNPATH_OF_EXECUTABLE is setWaldemar Brodkorb
2015-02-20sync with uClibcWaldemar Brodkorb
2015-02-20Allow use of executable RUNPATH/RPATH when finding libraries.Steve Ellcey
This option will modify ldso so that it will use the executables RUNPATH/RPATH to find to find libraries even though this behavour is not standard. Setting this option causes the uclibc dynamic linker behavour to match the glibc dynamic linker. Signed-off-by: Steve Ellcey <sellcey@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-02-08Use executables RPATH/RUNPATH when searching for libraries.Waldemar Brodkorb
Patch by Steve Ellcey <sellcey@imgtec.com> on uClibc mailinglist.
2015-01-25add support for $ORIGINWaldemar Brodkorb
This is for example required, used and tested with OpenJDK 7. No regressions found, while running the testsuite with embedded-test.
2014-09-04ldso: Fix compile-error on noMMUBernhard Reutner-Fischer
Thanks to Waldemar Brodkorb for noticing! Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-11-12ldso: silence warnings in debug codeBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-02-05mman: rename MAP_UNINITIALIZE to MAP_UNINITIALIZEDBernhard Reutner-Fischer
The name was changed to include a trailing 'D' when it went into the kernel. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15add LDSO_SAFE_RUNPATH config optionPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15ldso: use _dl_strdup and _dl_dprintf only in ld-uClibc.soPeter S. Mazinger
Add support for %p to _dl_dprintf for later corrections in debug messages. Disable _dl_debug_file if LD debugging is not enabled and change it's use to 2. The use of dprintf in elfinterp.c will spit out warnings, will be fixed in the reworked ldso. Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-06Clean up DSBT supportMark Salter
The existing DSBT support relies on the kernel to provide DSBT info as part of the load maps passed to user space. The problem with this approach is that the DSBT info is in the dynamic section, so the kernel must access a userspace mapping of the dynamic section (or separately read a copy for the kernel) in order to retrieve the information needed by userspace. This patch reworks the DSBT support to remove the reliance on DSBT info coming from the kernel. Instead, ldso reads the info itself from the dynamic section. One other benefit of this is that it allows the existing kernel FDPIC loader to also load DSBT binaries. Signed-off-by: Mark Salter <msalter@redhat.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-04-08ldso: fix fdpic support broken from prelink patchFilippo Arcidiacono
The fdpic support has been broken since the prelink support was added, because it didn't take into account DL_LOADADDR_TYPE could be a different type of ElfW(Addr). Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-07ldso: support RTLD_NOLOADTimo Teräs
So application query if specified module is loaded or not with dlopen. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-25ldso: let people disable to lookup into LD_LIBRARY_PATHCarmelo Amoroso
On hardened system it could be useful to disable the use of LD_LIBRARY_PATH. Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-10-25ldso: minor fixes to implicit search pathCarmelo Amoroso
Do not defined _dl_ldsopatch if implicit search path if not enabled, and avoid to call search_for_named_library (even if it is able to handle NULL search path). Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-10-19libdl: remove _dl_ldsopath from libdl.aCarmelo Amoroso
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-06-24Merge remote-tracking branch 'origin/master' into prelinkCarmelo Amoroso
* origin/master: (61 commits) fts: fix warning due to old-style function definition ldso_tls: fix compiler warning due to missing cast resolv: fix bug in res_init with ipv6 nameservers config: Fix passing defconfig args buildsys: pt-initfini.s depends on uClibc_config.h libdl: search for ELF_RTYPE_CLASS_DLSYM in dlsym() resolv: try next server on SERVFAIL getaddrinfo: allow numeric service without any hints bump version to 0.9.33-git nptl/pthread: Correct path for machine specific pt-initfini.c ctor/dtor nptl: Fix init and fini function compilation Rules.mak: Rearrange appending UCLIBC_EXTRA_CFLAGS to CFLAGS ARM: remove EABI/OABI selection ARM: detect BX availibility at build time ARM: #include <bits/arm_asm.h> where __USE_BX__ is used ARM: transform the EABI/OABI choice into a boolean ARM: remove sub-arch/variants selection from menuconfig ARM: introduce blind options to select & force THUMB mode ARM: reorder "Use BX" option Fix __libc_epoll_pwait compile failure on x86 ... Conflicts: ldso/libdl/libdl.c Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-05-27Correct a bug when remapping textrel segments on nommuAlan Davis
From: Alan Davis <adavis@ti.com> On C6X, when trying to execute a program that has a textrel DSO, it fails to load. The telltale line in the LD_DEBUG output is: _dl_get_ready_to_run:779: file=''; needed by './a.out' The corresponding DT_NEEDED entry has 'libc.so.0', but here the filename is empty. This is what is happening in _dl_elf_shared_library(): First, map all segments according to their permissions. Text gets initially mapped read-only. Then, parse the dynamic information. The dynamic table is in RW but some of the tags may point to RO. For example, DT_NEEDED points to a string in .dynstr which is in RO. These pointers get computed according to the loadmap from the original mapping. Then, in response to a DT_TEXTREL tag, the RO segment gets remapped, thereby invaliding anything that points to it, in particular certain dynamic tags such as DT_NEEDED. The following patch re-parses the dynamic info after the remapping so as to re-compute any invalid pointers. Signed-off-by: Alan Davis <adavis@ti.com> Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
2011-05-04Merge remote-tracking branch 'origin/master' into prelinkCarmelo Amoroso
* origin/master: (32 commits) libubacktrace: fix backtrace support on arm-eabi, which needs libgcc_eh linked too getaddrinfo.c: fix incorrect check for ERANGE from gethostbyaddr_r getaddrinfo.c: improve code readability. No functional changes string: remove unused variable x86_64: silence warning if !TLS buildsys: prettify ssp.c handling madvise is LINUX_SPECIFIC test_nptl: fix expected result for tst-cputimer[123] test_nptl: fix expected result for tst-clock2 test buildsys: make $(LOCAL_INSTALL_PATH) phony ether_aton: reject invalid input tests: disable ether tests if !HAS_SOCKET inet: add ether_aton testcase sysconf: clock_getres depends on HAS_REALTIME __rt_sigwaitinfo: depends on HAS_REALTIME buildsys: minor fixes in Makefile.arch for C6X buildsys: minor fixes in Makefile.arch for microblaze libubacktrace: enabled for all archs indeed. sparc: don't access fp registers when configured for no fpu libubacktrace: generic implementation based dwarf ... Conflicts: ldso/ldso/dl-elf.c ldso/ldso/mips/elfinterp.c ldso/ldso/x86_64/elfinterp.c Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-04-11Support dynamic assignment of DSBT_INDEXBernd Schmidt
For DSBT targets (C6X only at this point), we'd like to support the case where the user did not specify --dsbt-index at link time when building a shared library. The dynamic linker can still assign an index at runtime and fix up the DSBT_INDEX relocs, at the cost of startup time and memory space. Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
2011-04-11Fix nommu handling of DT_TEXTRELBernd Schmidt
We have a problem with DT_TEXTREL shared libraries on nommu machines. The dynamic linker's strategy is to map the text segment read-only first, then look for DT_TEXTREL, and use mprotect to change protections if necessary. This fails on nommu, since a nommu kernel can decide to share the memory for private read-only file mappings, and mprotect doesn't (can't) do anything about this sharing. Existing nommu targets apparently have no need for this, but on C6X, we may need to assign library indices at run-time if no --dsbt-index option was passed to the linker at build time. Hence, the following patch, which instead of using mprotect, redoes the mapping with PF_W set. Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
2011-04-06Merge remote-tracking branch 'origin/master' into prelinkCarmelo Amoroso
* origin/master: (137 commits) utils/ldd: Check for returned pointer from strrchr not the value it holds cris: add provide arch-specific vfork implementation lutimes.c, stubs.c: fix compiling lutimes, if __NR_utimensat is not defined bump version to 0.9.32-rc3-git release 0.9.32-rc3 memalign: include sys/param.h for MAX arm/bits/atomic.h: Include common/bit/atomic.h for thumb1 wctype.h: fix libc_hidden_proto for iswupper and add it for iswspace add libc_hidden_proto for wcs[n]casecmp_l really fix missing __libc_drand48_data Revert "missing prototype of __libc_drand48_data fixed" missing prototype of __libc_drand48_data fixed time.c, time.h: remove unused hidden strftime/strptime nanosleep.c: remove duplicated libc_hidden_proto ctype.c, ctype.h: remove commented parts that were banned for removal after 0.9.31 _wctype.c, wctype.h: remove unused isw* and wctype_l hidden functions time.c, wchar.h: remove unused hidden wcsftime str[n]casecmp.c: fix hidden usage remove unused hidden functions frv/memset.S: add missing libc_hidden_def ... Conflicts: ldso/ldso/ldso.c Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-03-07ldso: use ADDR_ALIGN instead of hard-coded valueCarmelo Amoroso
Use ADDR_ALIGN to align the minvma when loading shared libraries instead of the hard coded 0xffffU value. This fixes teh stand/alone support on ARM as reported in bug #3133. Signed-off-by: Sven Ola <sven-ola@gmx.de> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com> (cherry picked from commit 435471db8561e4686e5921b7f719ab6d5a0d06f7) Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-03-05Add sanity checks to ld.so DSBT supportMark Salter
This adds some DSBT index sanity checks to the runtime linker. It catches libraries which have no index (index 0) and libraries which try to use an already used index. Signed-off-by: Mark Salter <msalter@redhat.com> Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
2011-03-05Add support for DSBT ELF to ld.soMark Salter
This adds support for DSBT ELF to ld.so. This uses loadmaps like FD-PIC. Some code is added in ld.so to initialize the DSBT tables, and there's also a new target macro FINISH_BOOTSTRAP_RELOC. Signed-off-by: Mark Salter <msalter@redhat.com> Signed-off-by: Aurelien Jacquiot <a-jacquiot@ti.com> Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
2011-03-03ldso: use ADDR_ALIGN instead of hard-coded valueCarmelo Amoroso
Use ADDR_ALIGN to align the minvma when loading shared libraries instead of the hard coded 0xffffU value. This fixes teh stand/alone support on ARM as reported in bug #3133. Signed-off-by: Sven Ola <sven-ola@gmx.de> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2010-09-17ldso: Fix loadaddr and mappaddr when prelink support is enabled.Filippo Arcidiacono
Fixed loadaddr and mappaddr fields to correctly work when prelink support is enabled. - loadaddr is an offset relative to the first loadable segment. - mapaddr is the address where the object has been mapped in memory. Non PIC library detection fixed too. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2010-09-17ldso: Add runtime prelink supportFilippo Arcidiacono
Added runtime prelink support to be able to run a prelinked application; at process startup only the conflicts will be relocated. This speed up the startup time. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2010-09-17ldso: Rework global scope handling and symbol lookup mechanismFilippo Arcidiacono
Global symbol scope is implemented as a linked list of local scope, that dynamically grows and shrinks when dlopen/ dlclose are called. Each local scope is implemented as an array of pointer to struct elf_resolve. This will help to detect conflict when LD_TRACE_PRELINKING option will be implemented. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2010-09-17ldso: Add implementation of ld.so standalone executionFilippo Arcidiacono
The dynamic linker can be run either indirectly through running some dynamically linked program or library (in which case no command line options to the dynamic linker can be passed and, in the ELF case, the dynamic linker which is stored in the .interp section of the program is executed) or directly by running: /lib/ld-uClibc.so.* [OPTIONS] [PROGRAM [ARGUMENTS]] Stand-alone execution is a prerequisite for adding prelink capabilities to uClibc dynamic linker, as well useful for testing an updated version of the dynamic linker without breaking the whole system. Currently supported option: --library-path PATH use given PATH instead of content of the environment variable LD_LIBRARY_PATH (Mandatory for prelinking) Not supported options: --list list all dependencies and how they are resolved --verify verify that given object really is a dynamically linked object we can handle --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names in LIST This feature can be enabled by setting LDSO_STANDALONE_SUPPORT=y Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2010-04-22ldso: support RTLD_NODELETE and DF_1_NODELETETimo Teräs
Honor the nodelete flags so we don't delete shared library if it's sticky. This is useful for libpthread if it gets pulled in by a dlopen'ed library. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
2010-04-12silence debug warningBernhard Reutner-Fischer
variable 'tmp' set but not used Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-12-23Make _dl_dprintf buf non-static to avoid multithreading bugs.Chris Metcalf
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
2009-12-17check if USE_TLS is defined before useHans-Christian Egtvedt
This patch will convert all the #ifdef USE_TLS and #if USE_TLS to #if defined(USE_TLS) && USE_TLS. By checking if the USE_TLS is defined before checking its value will result in correct behavior for architectures not defining this config symbol. Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com> Acked-by: Carmelo AMOROSO <carmelo.amoroso@st.com>
2009-11-23nommu: use MAP_UNINITIALIZE for mallocsMike Frysinger
Now that the kernel supports MAP_UNINITIALIZE, have the malloc places use it to get real uninitialized memory on no-mmu systems. This avoids a lot of normally useless overhead involved in zeroing out all of the memory (sometimes multiple times). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-10-15ldso: clean up breakage in tls mergeMike Frysinger
The TLS merge 534661b91c9849 introduced multiple style problems as well as random breakage: - missing _dl_free - incomplete parametrization of _dl_lookup_hash - restore FDPIC handling in _dl_lookup_hash Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-10-07ldso: use O_CLOEXEC for cache fileMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-10-07ldso: use MAP_FAILED with ld.so.cacheMike Frysinger
Rather than use our own custom casted -1 value, just use the MAP_FAILED that common code already sets up for us for mmap(). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-09-26ldso/: tls support for dynamic linkerAustin Foxley
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>