From ea5b64ca9e8d9354ec55384c0f382b3ee2a7d43f Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Mon, 20 Apr 2020 14:28:38 +0200 Subject: [PATCH] Fuzzer: Permit linking of libraries in compilation framework --- test/tools/ossfuzz/abiV2FuzzerCommon.cpp | 7 +++++-- test/tools/ossfuzz/abiV2FuzzerCommon.h | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/tools/ossfuzz/abiV2FuzzerCommon.cpp b/test/tools/ossfuzz/abiV2FuzzerCommon.cpp index f30a8517a..c9109ecdb 100644 --- a/test/tools/ossfuzz/abiV2FuzzerCommon.cpp +++ b/test/tools/ossfuzz/abiV2FuzzerCommon.cpp @@ -9,13 +9,16 @@ SolidityCompilationFramework::SolidityCompilationFramework(langutil::EVMVersion solidity::bytes SolidityCompilationFramework::compileContract( std::string const& _sourceCode, - std::string const& _contractName + std::string const& _contractName, + std::map const& _libraryAddresses, + frontend::OptimiserSettings _optimization ) { std::string sourceCode = _sourceCode; m_compiler.setSources({{"", sourceCode}}); + m_compiler.setLibraries(_libraryAddresses); m_compiler.setEVMVersion(m_evmVersion); - m_compiler.setOptimiserSettings(m_optimiserSettings); + m_compiler.setOptimiserSettings(_optimization); if (!m_compiler.compile()) { langutil::SourceReferenceFormatter formatter(std::cerr); diff --git a/test/tools/ossfuzz/abiV2FuzzerCommon.h b/test/tools/ossfuzz/abiV2FuzzerCommon.h index 3094fbdc1..e18458b77 100644 --- a/test/tools/ossfuzz/abiV2FuzzerCommon.h +++ b/test/tools/ossfuzz/abiV2FuzzerCommon.h @@ -23,12 +23,13 @@ public: } bytes compileContract( std::string const& _sourceCode, - std::string const& _contractName = {} + std::string const& _contractName, + std::map const& _libraryAddresses = {}, + frontend::OptimiserSettings _optimization = frontend::OptimiserSettings::minimal() ); protected: frontend::CompilerStack m_compiler; langutil::EVMVersion m_evmVersion; - frontend::OptimiserSettings m_optimiserSettings = frontend::OptimiserSettings::none(); }; }