1276N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
98N/A# Use is subject to license terms.
919N/A# Permission is hereby granted, free of charge, to any person obtaining a
919N/A# copy of this software and associated documentation files (the "Software"),
919N/A# to deal in the Software without restriction, including without limitation
919N/A# the rights to use, copy, modify, merge, publish, distribute, sublicense,
919N/A#
and/or sell copies of the Software, and to permit persons to whom the
919N/A# Software is furnished to do so, subject to the following conditions:
919N/A# The above copyright notice and this permission notice (including the next
919N/A# paragraph) shall be included in all copies or substantial portions of the
919N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
919N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
919N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
919N/A# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
919N/A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
919N/A# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
98N/A@@ -167,6 +167,13 @@ InitPathList(const char *path)
98N/A list[n][len - 1] = '/';
1366N/A+#ifdef SUNSOFT /* strip amd64/ off loader path if it's there */
98N/A+ if (strcmp(list[n] + (len - 6), "amd64/") == 0) {
98N/A@@ -392,6 +399,18 @@ FindModuleInSubdir(const char *dirpath,
1276N/A char *ret = NULL, tmpBuf[PATH_MAX];
1634N/A+#if defined(SUNSOFT) && defined(__x86)
1366N/A+ if (strstr(dirpath, "/amd64") != NULL) {
98N/A+# if !(defined(__amd64) || defined(__amd64__))
@@ -399,6 +418,13 @@ FindModuleInSubdir(const char *dirpath,
while ((direntry = readdir(dir))) {
if (direntry->d_name[0] == '.')
+#if defined(SUNSOFT) && (defined(__i386) || defined(__i386__))
+ /* skip 64-bit subdirectories when running 32-bit server */
+ if (strcmp(direntry->d_name, "amd64") == 0)
snprintf(tmpBuf, PATH_MAX, "%s%s/", dirpath, direntry->d_name);
/* the stat with the appended / fails for normal files,
and works for sub dirs fine, looks a bit strange in strace
@@ -408,6 +434,12 @@ FindModuleInSubdir(const char *dirpath,
+#if defined(SUNSOFT) && (defined(__amd64) || defined(__amd64__))
+ /* Don't match files in non-amd64 directories */
snprintf(tmpBuf, PATH_MAX, "lib%
s.so", module);
if (strcmp(direntry->d_name, tmpBuf) == 0) {