From 95f3e79aa9e720b53e2fb6e06967d84bb3ef98a3 Mon Sep 17 00:00:00 2001 From: Peter Goodman Date: Fri, 13 Apr 2018 21:24:24 -0400 Subject: [PATCH] Updates for LLVM 6.0 (#241) * Updates for LLVM 6.0 * Missing include --- remill/BC/Compat/ToolOutputFile.h | 29 +++++++++++++++++++++++++++++ remill/BC/Util.cpp | 4 ++-- tests/X86/Run.cpp | 9 ++++++++- tools/CMakeLists.txt | 2 +- 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 remill/BC/Compat/ToolOutputFile.h diff --git a/remill/BC/Compat/ToolOutputFile.h b/remill/BC/Compat/ToolOutputFile.h new file mode 100644 index 00000000..d2ee402f --- /dev/null +++ b/remill/BC/Compat/ToolOutputFile.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018 Trail of Bits, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef REMILL_BC_COMPAT_TOOLOUTPUTFILE_H_ +#define REMILL_BC_COMPAT_TOOLOUTPUTFILE_H_ + +#include "remill/BC/Version.h" +#include + +#if LLVM_VERSION_NUMBER < LLVM_VERSION(6, 0) +namespace llvm { +using ToolOutputFile = tool_output_file; +} // namespace llvm +#endif + +#endif // REMILL_BC_COMPAT_TOOLOUTPUTFILE_H_ diff --git a/remill/BC/Util.cpp b/remill/BC/Util.cpp index ad28681d..a1096c2e 100644 --- a/remill/BC/Util.cpp +++ b/remill/BC/Util.cpp @@ -39,7 +39,6 @@ #include #include -#include #include #include "remill/Arch/Name.h" @@ -48,6 +47,7 @@ #include "remill/BC/Compat/DebugInfo.h" #include "remill/BC/Compat/GlobalValue.h" #include "remill/BC/Compat/IRReader.h" +#include "remill/BC/Compat/ToolOutputFile.h" #include "remill/BC/Compat/Verifier.h" #include "remill/BC/Util.h" #include "remill/BC/Version.h" @@ -289,7 +289,7 @@ bool StoreModuleToFile(llvm::Module *module, std::string file_name, #if LLVM_VERSION_NUMBER > LLVM_VERSION(3, 5) std::error_code ec; - llvm::tool_output_file bc(tmp_name.c_str(), ec, llvm::sys::fs::F_RW); + llvm::ToolOutputFile bc(tmp_name.c_str(), ec, llvm::sys::fs::F_RW); CHECK(!ec) << "Unable to open output bitcode file for writing: " << tmp_name; #else llvm::tool_output_file bc(tmp_name.c_str(), error, llvm::sys::fs::F_RW); diff --git a/tests/X86/Run.cpp b/tests/X86/Run.cpp index 0ebc1366..65d6603f 100644 --- a/tests/X86/Run.cpp +++ b/tests/X86/Run.cpp @@ -493,8 +493,15 @@ static void ResetFlags(void) { // but the logic in older versions (like eglibc 2.19, used on some Ubuntu 14.04 installations) // does not clear exception flags and also does *not* ignore denormal exceptions // see: https://sourceware.org/ml/libc-alpha/2015-10/msg01020.html +#if !defined(FE_DENORMALOPERAND) && defined(__FE_DENORM) +# define FE_DENORMALOPERAND __FE_DENORM +#endif +#if !defined(FE_DENORMALOPERAND) +# warning "Missing FE_DENORMALOPERAND." +# define FE_DENORMALOPERAND 0x2 +#endif static void FixGlibcMxcsrBug() { - const uint32_t FE_ALL_EXCEPT_X86 = (FE_ALL_EXCEPT | __FE_DENORM); + const uint32_t FE_ALL_EXCEPT_X86 = (FE_ALL_EXCEPT | FE_DENORMALOPERAND); uint32_t mxcsr = 0; // temporarily holds our MXCSR asm("stmxcsr %0;" : "=m"(mxcsr)); // assumes the rest of MXCSR was sanely set by std::fesetenv(FE_DFL_ENV); diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 1b8b8888..8550ae8f 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -23,6 +23,6 @@ endif () if (307 LESS ${REMILL_LLVM_VERSION_NUMBER}) if (EXISTS ${CMAKE_SOURCE_DIR}/tools/vmill) - add_subdirectory(vmill) +# add_subdirectory(vmill) endif () endif ()