summaryrefslogtreecommitdiff
path: root/ldso/ldso
AgeCommit message (Collapse)Author
2012-06-13Update C6X supportMark Salter
This patch updates the C6X support to work with latest uClibc code and uses reworked DSBT support to allow using kernel FDPIC loader. Signed-off-by: Mark Salter <msalter@redhat.com> 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-03-29ldso: mark _start hiddenMike Frysinger
There's no need to export this symbol, so mark them all hidden. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-03-27ldso: bfin: add alias from __start to _startMike Frysinger
On Blackfin systems, we have underscore prefixes in our ABI. So instead of _start, we use __start. However, the makefile explicitly sets _start as the entry point to support toolchains that implicitly use other symbols as the default entry. It's easy enough to add a hidden alias in the Blackfin code for free to support this. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-03-26ldso: bfin: tweak styleMike Frysinger
No functional changes here. We don't need line continuations as gcc is smart enough to merge the multiple strings for us. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-03-25ldso: use ELF_xxx()/ElfW() helpersMike Frysinger
They expand into the same code, but using the ELF_xxx()/ElfW() macros makes it much easier to spot similarities between code bases. Acked-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Acked-by: Carmelo Amoroso <carmelo.amoroso@st.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-03-15ldso: remove duplicated assignment with TLS symbolCarmelo Amoroso
The tpnt field is already set, so not needed to assign it again. Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2012-03-14ldso:sh: fix compiler warning due to unused-but-set-variableCarmelo Amoroso
gcc 4.6.x raises useful warnings due to unused-but-set-variable, This patch fixes the following one by using properly preprocessor guard In file included from ldso/libdl/libdl.c:129:0: ./ldso/ldso/sh/elfinterp.c: In function '_dl_do_reloc': ./ldso/ldso/sh/elfinterp.c:163:22: warning: variable 'tls_tpnt' set but not used [-Wunused-but-set-variable] Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2012-01-27ldso: fix typo in debug messageBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-01-23ldso/mips: fix symbol lookup for JUMP_SLOT and COPY relocationsCarmelo Amoroso
Fill properly the sym_ref fields when invoking _dl_find_hash to lookup symbols Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
2012-01-14buildsys: cache build flags in varsMike Frysinger
Running `make clean` atm takes like 20 seconds because every subdir re-evaluates all the toolchain flags. Add some helpers to automate the process of setting up variables to cache the result of tests, as well as the checking of an already set flag. Now `make clean` takes like 2 seconds on my system. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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-27ldso: bfin: fix sram_flags initMike Frysinger
An earlier version had this, but was lost as code was shuffled around. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-27ldso: bfin: shrink sram mapping funcMike Frysinger
The L1 data and L2 code paths duplicate a lot, so unify them. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-27ldso: fdpic: clean up styleMike Frysinger
There should (hopefully) be no functional changes here. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-27ldso: fdpic: unify duplicate bfin/frv logicMike Frysinger
Much of the logic in the bfin/frv subdirs is FDPIC specific and not arch specific. So start a new fdpic/ subdir to keep common things. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-27ldso: use __func__ rather than __FUNCTION__Mike Frysinger
The former is part of a standard (C99) while the latter is not. 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-10-19libdl: remove _dl_ldsopath from libdl.aCarmelo Amoroso
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-10-14ldso: silence harmless warning for !LDSO_PRELINK_SUPPORTBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-06ldso: unify pread syscall definitionMike Frysinger
A few arches want pread() defined, so move it to common code. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-06ldso: bfin/frv: drop dead simulator codeMike Frysinger
Nowhere do we define DYNAMIC_LOADER_IN_SIMULATOR, so drop the little bit of code that depends on it. At least in the Blackfin case, we can run an FDPIC ldso just fine under the simulator without hacks. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-06ldso: merge duplicate dl-syscalls.h code to common headerMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-06microblaze mmu/elf/shared lib supportRyan Flux
microblaze can either be with mmu or without If with, use elf rather than flat, and support shared libs Signed-off-by: Ryan Flux <ryan.flux@emsolutions.com.au> Signed-off-by: Steve Bennett <steveb@workware.net.au> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-01ldso: x86_64: delete unused variableMike Frysinger
gcc informed me: In file included from ldso/ldso/ldso.c:46:0: ldso/ldso/x86_64/elfinterp.c: In function '_dl_do_lazy_reloc': ldso/ldso/x86_64/elfinterp.c:294:6: warning: variable 'symtab_index' set but not used [-Wunused-but-set-variable] Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-10-01ldso: constify reloc array itselfMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-08-26ldso: fix build with PRELINK enabled and !TLSCarmelo Amoroso
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-07-27ldso/mips: Clean up warningsKevin Cernekee
Trivial fixes for these warnings: CC ldso/libdl/libdl.oS In file included from ldso/ldso/ldso.c:46:0: ldso/ldso/mips/elfinterp.c:88:1: warning: no previous prototype for '__dl_runtime_pltresolve' ldso/ldso/ldso.c: In function '_dl_get_ready_to_run': ldso/ldso/ldso.c:475:5: warning: assignment makes pointer from integer without a cast In file included from ldso/ldso/ldso.c:1097:0: ldso/ldso/dl-elf.c: In function '_dl_load_elf_shared_library': ldso/ldso/dl-elf.c:811:3: warning: assignment makes pointer from integer without a cast Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-07-27ldso/mips: dlsym() incorrectly matches undefined symbolsKevin Cernekee
check_match() relies on checking for (sym->st_value == 0) to see if the symbol is undefined. This works reasonably well on most architectures, such as ARM or i386: $ readelf -s /lib32/libcap.so.2 | grep -E "\<malloc\>" 17: 00000000 0 FUNC GLOBAL DEFAULT UND malloc@GLIBC_2.0 (2) However, on MIPS, libbfd puts nonzero data in the st_value field to facilitate resetting the symbol's GOT entry if the library that defines the symbol gets unloaded: $ mipsel-linux-readelf -s libfoo.so | grep -E "\<malloc\>" 74: 00003140 0 FUNC GLOBAL DEFAULT UND malloc This can cause check_match to report a false positive when examining the external symbol reference. Consequently dlsym() will return a bad pointer to the caller. Use the special MIPS logic from glibc-ports-2.13 to avoid this situation. Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-07-27ldso/mips: Enable bootstrap relocationsKevin Cernekee
_dl_reltypes_tab[] is an array of pointers to constant strings: Contents of section .data: 20000 01000000 02000000 00000000 00000000 ................ 20010 70e50000 7ce50000 88e50000 94e50000 p...|........... ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ (pointers are LE) Contents of section .rodata: e570 525f4d49 50535f4e 4f4e4500 525f4d49 R_MIPS_NONE.R_MI e580 50535f31 36000000 525f4d49 50535f33 PS_16...R_MIPS_3 e590 32000000 525f4d49 50535f52 454c3332 2...R_MIPS_REL32 These pointers require relocation: DYNAMIC RELOCATION RECORDS OFFSET TYPE VALUE 00000000 R_MIPS_NONE *ABS* 0001fffc R_MIPS_REL32 *ABS* 00020010 R_MIPS_REL32 *ABS* 00020014 R_MIPS_REL32 *ABS* 00020018 R_MIPS_REL32 *ABS* On MIPS, only GOT relocations are currently handled by ldso during startup. The net effect is that when running with "LD_DEBUG=reloc", ldso itself crashes before the program even starts. This is caused by _dl_dprintf() dereferencing an unadjusted string pointer such as 0xe570. This patch enables the missing relocations and allows LD_DEBUG to work as designed. Signed-off-by: Kevin Cernekee <cernekee@gmail.com> 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-07-07x86_64/elfinterp.c: Protect missed debug _dl_printf with __SUPPORT_LD_DEBUG__Khem Raj
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2011-07-01ldso: arm: fix build when prelinking is enabled.Carmelo Amoroso
This is a post merge fix to address build issue when PRELINK support is enabled. 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-06-24ldso_tls: fix compiler warning due to missing castCarmelo Amoroso
Fix compiler warning (as below) due to missign cast In file included from ldso/ldso/ldso.c:42:0: ldso/ldso/dl-tls.c: In function 'init_tls': ldso/ldso/dl-tls.c:1028:24: error: initialization makes pointer from integer without a cast Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-06-11ARM: #include <bits/arm_asm.h> where __USE_BX__ is usedYann E. MORIN
The check for __USE_BX__ will be available in bits/arm_asm.h, so the latter must be included wherever the former is used. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> Cc: Khem Raj <raj.khem@gmail.com> Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Cc: Carmelo AMOROSO <carmelo.amoroso@st.com> Signed-off-by: Khem Raj <raj.khem@gmail.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-11x86_64: add TODO for R_X86_64_RELATIVEBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.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-05-03x86_64: silence warning if !TLSBernhard Reutner-Fischer
TODO: fix all other arches Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-04-18dl-startup: fix typos in block commentKevin Cernekee
Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2011-04-18MIPS LDSO: pass sym_ref parameter to _dl_find_hash() to support PROTECTED ↵Maksim Rayskiy
symbols _dl_find_hash() relies on sym_ref parameter to check if the looked-up symbol is protected. The code fixes a case when _dl_perform_mips_global_got_relocations() was calling _dl_find_hash() without providing sym_ref parameter. The bug was causing hangs if a library exporting non-protected symbol was earlier in link order than library with the same symbol declared as protected. Signed-off-by: Maksim Rayskiy <mrayskiy@broadcom.com> 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>