runtime_loader: Set sSearchPathSubDir on first image, not on app image.

Under normal conditions this will behave identically. But when using LD_PRELOAD
or the like, some shared objects (and dependencies) are loaded before the
app image is, and on the secondary arch on hybrid builds, will fail to load
any of their dependencies due to sSearchPathSubDir not being set.

Fixes #12214, which had plagued users of libroot_debug for a long time now.
This commit is contained in:
Augustin Cavalier
2017-11-22 17:55:36 +01:00
parent f69717add6
commit df9bc792e0
+4 -3
View File
@@ -570,9 +570,10 @@ load_image(char const* name, image_type type, const char* rpath,
analyze_image_haiku_version_and_abi(fd, image, eheader, sheaderSize,
pheaderBuffer, sizeof(pheaderBuffer));
// If this is the executable image, we init the search path
// subdir, if the compiler version doesn't match ours.
if (type == B_APP_IMAGE) {
// If sSearchPathSubDir is unset (meaning, this is the first image we're
// loading) we init the search path subdir if the compiler version doesn't
// match ours.
if (sSearchPathSubDir == NULL) {
#if __GNUC__ == 2
if ((image->abi & B_HAIKU_ABI_MAJOR) == B_HAIKU_ABI_GCC_4)
sSearchPathSubDir = "x86";