diff --git a/.gitignore b/.gitignore index 3aba5f57712d8..4dbe1ceb6e173 100644 --- a/.gitignore +++ b/.gitignore @@ -76,10 +76,6 @@ shlr/sdb/src/sdb shlr/sdb/src/.sdb shlr/sdb/src/sdb.exe shlr/sdb/src/.sdb.exe -shlr/sdb/include/sdb/version.h -shlr/sdb/src/sdb-version.h -shlr/sdb/src/sdb_version.h -shlr/sdb/include/sdb/version.h shlr/sdb/src/libsdb.so* shlr/spp/config.h shlr/.cs_tmp.zip diff --git a/libr/esil/esil.c b/libr/esil/esil.c index 5ac637edce60d..33394060f7322 100644 --- a/libr/esil/esil.c +++ b/libr/esil/esil.c @@ -118,7 +118,7 @@ R_API bool r_esil_init(REsil *esil, int stacksize, bool iotrap, ut32 addrsize, REsilRegInterface *reg_if, REsilMemInterface *mem_if) { R_RETURN_VAL_IF_FAIL (esil && reg_if && reg_if->is_reg && reg_if->reg_read && reg_if->reg_write && reg_if->reg_size && mem_if && mem_if->mem_read && - mem_if->mem_write && (stacksize > 2), NULL); + mem_if->mem_write && (stacksize > 2), false); //do not check for mem_switch, as that is optional esil->stack = calloc (sizeof (char *), stacksize); if (R_UNLIKELY (!esil->stack)) { diff --git a/meson.build b/meson.build index eaec52b8ed76c..385122901c3c4 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,40 @@ project('radare2', 'c', license : 'LGPL3', meson_version : '>=0.50', version : '5.9.9') +# Global Arguments First + +# system dependencies +cc = meson.get_compiler('c') + +if get_option('wasan') + add_global_arguments('/DEBUG', language: 'c') + add_global_arguments('/MD', language: 'c') + add_global_arguments('/fsanitize=address', language: 'c') + # add_global_arguments('/Zi', language: 'c') # generate .pdb iirc + # add_global_arguments('/Z7', language: 'c') # generate .symbols instead of .pdb + # add_global_arguments('/guard:cf', language: 'c') +endif + +if cc.get_id() == 'msvc' + # add_project_arguments('/Zc:preprocessor', language: 'c') + if get_option('static_runtime') + add_global_arguments('/MT', language: 'c') + endif +endif + +if cc.get_id() == 'clang-cl' + add_global_arguments('-D__STDC__=1', language: 'c') + add_global_arguments('-D_CRT_DECLARE_NONSTDC_NAMES ', language: 'c') + add_global_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c') + add_global_arguments('-D_CRT_NONSTDC_NO_DEPRECATE', language: 'c') +endif + +if get_option('default_library') == 'shared' + if host_machine.system() != 'windows' or cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl' + add_global_arguments('-fvisibility=hidden', language: 'c') + endif +endif + + py3_exe = import('python').find_installation('python3') gen_py = '@0@/libr/syscall/d/gen.py'.format(meson.current_source_dir()) git_exe = find_program('git', required: false) @@ -96,8 +131,6 @@ endif r2_libversion = host_machine.system() == 'windows' ? '' : r2_version message('r2 lib version: ' + r2_libversion) -# system dependencies -cc = meson.get_compiler('c') # required for linux ldl = cc.find_library('dl', required: false) pth = dependency('threads', required: false) @@ -117,41 +150,12 @@ endif platform_inc = include_directories(platform_inc) -if cc.get_id() == 'msvc' -# add_project_arguments('/Zc:preprocessor', language: 'c') - if get_option('static_runtime') - add_project_arguments('/MT', language: 'c') - endif -endif - if get_option('threadsafety') r2_critical_enabled = 1 else r2_critical_enabled = 0 endif -if get_option('wasan') - add_project_arguments('/DEBUG', language: 'c') - add_project_arguments('/MD', language: 'c') - add_project_arguments('/fsanitize=address', language: 'c') - # add_project_arguments('/Zi', language: 'c') # generate .pdb iirc - # add_project_arguments('/Z7', language: 'c') # generate .symbols instead of .pdb - # add_project_arguments('/guard:cf', language: 'c') -endif - -if cc.get_id() == 'clang-cl' - add_project_arguments('-D__STDC__=1', language: 'c') - add_project_arguments('-D_CRT_DECLARE_NONSTDC_NAMES ', language: 'c') - add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c') - add_project_arguments('-D_CRT_NONSTDC_NO_DEPRECATE', language: 'c') -endif - -if get_option('default_library') == 'shared' - if host_machine.system() != 'windows' or cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl' - add_project_arguments('-fvisibility=hidden', language: 'c') - endif -endif - library_cflags = ['-DR2_PLUGIN_INCORE=1'] if host_machine.system() == 'windows' @@ -275,6 +279,8 @@ if sys_magic.found() and get_option('use_sys_magic') use_syslib_magic = true endif +# dep_sdb = dependency('sdb', fallback: ['sdb'], required: true) + # handle xxhash library sys_xxhash = dependency('libxxhash', required: false) use_sys_xxhash = false @@ -485,37 +491,36 @@ subdir('shlr/zip') # NOTE: copying most of the stuff from sdb to here for the moment, since we # should use subpackages to handle this well sdb_files = [ - 'shlr/sdb/src/array.c', - 'shlr/sdb/src/base64.c', - 'shlr/sdb/src/set.c', - 'shlr/sdb/src/cdb.c', - 'shlr/sdb/src/cdb_make.c', - 'shlr/sdb/src/dict.c', - 'shlr/sdb/src/diff.c', - 'shlr/sdb/src/disk.c', - 'shlr/sdb/src/fmt.c', - 'shlr/sdb/src/ht_uu.c', - 'shlr/sdb/src/ht_up.c', - 'shlr/sdb/src/ht_pp.c', - 'shlr/sdb/src/ht_pu.c', - 'shlr/sdb/src/ht_su.c', - 'shlr/sdb/src/journal.c', - 'shlr/sdb/src/json.c', - 'shlr/sdb/src/lock.c', - 'shlr/sdb/src/ls.c', - 'shlr/sdb/src/match.c', - 'shlr/sdb/src/ns.c', - 'shlr/sdb/src/num.c', - 'shlr/sdb/src/query.c', - 'shlr/sdb/src/sdb.c', - 'shlr/sdb/src/main.c', - 'shlr/sdb/src/heap.c', - 'shlr/sdb/src/ht.c', - 'shlr/sdb/src/util.c', - 'shlr/sdb/src/text.c' + 'subprojects/sdb/src/array.c', + 'subprojects/sdb/src/base64.c', + 'subprojects/sdb/src/set.c', + 'subprojects/sdb/src/cdb.c', + 'subprojects/sdb/src/cdb_make.c', + 'subprojects/sdb/src/dict.c', + 'subprojects/sdb/src/diff.c', + 'subprojects/sdb/src/disk.c', + 'subprojects/sdb/src/fmt.c', + 'subprojects/sdb/src/ht_uu.c', + 'subprojects/sdb/src/ht_up.c', + 'subprojects/sdb/src/ht_pp.c', + 'subprojects/sdb/src/ht_pu.c', + 'subprojects/sdb/src/ht_su.c', + 'subprojects/sdb/src/journal.c', + 'subprojects/sdb/src/json.c', + 'subprojects/sdb/src/lock.c', + 'subprojects/sdb/src/ls.c', + 'subprojects/sdb/src/match.c', + 'subprojects/sdb/src/ns.c', + 'subprojects/sdb/src/num.c', + 'subprojects/sdb/src/query.c', + 'subprojects/sdb/src/sdb.c', + 'subprojects/sdb/src/main.c', + 'subprojects/sdb/src/heap.c', + 'subprojects/sdb/src/ht.c', + 'subprojects/sdb/src/util.c', + 'subprojects/sdb/src/text.c' ] -sdb_inc = [platform_inc, include_directories(join_paths('shlr','sdb','include'))] # XXX we have sdb/meson.build for this!! dont dup # Create sdb_version.h @@ -525,33 +530,9 @@ if r.returncode() == 0 else sdb_version = 'unknown' endif -run_command(py3_exe, '-c', 'with open("shlr/sdb/include/sdb/version.h", "w") as f: f.write("#define SDB_VERSION \"' + sdb_version + '\"")') - -sdb_inc_files = [ - 'shlr/sdb/include/sdb/buffer.h', - 'shlr/sdb/include/sdb/cdb.h', - 'shlr/sdb/include/sdb/cdb_make.h', - 'shlr/sdb/include/sdb/config.h', - 'shlr/sdb/include/sdb/dict.h', - 'shlr/sdb/include/sdb/heap.h', - 'shlr/sdb/include/sdb/ht.h', - 'shlr/sdb/include/sdb/ht_inc.h', - 'shlr/sdb/include/sdb/ht_pp.h', - 'shlr/sdb/include/sdb/ht_pu.h', - 'shlr/sdb/include/sdb/ht_up.h', - 'shlr/sdb/include/sdb/ht_uu.h', - 'shlr/sdb/include/sdb/ls.h', - 'shlr/sdb/include/sdb/rangstr.h', - 'shlr/sdb/include/sdb/sdb.h', - 'shlr/sdb/include/sdb/set.h', - 'shlr/sdb/include/sdb/types.h', - 'shlr/sdb/include/sdb/version.h', - 'shlr/sdb/include/sdb/asserts.h', - 'shlr/sdb/include/sdb/cwisstable.h', - 'shlr/sdb/include/sdb/gcc_stdatomic.h', - 'shlr/sdb/include/sdb/msvc_stdatomic.h', -] -install_headers(sdb_inc_files, install_dir: join_paths(r2_incdir, 'sdb')) +run_command(py3_exe, '-c', 'with open("subprojects/sdb/include/sdb/version.h", "w") as f: f.write("#define SDB_VERSION \"' + sdb_version + '\"")') + +# install_headers(sdb_inc_files, install_dir: join_paths(r2_incdir, 'sdb')) script_files = [ 'scripts/il2cpp.r2.js', @@ -565,24 +546,19 @@ script_files = [ ] install_data(script_files, install_dir: r2_scripts) -libr2sdb = static_library('r2sdb', sdb_files, - include_directories: sdb_inc, - implicit_include_directories: false, - c_args: host_machine.system() == 'windows' ? '-DSDB_IPI= -DSDB_API=__declspec(dllexport)' : [], -) +dep_sdb = subproject('sdb') +# sdb_dep = dep_sdb.get_variable('sdb_dep') +libsdb = dep_sdb.get_variable('libsdb') +libsdb_includes = dep_sdb.get_variable('sdb_inc') +sdb_inc = libsdb_includes +libsdb_static = libsdb.get_static_lib() sdb_dep = declare_dependency( - link_whole: libr2sdb, - include_directories: sdb_inc + link_whole: libsdb_static, + include_directories: libsdb_includes ) -sdb_exe = executable('sdb', ['shlr/sdb/src/entry.c'] + sdb_files, - include_directories: [ - include_directories('shlr/sdb/include') - ], - implicit_include_directories: false, - native: true, -) +sdb_exe = dep_sdb.get_variable('sdb_exe') sdb_gen_cmd_cgen = [ sdb_exe, @@ -617,8 +593,8 @@ spp_files = [ spp_inc = [platform_inc, include_directories(join_paths('shlr','spp'))] libr2spp = static_library('r2spp', spp_files, - dependencies: sdb_dep, - include_directories: spp_inc, + link_with: [ libsdb ], # libsdb_static, + include_directories: [ sdb_inc, spp_inc ], c_args: ['-DHAVE_R_UTIL', '-DUSE_R2=1'], implicit_include_directories: false ) diff --git a/shlr/sdb/include/sdb/version.h b/shlr/sdb/include/sdb/version.h new file mode 100644 index 0000000000000..892f1c4edcc5c --- /dev/null +++ b/shlr/sdb/include/sdb/version.h @@ -0,0 +1 @@ +#define SDB_VERSION "2.0.1" diff --git a/subprojects/Makefile b/subprojects/Makefile new file mode 100644 index 0000000000000..4236db0a43e2b --- /dev/null +++ b/subprojects/Makefile @@ -0,0 +1,9 @@ +DEPS=sdb capstone-v5 + +all: $(DEPS) + +clean: + rm -rf $(DEPS) + +include sdb.mk +include capstone-v5.mk diff --git a/subprojects/autogen.sh b/subprojects/autogen.sh new file mode 100755 index 0000000000000..24b9234d069d4 --- /dev/null +++ b/subprojects/autogen.sh @@ -0,0 +1,9 @@ +#!/bin/sh +ACR_WRAP=/tmp/acr-wrap +#ACR_WRAP=acr-wrap + +for i in *.wrap ; do + o=`echo $i | sed -e 's,.wrap,.mk,'` + echo "[ACR] Wrapping $i" + ${ACR_WRAP} $i > $o +done diff --git a/subprojects/capstone-v5.mk b/subprojects/capstone-v5.mk new file mode 100644 index 0000000000000..e17856b1a6110 --- /dev/null +++ b/subprojects/capstone-v5.mk @@ -0,0 +1,19 @@ +# This file is autogenerated by acr-wrap + +WRAP_wrap_git_url:=https://github.com/capstone-engine/capstone.git +# revision = v5 +WRAP_wrap_git_revision:=8455b3c5a53b02e524494c7e72a3946a32518170 +# patch_directory = capstone-5.0.1 +WRAP_wrap_git_directory:=capstone-v5 +WRAP_wrap_git_depth:=1 + +capstone-v5_all: capstone-v5 + @echo "Nothing to do" + +capstone-v5: + git clone --no-checkout --depth=1 https://github.com/capstone-engine/capstone.git capstone-v5 + cd capstone-v5 && git fetch --depth=1 origin 8455b3c5a53b02e524494c7e72a3946a32518170 + cd capstone-v5 && git checkout + +capstone-v5_clean: + rm -rf capstone-v5 diff --git a/subprojects/capstone-v5.wrap b/subprojects/capstone-v5.wrap new file mode 100644 index 0000000000000..851926f01a047 --- /dev/null +++ b/subprojects/capstone-v5.wrap @@ -0,0 +1,7 @@ +[wrap-git] +url = https://github.com/capstone-engine/capstone.git +# revision = v5 +revision = 8455b3c5a53b02e524494c7e72a3946a32518170 +# patch_directory = capstone-5.0.1 +directory = capstone-v5 +depth = 1 diff --git a/subprojects/sdb.mk b/subprojects/sdb.mk new file mode 100644 index 0000000000000..87c9b6058b986 --- /dev/null +++ b/subprojects/sdb.mk @@ -0,0 +1,18 @@ +# This file is autogenerated by acr-wrap + +WRAP_wrap_git_url:=https://github.com/radareorg/sdb.git +WRAP_wrap_git_revision:=2e24eb0616dfce5e28130660313b56db9252dd5c +# revision = 2.0.1 +WRAP_wrap_git_directory:=sdb +WRAP_wrap_git_depth:=1 + +sdb_all: sdb + @echo "Nothing to do" + +sdb: + git clone --no-checkout --depth=1 https://github.com/radareorg/sdb.git sdb + cd sdb && git fetch --depth=1 origin 2e24eb0616dfce5e28130660313b56db9252dd5c + cd sdb && git checkout + +sdb_clean: + rm -rf sdb diff --git a/subprojects/sdb.wrap b/subprojects/sdb.wrap new file mode 100644 index 0000000000000..4159d395f8556 --- /dev/null +++ b/subprojects/sdb.wrap @@ -0,0 +1,6 @@ +[wrap-git] +url = https://github.com/radareorg/sdb.git +revision = 2e24eb0616dfce5e28130660313b56db9252dd5c +# revision = 2.0.1 +directory = sdb +depth = 1