diff options
author | cls%seawood.org <devnull@localhost> | 2001-08-13 08:05:34 +0000 |
---|---|---|
committer | cls%seawood.org <devnull@localhost> | 2001-08-13 08:05:34 +0000 |
commit | 3f6a0b6cee835aefd5d8b02161ebad158305feae (patch) | |
tree | 6d2fc181e8d7700bdc09d8039b481bccfef6219f | |
parent | 18cc073ae8196a36d904f787dd02538c4abfac25 (diff) | |
download | nspr-hg-3f6a0b6cee835aefd5d8b02161ebad158305feae.tar.gz |
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
-rw-r--r-- | pr/src/linking/prlink.c | 179 |
1 files changed, 91 insertions, 88 deletions
diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c index a7df17ca..8d3a79ca 100644 --- a/pr/src/linking/prlink.c +++ b/pr/src/linking/prlink.c @@ -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; - - 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; - } - } + 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 */ + 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]; - - /* 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"); - - /* 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; - - 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; - } - } - - } else { - /* we failed to load the "stub" - try to load the - component directly as an add-on */ - h = load_add_on(name); - } - } + 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. + */ + + strcpy(stubName, name); + strcat(stubName, ".stub"); + + /* 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 */ + imageid = info.id; + break; + } + } + + } 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 |