瀏覽代碼

Fix up of '_dlopen' call and removal of unneeded argument in call '_dl_load_elf_shared_library'.

"Steven J. Hill" 22 年之前
父節點
當前提交
1829481835
共有 5 個文件被更改,包括 43 次插入41 次删除
  1. 20 17
      ldso/ldso/dl-elf.c
  2. 1 1
      ldso/ldso/linuxelf.h
  3. 20 17
      ldso/ldso/readelflib1.c
  4. 1 3
      ldso/libdl/dlib.c
  5. 1 3
      ldso/libdl/libdl.c

+ 20 - 17
ldso/ldso/dl-elf.c

@@ -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

+ 1 - 1
ldso/ldso/linuxelf.h

@@ -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
 

+ 20 - 17
ldso/ldso/readelflib1.c

@@ -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

+ 1 - 3
ldso/libdl/dlib.c

@@ -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;
 		    };

+ 1 - 3
ldso/libdl/libdl.c

@@ -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;
 		    };