Initial support for capstone-less compilations ##build

This commit is contained in:
pancake 2021-06-21 17:48:00 +02:00 committed by GitHub
parent d3824bf0ce
commit 2e417ee938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 327 additions and 4 deletions

View File

@ -25,6 +25,16 @@ jobs:
export CFLAGS=-I/tmp/fakeincs/
export LDFLAGS=-L/tmp/fakelibs/
sys/install.sh
build-nocs:
name: linux-nocs
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Building without capstone
run: |
cp -f dist/plugins-cfg/plugins.nocs.cfg plugins.cfg
./configure --without-capstone && make -j
build-wasi:
name: linux-wasi
runs-on: ubuntu-20.04

View File

@ -17,6 +17,7 @@ USE_RPATH=@USE_RPATH@
HAVE_JEMALLOC=@HAVE_JEMALLOC@
HAVE_FORK=@HAVE_FORK@
WANT_DYLINK=@WANT_DYLINK@
WANT_CAPSTONE=@WANT_CAPSTONE@
WITH_LIBR=@WITH_LIBR@
ifeq ($(USE_RPATH),1)
@ -60,7 +61,11 @@ DL_LIBS=
endif
# capstone
ifeq ($(WANT_CAPSTONE),1)
USE_CAPSTONE=@USE_CAPSTONE@
else
USE_CAPSTONE=0
endif
ifeq ($(USE_CAPSTONE),1)
CAPSTONE_CFLAGS=@CAPSTONE_CFLAGS@
CAPSTONE_LDFLAGS=@CAPSTONE_LDFLAGS@

7
configure vendored
View File

@ -26,6 +26,7 @@ WANT_DYLINK=1
HAVE_FORK=1
WANT_PTRACE_WRAP=1
WANT_GPERF=1
WANT_CAPSTONE=1
WITH_LIBR=0
USE_CS5=0
USE_CS4=0
@ -189,6 +190,7 @@ Optional Features:
--without-fork disable fork
--without-ptrace-wrap build ptrace-wrap support needed for the iaito debugger on Linux
--without-gperf do not statically link the sdb databases even if gperf is found
--without-capstone dont build the capstone dependency
--with-libr build libr.a and libr.dylib
--with-capstone5 build next branch of capstone5 (default)
--with-capstone4 build v4 branch of capstone
@ -277,7 +279,7 @@ echo "LANGS: c"
echo "REQUIRED: libdl"
echo "OPTIONAL: libmagic libz libzip libxxhash libssl liblibuv>=1.0.0"
echo "PKG-CONFIG: capstone openssl libuv"
echo "FLAGS: --disable-debugger --with-sysmagic --disable-threads --disable-loadlibs --without-dylink --without-fork --without-ptrace-wrap --without-gperf --with-libr --with-capstone5 --with-capstone4 --with-syscapstone --with-syszip --with-sysxxhash --without-gpl --with-openssl --without-libuv --with-rpath --with-compiler=gcc --with-ostype=auto --with-libversion=xxx --without-jemalloc --with-checks-level=2"
echo "FLAGS: --disable-debugger --with-sysmagic --disable-threads --disable-loadlibs --without-dylink --without-fork --without-ptrace-wrap --without-gperf --without-capstone --with-libr --with-capstone5 --with-capstone4 --with-syscapstone --with-syszip --with-sysxxhash --without-gpl --with-openssl --without-libuv --with-rpath --with-compiler=gcc --with-ostype=auto --with-libversion=xxx --without-jemalloc --with-checks-level=2"
exit 0
;;
--cache-file)
@ -335,6 +337,7 @@ echo "FLAGS: --disable-debugger --with-sysmagic --disable-threads --disable-
"--without-fork") HAVE_FORK="0"; ;;
"--without-ptrace-wrap") WANT_PTRACE_WRAP="0"; ;;
"--without-gperf") WANT_GPERF="0"; ;;
"--without-capstone") WANT_CAPSTONE="0"; ;;
"--with-libr") WITH_LIBR="1"; ;;
"--with-capstone5") USE_CS5="1"; ;;
"--with-capstone4") USE_CS4="1"; ;;
@ -367,7 +370,7 @@ parse_options "$1"
shift
done
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR ETCDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_DL DL_LIBS PKGCONFIG HAVE_PATCH PATCH HAVE_GIT GIT HAVE_GPERF GPERF HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC WANT_THREADS LOADLIBS WANT_DYLINK HAVE_FORK WANT_PTRACE_WRAP WANT_GPERF WITH_LIBR USE_CS5 USE_CS4 WITH_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE USE_CAPSTONE HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_XXHASH USE_XXHASH USE_LIB_XXHASH LIBXXHASH WITH_GPL HAVE_DECL_ADDR_NO_RANDOMIZE HAVE_DECL___GLIBC__ HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_CLOCK_NANOSLEEP HAVE_SIGACTION HAVE_CLOCK_GETTIME CLOCK_LDFLAGS SUPPORT_GNU99 HAVE_LIB_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL HAVE_LIBUV_VERSION_1_0_0 LIBUV_CFLAGS LIBUV_LDFLAGS HAVE_PKGCFG_LIBUV HAVE_LIBUV WANT_LIBUV USE_RPATH USERCC USEROSTYPE LIBVERSION HAVE_JEMALLOC HAVE_PTRACE USE_PTRACE_WRAP R_CHECKS_LEVEL"
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR ETCDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_DL DL_LIBS PKGCONFIG HAVE_PATCH PATCH HAVE_GIT GIT HAVE_GPERF GPERF HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC WANT_THREADS LOADLIBS WANT_DYLINK HAVE_FORK WANT_PTRACE_WRAP WANT_GPERF WANT_CAPSTONE WITH_LIBR USE_CS5 USE_CS4 WITH_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE USE_CAPSTONE HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_XXHASH USE_XXHASH USE_LIB_XXHASH LIBXXHASH WITH_GPL HAVE_DECL_ADDR_NO_RANDOMIZE HAVE_DECL___GLIBC__ HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_CLOCK_NANOSLEEP HAVE_SIGACTION HAVE_CLOCK_GETTIME CLOCK_LDFLAGS SUPPORT_GNU99 HAVE_LIB_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL HAVE_LIBUV_VERSION_1_0_0 LIBUV_CFLAGS LIBUV_LDFLAGS HAVE_PKGCFG_LIBUV HAVE_LIBUV WANT_LIBUV USE_RPATH USERCC USEROSTYPE LIBVERSION HAVE_JEMALLOC HAVE_PTRACE USE_PTRACE_WRAP R_CHECKS_LEVEL"
create_environ

