From 55c2d04202c70f4d9d27ca27bb146d7d4066d9f8 Mon Sep 17 00:00:00 2001 From: Viktor Oreshkin Date: Wed, 13 Dec 2017 23:16:14 +0300 Subject: [PATCH 1/4] Fix bin2llvmirtool/llvmir2hlltool macOS build --- src/bin2llvmirtool/CMakeLists.txt | 4 +++- src/llvmir2hlltool/CMakeLists.txt | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bin2llvmirtool/CMakeLists.txt b/src/bin2llvmirtool/CMakeLists.txt index 77b21d2f..95d97b6c 100644 --- a/src/bin2llvmirtool/CMakeLists.txt +++ b/src/bin2llvmirtool/CMakeLists.txt @@ -14,7 +14,9 @@ if(MSVC) # its properties, second as path to library to link it as a whole. target_link_libraries(bin2llvmirtool bin2llvmir -WHOLEARCHIVE:$) set_target_properties(bin2llvmirtool PROPERTIES LINK_FLAGS "/FORCE:MULTIPLE") -else() # Linux/MSYS2 +elseif(APPLE) + target_link_libraries(bin2llvmirtool -Wl,-force_load bin2llvmir) +elseif() # Linux/MSYS2 target_link_libraries(bin2llvmirtool -Wl,--whole-archive bin2llvmir -Wl,--no-whole-archive) endif() diff --git a/src/llvmir2hlltool/CMakeLists.txt b/src/llvmir2hlltool/CMakeLists.txt index 72468e2e..584502d8 100644 --- a/src/llvmir2hlltool/CMakeLists.txt +++ b/src/llvmir2hlltool/CMakeLists.txt @@ -13,6 +13,8 @@ if(MSVC) # state 'llvmir2hll' 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(llvmir2hlltool llvmir2hll -WHOLEARCHIVE:$) +elseif(APPLE) + target_link_libraries(llvmir2hlltool -Wl,-force_load llvmir2hll) else() # Linux/MSYS2 target_link_libraries(llvmir2hlltool -Wl,--whole-archive llvmir2hll -Wl,--no-whole-archive) endif() From e2fa7df4fb870c9fe8721c53893a61e03305065b Mon Sep 17 00:00:00 2001 From: Viktor Oreshkin Date: Wed, 13 Dec 2017 23:17:10 +0300 Subject: [PATCH 2/4] Add macOS info to README --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 040f2ca0..3a71ce1c 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Features: ## Installation and Use -Currently, we support only Windows (7 or later) and Linux. +Currently, we support only Windows (7 or later), Linux and macOS. ### Windows @@ -62,6 +62,26 @@ Currently, we support only Windows (7 or later) and Linux. For more information, run `./decompile.sh --help`. +### macOS + +1. There are currently no pre-built packages for macOS. You will have to build and install the decompiler by yourself. The process is described below. + +2. After you have built the decompiler, you will need to install the following packages: + + * [UPX](https://upx.github.io/) + * [Graphviz](http://www.graphviz.org/) + * GNU Bash + * GNU getopt -- should be first in PATH + +3. Now, you are all set to run the decompiler. To decompile a binary file named `test.exe`, go into `$RETDEC_INSTALLED_DIR/bin` and run: + + ``` + # /usr/local/bin/bash if installed via Homebrew + /path/to/gnu/bash ./decompile.sh test.exe + ``` + + For more information, run `./decompile.sh --help`. + ## Build and Installation This section describes a manual build and installation of RetDec. @@ -96,6 +116,14 @@ sudo apt-get install build-essential cmake git perl python bash coreutils wget b * [Active Perl](https://www.activestate.com/activeperl). It needs to be the first Perl in `PATH`, or it has to be provided to CMake using `CMAKE_PROGRAM_PATH` variable, e.g. `-DCMAKE_PROGRAM_PATH=/c/perl/bin`. * [Python](https://www.python.org/) (version >= 3.4) +#### macOS: + + * Full Xcode installation (Command Line Tools are untested) + * CMake (version >= 3.6) + * Newer versions of bison and flex, preferably installed via [Homebrew](https://brew.sh) + * [wget](https://www.gnu.org/software/wget/) + * [Python](https://www.python.org/) (version >= 3.4, macOS has 2.7) + ### Process **Warning: Currently, RetDec has to be installed into a clean, dedicated directory. Do NOT install it into `/usr`, `/usr/local`, etc. because our build system is not yet ready for system-wide installations. So, when running `cmake`, always set `-DCMAKE_INSTALL_PREFIX=` to a directory that will be used just by RetDec. For more details, see #12.** @@ -115,6 +143,17 @@ sudo apt-get install build-essential cmake git perl python bash coreutils wget b * `msbuild /m /p:Configuration=Release retdec.sln` * `msbuild /m /p:Configuration=Release INSTALL.vcxproj` * Alternatively, you can open `retdec.sln` generated by `cmake` in Visual Studio IDE. +* macOS: + * `cd retdec` + * `mkdir build && cd build` + * ```sh + # Apple ships old flex & bison, so Homebrew versions should be used + export CMAKE_INCLUDE_PATH="/usr/local/opt/flex/include" + export CMAKE_LIBRARY_PATH="/usr/local/opt/flex/lib;/usr/local/opt/bison/lib" + export PATH="/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH" + ``` + * `cmake .. -DCMAKE_INSTALL_PREFIX=` + * `make && make install` You have to pass the following parameters to `cmake`: * `-DCMAKE_INSTALL_PREFIX=` to set the installation path to ``. From 75534e032f65dc87a6f766ffa93b71fde7f9a054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Milkovi=C4=8D?= Date: Wed, 20 Dec 2017 19:43:56 +0100 Subject: [PATCH 3/4] Added disclaimers that we do not officially support macOS to README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d9875e8e..a17d6ec8 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ For more information, you can check out: ## Installation and Use -Currently, we support only Windows (7 or later), Linux and macOS. +Currently, we support only Windows (7 or later), Linux and unofficially macOS. **Warning: Decompilations of larger binaries (1 MB or more) may require a lot of RAM. When running decompilations, we advise you to limit the maximal virtual memory for processes before decompiling to prevent potential swapping and unresponsiveness. On Linux, you can run e.g. `ulimit -Sv 9863168` in your shell to limit the maximal virtual memory to 8 GB.** @@ -71,6 +71,8 @@ Currently, we support only Windows (7 or later), Linux and macOS. ### macOS +**Warning: macOS build was added based on community feedback and is not directly supported by Avast RetDec Team. We do not guarantee you that these instructions will work for you. If you encounter any problem with your build, file an issue so macOS community can help you out.** + 1. There are currently no pre-built packages for macOS. You will have to build and install the decompiler by yourself. The process is described below. 2. After you have built the decompiler, you will need to install the following packages: From ea755faf7e04aae470ec1142b72759f41751455a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Milkovi=C4=8D?= Date: Wed, 20 Dec 2017 19:46:36 +0100 Subject: [PATCH 4/4] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b4384a6..740f0ab2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Enhancement: Decrease the default timeout when downloading the support package during installation ([#6](https://github.com/avast-tl/retdec/pull/6)). * Enhancement: Any shell can be used to install the decompiler, not just Bash. +* Enhancement: Added unofficial support for macOS build ([#7](https://github.com/avast-tl/retdec/issues/7)) * Fix: Ordering of compiler detections ([#39](https://github.com/avast-tl/retdec/issues/39)). * Fix: Remove duplicate `lib` prefix when installing [libdwarf](https://github.com/avast-tl/libdwarf) libraries ([#31](https://github.com/avast-tl/retdec/issues/31)). * Fix: When installing the decompiler, do not remove the entire `share` directory ([#12](https://github.com/avast-tl/retdec/issues/12)).