mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
On BeOS, leave the stub libraries loaded as future versions of the BeOS kernel may unload the real libraries otherwise.
Thanks to Josh Soref <timeless@mac.com> for the patch. Bug #83875 r=wtc,cls
This commit is contained in:
parent
0485d9445f
commit
de1bf3944c
@ -132,7 +132,8 @@ struct PRLibrary {
|
||||
#endif
|
||||
|
||||
#ifdef XP_BEOS
|
||||
void* dlh;
|
||||
void* dlh;
|
||||
void* stub_dlh;
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -358,7 +359,7 @@ PR_GetLibraryPath()
|
||||
#ifdef XP_BEOS
|
||||
ev = getenv("LIBRARY_PATH");
|
||||
if (!ev) {
|
||||
ev = "%A/lib:/boot/home/config/lib:/boot/beos/system/lib";
|
||||
ev = "%A/lib:/boot/home/config/lib:/boot/beos/system/lib";
|
||||
}
|
||||
#else
|
||||
ev = getenv("LD_LIBRARY_PATH");
|
||||
@ -810,91 +811,91 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags)
|
||||
|
||||
#ifdef XP_BEOS
|
||||
{
|
||||
image_info info;
|
||||
int32 cookie = 0;
|
||||
image_id h = B_ERROR;
|
||||
PRLibrary *p;
|
||||
image_info info;
|
||||
int32 cookie = 0;
|
||||
image_id imageid = B_ERROR;
|
||||
image_id stubid = B_ERROR;
|
||||
PRLibrary *p;
|
||||
|
||||
for (p = pr_loadmap; p != NULL; p = p->next) {
|
||||
/* hopefully, our caller will always use the same string
|
||||
to refer to the same library */
|
||||
if (strcmp(name, p->name) == 0) {
|
||||
/* we've already loaded this library */
|
||||
h = info.id;
|
||||
lm->refCount++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (p = pr_loadmap; p != NULL; p = p->next) {
|
||||
/* hopefully, our caller will always use the same string
|
||||
to refer to the same library */
|
||||
if (strcmp(name, p->name) == 0) {
|
||||
/* we've already loaded this library */
|
||||
imageid = info.id;
|
||||
lm->refCount++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(h == B_ERROR) {
|
||||
/* it appears the library isn't yet loaded - load it now */
|
||||
char stubName [B_PATH_NAME_LENGTH + 1];
|
||||
if(imageid == B_ERROR) {
|
||||
/* it appears the library isn't yet loaded - load it now */
|
||||
char stubName [B_PATH_NAME_LENGTH + 1];
|
||||
|
||||
/* the following is a work-around to a "bug" in the beos -
|
||||
the beos system loader allows only 32M (system-wide)
|
||||
to be used by code loaded as "add-ons" (code loaded
|
||||
through the 'load_add_on()' system call, which includes
|
||||
mozilla components), but allows 256M to be used by
|
||||
shared libraries.
|
||||
|
||||
unfortunately, mozilla is too large to fit into the
|
||||
"add-on" space, so we must trick the loader into
|
||||
loading some of the components as shared libraries. this
|
||||
is accomplished by creating a "stub" add-on (an empty
|
||||
shared object), and linking it with the component
|
||||
(the actual .so file generated by the build process,
|
||||
without any modifications). when this stub is loaded
|
||||
by load_add_on(), the loader will automatically load the
|
||||
component into the shared library space.
|
||||
*/
|
||||
/* the following is a work-around to a "bug" in the beos -
|
||||
the beos system loader allows only 32M (system-wide)
|
||||
to be used by code loaded as "add-ons" (code loaded
|
||||
through the 'load_add_on()' system call, which includes
|
||||
mozilla components), but allows 256M to be used by
|
||||
shared libraries.
|
||||
|
||||
unfortunately, mozilla is too large to fit into the
|
||||
"add-on" space, so we must trick the loader into
|
||||
loading some of the components as shared libraries. this
|
||||
is accomplished by creating a "stub" add-on (an empty
|
||||
shared object), and linking it with the component
|
||||
(the actual .so file generated by the build process,
|
||||
without any modifications). when this stub is loaded
|
||||
by load_add_on(), the loader will automatically load the
|
||||
component into the shared library space.
|
||||
*/
|
||||
|
||||
strcpy(stubName, name);
|
||||
strcat(stubName, ".stub");
|
||||
strcpy(stubName, name);
|
||||
strcat(stubName, ".stub");
|
||||
|
||||
/* first, attempt to load the stub (thereby loading the
|
||||
component as a shared library */
|
||||
if ((h = load_add_on(stubName)) > B_ERROR) {
|
||||
/* the stub was loaded successfully. however, the stub
|
||||
itself is useless (so useless, in fact, that we will
|
||||
simply unload it) */
|
||||
unload_add_on(h);
|
||||
h = B_FILE_NOT_FOUND;
|
||||
/* first, attempt to load the stub (thereby loading the
|
||||
component as a shared library */
|
||||
if ((stubid = load_add_on(stubName)) > B_ERROR) {
|
||||
/* the stub was loaded successfully. */
|
||||
imageid = B_FILE_NOT_FOUND;
|
||||
|
||||
cookie = 0;
|
||||
while (get_next_image_info(0, &cookie, &info) == B_OK) {
|
||||
char *endOfSystemName = strrchr(info.name, '/');
|
||||
char *endOfPassedName = strrchr(name, '/');
|
||||
if( 0 == endOfSystemName )
|
||||
endOfSystemName=info.name;
|
||||
else
|
||||
endOfSystemName++;
|
||||
if( 0 == endOfPassedName )
|
||||
endOfPassedName=name;
|
||||
else
|
||||
endOfPassedName++;
|
||||
if (strcmp(endOfSystemName, endOfPassedName) == 0) {
|
||||
/* this is the actual component - remember it */
|
||||
h = info.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
cookie = 0;
|
||||
while (get_next_image_info(0, &cookie, &info) == B_OK) {
|
||||
char *endOfSystemName = strrchr(info.name, '/');
|
||||
char *endOfPassedName = strrchr(name, '/');
|
||||
if( 0 == endOfSystemName )
|
||||
endOfSystemName=info.name;
|
||||
else
|
||||
endOfSystemName++;
|
||||
if( 0 == endOfPassedName )
|
||||
endOfPassedName=name;
|
||||
else
|
||||
endOfPassedName++;
|
||||
if (strcmp(endOfSystemName, endOfPassedName) == 0) {
|
||||
/* this is the actual component - remember it */
|
||||
imageid = info.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
/* we failed to load the "stub" - try to load the
|
||||
component directly as an add-on */
|
||||
h = load_add_on(name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* we failed to load the "stub" - try to load the
|
||||
component directly as an add-on */
|
||||
stubid = B_ERROR;
|
||||
imageid = load_add_on(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (h <= B_ERROR) {
|
||||
oserr = h;
|
||||
PR_DELETE( lm );
|
||||
goto unlock;
|
||||
}
|
||||
lm->name = strdup(name);
|
||||
lm->dlh = (void*)h;
|
||||
lm->next = pr_loadmap;
|
||||
pr_loadmap = lm;
|
||||
if (imageid <= B_ERROR) {
|
||||
oserr = imageid;
|
||||
PR_DELETE( lm );
|
||||
goto unlock;
|
||||
}
|
||||
lm->name = strdup(name);
|
||||
lm->dlh = (void*)imageid;
|
||||
lm->stub_dlh = (void*)stubid;
|
||||
lm->next = pr_loadmap;
|
||||
pr_loadmap = lm;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1075,7 +1076,10 @@ PR_UnloadLibrary(PRLibrary *lib)
|
||||
}
|
||||
|
||||
#ifdef XP_BEOS
|
||||
unload_add_on( (image_id) lib->dlh );
|
||||
if(((image_id)lib->stub_dlh) == B_ERROR)
|
||||
unload_add_on( (image_id) lib->dlh );
|
||||
else
|
||||
unload_add_on( (image_id) lib->stub_dlh);
|
||||
#endif
|
||||
|
||||
#ifdef XP_UNIX
|
||||
@ -1209,8 +1213,7 @@ pr_FindSymbolInLib(PRLibrary *lm, const char *name)
|
||||
|
||||
#ifdef XP_BEOS
|
||||
if( B_NO_ERROR != get_image_symbol( (image_id)lm->dlh, name, B_SYMBOL_TYPE_TEXT, &f ) ) {
|
||||
|
||||
f = NULL;
|
||||
f = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user