diff --git a/libevmjit-cpp/Ext.cpp b/libevmjit-cpp/Env.cpp similarity index 96% rename from libevmjit-cpp/Ext.cpp rename to libevmjit-cpp/Env.cpp index b5353499e..2e5b94c82 100644 --- a/libevmjit-cpp/Ext.cpp +++ b/libevmjit-cpp/Env.cpp @@ -11,11 +11,6 @@ #include "../libevmjit/Utils.h" -namespace dev -{ -namespace eth -{ - extern "C" { #ifdef _MSC_VER @@ -24,7 +19,10 @@ extern "C" #define EXPORT #endif - using namespace jit; + using namespace dev; + using namespace dev::eth; + using jit::i256; + using jit::eth2llvm; EXPORT void ext_store(ExtVMFace* _env, i256* _index, i256* o_value) { @@ -44,13 +42,12 @@ extern "C" _env->setStore(index, value); // Interface uses native endianness } - EXPORT void ext_calldataload(ExtVMFace* _env, i256* _index, i256* o_value) + EXPORT void ext_calldataload(ExtVMFace* _env, i256* _index, ::byte* o_value) { auto index = static_cast(llvm2eth(*_index)); assert(index + 31 > index); // TODO: Handle large index - auto b = reinterpret_cast(o_value); for (size_t i = index, j = 0; i <= index + 31; ++i, ++j) - b[j] = i < _env->data.size() ? _env->data[i] : 0; // Keep Big Endian + o_value[j] = i < _env->data.size() ? _env->data[i] : 0; // Keep Big Endian // TODO: It all can be done by adding padding to data or by using min() algorithm without branch } @@ -209,6 +206,3 @@ extern "C" } } -} -} - diff --git a/libevmjit-cpp/VM.cpp b/libevmjit-cpp/VM.cpp index d61b23bd7..bef51b5d9 100644 --- a/libevmjit-cpp/VM.cpp +++ b/libevmjit-cpp/VM.cpp @@ -65,3 +65,10 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const&, uint64_t) } } } + +namespace +{ + // MSVS linker ignores export symbols in Env.cpp if nothing point at least one of them + extern "C" void ext_store(); + void linkerWorkaround() { ext_store(); } +}