open_executable(): Changed search order according to the ABI specs. DT_RPATH
is now searched before the LIBRARY_PATH/ADDON_PATH. Fixes #7638. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41903 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -217,7 +217,6 @@ int
|
|||||||
open_executable(char *name, image_type type, const char *rpath,
|
open_executable(char *name, image_type type, const char *rpath,
|
||||||
const char *programPath, const char *compatibilitySubDir)
|
const char *programPath, const char *compatibilitySubDir)
|
||||||
{
|
{
|
||||||
const char *paths;
|
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
int fd = B_ENTRY_NOT_FOUND;
|
int fd = B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
@@ -236,31 +235,17 @@ open_executable(char *name, image_type type, const char *rpath,
|
|||||||
// them up in the usual search paths - at
|
// them up in the usual search paths - at
|
||||||
// least that seems to be what BeOS does, and since it doesn't hurt...
|
// least that seems to be what BeOS does, and since it doesn't hurt...
|
||||||
if (type == B_LIBRARY_IMAGE) {
|
if (type == B_LIBRARY_IMAGE) {
|
||||||
// For library (but not add-on), strip any path from name
|
// For library (but not add-on), strip any path from name.
|
||||||
// Relative path of add-on is kept
|
// Relative path of add-on is kept.
|
||||||
paths = strrchr(name, '/') + 1;
|
const char* paths = strrchr(name, '/') + 1;
|
||||||
memmove(name, paths, strlen(paths) + 1);
|
memmove(name, paths, strlen(paths) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// let's evaluate the system path variables to find the container
|
// try rpath (DT_RPATH)
|
||||||
paths = search_path_for_type(type);
|
if (rpath != NULL) {
|
||||||
if (paths) {
|
// It consists of a colon-separated search path list. Optionally a
|
||||||
fd = search_executable_in_path_list(name, paths, strlen(paths),
|
// second search path list follows, separated from the first by a
|
||||||
programPath, compatibilitySubDir, buffer, sizeof(buffer));
|
|
||||||
|
|
||||||
// If not found and a compatibility sub directory has been
|
|
||||||
// specified, look again in the standard search paths.
|
|
||||||
if (fd == B_ENTRY_NOT_FOUND && compatibilitySubDir != NULL) {
|
|
||||||
fd = search_executable_in_path_list(name, paths, strlen(paths),
|
|
||||||
programPath, NULL, buffer, sizeof(buffer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// try rpath (DT_RPATH), if not found yet
|
|
||||||
if (fd < 0 && rpath != NULL) {
|
|
||||||
// It consists of a colon-separated search path list. Optionally it
|
|
||||||
// follows a second search path list, separated from the first by a
|
|
||||||
// semicolon.
|
// semicolon.
|
||||||
const char *semicolon = strchr(rpath, ';');
|
const char *semicolon = strchr(rpath, ';');
|
||||||
const char *firstList = (semicolon ? rpath : NULL);
|
const char *firstList = (semicolon ? rpath : NULL);
|
||||||
@@ -277,6 +262,22 @@ open_executable(char *name, image_type type, const char *rpath,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If not found yet, let's evaluate the system path variables to find the
|
||||||
|
// shared object.
|
||||||
|
if (fd < 0) {
|
||||||
|
if (const char *paths = search_path_for_type(type)) {
|
||||||
|
fd = search_executable_in_path_list(name, paths, strlen(paths),
|
||||||
|
programPath, compatibilitySubDir, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
// If not found and a compatibility sub directory has been
|
||||||
|
// specified, look again in the standard search paths.
|
||||||
|
if (fd == B_ENTRY_NOT_FOUND && compatibilitySubDir != NULL) {
|
||||||
|
fd = search_executable_in_path_list(name, paths, strlen(paths),
|
||||||
|
programPath, NULL, buffer, sizeof(buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
// we found it, copy path!
|
// we found it, copy path!
|
||||||
TRACE(("runtime_loader: open_executable(%s): found at %s\n", name, buffer));
|
TRACE(("runtime_loader: open_executable(%s): found at %s\n", name, buffer));
|
||||||
|
|||||||
Reference in New Issue
Block a user