mirror of
https://github.com/radareorg/r2ghidra.git
synced 2026-11-07 06:25:57 -10:00
Remove cmake support
This commit is contained in:
1 parent
753da63578
commit
7ecb38a93f
15 files changed
+26
-770
No files matched your search
@@ -87,30 +87,6 @@ jobs:
|
||||
# R2_DEBUG=1 r2 -qc 'af;pdg' /bin/ls | tee a.txt
|
||||
# grep entry0 a.txt
|
||||
|
||||
# linux-cmake-ok:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@v2
|
||||
# - name: Cloning Repo
|
||||
# run: git clone --depth=1 https://github.com/radareorg/radare2
|
||||
# - name: Packaging Radare2 for Debian
|
||||
# # run: make -C radare2/dist/debian
|
||||
# run: ( cd radare2 && sys/debian.sh )
|
||||
# - name: Installing Radare2
|
||||
# run: sudo dpkg -i radare2/dist/debian/*/*.deb
|
||||
# - name: Building r2ghidra with cmake
|
||||
# run: |
|
||||
# ./preconfigure && cmake -DCMAKE_INSTALL_PREFIX=/usr -B b && make -C b -j4 && sudo make -C b install
|
||||
# ls -l /usr/lib/radare2/5.6.9/
|
||||
# ls -l /usr/lib/radare2/5.6.9/plugins
|
||||
# - name: Testing r2ghidra oneliner
|
||||
# run: r2 -H;r2 -l /usr/lib/radare2/last/plugins/core_ghidra.so -qc 'af;pdg' /bin/ls | tee a.txt && grep entry0 a.txt
|
||||
# - name: Pub
|
||||
# uses: actions/upload-artifact@v2
|
||||
# with:
|
||||
# path: radare2/dist/debian/*/*.deb
|
||||
|
||||
macos-acr-ok:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: macos-latest
|
||||
@@ -142,19 +118,6 @@ jobs:
|
||||
path: dist/macos/*.zip
|
||||
#path: radare2/dist/macos/*.pkg src/*.dylib /tmp/r2ghidra-macos-${{env.R2V}}.tar.gz dist/macos/*.zip
|
||||
|
||||
# macos-cmake-ok:
|
||||
# runs-on: macos-latest
|
||||
# if: ${{ false }} # disable for now
|
||||
# steps:
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@v2
|
||||
# - name: Installing radare2
|
||||
# run: git clone --depth=1 https://github.com/radareorg/radare2 && radare2/sys/install.sh
|
||||
# - name: Building r2ghidra with cmake
|
||||
# run: ./preconfigure && sudo cmake -DCMAKE_INSTALL_PREFIX=/usr -B build && sudo make -C build -j4 && sudo make -C build install
|
||||
# - name: Testing r2ghidra
|
||||
# run: r2 -qc 'af;pdg' /bin/ls | tee a.txt && grep iVar a.txt
|
||||
|
||||
w64:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
@@ -188,23 +151,6 @@ jobs:
|
||||
copy w\*.dll destdir
|
||||
cd destdir
|
||||
zip -r ..\r2ghidra-w64.zip *
|
||||
# - name: make
|
||||
# shell: cmd
|
||||
# run: |
|
||||
# cd
|
||||
# set PKG_CONFIG_PATH=%CD%\radare2\lib\pkgconfig
|
||||
# set PATH=%CD%\radare2\bin;%PATH%
|
||||
# set ARCH=x64
|
||||
# git submodule update --init
|
||||
# make ghidra-native
|
||||
# call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
|
||||
# mkdir destdir build
|
||||
# cd build
|
||||
# cmake -GNinja ..
|
||||
# cmake --build .
|
||||
# copy *.dll ..\destdir
|
||||
# cd ..\destdir
|
||||
# zip -r ..\r2ghidra-w64.zip *
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: r2ghidra-${{env.R2V}}-w64.zip
|
||||
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
|
||||
language: cpp
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
os: linux
|
||||
dist: bionic
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: "ppa:beineri/opt-qt-5.12.0-bionic"
|
||||
packages:
|
||||
- python3-pip
|
||||
- python3-setuptools
|
||||
- ninja-build
|
||||
- qt512base
|
||||
- libgl1-mesa-dev
|
||||
|
||||
env:
|
||||
- INSTALL_PREFIX=$TRAVIS_BUILD_DIR/radare2-prefix
|
||||
|
||||
install:
|
||||
- pip3 install meson
|
||||
- git clone --depth 1 https://github.com/radareorg/radare2
|
||||
- cd radare2 && mkdir build && cd build
|
||||
- meson --prefix="$INSTALL_PREFIX" ..
|
||||
- ninja
|
||||
- ninja install
|
||||
- cd ../..
|
||||
- git clone --depth 1 https://github.com/radareorg/cutter
|
||||
|
||||
script:
|
||||
- mkdir build && cd build
|
||||
- cmake
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_PREFIX_PATH="$TRAVIS_BUILD_DIR/radare2-prefix;/opt/qt512"
|
||||
-DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX"
|
||||
-DBUILD_CUTTER_PLUGIN=ON
|
||||
-DCUTTER_SOURCE_DIR="$TRAVIS_BUILD_DIR/cutter"
|
||||
-DBUILD_SLEIGH_PLUGIN=ON
|
||||
..
|
||||
- make -j4
|
||||
- make install
|
||||
- export LD_LIBRARY_PATH="$INSTALL_PREFIX/lib:$INSTALL_PREFIX/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH"
|
||||
- export PATH="$INSTALL_PREFIX/bin:$PATH"
|
||||
- export R2_LIBR_PLUGINS="$INSTALL_PREFIX/share/radare2/plugins"
|
||||
- cd ../test
|
||||
- make
|
||||
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH True)
|
||||
|
||||
project(r2ghidra)
|
||||
|
||||
set(RADARE2_INSTALL_PLUGDIR "lib/radare2/last/plugins" CACHE STRING "Directory to install radare2 plugin into")
|
||||
set(IAITO_INSTALL_PLUGDIR "lib/iaito/plugins/native" CACHE STRING "Directory to install iaito plugin into")
|
||||
|
||||
set(IAITO_SOURCE_DIR IAITO_SOURCE_DIR-NOTFOUND CACHE STRING "Root directory of iaito source")
|
||||
|
||||
option(BUILD_IAITO_PLUGIN "Build r2ghidra plugin for iaito" OFF)
|
||||
option(BUILD_DECOMPILE_EXECUTABLE "Build \"decompile\" executable as used by Ghidra (not needed for r2)" OFF)
|
||||
option(BUILD_DECOMPILE_CLI_EXECUTABLE "Build REPL decompiler (not needed for r2)" OFF)
|
||||
option(BUILD_SLASPECS "Build Sleigh specs for architectures from Ghidra" ON)
|
||||
option(GENERATE_PARSERS "Re-generate all parsers with Bison/Flex instead of using pre-generated ones" OFF)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
# C++latest needed for designed initializers, but funnily MSVC includes fail to compile with this flag
|
||||
# if (MSVC_VERSION GREATER_EQUAL "1900")
|
||||
# include(CheckCXXCompilerFlag)
|
||||
# CHECK_CXX_COMPILER_FLAG("/std:c++latest" _cpp_latest_flag_supported)
|
||||
# if (_cpp_latest_flag_supported)
|
||||
# add_compile_options("/std:c++latest")
|
||||
# endif()
|
||||
# endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS "3.1")
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
add_definitions(-std=c++11)
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
endif()
|
||||
|
||||
if (MSVC_VERSION GREATER_EQUAL "1900")
|
||||
add_definitions(-D_WINDOWS)
|
||||
add_compile_options("/MT")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "/MT")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "/MTd")
|
||||
endif()
|
||||
|
||||
add_subdirectory(ghidra)
|
||||
add_subdirectory(third-party)
|
||||
|
||||
set(CORE_SOURCE
|
||||
src/core_ghidra.cpp
|
||||
src/R2Architecture.cpp
|
||||
src/R2Architecture.h
|
||||
src/R2LoadImage.cpp
|
||||
src/R2LoadImage.h
|
||||
src/R2Scope.cpp
|
||||
src/R2Scope.h
|
||||
src/R2TypeFactory.cpp
|
||||
src/R2TypeFactory.h
|
||||
src/R2CommentDatabase.cpp
|
||||
src/R2CommentDatabase.h
|
||||
src/CodeXMLParse.h
|
||||
src/CodeXMLParse.cpp
|
||||
src/ArchMap.h
|
||||
src/ArchMap.cpp
|
||||
src/R2PrintC.h
|
||||
src/R2PrintC.cpp
|
||||
src/RCoreMutex.h
|
||||
src/RCoreMutex.cpp
|
||||
src/SleighAsm.h
|
||||
src/SleighAsm.cpp
|
||||
src/SleighInstruction.h
|
||||
src/SleighInstruction.cpp
|
||||
src/ArchMap.h
|
||||
src/ArchMap.cpp
|
||||
src/r2ghidra.h)
|
||||
|
||||
set(ANAL_SOURCE
|
||||
src/SleighAnalValue.h
|
||||
src/SleighAnalValue.cpp
|
||||
src/anal_ghidra.cpp)
|
||||
|
||||
find_package(Radare2 REQUIRED)
|
||||
|
||||
add_library(core_ghidra SHARED ${CORE_SOURCE})
|
||||
target_link_libraries(core_ghidra ghidra_decompiler_base ghidra_libdecomp ghidra_decompiler_sleigh)
|
||||
target_link_libraries(core_ghidra pugixml)
|
||||
target_link_libraries(core_ghidra Radare2::libr)
|
||||
if (WIN32)
|
||||
target_link_libraries(core_ghidra Ws2_32.lib wininet)
|
||||
endif()
|
||||
|
||||
set_target_properties(core_ghidra PROPERTIES
|
||||
OUTPUT_NAME core_ghidra
|
||||
PREFIX "")
|
||||
|
||||
|
||||
if(BUILD_IAITO_PLUGIN)
|
||||
add_subdirectory(iaito-plugin)
|
||||
endif()
|
||||
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
string (REPLACE ";" " " LD_RPATH_STR "@loader_path")
|
||||
else()
|
||||
string (REPLACE ";" " " LD_RPATH_STR "$ORIGIN")
|
||||
endif()
|
||||
|
||||
add_library(anal_ghidra SHARED ${ANAL_SOURCE})
|
||||
target_link_libraries(anal_ghidra core_ghidra)
|
||||
set_target_properties(anal_ghidra PROPERTIES
|
||||
OUTPUT_NAME anal_ghidra
|
||||
BUILD_RPATH "${LD_RPATH_STR}"
|
||||
INSTALL_RPATH "${LD_RPATH_STR}"
|
||||
PREFIX "")
|
||||
|
||||
if(SLEIGHHOME_DEFAULT)
|
||||
target_compile_definitions(core_ghidra PRIVATE "-DR2GHIDRA_SLEIGHHOME_DEFAULT=\"${SLEIGHHOME_DEFAULT}\"")
|
||||
target_compile_definitions(anal_ghidra PRIVATE "-DR2GHIDRA_SLEIGHHOME_DEFAULT=\"${SLEIGHHOME_DEFAULT}\"")
|
||||
endif()
|
||||
|
||||
install(TARGETS core_ghidra DESTINATION "${RADARE2_INSTALL_PLUGDIR}")
|
||||
install(TARGETS anal_ghidra DESTINATION "${RADARE2_INSTALL_PLUGDIR}")
|
||||
@@ -26,8 +26,8 @@ To build and install r2ghidra you need the following software installed in your
|
||||
|
||||
* radare2 (preferibly from git, for distro builds ensure the `-dev` package is also installed)
|
||||
* pkg-config - that's how build system find libraries and include files to compile stuff
|
||||
* make / cmake / meson - pick the build system you like! all of them are maintained and working
|
||||
* msvc/g++/clang++ - basically a C++ compiler
|
||||
* acr/make or meson/ninja - pick the build system you like! all of them are maintained and working
|
||||
* msvc/g++/clang++ - basically a C++ compiler (and a C compiler)
|
||||
* git/patch - needed to clone ghidra-native and build stuff
|
||||
|
||||
If the build fails, please carefully read the error message and act accordingly, r2pm should
|
||||
@@ -85,25 +85,29 @@ Here, `r2ghidra.sleighhome` must point to a directory containing the `*.sla`, `*
|
||||
the architectures that should supported by the decompiler. This is however set up automatically when using
|
||||
the r2pm package or installing as shown below.
|
||||
|
||||
## Building for Windows
|
||||
## Installation
|
||||
|
||||
Most users will just use `r2pm -ci r2ghidra` to build or update the plugin for the version of r2
|
||||
|
||||
### Windows Binary installation
|
||||
|
||||
First, make sure you have the latest version of radare2 for Windows, which can be found as a binary package [in the releases](https://github.com/radareorg/radare2/releases).
|
||||
|
||||
Then run the following command from the radare2/bin/ directory:
|
||||
Then run the following command from the radare2/bin/ directory to find out the `R2_USER_PLUGINS` path:
|
||||
|
||||
```
|
||||
$ r2 -hh
|
||||
```
|
||||
|
||||
Take note of the `R2_USER_PLUGINS` path that is displayed. If this path does not actually exist on your system, create it.
|
||||
Now, go to the [r2ghidra latest releases](https://github.com/radareorg/r2ghidra/releases) and download the Windows binary package, which contains 3 dll files. Copy these dll files to the R2_USER_PLUGINS directory.
|
||||
Now, download the [latest r2ghidra release](https://github.com/radareorg/r2ghidra/releases) for Windows and copy the `dll file in the `R2_USER_PLUGINS` directory.
|
||||
|
||||
You should now be able to do `pdg` while in radare2 to invoke the r2ghidra decompile command.
|
||||
|
||||
## Building
|
||||
|
||||
r2ghidra can be built with `meson`, `cmake` or `acr`. All the 3 build systems are maintained in sync and aims to provide to the packagers and users the choice to use whatever fits better for their needs.
|
||||
r2ghidra can be built with `meson/ninja` and `acr/make`. Both build systems are maintained, feel free to pick the one you feel more comfortable with.
|
||||
|
||||
### Building with ACR/Make
|
||||
### ACR/Make
|
||||
|
||||
The procedure is like the standard autoconf:
|
||||
|
||||
@@ -115,6 +119,14 @@ $ make install # or make user-install
|
||||
```
|
||||
At the moment there is no way to select which processors to support, so it builds them all and takes a lot of time to compile the sleighfiles.
|
||||
|
||||
### Meson/Ninja
|
||||
|
||||
Also works with `muon/samu` and that's the preferred way to build r2ghidra on Windows.
|
||||
|
||||
```
|
||||
meson b
|
||||
ninja -C b
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
@@ -122,62 +134,10 @@ To compile r2ghidra on windows you need Visual Studio and git installed:
|
||||
|
||||
```cmd
|
||||
preconfigure # find VS installation, sets path and download external code
|
||||
configure # prepare the build
|
||||
make # compile and zip the result
|
||||
```
|
||||
or
|
||||
|
||||
```
|
||||
dist\windows\build
|
||||
```
|
||||
|
||||
### Building with CMake
|
||||
|
||||
First, make sure the submodule contained within this repository is fetched and up to date:
|
||||
|
||||
```
|
||||
./preconfigure # or just 'preconfigure' on Windows to fetch ghidra-native and pugixml dependencies
|
||||
```
|
||||
|
||||
Then, the radare2 plugin can be built and installed as follows:
|
||||
|
||||
```
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
make
|
||||
make install DESTDIR=/tmp/r2ghidra-prefix
|
||||
```
|
||||
|
||||
Here, set the `CMAKE_INSTALL_PREFIX` to a location where radare2 can load the plugin from.
|
||||
|
||||
## Iaito plugin
|
||||
|
||||
Iaito can use r2ghidra without the need for a iaito-specific plugin. But the performance may be better when using the native plugin in contrast to the json-parsing generic solution.
|
||||
|
||||
The install step is necessary for the plugin to work because it includes installing the necessary Sleigh files.
|
||||
|
||||
To also build the Cutter plugin, pass `-DBUILD_IAITO_PLUGIN=ON -DIAITO_SOURCE_DIR=/path/to/cutter/source` to cmake, for example like this:
|
||||
```
|
||||
$ git clone https://github.com/radareorg/iaito
|
||||
$ mkdir build && cd build
|
||||
$ cmake -DBUILD_IAITO_PLUGIN=ON -DIAITO_SOURCE_DIR=/my/path/cutter -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
/my/path/r2ghidra/build> make && make install
|
||||
configure # prepare the build (run meson)
|
||||
make # compile and zip the result (run ninja)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Please note that this plugin is available under the **LGPLv3**, which
|
||||
is more strict than Ghidra's license!
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
See `LICENSE.md` for more details. but it's basically **LGPLv3**.
|
||||
@@ -1,37 +0,0 @@
|
||||
# requires IAITO_SOURCE_DIR
|
||||
# sets IAITO_INCLUDE_DIRS and Iaito::Iaito
|
||||
|
||||
|
||||
set(_module Iaito)
|
||||
|
||||
|
||||
# Prefer IaitoConfig.cmake from Iaito installation if available.
|
||||
# FindIaito.cmake can be fully removed once all Iaito release packages include IaitoConfig.
|
||||
find_package(${_module} CONFIG QUIET)
|
||||
if(${_module}_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(IAITO_SOURCE_DIR)
|
||||
find_path(Iaito_SOURCE_ROOT
|
||||
NAMES core/Iaito.h
|
||||
PATHS "${IAITO_SOURCE_DIR}"
|
||||
PATH_SUFFIXES src
|
||||
NO_DEFAULT_PATH)
|
||||
else()
|
||||
set(Iaito_SOURCE_ROOT Iaito_SOURCE_ROOT-NOTFOUND)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Iaito
|
||||
REQUIRED_VARS Iaito_SOURCE_ROOT
|
||||
FAIL_MESSAGE "#######################################################
|
||||
Could not find Iaito headers. Make sure IAITO_SOURCE_DIR is set to the root of the Iaito source repository.
|
||||
#######################################################
|
||||
")
|
||||
|
||||
if(Iaito_FOUND)
|
||||
set(IAITO_INCLUDE_DIRS "${Iaito_SOURCE_ROOT}" "${Iaito_SOURCE_ROOT}/common" "${Iaito_SOURCE_ROOT}/core")
|
||||
add_library(${_module}::Iaito INTERFACE IMPORTED GLOBAL)
|
||||
target_include_directories(${_module}::Iaito INTERFACE ${IAITO_INCLUDE_DIRS})
|
||||
endif()
|
||||
@@ -1,119 +0,0 @@
|
||||
# - Find Radare2 (libr)
|
||||
#
|
||||
# This module provides the following imported targets, if found:
|
||||
#
|
||||
# Radare2::libr
|
||||
#
|
||||
# This will define the following variables:
|
||||
# (but don't use them if you don't know what you are doing, use Radare2::libr)
|
||||
#
|
||||
# Radare2_FOUND - True if libr has been found.
|
||||
# Radare2_INCLUDE_DIRS - libr include directory
|
||||
# Radare2_LIBRARIES - List of libraries when using libr.
|
||||
# Radare2_LIBRARY_DIRS - libr library directories
|
||||
#
|
||||
# If libr was found using find_library and not pkg-config, the following variables will also be set:
|
||||
# Radare2_LIBRARY_<name> - Path to library r_<name>
|
||||
|
||||
if(WIN32)
|
||||
find_path(Radare2_INCLUDE_DIRS
|
||||
NAMES r_core.h r_bin.h r_util.h
|
||||
HINTS
|
||||
../radare2/include/libr
|
||||
radare2/include/libr
|
||||
"$ENV{HOME}/bin/prefix/radare2/include/libr"
|
||||
/usr/local/include/libr
|
||||
/usr/include/libr)
|
||||
find_path(SDB_INCLUDE_DIR
|
||||
NAMES sdb.h sdbht.h sdb_version.h
|
||||
HINTS
|
||||
../radare2/include/libr/sdb
|
||||
radare2/include/libr/sdb
|
||||
"$ENV{HOME}/bin/prefix/radare2/include/libr/sdb"
|
||||
/usr/local/include/libr/sdb
|
||||
/usr/include/libr/sdb)
|
||||
|
||||
list(APPEND Radare2_INCLUDE_DIRS ${SDB_INCLUDE_DIR})
|
||||
|
||||
set(Radare2_LIBRARY_NAMES
|
||||
core
|
||||
config
|
||||
cons
|
||||
io
|
||||
util
|
||||
flag
|
||||
asm
|
||||
debug
|
||||
hash
|
||||
bin
|
||||
lang
|
||||
io
|
||||
anal
|
||||
parse
|
||||
bp
|
||||
egg
|
||||
reg
|
||||
search
|
||||
syscall
|
||||
socket
|
||||
fs
|
||||
magic
|
||||
crypto)
|
||||
|
||||
set (Radare2_LIBRARIES "")
|
||||
set(Radare2_LIBRARIES_VARS "")
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
|
||||
foreach(libname ${Radare2_LIBRARY_NAMES})
|
||||
message(STATUS "searching for file: r_${libname}")
|
||||
find_library(Radare2_LIBRARY_${libname}
|
||||
r_${libname}
|
||||
HINTS
|
||||
../radare2/lib
|
||||
"$ENV{HOME}/bin/prefix/radare2/lib"
|
||||
../radare2/lib
|
||||
/usr/local/lib
|
||||
/usr/lib)
|
||||
list(APPEND Radare2_LIBRARIES ${Radare2_LIBRARY_${libname}})
|
||||
list(APPEND Radare2_LIBRARIES_VARS "Radare2_LIBRARY_${libname}")
|
||||
message(STATUS "Library set to ${Radare2_LIBRARY_${libname}}")
|
||||
endforeach()
|
||||
|
||||
add_library(Radare2::libr UNKNOWN IMPORTED)
|
||||
set_target_properties(Radare2::libr PROPERTIES
|
||||
IMPORTED_LOCATION "${Radare2_LIBRARY_core}"
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES "${Radare2_LIBRARIES}"
|
||||
INTERFACE_LINK_DIRECTORIES "${Radare2_LIBRARY_DIRS}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Radare2_INCLUDE_DIRS}")
|
||||
set(Radare2_TARGET Radare2::libr)
|
||||
else()
|
||||
# support installation locations used by r2 scripts like sys/user.sh and sys/install.sh
|
||||
set(Radare2_CMAKE_PREFIX_PATH_TEMP ${CMAKE_PREFIX_PATH})
|
||||
list(APPEND CMAKE_PREFIX_PATH "$ENV{HOME}/bin/prefix/radare2") # sys/user.sh
|
||||
list(APPEND CMAKE_PREFIX_PATH "/usr/local") # sys/install.sh
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.6")
|
||||
pkg_search_module(Radare2 REQUIRED r_core)
|
||||
else()
|
||||
pkg_search_module(Radare2 IMPORTED_TARGET REQUIRED r_core)
|
||||
endif()
|
||||
|
||||
# reset CMAKE_PREFIX_PATH
|
||||
set(CMAKE_PREFIX_PATH ${Radare2_CMAKE_PREFIX_PATH_TEMP})
|
||||
|
||||
if((TARGET PkgConfig::Radare2) AND (NOT CMAKE_VERSION VERSION_LESS "3.11.0"))
|
||||
set_target_properties(PkgConfig::Radare2 PROPERTIES IMPORTED_GLOBAL ON)
|
||||
add_library(Radare2::libr ALIAS PkgConfig::Radare2)
|
||||
set(Radare2_TARGET Radare2::libr)
|
||||
elseif(Radare2_FOUND)
|
||||
add_library(Radare2::libr INTERFACE IMPORTED)
|
||||
set_target_properties(Radare2::libr PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Radare2_INCLUDE_DIRS}")
|
||||
set_target_properties(Radare2::libr PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${Radare2_LIBRARIES}")
|
||||
set(Radare2_TARGET Radare2::libr)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Radare2 REQUIRED_VARS Radare2_TARGET Radare2_LIBRARIES Radare2_INCLUDE_DIRS)
|
||||
@@ -1,4 +1,3 @@
|
||||
@echo OFF
|
||||
echo "Configuring the build directory with cmake"
|
||||
meson w
|
||||
REM cmake -B build -GNinja
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
mkdir build && cd build
|
||||
cmake .. -DBUILD_SLEIGH_PLUGIN=ON -DCMAKE_INSTALL_PREFIX=$HOME/.local "$@"
|
||||
make -j8
|
||||
make install
|
||||
|
||||
cd ../test
|
||||
make
|
||||
Vendored
+1
-15
@@ -6,7 +6,7 @@ if [ $? != 0 ]; then
|
||||
# git clone --depth=1 [email protected]:radareorg/radare2 r2 || exit 1
|
||||
wget -c https://github.com/radareorg/radare2/archive/master.zip
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install git g++ make cmake pkg-config flex bison unzip patch
|
||||
sudo apt-get -y install git g++ make pkg-config flex bison unzip patch
|
||||
unzip master.zip
|
||||
mv radare2-master r2
|
||||
( cd r2 && sys/debian.sh ) # make -C r2/dist/debian
|
||||
@@ -23,20 +23,6 @@ R2_LIBR_PLUGINS=`r2 -HR2_LIBR_PLUGINS`
|
||||
export CFLAGS=-O2
|
||||
make R2_PLUGDIR=${R2_LIBR_PLUGINS} DESTDIR=${DESTDIR}
|
||||
|
||||
USE_CMAKE=0
|
||||
|
||||
if [ "$USE_CMAKE" = 1 ]; then
|
||||
set -e
|
||||
rm -rf build
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DRADARE2_INSTALL_PLUGDIR="`r2 -HR2_LIBR_PLUGINS`" \
|
||||
-DCMAKE_INSTALL_PREFIX="`r2 -HR2_PREFIX`"
|
||||
make -j4
|
||||
sudo make install DESTDIR=${DESTDIR}
|
||||
else
|
||||
./configure --prefix=/usr
|
||||
make -j4
|
||||
sudo make install DESTDIR="${DESTDIR}"
|
||||
fi
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
FROM debian:buster
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install git g++ cmake pkg-config flex bison unzip patch
|
||||
RUN apt-get -y install git g++ pkg-config flex bison unzip patch
|
||||
|
||||
RUN export CFLAGS=-O2 && cd /root && git clone --depth 1 https://github.com/radareorg/radare2 && cd radare2 && ./configure --prefix=/usr && make -j4 && make install
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
FROM debian:jessie
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install git g++ cmake pkg-config flex bison
|
||||
RUN apt-get -y install git g++ pkg-config flex bison
|
||||
|
||||
RUN cd /root && git clone --depth 1 https://github.com/radareorg/radare2 && cd radare2 && ./configure --prefix=/usr && make -j4 && make install
|
||||
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
|
||||
################################################################################
|
||||
# see Ghidra/Features/Decompiler/build.gradle in Ghidra source
|
||||
|
||||
set(DECOMPILER_SOURCE_BASE_CXX
|
||||
# xml.cc // generated by yacc task
|
||||
space.cc
|
||||
float.cc
|
||||
address.cc
|
||||
pcoderaw.cc
|
||||
translate.cc
|
||||
opcodes.cc
|
||||
globalcontext.cc
|
||||
capability.cc
|
||||
architecture.cc
|
||||
options.cc
|
||||
graph.cc
|
||||
cover.cc
|
||||
block.cc
|
||||
cast.cc
|
||||
typeop.cc
|
||||
database.cc
|
||||
cpool.cc
|
||||
comment.cc
|
||||
fspec.cc
|
||||
action.cc
|
||||
loadimage.cc
|
||||
# grammar.cc // doesn't seem to be used
|
||||
varnode.cc
|
||||
op.cc
|
||||
type.cc
|
||||
variable.cc
|
||||
varmap.cc
|
||||
jumptable.cc
|
||||
emulate.cc
|
||||
emulateutil.cc
|
||||
flow.cc
|
||||
userop.cc
|
||||
funcdata.cc
|
||||
funcdata_block.cc
|
||||
funcdata_varnode.cc
|
||||
funcdata_op.cc
|
||||
pcodeinject.cc
|
||||
heritage.cc
|
||||
prefersplit.cc
|
||||
rangeutil.cc
|
||||
ruleaction.cc
|
||||
subflow.cc
|
||||
blockaction.cc
|
||||
merge.cc
|
||||
double.cc
|
||||
coreaction.cc
|
||||
condexe.cc
|
||||
override.cc
|
||||
dynamic.cc
|
||||
crc32.cc
|
||||
prettyprint.cc
|
||||
printlanguage.cc
|
||||
printc.cc
|
||||
printjava.cc
|
||||
memstate.cc
|
||||
opbehavior.cc
|
||||
paramid.cc
|
||||
transform.cc
|
||||
string_ghidra.cc
|
||||
stringmanage.cc
|
||||
# callgraph.cc // uncomment for debug
|
||||
# ifacedecomp.cc // uncomment for debug
|
||||
# ifaceterm.cc // uncomment for debug
|
||||
# interface.cc // uncomment for debug
|
||||
)
|
||||
|
||||
set(DECOMPILER_SOURCE_BASE_YACC
|
||||
xml.y)
|
||||
|
||||
set(DECOMPILER_SOURCE_LIBDECOMP_CXX
|
||||
libdecomp.cc)
|
||||
|
||||
# Source specific to Ghidra
|
||||
set(DECOMPILER_SOURCE_GHIDRA_CXX
|
||||
ghidra_process.cc
|
||||
ghidra_arch.cc
|
||||
loadimage_ghidra.cc
|
||||
typegrp_ghidra.cc
|
||||
database_ghidra.cc
|
||||
ghidra_context.cc
|
||||
cpool_ghidra.cc
|
||||
comment_ghidra.cc
|
||||
inject_ghidra.cc
|
||||
ghidra_translate.cc)
|
||||
|
||||
set(DECOMPILER_SOURCE_SLEIGH_CXX
|
||||
sleigh_arch.cc
|
||||
sleigh.cc
|
||||
inject_sleigh.cc
|
||||
filemanage.cc
|
||||
semantics.cc
|
||||
slghsymbol.cc
|
||||
context.cc
|
||||
sleighbase.cc
|
||||
slghpatexpress.cc
|
||||
slghpattern.cc
|
||||
pcodecompile.cc)
|
||||
|
||||
set(DECOMPILER_SOURCE_SLEIGH_YACC
|
||||
pcodeparse.y
|
||||
grammar.y)
|
||||
|
||||
set(DECOMPILER_SOURCE_CONSOLE_CXX
|
||||
consolemain.cc
|
||||
interface.cc
|
||||
ifacedecomp.cc
|
||||
ifaceterm.cc
|
||||
callgraph.cc
|
||||
raw_arch.cc)
|
||||
|
||||
set(SLEIGH_COMPILER_SOURCE_CXX
|
||||
slgh_compile.cc
|
||||
slgh_compile.hh)
|
||||
|
||||
set(SLEIGH_COMPILER_SOURCE_YACC
|
||||
slghparse.y)
|
||||
|
||||
set(SLEIGH_COMPILER_SOURCE_FLEX
|
||||
slghscan.l)
|
||||
|
||||
# set(DECOMPILER_SOURCE_DIR ghidra/Ghidra/Features/Decompiler/src/decompile/cpp)
|
||||
set(DECOMPILER_SOURCE_DIR ../ghidra-native/src/decompiler)
|
||||
|
||||
################################################################################
|
||||
|
||||
function(prepend_src_dir list_name)
|
||||
set(tmp)
|
||||
foreach(r ${${list_name}})
|
||||
list(APPEND tmp "${DECOMPILER_SOURCE_DIR}/${r}")
|
||||
endforeach()
|
||||
set(${list_name} "${tmp}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
prepend_src_dir(DECOMPILER_SOURCE_BASE_CXX)
|
||||
prepend_src_dir(DECOMPILER_SOURCE_LIBDECOMP_CXX)
|
||||
prepend_src_dir(DECOMPILER_SOURCE_GHIDRA_CXX)
|
||||
prepend_src_dir(DECOMPILER_SOURCE_SLEIGH_CXX)
|
||||
prepend_src_dir(DECOMPILER_SOURCE_CONSOLE_CXX)
|
||||
prepend_src_dir(SLEIGH_COMPILER_SOURCE_CXX)
|
||||
set(SOURCE "${DECOMPILER_SOURCE_BASE_CXX}")
|
||||
|
||||
if(GENERATE_PARSERS)
|
||||
find_package(BISON REQUIRED)
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bison")
|
||||
find_package(FLEX REQUIRED)
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/flex")
|
||||
|
||||
# build yacc files and append the output files to OUT_VAR
|
||||
macro(build_bison OUT_VAR)
|
||||
foreach(yacc_file ${ARGN})
|
||||
get_filename_component(yacc_name "${yacc_file}" NAME_WE)
|
||||
if("${yacc_name}" STREQUAL "slghparse")
|
||||
set(yacc_prefix yy)
|
||||
else()
|
||||
set(yacc_prefix "${yacc_name}")
|
||||
endif()
|
||||
if(BISON_VERSION VERSION_LESS 2.6)
|
||||
set(BISON_COMPILE_FLAGS "--name-prefix=${yacc_prefix}")
|
||||
else()
|
||||
set(BISON_COMPILE_FLAGS "-Dapi.prefix={${yacc_prefix}}")
|
||||
endif()
|
||||
BISON_TARGET(${yacc_name}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${DECOMPILER_SOURCE_DIR}/${yacc_file}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/bison/${yacc_name}.cpp"
|
||||
COMPILE_FLAGS ${BISON_COMPILE_FLAGS})
|
||||
list(APPEND ${OUT_VAR} "${BISON_${yacc_name}_OUTPUTS}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
build_bison(SOURCE ${DECOMPILER_SOURCE_BASE_YACC})
|
||||
build_bison(DECOMPILER_SOURCE_SLEIGH_CXX ${DECOMPILER_SOURCE_SLEIGH_YACC})
|
||||
build_bison(SLEIGH_COMPILER_SOURCE_CXX ${SLEIGH_COMPILER_SOURCE_YACC})
|
||||
|
||||
FLEX_TARGET(slghscan "${DECOMPILER_SOURCE_DIR}/${SLEIGH_COMPILER_SOURCE_FLEX}" "${CMAKE_CURRENT_BINARY_DIR}/flex/slghscan.cpp")
|
||||
list(APPEND SLEIGH_COMPILER_SOURCE_CXX "${CMAKE_CURRENT_BINARY_DIR}/flex/slghscan.cpp")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/flex/slghparse.tab.hh" "#include \"../bison/slghparse.hpp\"")
|
||||
else()
|
||||
list(APPEND SOURCE
|
||||
"${DECOMPILER_SOURCE_DIR}/xml.hh"
|
||||
"${DECOMPILER_SOURCE_DIR}/xml.cc")
|
||||
list(APPEND DECOMPILER_SOURCE_SLEIGH_CXX
|
||||
"${DECOMPILER_SOURCE_DIR}/pcodeparse.hh"
|
||||
"${DECOMPILER_SOURCE_DIR}/pcodeparse.cc"
|
||||
"${DECOMPILER_SOURCE_DIR}/grammar.hh"
|
||||
"${DECOMPILER_SOURCE_DIR}/grammar.cc")
|
||||
list(APPEND SLEIGH_COMPILER_SOURCE_CXX
|
||||
"${DECOMPILER_SOURCE_DIR}/slghparse.hh"
|
||||
"${DECOMPILER_SOURCE_DIR}/slghparse.cc"
|
||||
"${DECOMPILER_SOURCE_DIR}/slghscan.cc")
|
||||
endif()
|
||||
|
||||
add_library(ghidra_decompiler_base STATIC ${SOURCE})
|
||||
target_include_directories(ghidra_decompiler_base PUBLIC "${DECOMPILER_SOURCE_DIR}")
|
||||
set_target_properties(ghidra_decompiler_base PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
add_library(ghidra_libdecomp STATIC ${DECOMPILER_SOURCE_LIBDECOMP_CXX})
|
||||
set_target_properties(ghidra_libdecomp PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
add_library(ghidra_decompiler_sleigh STATIC ${DECOMPILER_SOURCE_SLEIGH_CXX})
|
||||
target_include_directories(ghidra_decompiler_sleigh PUBLIC "${DECOMPILER_SOURCE_DIR}")
|
||||
set_target_properties(ghidra_decompiler_sleigh PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# "decompile" executable as used by Ghidra
|
||||
if(BUILD_DECOMPILE_EXECUTABLE)
|
||||
add_executable(ghidra_decompiler_exec ${DECOMPILER_SOURCE_GHIDRA_CXX})
|
||||
target_link_libraries(ghidra_decompiler_exec ghidra_decompiler_base)
|
||||
set_target_properties(ghidra_decompiler_exec PROPERTIES OUTPUT_NAME decompile)
|
||||
endif()
|
||||
|
||||
if(BUILD_DECOMPILE_CLI_EXECUTABLE)
|
||||
add_executable(ghidra_decompiler_cli ${DECOMPILER_SOURCE_CONSOLE_CXX})
|
||||
target_link_libraries(ghidra_decompiler_cli ghidra_decompiler_base ghidra_libdecomp ghidra_decompiler_sleigh)
|
||||
set_target_properties(ghidra_decompiler_cli PROPERTIES OUTPUT_NAME decompile_cli)
|
||||
endif()
|
||||
|
||||
add_executable(sleighc ${SLEIGH_COMPILER_SOURCE_CXX})
|
||||
target_link_libraries(sleighc ghidra_decompiler_sleigh ghidra_decompiler_base)
|
||||
target_include_directories(sleighc PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/flex")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-ULoadImage")
|
||||
|
||||
if(BUILD_SLASPECS)
|
||||
file(GLOB_RECURSE SLASPEC_FILES "../ghidra-native/src/Processors/*.slaspec")
|
||||
file(GLOB_RECURSE CPEC_FILES "../ghidra-native/src/Processors/*.cspec")
|
||||
file(GLOB_RECURSE LDEFS_FILES "../ghidra-native/src/Processors/*.ldefs")
|
||||
file(GLOB_RECURSE PSPEC_FILES "../ghidra-native/src/Processors/*.pspec")
|
||||
set(SLAFILES "")
|
||||
set(SLEIGH_BASE "${CMAKE_CURRENT_BINARY_DIR}/sleigh")
|
||||
file(MAKE_DIRECTORY "${SLEIGH_BASE}")
|
||||
foreach(slaspec ${SLASPEC_FILES})
|
||||
get_filename_component(sleigh_name "${slaspec}" NAME_WE)
|
||||
get_filename_component(sleigh_dir "${slaspec}" DIRECTORY)
|
||||
set(sla_file "${SLEIGH_BASE}/${sleigh_name}.sla")
|
||||
add_custom_command(OUTPUT "${sla_file}"
|
||||
COMMAND sleighc "${slaspec}" "${sla_file}"
|
||||
MAIN_DEPENDENCY "${slaspec}"
|
||||
WORKING_DIRECTORY "${sleigh_dir}")
|
||||
list(APPEND SLAFILES "${sla_file}")
|
||||
endforeach()
|
||||
add_custom_target(sla ALL DEPENDS ${SLAFILES})
|
||||
set(SLEIGH_INSTALL_DEST "${RADARE2_INSTALL_PLUGDIR}/r2ghidra_sleigh")
|
||||
install(FILES ${SLAFILES} ${CPEC_FILES} ${LDEFS_FILES} ${PSPEC_FILES} DESTINATION "${SLEIGH_INSTALL_DEST}")
|
||||
if(IS_ABSOLUTE "${SLEIGH_INSTALL_DEST}")
|
||||
set(SLEIGHHOME_DEFAULT "${SLEIGH_INSTALL_DEST}")
|
||||
else()
|
||||
set(SLEIGHHOME_DEFAULT "${CMAKE_INSTALL_PREFIX}/${SLEIGH_INSTALL_DEST}")
|
||||
endif()
|
||||
else()
|
||||
unset(SLEIGHHOME_DEFAULT)
|
||||
endif()
|
||||
set(SLEIGHHOME_DEFAULT "${SLEIGHHOME_DEFAULT}" PARENT_SCOPE)
|
||||
@@ -1,26 +0,0 @@
|
||||
|
||||
set(SOURCE
|
||||
R2GhidraPlugin.h
|
||||
R2GhidraPlugin.cpp
|
||||
R2GhidraDecompiler.h
|
||||
R2GhidraDecompiler.cpp)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
find_package(Qt5 REQUIRED COMPONENTS Widgets)
|
||||
|
||||
add_library(r2ghidra_iaito SHARED ${SOURCE})
|
||||
target_link_libraries(r2ghidra_iaito Qt5::Widgets)
|
||||
target_link_libraries(r2ghidra_iaito Radare2::libr)
|
||||
|
||||
find_package(Iaito REQUIRED)
|
||||
target_link_libraries(r2ghidra_iaito Iaito::Iaito)
|
||||
target_link_libraries(r2ghidra_iaito core_ghidra)
|
||||
|
||||
if(APPLE)
|
||||
target_link_options(r2ghidra_iaito PRIVATE -undefined dynamic_lookup)
|
||||
endif()
|
||||
|
||||
install(TARGETS r2ghidra_iaito DESTINATION "${IAITO_INSTALL_PLUGDIR}")
|
||||
@@ -5,7 +5,6 @@ if EXIST w (
|
||||
)
|
||||
|
||||
ninja -C w
|
||||
REM cmake --build build
|
||||
|
||||
echo Copying Plugins
|
||||
mkdir destdir
|
||||
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
option(USE_SYSTEM_PUGIXML "Use system pugixml library" OFF)
|
||||
|
||||
if (USE_SYSTEM_PUGIXML)
|
||||
find_package(pugixml REQUIRED)
|
||||
else()
|
||||
add_library(pugixml STATIC
|
||||
pugixml/src/pugiconfig.hpp
|
||||
pugixml/src/pugixml.cpp
|
||||
pugixml/src/pugixml.hpp)
|
||||
target_include_directories(pugixml PUBLIC pugixml/src)
|
||||
set_target_properties(pugixml PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
Reference in new issue
Block a user