summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2000-09-09 05:45:50 +0000
committerwtc%netscape.com <devnull@localhost>2000-09-09 05:45:50 +0000
commit8b6d181acae64398b3fce229bec48e12dc56ed37 (patch)
tree079c74110ed6cc9842d4c08001f7713ee77bc32f
parente22e0fa8ef3159686ed1f800d404a47923040c6d (diff)
downloadnspr-hg-8b6d181acae64398b3fce229bec48e12dc56ed37.tar.gz
Bugzilla bug #51655: checked in BeOS load_add_on() workaround contributedjar_restructuring_base
by Justin Morey <justin@68k.org>. r=wtc@netscape.com,a=brendan@mozilla.org. (NSPRPUB_CLIENT_BRANCH)
-rw-r--r--pr/src/linking/prlink.c69
1 files changed, 63 insertions, 6 deletions
diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c
index c42491ef..d302e559 100644
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -780,17 +780,74 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags)
image_info info;
int32 cookie = 0;
image_id h = B_ERROR;
+ PRLibrary *p;
- while(get_next_image_info(0, &cookie, &info) == B_OK)
- if(strcmp(name, info.name + strlen(info.name) - strlen(name)) == 0) {
+ 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++; /* it has been already loaded implcitly, so pretend it already had a control structure and ref */
+ lm->refCount++;
+ break;
}
+ }
- if(h == B_ERROR)
- h = load_add_on( name );
+ 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 *endOfName = info.name + strlen(info.name) - strlen(name);
+ if (endOfName < info.name)
+ continue;
+
+ if (strcmp(name, endOfName) == 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( h == B_ERROR || h <= 0 ) {
+ if (h <= B_ERROR) {
oserr = h;
PR_DELETE( lm );
goto unlock;