summaryrefslogtreecommitdiff
path: root/ldso/ldso/ldso.c
AgeCommit message (Collapse)Author
2015-04-24merge uClibc changesWaldemar Brodkorb
2015-04-22ldso: PRELINK: Remove surplus newlineBernhard Reutner-Fischer
in early debugging code Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
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-04-23ldso: Fix misplaced declarationBernhard Reutner-Fischer
Apparently i made a typo when applying 278a06d7abcc8774ba9bb9c15779749c7e2d68cd sorry.. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2014-04-08ldso: fix standalone execution on x86_64 architectureCédric VINCENT
If the dynamic linker is built with LDSO_STANDALONE_SUPPORT=y, it can load then run a dynamically linked program when explicitly invoked from the command line. This is used for test and prelink purposes, and also by other tools like PRoot to force the kernel to load the right ELF interpreter. This feature is currently broken on x86_64 since the number of command line arguments (ie. argc) passed from the kernel is an "elf_addr_t" (64 bit on x86_64), whereas it is read as an "unsigned int" (32 bit on x86_64). Ref: https://github.com/cedric-vincent/PRoot/issues/45 Signed-off-by: Cédric VINCENT <cedric.vincent@st.com> 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-11-06ldso: fix unused variable warningBaruch Siach
This fixes the following warning when SUPPORT_LD_DEBUG_EARLY is not enabled: ldso/ldso/ldso.c: In function '_dl_get_ready_to_run': ldso/ldso/ldso.c:754:16: warning: unused variable 'tmp' [-Wunused-variable] This was introduced with commit 94cc6edb (ldso: Rework global scope handling and symbol lookup mechanism). Cc: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-05-13libc: deal with aux vect inside __uClibc_main only if !SHAREDFilippo ARCIDIACONO
It's not safe to use the aux vect inside __uClibc_main if we are running with shared libraries, because it could have been already modified. For example, if some constructor plays with environment variables by using unsetenv, the modifications done into the stack to unset an environment variable, have impacts on the aux vect due to the extra NULL entries added. Due to this, __uClibc_main is not able to detect where the aux vect starts, so all the entries that are used by __uClibc_main (AT_UID, AT_EUID, AT_GID, AT_EGID, AT_PAGESZ and possibly other arch specific) are impacted. Same side effect on the aux vect is caused by the ld.so when running a SUID program with some of the unsecure environment variables set, that will be unset by the ld.so itself. In order to fix this issue, it needs to handle aux vect entries into __uClibc_main only if SHARED is not defined. In SHARED case, libc refers to __dl_secure and _dl_pagesize as initialised by the ld.so where the aux vext is still untouched. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Reviewed-by: Carmelo Amoroso <carmelo.amoroso@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.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-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-06ldso: preload standard path library with setuid bit setFilippo Arcidiacono
For set-user-ID/set-group-ID ELF binaries, only libraries in the standard search directories that are also set-user-ID must be loaded. This patch fixes existing logic according to the above statement. Furthermore if either library setuid bit isn't set or it cannot be found in the standard search path, the library won't be preloaded but execution go ahead with default one. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> 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-05-18ldso: sh: handle _dl_skip_args in linker startup instead of __uClibc_mainFilippo Arcidiacono
Handle _dl_skip_args in the asm part of the dynamic linker startup, to skip the ldso arguments, so we can keep this symbol hidden as other archs do. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.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>
2012-01-27ldso: fix typo in debug messageBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-01-02ldso: setup search path even when there are no "/"Mike Frysinger
If people use an interp path such as "ld.so", then there is no "/" found, and we end up dereferencing a NULL pointer. Simplify the logic by having a relative interp path like that be the same as "" (which the code later on interprets as $PWD). While we're here, document some of the nuances of this code. Reported-by: Ignacy Gawędzki <uclibc@qult.net> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-01-02ldso: simplify interp path search logicMike Frysinger
The setup logic is duplicated, so unify it in a local func. Mark the variable const while we're doing this, and add missing ifdef protection to the header that declares it availability. 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-25ldso: disable the implicit path search in stand-alone mode as wellCarmelo Amoroso
Honour LDSO_SEARCH_INTERP_PATH knob option also when running in stand-alone mode. Signed-off-by: Rune <u-uclibc-y2lt@aetey.se> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-08-26ldso: fix build with PRELINK enabled and !TLSCarmelo Amoroso
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-07-12ldso: fix build error due to missing variable 'st'Douglas Mencken
Fix a build error triggered when LDSO_PRELOAD_FILE_SUPPORT is enabled due to missing definition of 'st' variable. Signed-off-by: Douglas Mencken <dougmencken@gmail.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.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-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-03Correct ssp codePeter S. Mazinger
Avoid using strong_alias in ssp, some archs dislike it. Make stack_chk_guard static. Export __stack_smash_handler only if compatibility option is enabled. Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-03-03syntax fixPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-01-21Merge remote branch 'origin/master' into prelinkCarmelo Amoroso
* origin/master: bump version to 0.9.32-rc2-git release 0.9.32-rc2 nptl: Fix __USER_LABEL_PREFIX__ concatenatio nptl: fix start_thread() for _STACK_GROWS_UP ldso: get rid of _dl_lookup_hash Add protected symbols support for all architectures Revert "ldso/arm: Correct protected symbol resolution" Revert "ldso_sh: add support for protected symbols to SH" Revert "ldso/i386: support protected symbols" cris: Fix build issues syslog: fix 'everyone logs with user facility' __psfs_parse_spec: always use long int for %p buildsys: headers target should not depend on sysnum.h buildsys: fix make release target nptl: get rid of the last preprocessor warning when __ASSUME_TGKILL is not defined remove uClibc_ctype.h if !LOCALE Revert "Makefile.in: Add header to 'all' target" nptl: get rid of preprocessor warning when __ASSUME_TGKILL is not defined Conflicts: ldso/include/dl-hash.h ldso/ldso/arm/elfinterp.c ldso/ldso/avr32/elfinterp.c ldso/ldso/bfin/elfinterp.c ldso/ldso/cris/elfinterp.c ldso/ldso/dl-hash.c ldso/ldso/i386/elfinterp.c ldso/ldso/m68k/elfinterp.c ldso/ldso/mips/elfinterp.c ldso/ldso/powerpc/elfinterp.c ldso/ldso/sh/elfinterp.c ldso/ldso/sh64/elfinterp.c ldso/ldso/sparc/elfinterp.c ldso/ldso/x86_64/elfinterp.c ldso/ldso/xtensa/elfinterp.c ldso/libdl/libdl.c 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: Do not add the ld.so at the end of the loaded modules listFilippo Arcidiacono
The dynamic linker was included indifferently at the end of the loaded modules list. In order to be used with prelink, it is required to included the ld.so in the local scope of each shared libraries that depends directly on it. Also it is included in the global scope at the first occurrence. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2010-09-17ldso: Add support for LD_WARN and LD_TRACE_PRELINKINGFilippo Arcidiacono
Added support for the following tracing capabilities: - LD_WARN to warn about undefined symbols during the lookup stage. - LD_TRACE_PRELINKING to trace the needed libraries of the object that we are prelinking. 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-14Merge commit 'origin/master' into nptlAustin Foxley
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
2010-04-14ldso: Add config option for controlling LD_PRELOADCarmelo AMOROSO
On hardened system it could be useful to disable the use of LD_PRELOAD environment variable for preloading shared objects before the system libraries. So this patch add a config option, LDSO_PRELOAD_ENV_SUPPORT, to control this behaviour. It is enabled by default. Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-01-21ldso: tweak shadow warning with preload file supportBernhard Reutner-Fischer
The stat buffer is already declared at the top of the function. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> (cherry picked from commit 6140a2a7175a796a7c06119f036357db87a1b865) Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2010-01-21ldso: tweak shadow warning with preload file supportBernhard Reutner-Fischer
The stat buffer is already declared at the top of the function. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.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-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-28Merge remote branch 'origin/master' into nptlAustin Foxley
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
2009-11-27ldso: initialize stack_chk_guard after TLS is initializedNatanael Copa
stack_chk_guard is on thread local storage so we need to init TLS before we can init stack_chk_guard. Signed-off-by: Natanael Copa <natanael.copa@gmail.com> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
2009-11-25avoid warning about unused variableBernhard Reutner-Fischer
If LDSO_SEARCH_INTERP_PATH is off then ptmp wasn't used. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.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-11-22ldso: let people disable the implicit path searchMike Frysinger
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-09-26ldso/: tls support for dynamic linkerAustin Foxley
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
2009-07-23ldso: fix building for FDPIC systemsMike Frysinger
The force shareable code missed a spot of using the DL_RELOC_ADDR() indirection thus leading to invalid operands: ldso/ldso/ldso.c: In function '_dl_get_ready_to_run': ldso/ldso/ldso.c:409: error: invalid operands to binary + (have 'Elf32_Addr' and 'struct elf32_fdpic_loadaddr') Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-07-23silence warnings in Blackfin ldso codeMike Frysinger
In file included from ./ldso/include/ldso.h:135, from ldso/ldso/ldso.c:34: ./ldso/ldso/bfin/dl-inlines.h: In function '__dl_init_loadaddr_map': ./ldso/ldso/bfin/dl-inlines.h:43: warning: assignment makes pointer from integer without a cast In file included from ldso/ldso/ldso.c:43: ldso/ldso/bfin/elfinterp.c: In function '_dl_do_lazy_reloc': ldso/ldso/bfin/elfinterp.c:299: warning: assignment makes pointer from integer without a cast ldso/ldso/ldso.c: In function '_dl_get_ready_to_run': ldso/ldso/ldso.c:534: warning: assignment makes integer from pointer without a cast Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-02-23- fix weak ssp symbol on some arches (Peter S. Mazinger)Bernhard Reutner-Fischer
Work around alleged binutils glitch with weak symbols on some arches. See binutils ML, weak psm and vapier.