Tcl Source Code

Check-in [58a4f59ea3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[Bug #3216070] Loading extension libraries from embedded Tcl applications.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk | potential incompatibility
Files: files | file ages | folders
SHA1: 58a4f59ea35e933bfe22766145598b88473a358e
User & Date: jan.nijtmans 2011-03-22 10:14:00.321
Context
2011-03-22
10:15
typo check-in: 6ef9ab3ad5 user: jan.nijtmans tags: trunk
10:14
[Bug #3216070] Loading extension libraries from embedded Tcl applications. check-in: 58a4f59ea3 user: jan.nijtmans tags: trunk, potential incompatibility
10:10
[Bug #3216070] Loading extension libraries from embedded Tcl applications. check-in: e18262f10e user: jan.nijtmans tags: core-8-5-branch, potential incompatibility
2011-03-21
14:42
remove one level of allocator indirection in non-memdebug builds, imported from mig-alloc-reform. check-in: d74d7bb013 user: mig tags: trunk
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to ChangeLog.





1
2
3
4
5
6
7
1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+







2011-03-21  Jan Nijtmans  <[email protected]>

	* unix/tclLoadDl.c:    [Bug #3216070] Loading extension libraries
	* unix/tclLoadDyld.c:  from embedded Tcl applications.

2011-03-21  Miguel Sofer  <[email protected]>

	* generic/tclCkAlloc.c:
	* generic/tclInt.h: remove one level of allocator indirection in
	non memdebug builds, imported from mig-alloc-reform.

2011-03-20  Miguel Sofer  <[email protected]>
Changes to unix/tclLoadDl.c.
15
16
17
18
19
20
21
22

23
24


25
26
27
28
29
30
31
32


33
34
35
36
37
38
39
15
16
17
18
19
20
21

22


23
24
25
26
27
28
29
30


31
32
33
34
35
36
37
38
39







-
+
-
-
+
+






-
-
+
+







#   include "../compat/dlfcn.h"
#else
#   include <dlfcn.h>
#endif

/*
 * In some systems, like SunOS 4.1.3, the RTLD_NOW flag isn't defined and this
 * argument to dlopen must always be 1. The RTLD_GLOBAL flag is needed on some
 * argument to dlopen must always be 1. The RTLD_LOCAL flag doesn't exist on
 * systems (e.g. SCO and UnixWare) but doesn't exist on others; if it doesn't
 * exist, set it to 0 so it has no effect.
 * some platforms; if it doesn't exist, set it to 0 so it has no effect.
 * See [Bug #3216070]
 */

#ifndef RTLD_NOW
#   define RTLD_NOW 1
#endif

#ifndef RTLD_GLOBAL
#   define RTLD_GLOBAL 0
#ifndef RTLD_LOCAL
#   define RTLD_LOCAL 0
#endif

/*
 * Static procedures defined within this file.
 */

static void *		FindSymbol(Tcl_Interp *interp,
78
79
80
81
82
83
84



85

86
87
88
89
90
91
92
93
94
95
96



97

98
99
100
101
102
103
104
78
79
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110







+
+
+
-
+











+
+
+
-
+







    /*
     * 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);
    /*
     * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070]
     */
    handle = dlopen(native, RTLD_NOW | RTLD_GLOBAL);
    handle = dlopen(native, RTLD_NOW | RTLD_LOCAL);
    if (handle == NULL) {
	/*
	 * 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;
	const char *fileName = Tcl_GetString(pathPtr);

	native = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds);
	/*
	 * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070]
	 */
	handle = dlopen(native, RTLD_NOW | RTLD_GLOBAL);
	handle = dlopen(native, RTLD_NOW | RTLD_LOCAL);
	Tcl_DStringFree(&ds);
    }

    if (handle == NULL) {
	/*
	 * Write the string to a variable first to work around a compiler bug
	 * in the Sun Forte 6 compiler. [Bug 1503729]
Changes to unix/tclLoadDyld.c.
203
204
205
206
207
208
209



210

211
212
213
214
215
216
217
218
219



220

221
222
223
224
225
226
227
203
204
205
206
207
208
209
210
211
212

213
214
215
216
217
218
219
220
221
222
223
224
225

226
227
228
229
230
231
232
233







+
+
+
-
+









+
+
+
-
+







    nativePath = Tcl_FSGetNativePath(pathPtr);

#if TCL_DYLD_USE_DLFCN
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
    if (tclMacOSXDarwinRelease >= 8)
#endif
    {
    /*
     * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070]
     */
	dlHandle = dlopen(nativePath, RTLD_NOW | RTLD_GLOBAL);
	dlHandle = dlopen(nativePath, RTLD_NOW | RTLD_LOCAL);
	if (!dlHandle) {
	    /*
	     * 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.
	     */

	    fileName = Tcl_GetString(pathPtr);
	    nativeFileName = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds);
	    /*
	     * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070]
	     */
	    dlHandle = dlopen(nativeFileName, RTLD_NOW | RTLD_GLOBAL);
	    dlHandle = dlopen(nativeFileName, RTLD_NOW | RTLD_LOCAL);
	}
	if (dlHandle) {
	    TclLoadDbgMsg("dlopen() successful");
	} else {
	    errMsg = dlerror();
	    TclLoadDbgMsg("dlopen() failed: %s", errMsg);
	}