[uClibc-cvs] uClibc/ldso/ldso hash.c,1.12,1.13 readelflib1.c,1.40,1.41 ldso.c,1.66,1.67
Erik Andersen
andersen at uclibc.org
Wed Jun 18 22:42:28 UTC 2003
Update of /var/cvs/uClibc/ldso/ldso
In directory winder:/tmp/cvs-serv25935
Modified Files:
hash.c readelflib1.c ldso.c
Log Message:
Be extra careful to memset the correct size, not the size of some random
pointer. Fix printing of '0x0x' in ldd output. Simplify discrimination of
libname, so doing things like dlopen("./libfoo.so",RTLD_NOW) with a leading
"./" in the path will work as expected.
-Erik
Index: hash.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/hash.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- hash.c 12 Dec 2002 22:22:00 -0000 1.12
+++ hash.c 18 Jun 2003 22:42:23 -0000 1.13
@@ -109,13 +109,13 @@
if (!_dl_loaded_modules) {
tpnt = _dl_loaded_modules =
(struct elf_resolve *) _dl_malloc(sizeof(struct elf_resolve));
- _dl_memset(tpnt, 0, sizeof(*tpnt));
+ _dl_memset(tpnt, 0, sizeof(struct elf_resolve));
} else {
tpnt = _dl_loaded_modules;
while (tpnt->next)
tpnt = tpnt->next;
tpnt->next = (struct elf_resolve *) _dl_malloc(sizeof(struct elf_resolve));
- _dl_memset(tpnt->next, 0, sizeof(*(tpnt->next)));
+ _dl_memset(tpnt->next, 0, sizeof(struct elf_resolve));
tpnt->next->prev = tpnt;
tpnt = tpnt->next;
};
Index: readelflib1.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/readelflib1.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- readelflib1.c 1 Mar 2003 07:11:39 -0000 1.40
+++ readelflib1.c 18 Jun 2003 22:42:23 -0000 1.41
@@ -178,7 +178,7 @@
struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
struct elf_resolve *tpnt, char *full_libname)
{
- char *pnt;
+ char *pnt, *pnt1;
struct elf_resolve *tpnt1;
char *libname;
@@ -190,10 +190,10 @@
if (_dl_strlen(full_libname) > 1024)
goto goof;
- while (*pnt) {
- if (*pnt == '/')
- libname = pnt + 1;
- pnt++;
+ /* Skip over any initial initial './' path to get the libname */
+ pnt1 = _dl_strrchr(pnt, '/');
+ if (pnt1) {
+ libname = pnt1 + 1;
}
#if defined (__SUPPORT_LD_DEBUG__)
@@ -207,7 +207,7 @@
tpnt1 = _dl_load_elf_shared_library(secure, rpnt, full_libname);
if (tpnt1)
return tpnt1;
- goto goof;
+ //goto goof;
}
/*
@@ -334,9 +334,8 @@
tpnt = _dl_check_hashed_files(libname);
if (tpnt) {
if (*rpnt) {
- (*rpnt)->next = (struct dyn_elf *)
- _dl_malloc(sizeof(struct dyn_elf));
- _dl_memset((*rpnt)->next, 0, sizeof(*((*rpnt)->next)));
+ (*rpnt)->next = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
+ _dl_memset((*rpnt)->next, 0, sizeof(struct dyn_elf));
(*rpnt)->next->prev = (*rpnt);
*rpnt = (*rpnt)->next;
(*rpnt)->dyn = tpnt;
@@ -602,9 +601,8 @@
* Add this object into the symbol chain
*/
if (*rpnt) {
- (*rpnt)->next = (struct dyn_elf *)
- _dl_malloc(sizeof(struct dyn_elf));
- _dl_memset((*rpnt)->next, 0, sizeof(*((*rpnt)->next)));
+ (*rpnt)->next = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
+ _dl_memset((*rpnt)->next, 0, sizeof(struct dyn_elf));
(*rpnt)->next->prev = (*rpnt);
*rpnt = (*rpnt)->next;
(*rpnt)->dyn = tpnt;
Index: ldso.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/ldso.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- ldso.c 4 Mar 2003 10:13:01 -0000 1.66
+++ ldso.c 18 Jun 2003 22:42:23 -0000 1.67
@@ -372,9 +372,9 @@
}
tpnt = LD_MALLOC(sizeof(struct elf_resolve));
- _dl_memset(tpnt, 0, sizeof(*tpnt));
+ _dl_memset(tpnt, 0, sizeof(struct elf_resolve));
app_tpnt = LD_MALLOC(sizeof(struct elf_resolve));
- _dl_memset(app_tpnt, 0, sizeof(*app_tpnt));
+ _dl_memset(app_tpnt, 0, sizeof(struct elf_resolve));
/*
* This is used by gdb to locate the chain of shared libraries that are currently loaded.
@@ -754,7 +754,7 @@
_dl_loaded_modules->ppnt = (elf_phdr *) auxvt[AT_PHDR].a_un.a_ptr;
_dl_loaded_modules->n_phent = auxvt[AT_PHNUM].a_un.a_val;
_dl_symbol_tables = rpnt = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
- _dl_memset(rpnt, 0, sizeof(*rpnt));
+ _dl_memset(rpnt, 0, sizeof(struct dyn_elf));
rpnt->dyn = _dl_loaded_modules;
app_tpnt->usage_count++;
app_tpnt->symbol_scope = _dl_symbol_tables;
@@ -946,7 +946,7 @@
/* this is a real hack to make ldd not print
* the library itself when run on a library. */
if (_dl_strcmp(_dl_progname, str) != 0)
- _dl_dprintf(1, "\t%s => %s (0x%x)\n", str, tpnt1->libname,
+ _dl_dprintf(1, "\t%s => %s (%x)\n", str, tpnt1->libname,
(unsigned) tpnt1->loadaddr);
}
#endif
@@ -1019,7 +1019,7 @@
#endif
#ifdef __LDSO_LDD_SUPPORT__
if (_dl_trace_loaded_objects && tpnt1->usage_count==1) {
- _dl_dprintf(1, "\t%s => %s (0x%x)\n", cp2,
+ _dl_dprintf(1, "\t%s => %s (%x)\n", cp2,
tpnt1->libname, (unsigned) tpnt1->loadaddr);
}
#endif
@@ -1073,7 +1073,7 @@
name = tpnt->libname;
while(*name == '/')
name++;
- _dl_dprintf(1, "\t%s => %s (0x%x)\n",
+ _dl_dprintf(1, "\t%s => %s (%x)\n",
lpntstr, --name, (unsigned) tpnt->loadaddr);
}
#endif
@@ -1083,9 +1083,8 @@
ttmp->next = tpnt;
tpnt->prev = ttmp;
tpnt->next = NULL;
- rpnt->next = (struct dyn_elf *)
- _dl_malloc(sizeof(struct dyn_elf));
- _dl_memset(rpnt->next, 0, sizeof(*(rpnt->next)));
+ rpnt->next = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
+ _dl_memset(rpnt->next, 0, sizeof(struct dyn_elf));
rpnt->next->prev = rpnt;
rpnt = rpnt->next;
rpnt->dyn = tpnt;
@@ -1115,7 +1114,7 @@
name = tpnt1->libname;
while(*name == '/')
name++;
- _dl_dprintf(1, "\t%s => %s (0x%x)\n", lpntstr, --name,
+ _dl_dprintf(1, "\t%s => %s (%x)\n", lpntstr, --name,
(unsigned) tpnt1->loadaddr);
}
#endif
@@ -1150,14 +1149,13 @@
tpnt->prev = NULL;
}
if (rpnt) {
- rpnt->next =
- (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
- _dl_memset(rpnt->next, 0, sizeof(*(rpnt->next)));
+ rpnt->next = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
+ _dl_memset(rpnt->next, 0, sizeof(struct dyn_elf));
rpnt->next->prev = rpnt;
rpnt = rpnt->next;
} else {
rpnt = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
- _dl_memset(rpnt, 0, sizeof(*(rpnt->next)));
+ _dl_memset(rpnt, 0, sizeof(struct dyn_elf));
}
rpnt->dyn = tpnt;
tpnt = NULL;
@@ -1166,7 +1164,7 @@
#ifdef __LDSO_LDD_SUPPORT__
/* End of the line for ldd.... */
if (_dl_trace_loaded_objects) {
- _dl_dprintf(1, "\t%s => %s (0x%x)\n", rpnt->dyn->libname + (_dl_strlen(_dl_ldsopath)) + 1,
+ _dl_dprintf(1, "\t%s => %s (%x)\n", rpnt->dyn->libname + (_dl_strlen(_dl_ldsopath)) + 1,
rpnt->dyn->libname, rpnt->dyn->loadaddr);
_dl_exit(0);
}
More information about the uClibc-cvs
mailing list