diff options
Diffstat (limited to 'unix/tclLoadDl.c')
| -rw-r--r-- | unix/tclLoadDl.c | 32 | 
1 files changed, 25 insertions, 7 deletions
| diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c index f8fe6d3..dc711f8 100644 --- a/unix/tclLoadDl.c +++ b/unix/tclLoadDl.c @@ -66,14 +66,16 @@ TclpDlopen(      Tcl_LoadHandle *loadHandle,	/* Filled with token for dynamically loaded  				 * file which will be passed back to  				 * (*unloadProcPtr)() to unload the file. */ -    Tcl_FSUnloadFileProc **unloadProcPtr) +    Tcl_FSUnloadFileProc **unloadProcPtr,  				/* Filled with address of Tcl_FSUnloadFileProc  				 * function which should be used for this  				 * file. */ +    int flags)  {      void *handle;      Tcl_LoadHandle newHandle;      const char *native; +    int dlopenflags = 0;      /*       * First try the full path the user gave us. This is particularly @@ -83,9 +85,19 @@ TclpDlopen(      native = Tcl_FSGetNativePath(pathPtr);      /* -     * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070] +     * Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070]       */ -    handle = dlopen(native, RTLD_NOW | RTLD_LOCAL); +    if (flags & TCL_LOAD_GLOBAL) { +    	dlopenflags |= RTLD_GLOBAL; +    } else { +    	dlopenflags |= RTLD_LOCAL; +    } +    if (flags & TCL_LOAD_LAZY) { +    	dlopenflags |= RTLD_LAZY; +    } else { +    	dlopenflags |= RTLD_NOW; +    } +    handle = dlopen(native, dlopenflags);      if (handle == NULL) {  	/*  	 * Let the OS loader examine the binary search path for whatever @@ -98,9 +110,9 @@ TclpDlopen(  	native = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds);  	/* -	 * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070] +	 * Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070]  	 */ -	handle = dlopen(native, RTLD_NOW | RTLD_LOCAL); +	handle = dlopen(native, dlopenflags);  	Tcl_DStringFree(&ds);      } @@ -152,7 +164,7 @@ FindSymbol(      const char *native;		/* Name of the library to be loaded, in  				 * system encoding */      Tcl_DString newName, ds;	/* Buffers for converting the name to -				 * system encoding and prepending an  +				 * system encoding and prepending an  				 * underscore*/      void *handle = (void *) loadHandle->clientData;  				/* Native handle to the loaded library */ @@ -176,8 +188,14 @@ FindSymbol(      }      Tcl_DStringFree(&ds);      if (proc == NULL && interp != NULL) { +	const char *errorStr = dlerror(); + +	if (!errorStr) { +	    errorStr = "unknown"; +	} +  	Tcl_SetObjResult(interp, Tcl_ObjPrintf( -		"cannot find symbol \"%s\": %s", symbol, dlerror())); +		"cannot find symbol \"%s\": %s", symbol, errorStr));  	Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "LOAD_SYMBOL", symbol,  		NULL);      } | 
