Bug 280948 - Work around the L_IGNOREUNLOAD flag not being supported on 64-bit AIX. MOZILLA_1_7_BRANCH CAMINO_0_8_3_RELEASE MOZILLA_1_7_6_RELEASE
authorpkw%us.ibm.com
Thu, 10 Feb 2005 00:19:56 +0000
branchMOZILLA_1_7_BRANCH
changeset 3271 7e6bfc9aeeb253f899fa583320861666e56ba967
parent 3268 ba59472a51bc21ac6954f0ebda2251bdb6f89682
child 3343 d2eec99c12d06ba021431f0af32a5555543d7c6c
push idunknown
push userunknown
push dateunknown
bugs280948
Bug 280948 - Work around the L_IGNOREUNLOAD flag not being supported on 64-bit AIX. r=wtchang@redhat.com, a=mkaply@us.ibm.com
pr/src/linking/prlink.c
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -1748,26 +1748,40 @@ PR_GetLibraryFilePathname(const char *na
     PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, 0);
     return NULL;
 #elif defined(AIX)
     char *result;
 #define LD_INFO_INCREMENT 64
     struct ld_info *info;
     unsigned int info_length = LD_INFO_INCREMENT * sizeof(struct ld_info);
     struct ld_info *infop;
+    int loadflags = L_GETINFO | L_IGNOREUNLOAD;
 
     for (;;) {
         info = PR_Malloc(info_length);
         if (info == NULL) {
             return NULL;
         }
         /* If buffer is too small, loadquery fails with ENOMEM. */
-        if (loadquery(L_GETINFO | L_IGNOREUNLOAD, info, info_length) != -1) {
+        if (loadquery(loadflags, info, info_length) != -1) {
             break;
         }
+        /*
+         * Calling loadquery when compiled for 64-bit with the
+         * L_IGNOREUNLOAD flag can cause an invalid argument error
+         * on AIX 5.1. Detect this error the first time that
+         * loadquery is called, and try calling it again without
+         * this flag set.
+         */
+        if (errno == EINVAL && (loadflags & L_IGNOREUNLOAD)) {
+            loadflags &= ~L_IGNOREUNLOAD;
+            if (loadquery(loadflags, info, info_length) != -1) {
+                break;
+            }
+        }
         PR_Free(info);
         if (errno != ENOMEM) {
             /* should not happen */
             _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO());
             return NULL;
         }
         /* retry with a larger buffer */
         info_length += LD_INFO_INCREMENT * sizeof(struct ld_info);