diff options
author | vincentdarley <vincentdarley@noemail.net> | 2002-10-10 12:25:52 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley@noemail.net> | 2002-10-10 12:25:52 (GMT) |
commit | 91bb0051e7d19c110afa67bd8e0ebafa052edcdc (patch) | |
tree | 53b758745c52382936e9eab9d435276110cf48e6 /unix/tclLoadDyld.c | |
parent | afdb69445888c884ed001e631ecbfd387496c98f (diff) | |
download | tcl-91bb0051e7d19c110afa67bd8e0ebafa052edcdc.zip tcl-91bb0051e7d19c110afa67bd8e0ebafa052edcdc.tar.gz tcl-91bb0051e7d19c110afa67bd8e0ebafa052edcdc.tar.bz2 |
load fixes for Bug 611108
FossilOrigin-Name: 4a2a8cda84e8705e04c0b6b3b5a9d8e445298b35
Diffstat (limited to 'unix/tclLoadDyld.c')
-rw-r--r-- | unix/tclLoadDyld.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index f203564..531a3c2 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclLoadDyld.c,v 1.12 2002/07/24 13:51:18 das Exp $ + * RCS: @(#) $Id: tclLoadDyld.c,v 1.13 2002/10/10 12:25:53 vincentdarley Exp $ */ #include "tclInt.h" @@ -63,10 +63,30 @@ TclpDlopen(interp, pathPtr, loadHandle, unloadProcPtr) const struct mach_header *dyld_lib; CONST char *native; + /* + * First try the full path the user gave us. This is particularly + * important if the cwd is inside a vfs, and we are trying to load + * using a relative path. + */ native = Tcl_FSGetNativePath(pathPtr); dyld_lib = NSAddImage(native, - NSADDIMAGE_OPTION_WITH_SEARCHING | - NSADDIMAGE_OPTION_RETURN_ON_ERROR); + NSADDIMAGE_OPTION_WITH_SEARCHING | + NSADDIMAGE_OPTION_RETURN_ON_ERROR); + + if (!dyld_lib) { + /* + * Let the OS loader examine the binary search path for + * whatever string the user gave us which hopefully refers + * to a file on the binary path + */ + Tcl_DString ds; + char *fileName = Tcl_GetString(pathPtr); + native = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds); + dyld_lib = NSAddImage(native, + NSADDIMAGE_OPTION_WITH_SEARCHING | + NSADDIMAGE_OPTION_RETURN_ON_ERROR); + Tcl_DStringFree(&ds); + } if (!dyld_lib) { NSLinkEditErrors editError; @@ -75,6 +95,7 @@ TclpDlopen(interp, pathPtr, loadHandle, unloadProcPtr) Tcl_AppendResult(interp, msg, (char *) NULL); return TCL_ERROR; } + dyldLoadHandle = (Tcl_DyldLoadHandle *) ckalloc(sizeof(Tcl_DyldLoadHandle)); if (!dyldLoadHandle) return TCL_ERROR; dyldLoadHandle->dyld_lib = dyld_lib; |