From d1e77398a88c782621e53c1697ab594399d0fa3b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 10 Jun 2021 14:49:08 +0000 Subject: Experiment: use dladdr() on Linux to locate the shared library. Won't work on other platforms! WIP --- generic/tclZipfs.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 35b6712..303ea03 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -16,6 +16,7 @@ * projects. */ +#define _GNU_SOURCE #include "tclInt.h" #include "tclFileSystem.h" @@ -32,6 +33,10 @@ #define TBLS 1 #endif +#if 1 /* HAVE_DLADDR */ +#include +#endif + #ifdef HAVE_ZLIB #include "zlib.h" #include "crypt.h" @@ -3907,6 +3912,12 @@ TclZipfs_TclLibrary(void) if (ZipfsAppHookFindTclInit(dllName) == TCL_OK) { return Tcl_NewStringObj(zipfs_literal_tcl_library, -1); } +#elif 1 + Dl_info dlinfo; + if (dladdr(TclZipfs_TclLibrary, &dlinfo) && (dlinfo.dli_fname != NULL) + && (ZipfsAppHookFindTclInit(dlinfo.dli_fname) == TCL_OK)) { + return Tcl_NewStringObj(zipfs_literal_tcl_library, -1); + } #else if (ZipfsAppHookFindTclInit(CFG_RUNTIME_LIBDIR "/" CFG_RUNTIME_DLLFILE) == TCL_OK) { return Tcl_NewStringObj(zipfs_literal_tcl_library, -1); -- cgit v0.12