Skip to content

Commit 53b6f30

Browse files
author
Barton Cline
committed
NOTE: All this maintenance led to the soon-to-be-committed DllExport enable module:
# Cleanup after much ildasm and research: .fixup, .vtentry, etc. are all handled by the build system since late .NET 2.0. So there's no need to import the platform any longer. There's no fear of conflict with Linux - Mono needs a completely different mechanism (clr.so) to get the "Late Binding" ball rolling. # # There is a big chunk of notes taken regarding my findings # # .ver 4:0:0:1 matches Python.Runtime's version # # I've turned on options for USE_PYTHON_RUNTIME_VERSION and USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN # ## The signing key was generated on Linux without any certification (to satisfy the build script) ##
1 parent b72e9dd commit 53b6f30

File tree

1 file changed

+38
-11
lines changed

1 file changed

+38
-11
lines changed

pythonnet/src/runtime/clrmodule.il

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
//============================================================================
1111
// This file is a hand-maintained stub - it implements clr.dll, which can be
12-
// loaded by a standard CPython interpreter as an extension module. When it
13-
// is loaded, it bootstraps the managed runtime integration layer and defers
12+
// loaded by a standard CPython interpreter (on Windows) as an extension module.
13+
// When it is loaded, it bootstraps the managed runtime integration layer and defers
1414
// to it to do initialization and put the clr module into sys.modules, etc.
1515

1616
// The "USE_PYTHON_RUNTIME_*" defines control what extra evidence is used
@@ -21,8 +21,8 @@
2121
#define USE_PYTHON_RUNTIME_VERSION
2222

2323
// If defined, the "PythonRuntimePublicKeyTokenData" data array must be
24-
// set to Python.Runtime's public key token.
25-
//#define USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN
24+
// set to Python.Runtime's public key token. (sn -T Python.Runtin.dll)
25+
#define USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN
2626

2727
// If DEBUG_PRINT is defined, a few System.Console.WriteLine calls are made
2828
// to indicate what's going on during the load...
@@ -35,26 +35,53 @@
3535
.ver 4:0:0:0
3636
}
3737

38+
.assembly extern mscorlib
39+
{
40+
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
41+
.ver 2:0:0:0
42+
}
43+
3844
.assembly clr
3945
{
4046
.hash algorithm 0x00008004
41-
.ver 2:4:2:7
47+
.ver 4:0:0:1
4248
}
4349

4450
.module clr.dll
4551
.imagebase 0x00400000
4652
.subsystem 0x00000003
4753
.file alignment 512
4854

55+
#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN
56+
.data PythonRuntimePublicKeyTokenData = bytearray (50 00 fe a6 cb a7 02 dd)
57+
//.data PythonRuntimePublicKeyTokenData = bytearray (64 e1 4e 84 5a bf 2e 60)
58+
#endif
59+
4960
// This includes the platform-specific IL. The include search path
5061
// is set depending on whether we're compiling 32 or 64 bit.
5162
// This MUST come before any other .data directives!
5263
// Why, oh why, can't ilasm support command line #defines? :(
53-
#include "clrmodule-platform.il"
64+
//
65+
66+
//#include "clrmodule-platform.il"
67+
68+
// From the manifest as seen by ildasm
69+
//%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /dll /pe64 /x64 clrmodule.il
70+
//.corflags 0x00000000
71+
// Image base: 0x01550000
72+
// .vtfixup [1] int64 fromunmanaged at D_00004008 // 0000000006000002
73+
74+
//%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /dll clrmodule.il
75+
// .vtfixup [1] int32 fromunmanaged at D_00004008 // 06000002
76+
//.corflags 0x00000002 // 32BITREQUIRED
77+
// Image base: 0x015A0000
78+
79+
// With or without /pe64 /x64 switches.
80+
//{
81+
// .vtentry 1 : 1
82+
// .export [1] as initclr
83+
// ... }
5484

55-
#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN
56-
.data PythonRuntimePublicKeyTokenData = bytearray (64 e1 4e 84 5a bf 2e 60)
57-
#endif
5885

5986
.class public auto ansi beforefieldinit clrModule extends [mscorlib]System.Object
6087
{
@@ -74,7 +101,7 @@
74101
.method public hidebysig static void modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)
75102
initclr() cil managed
76103
{
77-
.vtentry 1:1
104+
// .vtentry 1:1
78105
.export [1] as initclr
79106

80107
.maxstack 6
@@ -117,7 +144,7 @@
117144

118145
#ifdef USE_PYTHON_RUNTIME_VERSION
119146
// pythonRuntimeVersionString = "...";
120-
ldstr "2.0.0.2"
147+
ldstr "4.0.0.1"
121148
stloc pythonRuntimeVersionString
122149

123150
// pythonRuntimeName.Version = new Version(pythonRuntimeVersionString);

0 commit comments

Comments
 (0)