[PATCH] mscoree: Implement VTable fixup for x86_64 architecture.
Paul Gofman
gofmanp at gmail.com
Thu Jan 21 08:39:44 CST 2016
Hi Vincent,
I managed to run x86_64 mixed assembly and to test that my x64
VTable fixup is actually working so far.
This required fixing mono assembly compiler. It has a few bugs on
checking assembly in 'check_call_signature' and in 'type_from_op' (it
sometimes forgets that ptrs are 8 bytes in x64). I am attaching a patch
for wine-mono which includes the fixes I made to compiler and also the
"quick-fix" changes to makefiles (which are really dumb). The patch for
assembly compiler is not complete. There are other num tables which are
incorrect for x64 also but I did not fall to an error with them in my
test case so I did not touch them.
I guess the assembly compiler issue should affect not only our case
but mono64 also.
Now I will get back to my real app, but most likely I will fall into
the problem that in real app there are pure .Net i386 dlls which are
used from mixed x86_64.
Do you want me to send my test case (MSVC source code and/or
compiled), or do something else to make my test reproducible?
Thanks,
Paul.
-------------- next part --------------
From d456a651dbe2659db9fae8f6080cc41e4307c187 Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp at gmail.com>
Date: Thu, 21 Jan 2016 16:53:34 +0300
Subject: [PATCH] libmono: Fix assembly check routines for x86_64 mode.
makefiles: temporary workarounds to build pure .net libs in x86_64 arch.
---
mcs/build/library.make | 7 +++++--
mcs/class/corlib/Makefile | 4 ++--
mono/mini/method-to-ir.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/mcs/build/library.make b/mcs/build/library.make
index c9c0124..c8f31d8 100644
--- a/mcs/build/library.make
+++ b/mcs/build/library.make
@@ -280,8 +280,11 @@ endif
$(the_lib): $(the_libdir)/.stamp
$(build_lib): $(response) $(sn) $(BUILT_SOURCES) $(build_libdir:=/.stamp)
- $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) $(MCS_FLAGS_RESOURCE_STRINGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
- $(Q) $(SN) -R $@ $(LIBRARY_SNK)
+ echo $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) $(MCS_FLAGS_RESOURCE_STRINGS) -target:library -platform:x64 -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
+ #$(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) $(MCS_FLAGS_RESOURCE_STRINGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
+ $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) $(MCS_FLAGS_RESOURCE_STRINGS) -target:library -platform:x64 -debug+ -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
+ #echo $(Q) $(SN) -R $@ $(LIBRARY_SNK)
+ #$(Q) $(SN) -R $@ $(LIBRARY_SNK)
ifdef LIBRARY_USE_INTERMEDIATE_FILE
$(the_lib): $(build_lib)
diff --git a/mcs/class/corlib/Makefile b/mcs/class/corlib/Makefile
index 1162bf5..c9c4506 100644
--- a/mcs/class/corlib/Makefile
+++ b/mcs/class/corlib/Makefile
@@ -97,7 +97,7 @@ EXTRA_DISTFILES += corlib_cmp.dll.excludes
CLEAN_FILES += $(cmplib) $(cmp_response) $(cmp_makefrag) $(cmppdb)
$(cmplib): $(cmp_makefrag) $(cmp_response)
- $(BOOT_COMPILE) $(LIBRARY_FLAGS) $(cmp_flags) -target:library -out:$@ @$(cmp_response)
+ $(BOOT_COMPILE) $(LIBRARY_FLAGS) $(cmp_flags) -target:library -platform:x64 -out:$@ @$(cmp_response)
$(cmp_response): $(sourcefile) corlib_cmp.dll.excludes
@echo Creating $@ ...
@@ -148,7 +148,7 @@ test-vts: $(vtslibs) $(vtsdir)/$(PROFILE)_TestLib/BinarySerializationOverVersion
$(vtsdir)/$(PROFILE)_TestLib/%/Address.dll: $(vtsdir)/VersionTolerantSerializationTestLib/%/Address.cs
@mkdir -p $(dir $@)
- $(CSCOMPILE) -target:library -r:$(corlib) -warn:0 -out:$@ $^
+ $(CSCOMPILE) -target:library -r:$(corlib) -platform:x64 -warn:0 -out:$@ $^
$(vtsdir)/$(PROFILE)_TestLib/BinarySerializationOverVersions.exe: $(vtsdir)/BinarySerializationOverVersions.cs $(vtsdir)/$(PROFILE)_TestLib/1.0/Address.dll $(test_nunit_dep)
$(CSCOMPILE) $(test_nunit_ref) -warn:0 -r:$(corlib) \
diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c
index c3cedd9..4544ee3 100644
--- a/mono/mini/method-to-ir.c
+++ b/mono/mini/method-to-ir.c
@@ -806,10 +806,24 @@ handle_enum:
/*
* The following tables are used to quickly validate the IL code in type_from_op ().
*/
+
+#if defined(TARGET_AMD64)
static const char
bin_num_table [STACK_MAX] [STACK_MAX] = {
{STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV},
{STACK_INV, STACK_I4, STACK_INV, STACK_PTR, STACK_INV, STACK_MP, STACK_INV, STACK_INV},
+ {STACK_INV, STACK_INV, STACK_I8, STACK_PTR, STACK_INV, STACK_INV, STACK_INV, STACK_INV},
+ {STACK_INV, STACK_PTR, STACK_PTR, STACK_PTR, STACK_INV, STACK_MP, STACK_INV, STACK_INV},
+ {STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_R8, STACK_INV, STACK_INV, STACK_INV, STACK_R8},
+ {STACK_INV, STACK_MP, STACK_INV, STACK_MP, STACK_INV, STACK_PTR, STACK_INV, STACK_INV},
+ {STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV},
+ {STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV},
+ {STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_R8, STACK_INV, STACK_INV, STACK_INV, STACK_R4}
+};
+#else
+bin_num_table [STACK_MAX] [STACK_MAX] = {
+ {STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV},
+ {STACK_INV, STACK_I4, STACK_INV, STACK_PTR, STACK_INV, STACK_MP, STACK_INV, STACK_INV},
{STACK_INV, STACK_INV, STACK_I8, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV},
{STACK_INV, STACK_PTR, STACK_INV, STACK_PTR, STACK_INV, STACK_MP, STACK_INV, STACK_INV},
{STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_R8, STACK_INV, STACK_INV, STACK_INV, STACK_R8},
@@ -818,6 +832,7 @@ bin_num_table [STACK_MAX] [STACK_MAX] = {
{STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_INV},
{STACK_INV, STACK_INV, STACK_INV, STACK_INV, STACK_R8, STACK_INV, STACK_INV, STACK_INV, STACK_R4}
};
+#endif
static const char
neg_table [] = {
@@ -2335,6 +2350,18 @@ handle_enum:
if (args [i]->type != STACK_I4 && args [i]->type != STACK_PTR)
return 1;
continue;
+#if defined(TARGET_AMD64)
+ case MONO_TYPE_I:
+ case MONO_TYPE_U:
+ if (args [i]->type != STACK_I4 && args [i]->type != STACK_PTR && args [i]->type != STACK_MP && args [i]->type != STACK_OBJ)
+ return 1;
+ continue;
+ case MONO_TYPE_PTR:
+ case MONO_TYPE_FNPTR:
+ if (args [i]->type != STACK_I8 && args [i]->type != STACK_PTR && args [i]->type != STACK_MP && args [i]->type != STACK_OBJ)
+ return 1;
+ continue;
+#else
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
@@ -2342,6 +2369,7 @@ handle_enum:
if (args [i]->type != STACK_I4 && args [i]->type != STACK_PTR && args [i]->type != STACK_MP && args [i]->type != STACK_OBJ)
return 1;
continue;
+#endif
case MONO_TYPE_CLASS:
case MONO_TYPE_STRING:
case MONO_TYPE_OBJECT:
@@ -2352,7 +2380,11 @@ handle_enum:
continue;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
+#if defined(TARGET_AMD64)
+ if (args [i]->type != STACK_I8 && args [i]->type != STACK_PTR)
+#else
if (args [i]->type != STACK_I8)
+#endif
return 1;
continue;
case MONO_TYPE_R4:
--
2.5.0
More information about the wine-devel
mailing list