tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

dlopen of dynamic linker



Hi,

rump does strange things including dlopen'ing the dynamic linker. At present the dynamic linker will (re-)map/load the file. This patch returns the Obj_Entry *
of the dynamic linker which makes more sense.

Does NULL make more sense than this?

FWIW, linux returns a handle.

Nick


Index: libexec/ld.elf_so/load.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/load.c,v
retrieving revision 1.45
diff -u -p -u -r1.45 load.c
--- libexec/ld.elf_so/load.c    9 May 2013 15:37:58 -0000       1.45
+++ libexec/ld.elf_so/load.c    18 Nov 2013 14:18:30 -0000
@@ -146,6 +146,11 @@ _rtld_load_object(const char *filepath, 
                }
        }
 
+       if (pathlen == _rtld_objself.pathlen &&
+           strcmp(_rtld_objself.path, filepath) == 0) {
+               return &_rtld_objself;
+       }
+
        if (obj == NULL) { /* First use of this object, so we must map it in */
                obj = _rtld_map_object(filepath, fd, &sb);
                (void)close(fd);
Index: libexec/ld.elf_so/rtld.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/rtld.c,v
retrieving revision 1.170
diff -u -p -u -r1.170 rtld.c
--- libexec/ld.elf_so/rtld.c    19 Oct 2013 17:19:30 -0000      1.170
+++ libexec/ld.elf_so/rtld.c    18 Nov 2013 14:18:30 -0000
@@ -636,8 +636,10 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
         * one is being used.
         */
        if (_rtld_objmain->interp != NULL &&
-           strcmp(_rtld_objmain->interp, _rtld_objself.path) != 0)
+           strcmp(_rtld_objmain->interp, _rtld_objself.path) != 0) {
                _rtld_objself.path = xstrdup(_rtld_objmain->interp);
+               _rtld_objself.pathlen = strlen(_rtld_objself.path);
+       }
        dbg(("actual dynamic linker is %s", _rtld_objself.path));
 
        _rtld_digest_dynamic(execname, _rtld_objmain);



Home | Main Index | Thread Index | Old Index