From e6bf045bcbf9d4984bae5b64267c776d41f8d017 Mon Sep 17 00:00:00 2001 From: das Date: Mon, 25 Feb 2002 15:21:59 +0000 Subject: * unix/tclLoadDyld.c: updated to use Mac OS X 10.1 dyld APIs that have more libdl-like semantics. (bug #514392) --- ChangeLog | 5 +++++ unix/tclLoadDyld.c | 32 ++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3be8437..1e2594f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-02-25 Daniel Steffen + + * unix/tclLoadDyld.c: updated to use Mac OS X 10.1 dyld APIs that + have more libdl-like semantics. (bug #514392) + 2002-02-25 Miguel Sofer * generic/tclCompCmds: fixing a bug in patch dated 2002-02-22, in diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index a6e16f5..8541416 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -11,10 +11,11 @@ * 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.7 2002/01/09 19:09:28 kennykb Exp $ + * RCS: @(#) $Id: tclLoadDyld.c,v 1.8 2002/02/25 15:21:59 das Exp $ */ #include "tclInt.h" +#include "tclPort.h" #include /* @@ -58,18 +59,21 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, * this file. */ { NSSymbol symbol; - enum DYLD_BOOL dyld_return; + const struct mach_header *dyld_lib; Tcl_DString newName, ds; char *native; native = Tcl_FSGetNativePath(pathPtr); - dyld_return = NSAddLibrary(native); + dyld_lib = NSAddImage(native, + NSADDIMAGE_OPTION_WITH_SEARCHING | + NSADDIMAGE_OPTION_RETURN_ON_ERROR); - if (dyld_return != TRUE) { - Tcl_AppendResult(interp, "dyld: couldn't add library \"", - Tcl_GetString(pathPtr), - "\": ", Tcl_PosixError(interp), (char *) NULL); - return TCL_ERROR; + if (!dyld_lib) { + NSLinkEditErrors editError; + char *name, *msg; + NSLinkEditError(&editError, &errno, &name, &msg); + Tcl_AppendResult(interp, msg, (char *) NULL); + return TCL_ERROR; } *unloadProcPtr = &TclpUnloadFile; @@ -82,8 +86,10 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, Tcl_DStringInit(&newName); Tcl_DStringAppend(&newName, "_", 1); native = Tcl_DStringAppend(&newName, native, -1); - if(NSIsSymbolNameDefined(native)) { - symbol = NSLookupAndBindSymbol(native); + symbol = NSLookupSymbolInImage(dyld_lib, native, + NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW | + NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + if(symbol) { *proc1Ptr = NSAddressOfSymbol(symbol); *clientDataPtr = NSModuleForSymbol(symbol); } else { @@ -97,8 +103,10 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, Tcl_DStringInit(&newName); Tcl_DStringAppend(&newName, "_", 1); native = Tcl_DStringAppend(&newName, native, -1); - if(NSIsSymbolNameDefined(native)) { - symbol = NSLookupAndBindSymbol(native); + symbol = NSLookupSymbolInImage(dyld_lib, native, + NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW | + NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + if(symbol) { *proc2Ptr = NSAddressOfSymbol(symbol); } else { *proc2Ptr=NULL; -- cgit v0.12