OSDN Git Service

Fix up of '_dlopen' call and removal of unneeded argument in call '_dl_load_elf_share...
author"Steven J. Hill" <sjhill@realitydiluted.com>
Wed, 5 Jun 2002 18:40:46 +0000 (18:40 -0000)
committer"Steven J. Hill" <sjhill@realitydiluted.com>
Wed, 5 Jun 2002 18:40:46 +0000 (18:40 -0000)
ldso/ldso/dl-elf.c
ldso/ldso/linuxelf.h
ldso/ldso/readelflib1.c
ldso/libdl/dlib.c
ldso/libdl/libdl.c

index 4422a46..c5e7607 100644 (file)
@@ -141,7 +141,7 @@ search_for_named_library(char *name, int secure, const char *path_list,
                _dl_strcat(mylibname, "/"); 
                _dl_strcat(mylibname, name);
                if ((tpnt1 = _dl_load_elf_shared_library(secure, rpnt,
-                       mylibname, 0)) != NULL)
+                       mylibname)) != NULL)
                {
                        return tpnt1;
                }
@@ -188,7 +188,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
           /usr/i486-sysv4/lib for /usr/lib in library names. */
 
        if (libname != full_libname) {
-               tpnt1 = _dl_load_elf_shared_library(secure, rpnt, full_libname, 0);
+               tpnt1 = _dl_load_elf_shared_library(secure, rpnt, full_libname);
                if (tpnt1)
                        return tpnt1;
                goto goof;
@@ -243,7 +243,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
                                 libent[i].flags == LIB_ELF_LIBC5) &&
                                _dl_strcmp(libname, strs + libent[i].sooffset) == 0 &&
                                (tpnt1 = _dl_load_elf_shared_library(secure, 
-                                    rpnt, strs + libent[i].liboffset, 0)))
+                                    rpnt, strs + libent[i].liboffset)))
                                return tpnt1;
                }
        }
@@ -297,7 +297,7 @@ goof:
  */
 
 struct elf_resolve *_dl_load_elf_shared_library(int secure,
-       struct dyn_elf **rpnt, char *libname, int flag)
+       struct dyn_elf **rpnt, char *libname)
 {
        elfhdr *epnt;
        unsigned long dynamic_addr = 0;
@@ -319,14 +319,16 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
        /* If this file is already loaded, skip this step */
        tpnt = _dl_check_hashed_files(libname);
        if (tpnt) {
-               (*rpnt)->next = (struct dyn_elf *)
-                       _dl_malloc(sizeof(struct dyn_elf));
-               _dl_memset((*rpnt)->next, 0, sizeof(*((*rpnt)->next)));
-               *rpnt = (*rpnt)->next;
+               if (*rpnt) {
+                       (*rpnt)->next = (struct dyn_elf *)
+                               _dl_malloc(sizeof(struct dyn_elf));
+                       _dl_memset((*rpnt)->next, 0, sizeof(*((*rpnt)->next)));
+                       *rpnt = (*rpnt)->next;
+                       (*rpnt)->dyn = tpnt;
+                       tpnt->symbol_scope = _dl_symbol_tables;
+               }
                tpnt->usage_count++;
-               tpnt->symbol_scope = _dl_symbol_tables;
                tpnt->libtype = elf_lib;
-               (*rpnt)->dyn = tpnt;
                return tpnt;
        }
 
@@ -565,7 +567,6 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                }
        }
 
-
        tpnt = _dl_add_elf_hash_table(libname, (char *) libaddr, dynamic_info, 
                dynamic_addr, dynamic_size);
 
@@ -575,14 +576,16 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
        /*
         * Add this object into the symbol chain
         */
-       (*rpnt)->next = (struct dyn_elf *)
-               _dl_malloc(sizeof(struct dyn_elf));
-       _dl_memset((*rpnt)->next, 0, sizeof(*((*rpnt)->next)));
-       *rpnt = (*rpnt)->next;
+       if (*rpnt) {
+               (*rpnt)->next = (struct dyn_elf *)
+                       _dl_malloc(sizeof(struct dyn_elf));
+               _dl_memset((*rpnt)->next, 0, sizeof(*((*rpnt)->next)));
+               *rpnt = (*rpnt)->next;
+               (*rpnt)->dyn = tpnt;
+               tpnt->symbol_scope = _dl_symbol_tables;
+       }
        tpnt->usage_count++;
-       tpnt->symbol_scope = _dl_symbol_tables;
        tpnt->libtype = elf_lib;
-       (*rpnt)->dyn = tpnt;
 
        /*
         * OK, the next thing we need to do is to insert the dynamic linker into
index a1c9903..5a6e8b8 100644 (file)
@@ -25,7 +25,7 @@ extern int _dl_parse_relocation_information(struct elf_resolve *tpnt,
 extern struct elf_resolve * _dl_load_shared_library(int secure, 
        struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname);
 extern struct elf_resolve * _dl_load_elf_shared_library(int secure, 
-       struct dyn_elf **rpnt, char *libname, int flag);
+       struct dyn_elf **rpnt, char *libname);
 extern int _dl_linux_resolve(void);
 #define ELF_CLASS   ELFCLASS32
 
index 4422a46..c5e7607 100644 (file)
@@ -141,7 +141,7 @@ search_for_named_library(char *name, int secure, const char *path_list,
                _dl_strcat(mylibname, "/"); 
                _dl_strcat(mylibname, name);
                if ((tpnt1 = _dl_load_elf_shared_library(secure, rpnt,
-                       mylibname, 0)) != NULL)
+                       mylibname)) != NULL)
                {
                        return tpnt1;
                }
@@ -188,7 +188,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
           /usr/i486-sysv4/lib for /usr/lib in library names. */
 
        if (libname != full_libname) {
-               tpnt1 = _dl_load_elf_shared_library(secure, rpnt, full_libname, 0);
+               tpnt1 = _dl_load_elf_shared_library(secure, rpnt, full_libname);
                if (tpnt1)
                        return tpnt1;
                goto goof;
@@ -243,7 +243,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
                                 libent[i].flags == LIB_ELF_LIBC5) &&
                                _dl_strcmp(libname, strs + libent[i].sooffset) == 0 &&
                                (tpnt1 = _dl_load_elf_shared_library(secure, 
-                                    rpnt, strs + libent[i].liboffset, 0)))
+                                    rpnt, strs + libent[i].liboffset)))
                                return tpnt1;
                }
        }
