Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 774 #785

Merged
merged 5 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# dev

* Enhancement: Support all the CMake build types (i.e. `Debug`, `Release`, `RelWithDebInfo` and `MinSizeRel`) on all systems ([#774](https://github.com/avast/retdec/issues/774)).
* Enhancement: YARA updated to version 4.0.1 ([#758](https://github.com/avast/retdec/issues/758)), fixed Mach-O parsing issue ([#283](https://github.com/avast/retdec/issues/283)).
* Enhancement: Improved detection of many packers/installers/compilers in `retdec-fileinfo`, including Armadillo ([#733](https://github.com/avast/retdec/pull/733)), VMProtect ([#734](https://github.com/avast/retdec/pull/734), [#778](https://github.com/avast/retdec/pull/778)), Petite ([#735](https://github.com/avast/retdec/pull/735)), Enigma ([#741](https://github.com/avast/retdec/pull/741)), ASPack ([#743](https://github.com/avast/retdec/pull/743)), Eziriz ([#746](https://github.com/avast/retdec/pull/746)), PyInstaller ([#748](https://github.com/avast/retdec/pull/748)), Astrum InstallWizard ([#753](https://github.com/avast/retdec/pull/753)), AutoHotKey ([#756](https://github.com/avast/retdec/pull/756)), AutoIt ([#757](https://github.com/avast/retdec/pull/757)), BAT to PE-EXE script compilers ([#761](https://github.com/avast/retdec/pull/761)), Bero ([#764](https://github.com/avast/retdec/pull/764)), CExe ([#781](https://github.com/avast/retdec/pull/781)).
* Enhancement: Enable .NET module in RetDec's YARA ([#747](https://github.com/avast/retdec/issues/747)).
Expand Down
7 changes: 2 additions & 5 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ if(CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
endif()

if(MSVC)
set(RELEASE_DIR "Release/")
set(DEBUG_DIR "Debug/")
set(DEBUG_LIB_SUFFIX "d")
endif()
set(MSVC_GE $<BOOL:${MSVC}>)
set(MSVC_CONFIG $<${MSVC_GE}:$<CONFIG>/>)

cond_add_subdirectory(capstone RETDEC_ENABLE_CAPSTONE)
cond_add_subdirectory(elfio RETDEC_ENABLE_ELFIO)
Expand Down
18 changes: 3 additions & 15 deletions deps/capstone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ ExternalProject_Get_Property(capstone-project binary_dir)

set(CAPSTONE_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
set(CAPSTONE_LIB_PNAME ${CMAKE_STATIC_LIBRARY_PREFIX}retdec-capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
set(CAPSTONE_LIB_DEBUG ${binary_dir}/${DEBUG_DIR}${CAPSTONE_LIB_NAME})
set(CAPSTONE_LIB_OPT ${binary_dir}/${RELEASE_DIR}${CAPSTONE_LIB_NAME})
set(CAPSTONE_LIB ${binary_dir}/${MSVC_CONFIG}${CAPSTONE_LIB_NAME})

# Create target.
add_library(capstone INTERFACE)
Expand All @@ -116,11 +115,8 @@ target_include_directories(capstone
)

target_link_libraries(capstone INTERFACE
$<BUILD_INTERFACE:${CAPSTONE_LIB}>
$<INSTALL_INTERFACE:retdec::deps::capstone-libs>
debug
$<BUILD_INTERFACE:${CAPSTONE_LIB_DEBUG}>
optimized
$<BUILD_INTERFACE:${CAPSTONE_LIB_OPT}>
)

# Install includes.
Expand All @@ -130,16 +126,8 @@ install(
)

# Install libs.
# Install both Release and Debug variant to the same location.
# We assume that only one variant will be present at the time.
install(
FILES ${CAPSTONE_LIB_DEBUG}
DESTINATION ${RETDEC_INSTALL_LIB_DIR}
RENAME ${CAPSTONE_LIB_PNAME}
OPTIONAL
)
install(
FILES ${CAPSTONE_LIB_OPT}
FILES ${CAPSTONE_LIB}
DESTINATION ${RETDEC_INSTALL_LIB_DIR}
RENAME ${CAPSTONE_LIB_PNAME}
OPTIONAL
Expand Down
34 changes: 10 additions & 24 deletions deps/googletest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,15 @@ set(GMOCK_INCLUDE_DIR ${source_dir}/googlemock/include)

# Create targets.

set(MSVC_DEBUG_LIB_SUFFIX $<$<AND:${MSVC_GE},$<CONFIG:Debug>>:d>)

# gtest
add_library(gtest INTERFACE)
add_library(retdec::deps::gtest ALIAS gtest)
add_dependencies(gtest googletest)
target_link_libraries(gtest INTERFACE
debug
${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
optimized
${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
general
Threads::Threads
${binary_dir}/lib/${MSVC_CONFIG}${CMAKE_STATIC_LIBRARY_PREFIX}gtest${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
Threads::Threads
)
target_include_directories(gtest
SYSTEM INTERFACE
Expand All @@ -98,24 +96,16 @@ target_include_directories(gtest
add_library(gtest_main INTERFACE)
add_library(retdec::deps::gtest_main ALIAS gtest_main)
target_link_libraries(gtest_main INTERFACE
debug
${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
optimized
${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}
general
gtest
${binary_dir}/lib/${MSVC_CONFIG}${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
gtest
)

# gmock
add_library(gmock INTERFACE)
add_library(retdec::deps::gmock ALIAS gmock)
target_link_libraries(gmock INTERFACE
debug
${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
optimized
${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}
general
gtest
${binary_dir}/lib/${MSVC_CONFIG}${CMAKE_STATIC_LIBRARY_PREFIX}gmock${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
gtest
)
target_include_directories(gmock
SYSTEM INTERFACE
Expand All @@ -126,10 +116,6 @@ target_include_directories(gmock
add_library(gmock_main INTERFACE)
add_library(retdec::deps::gmock_main ALIAS gmock_main)
target_link_libraries(gmock_main INTERFACE
debug
${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
optimized
${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${CMAKE_STATIC_LIBRARY_SUFFIX}
general
gmock
${binary_dir}/lib/${MSVC_CONFIG}${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
gmock
)
5 changes: 1 addition & 4 deletions deps/keystone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,5 @@ target_include_directories(keystone
)

target_link_libraries(keystone INTERFACE
debug
${binary_dir}/llvm/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}keystone${CMAKE_STATIC_LIBRARY_SUFFIX}
optimized
${binary_dir}/llvm/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}keystone${CMAKE_STATIC_LIBRARY_SUFFIX}
${binary_dir}/llvm/lib/${MSVC_CONFIG}${CMAKE_STATIC_LIBRARY_PREFIX}keystone${CMAKE_STATIC_LIBRARY_SUFFIX}
)
18 changes: 3 additions & 15 deletions deps/llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,27 +223,15 @@ target_include_directories(llvm
foreach(LLVM_LIB ${LLVM_LIB_LIST})
set(LLVM_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}${LLVM_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(LLVM_LIB_PNAME ${CMAKE_STATIC_LIBRARY_PREFIX}retdec-${LLVM_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(LLVM_LIB_OPT ${binary_dir}/${RELEASE_DIR}lib/${LLVM_LIB_NAME})
set(LLVM_LIB_DEBUG ${binary_dir}/${DEBUG_DIR}lib/${LLVM_LIB_NAME})
set(LLVM_LIB ${binary_dir}/${MSVC_CONFIG}lib/${LLVM_LIB_NAME})

target_link_libraries(llvm INTERFACE
optimized
$<BUILD_INTERFACE:${LLVM_LIB_OPT}>
debug
$<BUILD_INTERFACE:${LLVM_LIB_DEBUG}>
${LLVM_LIB}
)

# Install libs.
# Install both Release and Debug variant to the same location.
# We assume that only one variant will be present at the time.
install(
FILES ${LLVM_LIB_DEBUG}
DESTINATION ${RETDEC_INSTALL_LIB_DIR}
RENAME ${LLVM_LIB_PNAME}
OPTIONAL
)
install(
FILES ${LLVM_LIB_OPT}
FILES ${LLVM_LIB}
DESTINATION ${RETDEC_INSTALL_LIB_DIR}
RENAME ${LLVM_LIB_PNAME}
OPTIONAL
Expand Down
5 changes: 3 additions & 2 deletions deps/yara/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ if(MSVC)
set(YARAC_NAME "yarac32.exe" CACHE STRING "Yarac binary name" FORCE)
endif()

set(MSVC_CONFIG $<IF:$<CONFIG:Debug>,Debug,Release>)
set(YARA_WIN_DIR ${YARA_DIR}/windows/vs2015)
set(YARA_SOLUTION ${YARA_WIN_DIR}/yara.sln)
set(YARA_LIBRARY_DIR ${YARA_WIN_DIR}/libyara/$<CONFIGURATION>)
set(YARA_LIBRARY_DIR ${YARA_WIN_DIR}/libyara/${MSVC_CONFIG})
set(YARA_CLEAN_COMMAND "${CMAKE_VS_MSBUILD_COMMAND}"
/t:Clean
${YARA_SOLUTION}
)
set(YARA_BUILD_COMMAND "${CMAKE_VS_MSBUILD_COMMAND}"
/m:${CPUS}
/p:Platform=${PLATFORM}
/p:Configuration=$<CONFIGURATION>
/p:Configuration=${MSVC_CONFIG}
/p:PlatformToolset=${CMAKE_VS_PLATFORM_TOOLSET}
/p:WindowsTargetPlatformVersion=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}
${YARA_SOLUTION}
Expand Down
22 changes: 5 additions & 17 deletions deps/yaramod/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ ExternalProject_Get_Property(yaramod-project binary_dir)

set(YARAMOD_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}yaramod${CMAKE_STATIC_LIBRARY_SUFFIX})
set(YARAMOD_LIB_PNAME ${CMAKE_STATIC_LIBRARY_PREFIX}retdec-yaramod${CMAKE_STATIC_LIBRARY_SUFFIX})
set(YARAMOD_LIB_OPT ${binary_dir}/src/${RELEASE_DIR}${YARAMOD_LIB_NAME})
set(YARAMOD_LIB_DEBUG ${binary_dir}/src/${DEBUG_DIR}${YARAMOD_LIB_NAME})
set(YARAMOD_LIB ${binary_dir}/src/${MSVC_CONFIG}${YARAMOD_LIB_NAME})

set(FMT_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}pog_fmt${CMAKE_STATIC_LIBRARY_SUFFIX})
set(FMT_LIB_PNAME ${CMAKE_STATIC_LIBRARY_PREFIX}retdec-pog_fmt${CMAKE_STATIC_LIBRARY_SUFFIX})
Expand All @@ -88,12 +87,9 @@ target_include_directories(yaramod
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
)

target_link_libraries(yaramod INTERFACE
debug
$<BUILD_INTERFACE:${YARAMOD_LIB_DEBUG}>
optimized
$<BUILD_INTERFACE:${YARAMOD_LIB_OPT}>
general
target_link_libraries(yaramod
INTERFACE
$<BUILD_INTERFACE:${YARAMOD_LIB}>
$<BUILD_INTERFACE:${FMT_LIB}>
$<BUILD_INTERFACE:${RE2_LIB}>
$<INSTALL_INTERFACE:retdec::deps::yaramod-libs>
Expand All @@ -109,20 +105,12 @@ install(
)

# Install libs.
# Install both Release and Debug variant to the same location.
# We assume that only one variant will be present at the time.
install(
FILES ${YARAMOD_LIB_DEBUG}
FILES ${YARAMOD_LIB}
DESTINATION ${RETDEC_INSTALL_LIB_DIR}
RENAME ${YARAMOD_LIB_PNAME}
OPTIONAL
)
install(
FILES ${YARAMOD_LIB_OPT}
DESTINATION ${RETDEC_INSTALL_LIB_DIR}
RENAME ${YARAMOD_LIB_PNAME}
OPTIONAL
)
install(
FILES ${FMT_LIB}
DESTINATION ${RETDEC_INSTALL_LIB_DIR}
Expand Down
12 changes: 9 additions & 3 deletions src/retdec-decompiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ if(MSVC)
retdec::bin2llvmir -WHOLEARCHIVE:$<TARGET_FILE_NAME:retdec::bin2llvmir>
retdec::llvmir2hll -WHOLEARCHIVE:$<TARGET_FILE_NAME:retdec::llvmir2hll>
)
target_link_options(retdec-decompiler PUBLIC "/FORCE:MULTIPLE")
set_property(TARGET retdec-decompiler
APPEND_STRING PROPERTY LINK_FLAGS " /FORCE:MULTIPLE"
)
# Increase the stack size of the created binaries on MS Windows because the
# default value is too small. The default Linux value is 8388608 (8 MB).
target_link_options(retdec-decompiler PUBLIC "/STACK:16777216")
set_property(TARGET retdec-decompiler
APPEND_STRING PROPERTY LINK_FLAGS " /STACK:16777216"
)
# Allow the 32b version of bin2llvmir on Windows handle addresses larger
# than 2 GB (up to 4 GB).
if(CMAKE_SIZEOF_VOID_P MATCHES "4")
target_link_options(retdec-decompiler PUBLIC "/LARGEADDRESSAWARE")
set_property(TARGET retdec
APPEND_STRING PROPERTY LINK_FLAGS " /LARGEADDRESSAWARE"
)
endif()
elseif(APPLE)
target_link_libraries(retdec-decompiler
Expand Down
12 changes: 8 additions & 4 deletions src/retdectool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ target_link_libraries(retdectool retdec::retdec)
if(MSVC)
# -WHOLEARCHIVE needs path to the target, but when we use the target like
# that, its properties (associated includes, etc.) are not propagated.
# Therefore, we state 'retdectool' twice in target_link_libraries(),
# Therefore, we state 'bin2llvmir' twice in target_link_libraries(),
# first as a target to get its properties, second as path to library to
# link it as a whole.
target_link_libraries(retdectool
retdec::bin2llvmir -WHOLEARCHIVE:$<TARGET_FILE_NAME:retdec::bin2llvmir>
)
target_link_options(retdectool PUBLIC "/FORCE:MULTIPLE")
# Allow the 32b version of retdectool on Windows handle addresses larger
set_property(TARGET retdectool
APPEND_STRING PROPERTY LINK_FLAGS " /FORCE:MULTIPLE"
)
# Allow the 32b version of bin2llvmir on Windows handle addresses larger
# than 2 GB (up to 4 GB).
if(CMAKE_SIZEOF_VOID_P MATCHES "4")
target_link_options(retdectool PUBLIC "/LARGEADDRESSAWARE")
set_property(TARGET retdec
APPEND_STRING PROPERTY LINK_FLAGS " /LARGEADDRESSAWARE"
)
endif()
elseif(APPLE)
target_link_libraries(retdectool
Expand Down