From 84b6251181acf5580fd07771cc9e202c8bba8233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 16 Jan 2015 22:06:07 +0100 Subject: [PATCH] Remove env_sha3 symbol reference in evmjit shared library to be build with no unresolved symbols --- CMakeLists.txt | 9 +++++---- libevmjit/ExecutionEngine.cpp | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25c62ff2fc..5193460076 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,13 +4,14 @@ project(evmjit) set_property(GLOBAL PROPERTY USE_FOLDERS ON) -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") -else () +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +else() set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -fPIC") endif() -if(APPLE) - set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup") +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # Do not allow unresovled symbols in shared library (default on linux) + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined") endif() # LLVM diff --git a/libevmjit/ExecutionEngine.cpp b/libevmjit/ExecutionEngine.cpp index 1f87c8b588..b6b140fd51 100644 --- a/libevmjit/ExecutionEngine.cpp +++ b/libevmjit/ExecutionEngine.cpp @@ -26,9 +26,6 @@ #define DEBUG_ENV_OPTION(name) (std::getenv(#name) != nullptr) #endif - -extern "C" void env_sha3(dev::eth::jit::byte const* _begin, uint64_t _size, std::array* o_hash); - namespace dev { namespace eth @@ -57,14 +54,17 @@ ReturnCode runEntryFunc(EntryFuncPtr _mainFunc, Runtime* _runtime) std::string codeHash(bytes const& _code) { - std::array binHash; - env_sha3(_code.data(), _code.size(), &binHash); - - std::ostringstream os; - for (auto i: binHash) - os << std::hex << std::setfill('0') << std::setw(2) << (int)(std::make_unsigned::type)i; - - return os.str(); + uint32_t hash = 0; + for (auto b : _code) + { + hash += b; + hash += (hash << 10); + hash ^= (hash >> 6); + } + hash += (hash << 3); + hash ^= (hash >> 11); + hash += (hash << 15); + return std::to_string(hash); } }