View File

@ -33,6 +33,7 @@ ARG_WITHOUT WANT_DYLINK dylink disable support for dynamic loading of plugins ;
ARG_WITHOUT HAVE_FORK fork disable fork ;
ARG_WITHOUT WANT_PTRACE_WRAP ptrace-wrap build ptrace-wrap support needed for the iaito debugger on Linux ;
ARG_WITHOUT WANT_GPERF gperf do not statically link the sdb databases even if gperf is found ;
ARG_WITHOUT WANT_CAPSTONE capstone dont build the capstone dependency ;
IFNOT WANT_GPERF {
HAVE_GPERF = 0 ;

273
dist/plugins-cfg/plugins.nocs.cfg vendored Normal file
View File

@ -0,0 +1,273 @@
STATIC="anal.8051
anal.amd29k
anal.arc
anal.arm_gnu
anal.avr
anal.i4004
anal.bf
anal.chip8
anal.cr16
anal.cris
anal.dalvik
anal.ebc
anal.gb
anal.h8300
anal.hexagon
anal.i8080
anal.java
anal.xtensa
anal.malbolge
anal.mcore
anal.mips_gnu
anal.msp430
anal.nios2
anal.null
anal.or1k
anal.ppc_gnu
anal.sh
anal.sparc_gnu
anal.tricore
anal.v850
anal.ws
anal.xap
anal.z80
anal.v810
anal.vax
anal.6502
anal.snes
anal.riscv
anal.pic
anal.rsp
anal.wasm
anal.pyc
esil.dummy
asm.8051
asm.6502
asm.amd29k
asm.arc
asm.arm_gnu
asm.arm_winedbg
asm.avr
asm.bf
asm.chip8
asm.cr16
asm.cris_gnu
asm.dalvik
asm.dcpu16
asm.null
asm.hexagon
asm.ebc
asm.gb
asm.h8300
asm.hppa_gnu
asm.i4004
asm.i8080
asm.java
asm.lm32
asm.tricore
asm.xtensa
asm.malbolge
asm.mcore
asm.mips_gnu
asm.msp430
asm.nios2
asm.or1k
asm.ppc_as
asm.ppc_gnu
asm.propeller
asm.riscv
asm.rsp
asm.lanai_gnu
asm.sh
asm.snes
asm.sparc_gnu
asm.s390_gnu
asm.tms320
asm.v850
asm.v850_gnu
asm.m68k_gnu
asm.ws
asm.xap
asm.arm_as
asm.wasm
asm.x86_as
asm.x86_nz
asm.x86_nasm
asm.z80
asm.lh5801
asm.v810
asm.vax
asm.mcs96
asm.pic
asm.pyc
bin.any
bin.wasm
bin.nro
bin.nso
bin.art
bin.bf
bin.bflt
bin.bios
bin.symbols
bin.bootimg
bin.cgc
bin.coff
bin.off
bin.dex
bin.dol
bin.elf
bin.elf64
bin.fs
bin.java
bin.dmp64
bin.le
bin.menuet
bin.mach0
bin.mach064
bin.mbn
bin.mdmp
bin.ne
bin.mz
bin.nes
bin.qnx
bin.nin3ds
bin.ninds
bin.ningb
bin.ningba
bin.omf
bin.p9
bin.pe
bin.pe64
bin.pebble
bin.prg
bin.smd
bin.sms
bin.avr
bin.sfc
bin.te
bin.vsf
bin.xbe
bin.z64
bin.dyldcache
bin.xnu_kernelcache
bin_xtr.xtr_dyldcache
bin_xtr.xtr_fatmach0
bin_xtr.xtr_pemixed
bin_xtr.xtr_sep64
bin_ldr.ldr_linux
bin.zimg
bin.psxexe
bin.pyc
bin.wad
bp.arm
bp.bf
bp.mips
bp.ppc
bp.x86
core.a2f
core.sixref
core.java
crypto.aes
crypto.des
crypto.rc4
crypto.cps2
crypto.xor
crypto.blowfish
crypto.rc2
crypto.rot
crypto.rol
crypto.ror
crypto.base64
crypto.base91
crypto.aes_cbc
crypto.punycode
crypto.rc6
crypto.serpent
debug.bf
debug.io
debug.esil
debug.gdb
debug.qnx
debug.native
debug.rap
debug.winkd
debug.bochs
debug.null
egg.exec
egg.xor
fs.io
fs.r2
fs.ext2
fs.fat
fs.fb
fs.hfs
fs.hfsplus
fs.iso9660
fs.jfs
fs.minix
fs.ntfs
fs.posix
fs.reiserfs
fs.sfs
fs.tar
fs.udf
fs.ufs
fs.xfs
io.null
io.bfdbg
io.bochs
io.debug
io.default
io.gprobe
io.gdb
io.qnx
io.r2pipe
io.gzip
io.http
io.tcpslurp
io.socket
io.r2web
io.ihex
io.mach
io.malloc
io.sparse
io.mmap
io.procpid
io.ptrace
io.rap
io.self
io.shm
io.w32
io.w32dbg
io.winkd
io.winedbg
io.zip
io.r2k
io.ar
io.fd
io.rbuf
lang.c
lang.v
lang.zig
lang.rust
lang.spp
lang.vala
lang.pipe
lang.cpipe
parse.6502_pseudo
parse.tms320_pseudo
parse.v850_pseudo
parse.arm_pseudo
parse.att2intel
parse.chip8_pseudo
parse.dalvik_pseudo
parse.m68k_pseudo
parse.riscv_pseudo
parse.mips_pseudo
parse.ppc_pseudo
parse.sh_pseudo
parse.wasm_pseudo
parse.avr_pseudo
parse.x86_pseudo
parse.z80_pseudo"
SHARED="io.shm"

View File

@ -1,4 +1,5 @@
ifeq ($(WANT_CAPSTONE),1)
ifeq ($(USE_CAPSTONE),1)
# use system capstone
CS_CFLAGS=${CAPSTONE_CFLAGS}
@ -15,3 +16,7 @@ ifeq ($(CS_CFLAGS_INCLUDED),)
CFLAGS+=$(CS_CFLAGS)
CS_CFLAGS_INCLUDED=Yes
endif
else
# nothing happens
endif

View File

@ -4,7 +4,7 @@
#include <r_util.h>
#include <r_asm.h>
#include <r_lib.h>
#include "cs_version.h"
// #include "cs_version.h"
#include "../arch/riscv/riscv-opc.c"
#include "../arch/riscv/riscv.c"
@ -14,7 +14,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
RAsmPlugin r_asm_plugin_riscv = {
.name = "riscv",
.desc = "Capstone "CAPSTONE_VERSION_STRING" RISC-V disassembler",
.desc = "RISC-V disassembler",
.arch = "riscv",
.bits = 32|64,
.endian = R_SYS_ENDIAN_LITTLE | R_SYS_ENDIAN_BIG,

View File

@ -10,7 +10,9 @@
#include <r_types.h>
#include <r_lib.h>
#include <r_asm.h>
#if WANT_CAPSTONE
#include <capstone.h>
#endif
#ifdef CAPSTONE_TMS320C64X_H
#define CAPSTONE_HAS_TMS320C64X 1

View File

@ -1,3 +1,4 @@
ifeq ($(WANT_CAPSTONE),1)
ifeq ($(USE_CAPSTONE),1)
CS_CFLAGS=${CAPSTONE_CFLAGS}
CS_LDFLAGS=${CAPSTONE_LDFLAGS}
@ -13,3 +14,6 @@ ifeq ($(CS_CFLAGS_INCLUDED),)
CFLAGS+=$(CS_CFLAGS)
CS_CFLAGS_INCLUDED=Yes
endif
else
CS_CFLAGS=
endif

View File

@ -5,6 +5,10 @@ OBJ_MIPS+=../arch/mips/gnu/mips16-opc.o
OBJ_MIPS+=../arch/mips/gnu/micromips-opc.o
OBJ_MIPS+=../arch/mips/gnu/mips-opc.o
ifeq ($(WANT_CAPSTONE),0)
OBJ_MIPS+=../arch/mips/mipsasm.o
endif
TARGET_MIPS=asm_mips_gnu.${EXT_SO}
STATIC_OBJ+=${OBJ_MIPS}

View File

@ -12,6 +12,7 @@
#define HAVE_CLOCK_NANOSLEEP @HAVE_CLOCK_NANOSLEEP@
#define HAVE_SIGACTION @HAVE_SIGACTION@
#define WANT_THREADS @WANT_THREADS@
#define WANT_CAPSTONE @WANT_CAPSTONE@
#if (HAVE_GPERF) == 1
#define HAVE_GPERF @HAVE_GPERF@

View File

@ -350,6 +350,7 @@ userconf.set10('HAVE_LIBUV', use_libuv)
userconf.set10('HAVE_FORK', use_fork)
userconf.set10('WANT_DYLINK', use_dylink)
userconf.set10('WANT_THREADS', get_option('want_threads'))
userconf.set10('WANT_CAPSTONE', get_option('want_capstone'))
userconf.set10('HAVE_GPERF', get_option('sdb_cgen'))
userconf.set10('HAVE_PTRACE', have_ptrace)
userconf.set10('USE_PTRACE_WRAP', use_ptrace_wrap)

View File

@ -24,6 +24,7 @@ option('r2_gittip', type: 'string', value: '')
option('checks_level', type: 'integer', value: 9999, description: 'Value between 0 and 3 to enable different level of assert (see R_CHECKS_LEVEL). By default its value depends on buildtype (2 on debug, 1 on release).')
option('capstone_in_builddir', type: 'boolean', value: false, description: 'When true, capstone is downloaded in the build directory and not in the source one')
option('want_threads', type: 'boolean', value: true)
option('want_capstone', type: 'boolean', value: true)
option('use_sys_capstone', type: 'boolean', value: false)
option('use_capstone_version', type: 'combo', choices: ['v3', 'v4', 'v5'], value: 'v5')
option('use_sys_magic', type: 'boolean', value: false)

View File

@ -199,6 +199,13 @@ install-symlink symstall:
uninstall deinstall:
rm -f ${DESTDIR}${LIBDIR}/libr_shlr.${EXT_AR}
ifeq ($(WANT_CAPSTONE),0)
capstone:
capstone-sync:
capstone-build:
else
ifeq ($(USE_CAPSTONE),1)
# Do nothing here
capstone:
@ -266,6 +273,8 @@ ifneq (${EXT_AR},a)
-cp -f capstone/libcapstone.a capstone/libcapstone.${EXT_AR}
endif
endif
endif
../../radare2-webui:
cd ../.. ; git clone --depth 1 https://github.com/radareorg/radare2-webui

View File

@ -1,5 +1,9 @@
ifeq ($(WANT_CAPSTONE),1)
ifeq ($(USE_CAPSTONE),1)
LINK+=${CAPSTONE_LDFLAGS}
else
LINK+=$(SHLR)/capstone/libcapstone.a
endif
else
# nothing
endif