From ae7919722a73430ca76d764038daa024ae03d79c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 3 Feb 2015 13:52:23 +0100 Subject: [PATCH] Workaround for linker removing JIT callback functions --- libevmjit-cpp/JitVM.cpp | 16 +++++----------- libevmjit/Common.h | 14 ++++++++------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/libevmjit-cpp/JitVM.cpp b/libevmjit-cpp/JitVM.cpp index 613b5031c..413525e5a 100644 --- a/libevmjit-cpp/JitVM.cpp +++ b/libevmjit-cpp/JitVM.cpp @@ -9,6 +9,8 @@ namespace dev namespace eth { +extern "C" void env_sload(); // fake declaration for linker symbol stripping workaround, see a call below + bytesConstRef JitVM::go(ExtVMFace& _ext, OnOpFunc const&, uint64_t) { using namespace jit; @@ -58,6 +60,9 @@ bytesConstRef JitVM::go(ExtVMFace& _ext, OnOpFunc const&, uint64_t) BOOST_THROW_EXCEPTION(StackTooSmall()); case ReturnCode::BadInstruction: BOOST_THROW_EXCEPTION(BadInstruction()); + case ReturnCode::LinkerWorkaround: // never happens + env_sload(); // but forces linker to include env_* JIT callback functions + break; default: break; } @@ -68,14 +73,3 @@ bytesConstRef JitVM::go(ExtVMFace& _ext, OnOpFunc const&, uint64_t) } } - -namespace -{ - // MSVS linker ignores export symbols in Env.cpp if nothing points at least one of them - extern "C" void env_sload(); - void linkerWorkaround() - { - env_sload(); - (void)&linkerWorkaround; // suppress unused function warning from GCC - } -} diff --git a/libevmjit/Common.h b/libevmjit/Common.h index 7383b9f93..d629f25ad 100644 --- a/libevmjit/Common.h +++ b/libevmjit/Common.h @@ -2,12 +2,12 @@ #include #include -#include - -#ifdef _MSC_VER -#define EXPORT __declspec(dllexport) -#else -#define EXPORT +#include + +#ifdef _MSC_VER +#define EXPORT __declspec(dllexport) +#else +#define EXPORT #endif namespace dev @@ -39,6 +39,8 @@ enum class ReturnCode LLVMLinkError = -7, UnexpectedException = -8, + + LinkerWorkaround = -299, }; /// Representation of 256-bit value binary compatible with LLVM i256