Issue #1829 - Revert "Issue #1751"

This commit is contained in:
Brian Smith 2022-04-26 11:34:08 -05:00 committed by roytam1
commit 13fcc4a046
949 changed files with 95662 additions and 444 deletions

View file

@ -97,7 +97,11 @@ static LibHandleType
GetLibHandle(pathstr_t aDependentLib)
{
LibHandleType libHandle = dlopen(aDependentLib,
RTLD_GLOBAL | RTLD_LAZY);
RTLD_GLOBAL | RTLD_LAZY
#ifdef XP_MACOSX
| RTLD_FIRST
#endif
);
if (!libHandle) {
fprintf(stderr, "XPCOMGlueLoad error for file %s:\n%s\n", aDependentLib,
dlerror());
@ -231,6 +235,22 @@ XPCOMGlueLoad(const char* aXPCOMFile)
char xpcomDir[MAXPATHLEN];
#ifdef XP_WIN
const char* lastSlash = ns_strrpbrk(aXPCOMFile, "/\\");
#elif XP_MACOSX
// On OSX, the dependentlibs.list file lives under Contents/Resources.
// However, the actual libraries listed in dependentlibs.list live under
// Contents/MacOS. We want to read the list from Contents/Resources, then
// load the libraries from Contents/MacOS.
const char *tempSlash = strrchr(aXPCOMFile, '/');
size_t tempLen = size_t(tempSlash - aXPCOMFile);
if (tempLen > MAXPATHLEN) {
return nullptr;
}
char tempBuffer[MAXPATHLEN];
memcpy(tempBuffer, aXPCOMFile, tempLen);
tempBuffer[tempLen] = '\0';
const char *slash = strrchr(tempBuffer, '/');
tempLen = size_t(slash - tempBuffer);
const char *lastSlash = aXPCOMFile + tempLen;
#else
const char* lastSlash = strrchr(aXPCOMFile, '/');
#endif
@ -239,11 +259,19 @@ XPCOMGlueLoad(const char* aXPCOMFile)
size_t len = size_t(lastSlash - aXPCOMFile);
if (len > MAXPATHLEN - sizeof(XPCOM_FILE_PATH_SEPARATOR
#ifdef XP_MACOSX
"Resources"
XPCOM_FILE_PATH_SEPARATOR
#endif
XPCOM_DEPENDENT_LIBS_LIST)) {
return nullptr;
}
memcpy(xpcomDir, aXPCOMFile, len);
strcpy(xpcomDir + len, XPCOM_FILE_PATH_SEPARATOR
#ifdef XP_MACOSX
"Resources"
XPCOM_FILE_PATH_SEPARATOR
#endif
XPCOM_DEPENDENT_LIBS_LIST);
cursor = xpcomDir + len + 1;
} else {
@ -261,6 +289,14 @@ XPCOMGlueLoad(const char* aXPCOMFile)
return nullptr;
}
#ifdef XP_MACOSX
tempLen = size_t(cursor - xpcomDir);
if (tempLen > MAXPATHLEN - sizeof("MacOS" XPCOM_FILE_PATH_SEPARATOR) - 1) {
return nullptr;
}
strcpy(cursor, "MacOS" XPCOM_FILE_PATH_SEPARATOR);
cursor += strlen(cursor);
#endif
*cursor = '\0';
char buffer[MAXPATHLEN];