summaryrefslogtreecommitdiff
path: root/ldso/ldso/dl-elf.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-08-19 13:11:09 +0000
committerEric Andersen <andersen@codepoet.org>2003-08-19 13:11:09 +0000
commit2711bc5895accc67e27232d9b75fc12c7994837f (patch)
tree945cf31c093b07bbdc09222c405297b7951336d1 /ldso/ldso/dl-elf.c
parentbca6a155c79147f706242ed7c590a3538e407a40 (diff)
Cool. Found most of the problem. Turns out we were inadvertanly loading some
libraries multiple times, wasting memory and causing different libraries to use different symbol sets, some of which were not properly resolved. Continue scrubbing ld.so and converting it to use proper types.
Diffstat (limited to 'ldso/ldso/dl-elf.c')
-rw-r--r--ldso/ldso/dl-elf.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index dd3d9a293..3df8b1461 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -180,7 +180,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
{
char *pnt, *pnt1;
struct elf_resolve *tpnt1;
- char *libname;
+ char *libname, *libname2;
_dl_internal_error_number = 0;
pnt = libname = full_libname;
@@ -190,12 +190,33 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
if (_dl_strlen(full_libname) > 1024)
goto goof;
- /* Skip over any initial initial './' path to get the libname */
+ /* Skip over any initial initial './' and '/' stuff to
+ * get the short form libname with no path garbage */
pnt1 = _dl_strrchr(pnt, '/');
if (pnt1) {
libname = pnt1 + 1;
}
+ /* Critical step! Weed out duplicates early to avoid
+ * function aliasing, which wastes memory, and causes
+ * really bad things to happen with weaks and globals. */
+ for (tpnt1 = _dl_loaded_modules; tpnt1; tpnt1 = tpnt1->next) {
+
+ /* Skip over any initial initial './' and '/' stuff to
+ * get the short form libname with no path garbage */
+ libname2 = tpnt1->libname;
+ pnt1 = _dl_strrchr(libname2, '/');
+ if (pnt1) {
+ libname2 = pnt1 + 1;
+ }
+
+ if (_dl_strcmp(libname2, libname) == 0) {
+ /* Well, that was certainly easy */
+ return tpnt1;
+ }
+ }
+
+
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug) _dl_dprintf(_dl_debug_file, "searching for library: '%s'\n", libname);
#endif