From 02e577f99a33f6425c661aaae56f56ae5f3f6479 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 23 Oct 2008 12:11:24 +0000 Subject: [PATCH] When going to load a library also check whether the last path component matches the program's image name. This is a special case for add-ons that link against the application, with the application not having a soname set. The concerned Pe add-ons (HeaderHeader and others) work now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28294 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/runtime_loader/elf.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/system/runtime_loader/elf.cpp b/src/system/runtime_loader/elf.cpp index 54d6edeac4..35f456abd0 100644 --- a/src/system/runtime_loader/elf.cpp +++ b/src/system/runtime_loader/elf.cpp @@ -1261,6 +1261,17 @@ load_container(char const *name, image_type type, const char *rpath, image_t **_ // reload them. if (type != B_ADD_ON_IMAGE) { found = find_image(name, APP_OR_LIBRARY_TYPE); + + if (found == NULL && type != B_APP_IMAGE) { + // Special case for add-ons that link against the application + // executable, with the executable not having a soname set. + if (const char* lastSlash = strrchr(name, '/')) { + image_t* programImage = get_program_image(); + if (strcmp(programImage->name, lastSlash + 1) == 0) + found = programImage; + } + } + if (found) { atomic_add(&found->ref_count, 1); *_image = found; @@ -1279,7 +1290,7 @@ load_container(char const *name, image_type type, const char *rpath, image_t **_ fd = open_executable(path, type, rpath, get_program_path(), sSearchPathSubDir); if (fd < 0) { - FATAL("cannot open file %s\n", path); + FATAL("cannot open file %s\n", name); KTRACE("rld: load_container(\"%s\"): failed to open file", name); return fd; }