@@ -297,7 +297,7 @@ goof:
  */
 
 struct elf_resolve *_dl_load_elf_shared_library(int secure,
-       struct dyn_elf **rpnt, char *libname, int flag)
+       struct dyn_elf **rpnt, char *libname)
 {
        elfhdr *epnt;
        unsigned long dynamic_addr = 0;
@@ -319,14 +319,16 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
        /* If this file is already loaded, skip this step */
        tpnt = _dl_check_hashed_files(libname);
        if (tpnt) {
-               (*rpnt)->next = (struct dyn_elf *)
-                       _dl_malloc(sizeof(struct dyn_elf));
-               _dl_memset((*rpnt)->next, 0, sizeof(*((*rpnt)->next)));
-               *rpnt = (*rpnt)->next;
+               if (*rpnt) {
+                       (*rpnt)->next = (struct dyn_elf *)
+                               _dl_malloc(sizeof(struct dyn_elf));
+                       _dl_memset((*rpnt)->next, 0, sizeof(*((*rpnt)->next)));
+                       *rpnt = (*rpnt)->next;
+                       (*rpnt)->dyn = tpnt;
+                       tpnt->symbol_scope = _dl_symbol_tables;
+               }
                tpnt->usage_count++;
-               tpnt->symbol_scope = _dl_symbol_tables;
                tpnt->libtype = elf_lib;
-               (*rpnt)->dyn = tpnt;
                return tpnt;
        }
 
@@ -565,7 +567,6 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                }
        }
 
-
        tpnt = _dl_add_elf_hash_table(libname, (char *) libaddr, dynamic_info, 
                dynamic_addr, dynamic_size);
 
@@ -575,14 +576,16 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
        /*
         * Add this object into the symbol chain
         */
-       (*rpnt)->next = (struct dyn_elf *)
-               _dl_malloc(sizeof(struct dyn_elf));
-       _dl_memset((*rpnt)->next, 0, sizeof(*((*rpnt)->next)));
-       *rpnt = (*rpnt)->next;
+       if (*rpnt) {
+               (*rpnt)->next = (struct dyn_elf *)
+                       _dl_malloc(sizeof(struct dyn_elf));
+               _dl_memset((*rpnt)->next, 0, sizeof(*((*rpnt)->next)));
+               *rpnt = (*rpnt)->next;
+               (*rpnt)->dyn = tpnt;
+               tpnt->symbol_scope = _dl_symbol_tables;
+       }
        tpnt->usage_count++;
-       tpnt->symbol_scope = _dl_symbol_tables;
        tpnt->libtype = elf_lib;
-       (*rpnt)->dyn = tpnt;
 
        /*
         * OK, the next thing we need to do is to insert the dynamic linker into
index 5140ae2..82ec509 100644 (file)
@@ -68,7 +68,7 @@ static void dl_cleanup(void)
 void *_dlopen(const char *libname, int flag)
 {
        struct elf_resolve *tpnt, *tfrom;
-       struct dyn_elf *rpnt;
+       struct dyn_elf *rpnt = NULL;
        struct dyn_elf *dyn_chain;
        struct dyn_elf *dpnt;
        static int dl_init = 0;
@@ -115,7 +115,6 @@ void *_dlopen(const char *libname, int flag)
                return NULL;
        }
 
-       tpnt->usage_count++;
        dyn_chain = rpnt = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
        _dl_memset(rpnt, 0, sizeof(*rpnt));
        rpnt->dyn = tpnt;
@@ -151,7 +150,6 @@ void *_dlopen(const char *libname, int flag)
                      rpnt->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
                      _dl_memset (rpnt->next, 0, sizeof (*(rpnt->next)));
                      rpnt = rpnt->next;
-                     tpnt1->usage_count++;
                      if (!tpnt1->symbol_scope) tpnt1->symbol_scope = dyn_chain;
                      rpnt->dyn = tpnt1;
                    };
index 5140ae2..82ec509 100644 (file)
@@ -68,7 +68,7 @@ static void dl_cleanup(void)
 void *_dlopen(const char *libname, int flag)
 {
        struct elf_resolve *tpnt, *tfrom;
-       struct dyn_elf *rpnt;
+       struct dyn_elf *rpnt = NULL;
        struct dyn_elf *dyn_chain;
        struct dyn_elf *dpnt;
        static int dl_init = 0;
@@ -115,7 +115,6 @@ void *_dlopen(const char *libname, int flag)
                return NULL;
        }
 
-       tpnt->usage_count++;
        dyn_chain = rpnt = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
        _dl_memset(rpnt, 0, sizeof(*rpnt));
        rpnt->dyn = tpnt;
@@ -151,7 +150,6 @@ void *_dlopen(const char *libname, int flag)
                      rpnt->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
                      _dl_memset (rpnt->next, 0, sizeof (*(rpnt->next)));
                      rpnt = rpnt->next;
-                     tpnt1->usage_count++;
                      if (!tpnt1->symbol_scope) tpnt1->symbol_scope = dyn_chain;
                      rpnt->dyn = tpnt1;
                    };