1 From 7f82a682a730899d30d8640b6af5178919339837 Mon Sep 17 00:00:00 2001
2 From: Filippo Arcidiacono <filippo.arcidiacono@st.com>
3 Date: Thu, 9 May 2013 09:04:20 +0200
4 Subject: [PATCH] libdl: fix dlopen implementation from statically linked
7 Calling dlopen from statically linked application is actually broken,
8 because _dl_find_hash enters into an infinite loop when trying to
9 resolve symbols. In this case it doesn't need to extend the global
10 scope, it is readyto be used as it is, because _dl_loaded_modules already points
11 to the dlopened library.
13 The patch also fixesi a typo in __LDSO_LD_LIBRARY_PATH__ macro, that was
14 preventing to get the actual value of the LD_LIBRARY_PATH.
16 Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
17 Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
18 (cherry picked from commit 231e4a9b4b972662a6832f714a05525a3754892d)
20 Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
22 ldso/libdl/libdl.c | 11 +++++++++--
23 1 file changed, 9 insertions(+), 2 deletions(-)
25 diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
26 index 018c720..49711a8 100644
27 --- a/ldso/libdl/libdl.c
28 +++ b/ldso/libdl/libdl.c
29 @@ -374,7 +374,7 @@ static void *do_dlopen(const char *libname, int flag, ElfW(Addr) from)
30 if (getenv("LD_BIND_NOW"))
33 -#if !defined SHARED && defined __LDSO_LIBRARY_PATH__
34 +#if !defined SHARED && defined __LDSO_LD_LIBRARY_PATH__
35 /* When statically linked, the _dl_library_path is not yet initialized */
36 _dl_library_path = getenv("LD_LIBRARY_PATH");
38 @@ -541,11 +541,18 @@ static void *do_dlopen(const char *libname, int flag, ElfW(Addr) from)
39 * to the GOT tables. We need to do this in reverse order so that COPY
40 * directives work correctly */
42 - /* Get the tail of the list */
45 + * Get the tail of the list.
46 + * In the static case doesn't need to extend the global scope, it is
47 + * ready to be used as it is, because _dl_loaded_modules already points
48 + * to the dlopened library.
50 for (ls = &_dl_loaded_modules->symbol_scope; ls && ls->next; ls = ls->next);
52 /* Extend the global scope by adding the local scope of the dlopened DSO. */
53 ls->next = &dyn_chain->dyn->symbol_scope;
57 * Relocation of the GOT entries for MIPS have to be done