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:
parent
6e53f9a990
commit
dfc8551aad
@ -217,7 +217,6 @@ int
|
||||
open_executable(char *name, image_type type, const char *rpath,
|
||||
const char *programPath, const char *compatibilitySubDir)
|
||||
{
|
||||
const char *paths;
|
||||
char buffer[PATH_MAX];
|
||||
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
|
||||
// least that seems to be what BeOS does, and since it doesn't hurt...
|
||||
if (type == B_LIBRARY_IMAGE) {
|
||||
// For library (but not add-on), strip any path from name
|
||||
// Relative path of add-on is kept
|
||||
paths = strrchr(name, '/') + 1;
|
||||
// For library (but not add-on), strip any path from name.
|
||||
// Relative path of add-on is kept.
|
||||
const char* paths = strrchr(name, '/') + 1;
|
||||
memmove(name, paths, strlen(paths) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// let's evaluate the system path variables to find the container
|
||||
paths = search_path_for_type(type);
|
||||
if (paths) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
// try rpath (DT_RPATH)
|
||||
if (rpath != NULL) {
|
||||
// It consists of a colon-separated search path list. Optionally a
|
||||
// second search path list follows, separated from the first by a
|
||||
// semicolon.
|
||||
const char *semicolon = strchr(rpath, ';');
|
||||
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) {
|
||||
// we found it, copy path!
|
||||
TRACE(("runtime_loader: open_executable(%s): found at %s\n", name, buffer));
|
||||
|
Loading…
Reference in New Issue
Block a user