Merge branch 'master' into new-demangler

This commit is contained in:
Peter Matula 2019-05-31 16:00:19 +02:00
commit 70785eb3a9
39 changed files with 41 additions and 90 deletions

View File

@ -64,7 +64,7 @@ script:
- cd ..
- rm -rf build
# Run unit tests.
if [ "$TRAVIS_OS_NAME" = "osx" ]; then python3 retdec-install/bin/retdec-tests-runner.py ; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then python3 retdec-install/bin/retdec-tests-runner.py ; fi
# Run the decompilation script.
- python3 retdec-install/bin/retdec-decompiler.py --help
# Run a simple decompilation.

View File

@ -2,6 +2,7 @@
# dev
* New Feature: Added support for decompilation of 64-bit ARM binaries ([#268](https://github.com/avast/retdec/issues/268), [#533](https://github.com/avast/retdec/pull/533), [#550](https://github.com/avast/retdec/pull/550)).
* New Feature: Added presentation of section and overlay entropy in `retdec-fileinfo` ([#502](https://github.com/avast/retdec/issues/502), [#507](https://github.com/avast/retdec/pull/507)).
* New Feature: Added presentation of version info from PE file in `retdec-fileinfo` ([#408](https://github.com/avast/retdec/issues/408), [#519](https://github.com/avast/retdec/pull/519)).
* New Feature: Added presentation of thread-local storage directory from PE file in `retdec-fileinfo` ([#417](https://github.com/avast/retdec/issues/417), [#523](https://github.com/avast/retdec/pull/523)).

View File

@ -251,7 +251,7 @@ You can pass the following additional parameters to `cmake`:
* `-DRETDEC_COMPILE_YARA=OFF` to disable YARA rules compilation at installation step (enabled by default).
* `-DCMAKE_BUILD_TYPE=Debug` to build with debugging information, which is useful during development. By default, the project is built in the `Release` mode. This has no effect on Windows, but the same thing can be achieved by running `cmake --build .` with the `--config Debug` parameter.
* `-DCMAKE_PROGRAM_PATH=<path>` to use Perl at `<path>` (probably useful only on Windows).
* `-D<dep>_LOCAL_DIR=<path>` where `<dep>` is from `{CAPSTONE, ELFIO, GOOGLETEST, JSONCPP, KEYSTONE, LIBDWARF, LLVM, PELIB, RAPIDJSON, TINYXML, YARACPP, YARAMOD}` (e.g. `-DCAPSTONE_LOCAL_DIR=<path>`), to use the local repository clone at `<path>` for RetDec dependency instead of downloading a fresh copy at build time. Multiple such options may be used at the same time.
* `-D<dep>_LOCAL_DIR=<path>` where `<dep>` is from `{CAPSTONE, ELFIO, GOOGLETEST, JSONCPP, KEYSTONE, LIBDWARF, LLVM, PELIB, RAPIDJSON, TINYXML, YARACPP, YARAMOD}` (e.g. `-DCAPSTONE_LOCAL_DIR=<path>`), to use the local repository clone at `<path>` for RetDec dependency instead of downloading a fresh copy at build time. Multiple such options may be used at the same time.
## Build in Docker

View File

@ -47,7 +47,7 @@ if(CAPSTONE_LOCAL_DIR)
force_configure_step(capstone-project)
else()
message(STATUS "Capstone: using remote Capstone revision.")
ExternalProject_Add(capstone-project
URL https://github.com/avast/capstone/archive/27c713fe4f6eaf9721785932d850b6291a6073fe.zip
URL_HASH SHA256=4d8d0461d7d5737893253698cd0b6d0d64545c1a74b166e8b1d823156a3109cb

View File

@ -11,7 +11,7 @@ endif()
if(GOOGLETEST_LOCAL_DIR)
message(STATUS "Googletest: using local Googletest directory.")
ExternalProject_Add(googletest
DOWNLOAD_COMMAND ""
SOURCE_DIR "${GOOGLETEST_LOCAL_DIR}"
@ -35,7 +35,7 @@ if(GOOGLETEST_LOCAL_DIR)
force_configure_step(googletest)
else()
message(STATUS "Googletest: using remote Googletest revision.")
ExternalProject_Add(googletest
URL https://github.com/google/googletest/archive/83fa0cb17dad47a1d905526dcdddb5b96ed189d2.zip
URL_HASH SHA256=3b7cf6bfd1fdec3204933b4c0419c010e89b2409dcd8cbc1ac6a78aab058e2b0

View File

@ -9,7 +9,7 @@ endif()
if(JSONCPP_LOCAL_DIR)
message(STATUS "JsonCpp: using local JsonCpp directory.")
ExternalProject_Add(jsoncpp-project
DOWNLOAD_COMMAND ""
SOURCE_DIR "${JSONCPP_LOCAL_DIR}"

View File

@ -29,7 +29,7 @@ include(ExternalProject)
if(LLVM_LOCAL_DIR)
message(STATUS "LLVM: using local LLVM directory.")
ExternalProject_Add(llvm-project
DOWNLOAD_COMMAND ""
SOURCE_DIR "${LLVM_LOCAL_DIR}"
@ -38,27 +38,27 @@ if(LLVM_LOCAL_DIR)
# This has no effect on Windows with MSVC, but is useful on Linux.
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
# Force Python3.
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
# Targets to be build.
-DLLVM_TARGETS_TO_BUILD=X86
# Our tools depending on LLVM require RTTI, so build LLVM with it.
-DLLVM_REQUIRES_RTTI=YES
# When building in the debug mode (=> assertions are enabled), we
# have to build LLVM with assertions. This prevents link errors
# when building the middle-end and back-end (see
# https://github.com/oclint/oclint/issues/129).
-DLLVM_ENABLE_ASSERTIONS=${IS_DEBUG_BUILD}
# Disable the emission of warnings, which are useless since we do
# not modify the LLVM sources (of course, except for a few
# exceptions).
-DLLVM_ENABLE_WARNINGS=NO
# Disable the generation of targets for tests (we don't need them).
-DLLVM_INCLUDE_TOOLS=OFF
-DLLVM_INCLUDE_UTILS=OFF
@ -68,7 +68,7 @@ if(LLVM_LOCAL_DIR)
-DLLVM_INCLUDE_GO_TESTS=OFF
-DLLVM_INCLUDE_BENCHMARKS=OFF
-DLLVM_INCLUDE_DOCS=OFF
# Disable build of unnecessary LLVM parts.
-DLLVM_BUILD_TOOLS=OFF
-DLLVM_BUILD_UTILS=OFF
@ -81,16 +81,16 @@ if(LLVM_LOCAL_DIR)
# We don't want this so that we don't have to link with tinfo.
# It looks like terminal colors are working even without this.
-DLLVM_ENABLE_TERMINFO=OFF
# Necessary for builds with older MS Visual Studios (e.g. 2015).
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON
# Force the use of the same compiler as used to build the top-level
# project. Otherwise, the external project may pick up a different
# compiler, which may result in link errors.
"${CMAKE_C_COMPILER_OPTION}"
"${CMAKE_CXX_COMPILER_OPTION}"
# Disable the installation right after build (we want to install the
# needed libraries and tools manually).
INSTALL_COMMAND ""
@ -108,27 +108,27 @@ else()
# This has no effect on Windows with MSVC, but is useful on Linux.
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
# Force Python3.
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
# Targets to be build.
-DLLVM_TARGETS_TO_BUILD=X86
# Our tools depending on LLVM require RTTI, so build LLVM with it.
-DLLVM_REQUIRES_RTTI=YES
# When building in the debug mode (=> assertions are enabled), we
# have to build LLVM with assertions. This prevents link errors
# when building the middle-end and back-end (see
# https://github.com/oclint/oclint/issues/129).
-DLLVM_ENABLE_ASSERTIONS=${IS_DEBUG_BUILD}
# Disable the emission of warnings, which are useless since we do
# not modify the LLVM sources (of course, except for a few
# exceptions).
-DLLVM_ENABLE_WARNINGS=NO
# Disable the generation of targets for tests (we don't need them).
-DLLVM_INCLUDE_TOOLS=OFF
-DLLVM_INCLUDE_UTILS=OFF
@ -138,7 +138,7 @@ else()
-DLLVM_INCLUDE_GO_TESTS=OFF
-DLLVM_INCLUDE_BENCHMARKS=OFF
-DLLVM_INCLUDE_DOCS=OFF
# Disable build of unnecessary LLVM parts.
-DLLVM_BUILD_TOOLS=OFF
-DLLVM_BUILD_UTILS=OFF
@ -151,16 +151,16 @@ else()
# We don't want this so that we don't have to link with tinfo.
# It looks like terminal colors are working even without this.
-DLLVM_ENABLE_TERMINFO=OFF
# Necessary for builds with older MS Visual Studios (e.g. 2015).
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON
# Force the use of the same compiler as used to build the top-level
# project. Otherwise, the external project may pick up a different
# compiler, which may result in link errors.
"${CMAKE_C_COMPILER_OPTION}"
"${CMAKE_CXX_COMPILER_OPTION}"
# Disable the installation right after build (we want to install the
# needed libraries and tools manually).
INSTALL_COMMAND ""

View File

@ -37,7 +37,6 @@ class ReturnEntry
const std::vector<llvm::StoreInst*>& retStores() const;
const std::vector<llvm::Value*>& retValues() const;
protected:
llvm::ReturnInst* _retInst = nullptr;

View File

@ -30,7 +30,6 @@ class AbiX86 : public Abi
public:
virtual bool isNopInstruction(cs_insn* insn) override;
// Calling conventions.
//
private:

View File

@ -4,7 +4,6 @@
* @copyright (c) 2019 Avast Software, licensed under the MIT license
*/
#ifndef RETDEC_BIN2LLVMIR_PROVIDERS_CALL_CONV_CALL_CONV_H
#define RETDEC_BIN2LLVMIR_PROVIDERS_CALL_CONV_CALL_CONV_H

View File

@ -306,7 +306,6 @@ void Collector::collectStoresRecursively(
seen[block] = values;
}
bool Collector::collectStoresInInstructionBlock(
Instruction* start,
std::set<Value*>& values,
@ -476,7 +475,6 @@ void Collector::collectCallSpecificTypes(CallEntry* ce) const
return;
}
if (!extractFormatString(ce))
{
return;

View File

@ -440,7 +440,6 @@ void Filter::filterArgsByKnownTypes(FilterableLayout& lay) const
}
}
if (!requiredStacks && stackOrd == OrderID::ORD_STACK)
{
requiredStacks = getNumberOfStacksForType(t);
@ -770,7 +769,6 @@ void Filter::filterRetsByKnownTypes(FilterableLayout& lay) const
lay.knownTypes = {retType};
}
void Filter::leaveCommonArgs(std::vector<FilterableLayout>& allArgs) const
{
leaveCommon(allArgs);
@ -1093,7 +1091,6 @@ std::vector<llvm::Value*> Filter::createGroupedValues(const FilterableLayout& la
}
break;
default:
continue;
}

View File

@ -4,7 +4,6 @@
* @copyright (c) 2019 Avast Software, licensed under the MIT license
*/
#include "retdec/bin2llvmir/providers/abi/abi.h"
#include "retdec/bin2llvmir/providers/calling_convention/calling_convention.h"
#include "retdec/bin2llvmir/providers/calling_convention/arm/arm_conv.h"

View File

@ -699,7 +699,6 @@ llvm::Value* Capstone2LlvmIrTranslatorArm64_impl::loadRegister(
return getCurrentPc(_insn);
}
llvm::Type* rt = nullptr;
try
{
@ -783,9 +782,9 @@ llvm::Value* Capstone2LlvmIrTranslatorArm64_impl::loadOp(
auto* val = llvm::ConstantFP::get(irb.getDoubleTy(), op.fp);
return val;
}
case ARM64_OP_INVALID:
case ARM64_OP_CIMM:
case ARM64_OP_PREFETCH:
case ARM64_OP_INVALID:
case ARM64_OP_CIMM:
case ARM64_OP_PREFETCH:
case ARM64_OP_BARRIER:
default:
{
@ -857,18 +856,18 @@ llvm::Instruction* Capstone2LlvmIrTranslatorArm64_impl::storeOp(
addr = irb.CreateIntToPtr(addr, pt);
return irb.CreateStore(val, addr);
}
case ARM64_OP_INVALID:
case ARM64_OP_IMM:
case ARM64_OP_INVALID:
case ARM64_OP_IMM:
{
// This is here because some operands that are for example in post-index addressing mode
// will have the write flag set and generic functions try to write to IMM, which is not correct
// Maybe solve this better?
return nullptr;
}
case ARM64_OP_FP:
case ARM64_OP_CIMM:
case ARM64_OP_PREFETCH:
case ARM64_OP_BARRIER:
case ARM64_OP_FP:
case ARM64_OP_CIMM:
case ARM64_OP_PREFETCH:
case ARM64_OP_BARRIER:
default:
{
throw GenericError("storeOp(): unhandled operand type");
@ -1844,7 +1843,7 @@ void Capstone2LlvmIrTranslatorArm64_impl::translateBr(cs_insn* i, cs_arm64* ai,
void Capstone2LlvmIrTranslatorArm64_impl::translateB(cs_insn* i, cs_arm64* ai, llvm::IRBuilder<>& irb)
{
EXPECT_IS_UNARY(i, ai, irb);
op0 = loadOpUnary(ai, irb);
if (isCondIns(ai)) {
@ -1863,7 +1862,7 @@ void Capstone2LlvmIrTranslatorArm64_impl::translateB(cs_insn* i, cs_arm64* ai, l
void Capstone2LlvmIrTranslatorArm64_impl::translateBl(cs_insn* i, cs_arm64* ai, llvm::IRBuilder<>& irb)
{
EXPECT_IS_UNARY(i, ai, irb);
storeRegister(ARM64_REG_LR, getNextInsnAddress(i), irb);
op0 = loadOpUnary(ai, irb);
generateCallFunctionCall(irb, op0);
@ -2906,7 +2905,6 @@ void Capstone2LlvmIrTranslatorArm64_impl::translateMovi(cs_insn* i, cs_arm64* ai
storeOp(ai->operands[0], op1, irb);
}
/**
* ARM64_INS_FMUL, ARM64_INS_FNMUL
*/

View File

@ -147,7 +147,7 @@ class Capstone2LlvmIrTranslatorArm64_impl :
/**
* @brief This functions will generate psuedo asm translation.
* Instructions that are not implemented fall back to this method which will
* Instructions that are not implemented fall back to this method which will
* check there is need to generate conditional code and then generate given pseudo.
*/
void generatePseudoInstruction(cs_insn* i, cs_arm64* ai, llvm::IRBuilder<>& irb);

View File

@ -630,7 +630,6 @@ void Capstone2LlvmIrTranslatorArm64_impl::initializeRegTypeMap()
auto* f64 = llvm::Type::getDoubleTy(_module->getContext());
auto* f128 = llvm::Type::getFP128Ty(_module->getContext());
std::map<uint32_t, llvm::Type*> r2t =
{
// General purpose registers.
@ -1557,7 +1556,6 @@ void Capstone2LlvmIrTranslatorArm64_impl::initializeRegistersParentMapToOther(
}
}
void Capstone2LlvmIrTranslatorArm64_impl::initializeRegistersParentMap()
{
// Last element in vector is its own parent.

View File

@ -476,7 +476,6 @@ class Capstone2LlvmIrTranslator_impl : virtual public Capstone2LlvmIrTranslator
virtual uint8_t getOperandAccess(CInsnOp& op);
virtual void translatePseudoAsmGeneric(cs_insn* i, CInsn* ci, llvm::IRBuilder<>& irb);
void throwUnexpectedOperands(cs_insn* i, const std::string comment = "");
void throwUnhandledInstructions(cs_insn* i, const std::string comment = "");

View File

@ -4427,7 +4427,6 @@ void Capstone2LlvmIrTranslatorX86_impl::translateFst(cs_insn* i, cs_x86* xi, llv
storeOp(xi->operands[0], src, irb, eOpConv::FP_CAST);
}
if (i->id == X86_INS_FSTP)
{
storeX87TagReg(irb, top, llvm::ConstantInt::get(irb.getIntNTy(2), 3)); // 0b11

View File

@ -150,7 +150,6 @@ class ProgramOptions
}
}
void dump()
{
cout << endl;

View File

@ -1569,7 +1569,6 @@ const TlsInfo* FileFormat::getTlsInfo() const
return tlsInfo;
}
/**
* Get information about ELF core file
* @return Pointer to ELF core info of @c nullptr if file has no certificates

View File

@ -30,7 +30,6 @@
#include "retdec/fileformat/utils/file_io.h"
#include "retdec/crypto/crypto.h"
using namespace retdec::utils;
using namespace PeLib;
@ -739,7 +738,6 @@ void PeFormat::loadVisualBasicHeader()
visualBasicInfo.setLanguageDLLPrimaryLCID(vbh.LCID1);
visualBasicInfo.setLanguageDLLSecondaryLCID(vbh.LCID2);
if (getOffsetFromAddress(vbProjectInfoOffset, vbh.projectInfoAddr))
{
parseVisualBasicProjectInfo(vbProjectInfoOffset);

View File

@ -607,7 +607,6 @@ bool BitmapImage::reduce8x8()
}
}
/* crop to 8x8 */
image.resize(8);
for (auto &row : image)
@ -711,6 +710,5 @@ void BitmapImage::greyScale()
}
}
} // namespace fileformat
} // namespace retdec

View File

@ -187,7 +187,6 @@ bool ResourceIcon::hasLoadedProperties() const
return loadedProperties;
}
/**
* A method which indicates whether color count of an icon is valid.
* @return @c `true` if it is, otherwise `false`

View File

@ -7,7 +7,6 @@
#include "retdec/fileformat/types/resource_table/resource_icon.h"
#include "retdec/fileformat/types/resource_table/resource_icon_group.h"
namespace {
// Icon priority list

View File

@ -68,12 +68,9 @@ struct VersionInfoHeader
} // anonymous namespace
namespace retdec {
namespace fileformat {
/**
* Constructor
*/

View File

@ -61,6 +61,5 @@ void VisualBasicExtern::setApiName(const std::string &aName)
apiName = aName;
}
} // namespace fileformat
} // namespace retdec

View File

@ -10,7 +10,6 @@
#include "retdec/utils/conversion.h"
#include "retdec/fileformat/types/visual_basic/visual_basic_info.h"
using namespace retdec::utils;
namespace retdec {
@ -768,6 +767,5 @@ std::string VisualBasicInfo::guidToStr(const std::uint8_t data[16])
return r1 + "-" + r2 + "-" + r3 + "-" + r4 + "-" + r5;
}
} // namespace fileformat
} // namespace retdec

View File

@ -70,7 +70,5 @@ void VisualBasicObject::addMethod(const std::string &method)
methods.push_back(method);
}
} // namespace fileformat
} // namespace retdec

View File

@ -1118,13 +1118,6 @@ std::string FileInformation::getVisualBasicObjectTableHashSha256() const
return visualBasicInfo.getObjectTableHashSha256();
}
/**
* Get type of related PDB file
* @return Type of related PDB file

View File

@ -195,7 +195,6 @@ class FileInformation
std::string getVisualBasicObjectTableHashSha256() const;
/// @}
/// @name Getters of @a pdbInfo
/// @{
std::string getPdbType() const;

View File

@ -133,5 +133,4 @@ bool TlsInfo::isUsed() const
return tlsInfo != nullptr;
}
} // namespace fileinfo

View File

@ -412,5 +412,4 @@ bool VisualBasicInfo::isPcode() const
return visualBasicInfo ? visualBasicInfo->isPcode() : false;
}
} // namespace fileinfo

View File

@ -385,7 +385,7 @@ void JsonPresentation::presentTlsInfo(Json::Value &root) const
{
return;
}
Value jTlsInfo;
presentIfNotEmpty("rawDataStartAddress", fileinfo.getTlsRawDataStartAddrStr(hexWithPrefix), jTlsInfo);
presentIfNotEmpty("rawDataEndAddress", fileinfo.getTlsRawDataEndAddrStr(hexWithPrefix), jTlsInfo);

View File

@ -765,6 +765,5 @@ void BIRWriter::visit(ShPtr<UnknownType> type) {
out << "type_unknown";
}
} // namespace llvmir2hll
} // namespace retdec

View File

@ -92,7 +92,6 @@ bool DeadLocalAssignOptimizer::canBeOptimized(ShPtr<Variable> var,
return false;
}
// The use cannot contain any function calls.
if (useData->hasCalls()) {
return false;

View File

@ -8,7 +8,6 @@
#include "unpackertool/plugins/upx/decompressors/decompressor.h"
namespace retdec {
namespace unpackertool {
namespace upx {

View File

@ -1,2 +1 @@

View File

@ -3675,7 +3675,6 @@ TEST_F(ParamReturnTests, x86FastcallBasic)
checkModuleAgainstExpectedIr(exp);
}
TEST_F(ParamReturnTests, x86FastcallLargeTypeCatch)
{
parseInput(R"(

View File

@ -276,7 +276,6 @@ TEST_P(Capstone2LlvmIrTranslatorArm64Tests, ARM64_INS_ADC32_flags)
EXPECT_NO_VALUE_CALLED();
}
TEST_P(Capstone2LlvmIrTranslatorArm64Tests, ARM64_INS_ADC_flags)
{
setRegisters({
@ -6018,7 +6017,6 @@ TEST_P(Capstone2LlvmIrTranslatorArm64Tests, ARM64_INS_UXTH_r_r_false)
EXPECT_NO_VALUE_CALLED();
}
//
// ARM64_INS_TBNZ
//
@ -7496,7 +7494,6 @@ TEST_P(Capstone2LlvmIrTranslatorArm64Tests, ARM64_INS_FMAX_d_d_d)
EXPECT_NO_VALUE_CALLED();
}
TEST_P(Capstone2LlvmIrTranslatorArm64Tests, ARM64_INS_FMAX_d_d_d_1)
{
setRegisters({
@ -7611,7 +7608,6 @@ TEST_P(Capstone2LlvmIrTranslatorArm64Tests, ARM64_INS_FMIN_d_d_d)
EXPECT_NO_VALUE_CALLED();
}
TEST_P(Capstone2LlvmIrTranslatorArm64Tests, ARM64_INS_FMIN_d_d_d_1)
{
setRegisters({