On Tue, Sep 11, 2018 at 10:47:58PM +0200, Andreas Longwitz wrote:
> Thanks very much for answer !
>
> Now I use the following libmap32.conf:
>
> ## php52
> [/usr/local/php52/lib/php/20060613/mysql.so]
> /usr/local/lib/mysql/usr/local/lib32/mysql
> [/usr/local/php52/]
> /usr/local/lib /usr/local/lib32
>
> > I am having problem understanding what do you mean by step1/step2. The
> > refobj reference that you cache in the patch, comes into load_object()
> > as the pointer to the object which initiate the load_object() call. It
> > is NULL for preloaded objects, otherwise it is not.
> > So, could you, please, explain where does it get passed as NULL in your
> > case ?
>
> Ok, I try to explain better:
>
> step1 means: call of lm_find() in rtld.c (line 1500) and first argument
> is refobj->path, which is used in libmap.c to find the correct entry in
> the lmp_list.
>
> step2 means: call of lm_findn() in rtld.c (line 2834) when called from
> search_library_path(). In this case the first argument is NULL and in
> libmap.c this means "$DEFAULT" entry in the lmp_list. Please notice that
> after reading libmap32.conf in lm_init() the entry $DEFAULT in the
> lmp_list does not exist, when all mappings are defined with constraints.
Can you try this instead ?
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index dfd0388478f..83d5e28e287 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -125,7 +125,7 @@ static void objlist_remove(Objlist *, Obj_Entry *);
static int open_binary_fd(const char *argv0, bool search_in_path);
static int parse_args(char* argv[], int argc, bool *use_pathp, int *fdp);
static int parse_integer(const char *);
-static void *path_enumerate(const char *, path_enum_proc, void *);
+static void *path_enumerate(const char *, path_enum_proc, const char *, void
*);
static void print_usage(const char *argv0);
static void release_object(Obj_Entry *);
static int relocate_object_dag(Obj_Entry *root, bool bind_now,
@@ -140,7 +140,8 @@ static int rtld_dirname(const char *, char *);
static int rtld_dirname_abs(const char *, char *);
static void *rtld_dlopen(const char *name, int fd, int mode);
static void rtld_exit(void);
-static char *search_library_path(const char *, const char *, int *);
+static char *search_library_path(const char *, const char *, const char *,
+int *);
static char *search_library_pathfds(const char *, const char *, int *);
static const void **get_program_var_addr(const char *, RtldLockState *);
static void set_program_var(const char *, const void *);
@@ -1576,8 +1577,7 @@ gnu_hash(const char *s)
static char *
find_library(const char *xname, const Obj_Entry *refobj, int *fdp)
{
- char *pathname;
- char *name;
+ char *name, *pathname, *refobj_path;
bool nodeflib, objgiven;
objgiven = refobj != NULL;
@@ -1597,6 +1597,7 @@ find_library(const char *xname, const Obj_Entry *refobj,
int *fdp)
}
dbg(" Searching for \"%s\"", name);
+ refobj_path = objgiven ? refobj->path : NULL;
/*
* If refobj->rpath != NULL, then refobj->runpath is NULL. Fall
@@ -1605,52 +1606,61 @@ find_library(const char *xname, const Obj_Entry
*refobj, int *fdp)
* nodeflib.
*/
if (objgiven && refobj->rpath != NULL && ld_library_path_rpath) {
- pathname = search_library_path(name, ld_library_path, fdp);
+ pathname = search_library_path(name, ld_library_path,
+ refobj_path, fdp);
if (pathname != NULL)
return (pathname);
if (refobj != NULL) {
- pathname = search_library_path(name, refobj->rpath,
fdp);
+ pathname = search_library_path(name, refobj->rpath,
+ refobj_path, fdp);
if (pathname != NULL)
return (pathname);
}
pathname = search_library_pathfds(name, ld_library_dirs, fdp);
if (pathname != NULL)
return (pathname);
- pathname = search_library_path(name, gethints(false), fdp);
+ pathname = search_library_path(name, gethints(false),
+ refobj_path, fdp);
if (pathname != NULL)
return (pathname);
- pathname = search_library_path(name, ld_standard_library_path,
fdp);
+ pathname = search_library_path(name, ld_standard_library_path,
+ refobj_path, fdp);
if (pathname != NULL)
return (pathname);
} else {
nodeflib = objgiven ? refobj->z_nodeflib : false;
if (objgiven) {
- pathname = search_library_path(name, refobj->rpath,
fdp);
+ pathname = search_library_path(name, refobj->rpath,
+