Rename R_ and R2_ to RZ_ (#8)

* Rename R2_ -> RZ_
* Rename R_ -> RZ_
* Rename R2R_ -> RZ_TEST_
* Rename R2R defines and types to RZ_TEST/RzTest
* Keep R_ for REIL registers
This commit is contained in:
Riccardo Schirone
2020-10-02 16:09:13 +02:00
committed by GitHub
parent 881058693d
commit 502e91aff7
955 changed files with 23837 additions and 23838 deletions
+4 -4
View File
@@ -65,8 +65,8 @@ init:
# Required software for building
install:
# Update environment variables
- ps: $env:R2_VERSION = ( python sys\\version.py )
- ps: $env:DIST_FOLDER = "rizin-$env:builder-$env:R2_VERSION"
- ps: $env:RZ_VERSION = ( python sys\\version.py )
- ps: $env:DIST_FOLDER = "rizin-$env:builder-$env:RZ_VERSION"
- ps: $env:ARTIFACT_ZIP = "$env:DIST_FOLDER.zip"
# Download required packages
- cmd: if defined BUILD_DIR ( %PYTHON%\python.exe -m pip install meson )
@@ -74,7 +74,7 @@ install:
# Build scripts
build_script:
- appveyor AddMessage "Compiling rizin %R2_VERSION% (%builder%)"
- appveyor AddMessage "Compiling rizin %RZ_VERSION% (%builder%)"
- cmd: if %builder% == vs2017_64 ( set "PATH=C:\mingw\bin;C:\mingw\msys\1.0\bin;%PYTHON%;%PATH%" && call "%VSVARSALLPATH2017%" x64 && python sys\meson.py --backend vs2017 --release --xp --install --prefix="%DIST_FOLDER%" --webui --options static_runtime=true && 7z a %ARTIFACT_ZIP% %DIST_FOLDER% )
@@ -106,7 +106,7 @@ for:
after_test:
- git clone --depth 1 https://github.com/radare/rizin-win-installer
- set PATH=%PATH%;%INNO_SETUP%
- iscc rizin-win-installer/rizin.iss /DRadare2Location=..\%DIST_FOLDER%\* /DLicenseLocation=..\COPYING.LESSER /DIcoLocation=rizin.ico /DMyAppVersion=%R2_VERSION%
- iscc rizin-win-installer/rizin.iss /DRadare2Location=..\%DIST_FOLDER%\* /DLicenseLocation=..\COPYING.LESSER /DIcoLocation=rizin.ico /DMyAppVersion=%RZ_VERSION%
- move rizin-win-installer\Output\rizin.exe rizin_installer-%builder%.exe
# Artifacts
+3 -3
View File
@@ -86,7 +86,7 @@ jobs:
# os: ubuntu-20.04
# build_system: meson
# compiler: gcc
# cflags: '-DR2_ASSERT_STDOUT=1'
# cflags: '-DRZ_ASSERT_STDOUT=1'
# meson_options: -Db_sanitize=address,undefined -Duse_webui=true
# asan: true
# asan_options: 'detect_leaks=0,detect_odr_violation=0,allocator_may_return_null=1'
@@ -193,7 +193,7 @@ jobs:
export LD_LIBRARY_PATH=${HOME}/lib/$(uname -m)-linux-gnu:${HOME}/lib:${HOME}/lib64:${LD_LIBRARY_PATH}
export PKG_CONFIG_PATH=${HOME}/lib/pkgconfig:${HOME}/lib/$(uname -m)-linux-gnu/pkgconfig:${PKG_CONFIG_PATH}
if [ "$NEWSHELL" == "true" ]; then
export R2_CFG_NEWSHELL=1
export RZ_CFG_NEWSHELL=1
fi
if [ "$ASAN" == "true" ]; then
export ASAN=1
@@ -215,7 +215,7 @@ jobs:
export LD_LIBRARY_PATH=${HOME}/lib/$(uname -m)-linux-gnu:${HOME}/lib:${HOME}/lib64:${LD_LIBRARY_PATH}
export PKG_CONFIG_PATH=${HOME}/lib/pkgconfig:${HOME}/lib/$(uname -m)-linux-gnu/pkgconfig:${PKG_CONFIG_PATH}
if [ "$NEWSHELL" == "true" ]; then
export R2_CFG_NEWSHELL=1
export RZ_CFG_NEWSHELL=1
fi
cd test
make fuzz-tests
+13 -13
View File
@@ -31,46 +31,46 @@ jobs:
name: PPC64
arch: ppc64le
dist: bionic
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DR2_ASSERT_STDOUT=1"
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DRZ_ASSERT_STDOUT=1"
# Linux with GCC on System Z
- if: (branch = dev AND type = push) OR head_branch =~ ^s390x-*
os: linux
name: S390X
arch: s390x
dist: bionic
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DR2_ASSERT_STDOUT=1"
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DRZ_ASSERT_STDOUT=1"
# Linux with GCC on ARMv8 (64bit)
- if: (branch = dev AND type = push) OR head_branch =~ ^arm64-*
os: linux
name: ARM64
arch: arm64
dist: bionic
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DR2_ASSERT_STDOUT=1"
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DRZ_ASSERT_STDOUT=1"
# Run Fuzzing Sanity Test on every push
# XXX its broken it complains about invalid key
#- os: linux
# env: COMPILER_NAME=clang CXX=clang++ CC=clang R2_TESTS_DISABLE=1 FUZZIT=0 INSTALL_SYSTEM=static CXXFLAGS="-fsanitize=fuzzer"
# env: COMPILER_NAME=clang CXX=clang++ CC=clang RZ_TESTS_DISABLE=1 FUZZIT=0 INSTALL_SYSTEM=static CXXFLAGS="-fsanitize=fuzzer"
# TODO: move this as new GitHub workflows
# release-only: meson build with system libraries
- if: head_branch =~ ^release-* OR head_branch =~ ^prerelease-* OR branch =~ ^release-* OR branch =~ ^prerelease-*
os: linux
env: COMPILER_NAME=gcc CXX=g++ CC=gcc INSTALL_SYSTEM=meson R2_SYS_MAGIC=true R2_SYS_ZIP=true R2_SYS_LZ4=true R2_SYS_ZLIB=true R2_SYS_OPENSSL=true
env: COMPILER_NAME=gcc CXX=g++ CC=gcc INSTALL_SYSTEM=meson RZ_SYS_MAGIC=true RZ_SYS_ZIP=true RZ_SYS_LZ4=true RZ_SYS_ZLIB=true RZ_SYS_OPENSSL=true
# release-only: nogpl plugins file, just test if it builds
- if: head_branch =~ ^release-* OR head_branch =~ ^prerelease-* OR branch =~ ^release-* OR branch =~ ^prerelease-*
os: linux
env: COMPILER_NAME=gcc CXX=g++ CC=gcc R2_PLUGINS_FILE=nogpl R2_TESTS_DISABLE=1
env: COMPILER_NAME=gcc CXX=g++ CC=gcc RZ_PLUGINS_FILE=nogpl RZ_TESTS_DISABLE=1
# release-only: static plugins file, just test if it builds
- if: head_branch =~ ^release-* OR head_branch =~ ^prerelease-* OR branch =~ ^release-* OR branch =~ ^prerelease-*
os: linux
env: COMPILER_NAME=gcc CXX=g++ CC=gcc R2_PLUGINS_FILE=static R2_TESTS_DISABLE=1
env: COMPILER_NAME=gcc CXX=g++ CC=gcc RZ_PLUGINS_FILE=static RZ_TESTS_DISABLE=1
# release-only: tiny plugins file, just test if it builds
- if: head_branch =~ ^release-* OR head_branch =~ ^prerelease-* OR branch =~ ^release-* OR branch =~ ^prerelease-*
os: linux
env: COMPILER_NAME=gcc CXX=g++ CC=gcc R2_PLUGINS_FILE=tiny R2_TESTS_DISABLE=1
env: COMPILER_NAME=gcc CXX=g++ CC=gcc RZ_PLUGINS_FILE=tiny RZ_TESTS_DISABLE=1
# release-only: system capstone (capstone3), just test if it builds
- if: head_branch =~ ^release-* OR head_branch =~ ^prerelease-* OR branch =~ ^release-* OR branch =~ ^prerelease-*
os: linux
env: COMPILER_NAME=gcc CXX=g++ CC=gcc INSTALL_SYSTEM=meson R2_SYS_CAPSTONE=true R2_TESTS_DISABLE=1
env: COMPILER_NAME=gcc CXX=g++ CC=gcc INSTALL_SYSTEM=meson RZ_SYS_CAPSTONE=true RZ_TESTS_DISABLE=1
allow_failures:
# Emscripten
@@ -80,17 +80,17 @@ jobs:
# Linux with GCC on PowerPC
- os: linux
arch: ppc64le
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DR2_ASSERT_STDOUT=1"
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DRZ_ASSERT_STDOUT=1"
# Linux with GCC on System Z
- os: linux
arch: s390x
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DR2_ASSERT_STDOUT=1"
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DRZ_ASSERT_STDOUT=1"
# Linux with GCC on ARMv8 (64bit)
- os: linux
arch: arm64
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DR2_ASSERT_STDOUT=1"
env: NODOCKER=1 COMPILER_NAME=gcc CXX=g++ CC=gcc CFLAGS="-DRZ_ASSERT_STDOUT=1"
- os: linux
env: COMPILER_NAME=clang CXX=clang++ CC=clang ASAN=1 ASAN_OPTIONS=detect_odr_violation=0 LSAN_OPTIONS=detect_leaks=0 CFLAGS="-DR2_ASSERT_STDOUT=1"
env: COMPILER_NAME=clang CXX=clang++ CC=clang ASAN=1 ASAN_OPTIONS=detect_odr_violation=0 LSAN_OPTIONS=detect_leaks=0 CFLAGS="-DRZ_ASSERT_STDOUT=1"
cache:
- ccache
+8 -8
View File
@@ -146,7 +146,7 @@ a = (b << 3) * 5;
+ return (!rwx || (rwx && b->rwx));
+}
+
R_API RBreakpointItem *r_bp_get_in(RBreakpoint *bp, ut64 addr, int rwx) {
RZ_API RBreakpointItem *r_bp_get_in(RBreakpoint *bp, ut64 addr, int rwx) {
RBreakpointItem *b;
RListIter *iter;
r_list_foreach (bp->bps, iter, b) {
@@ -169,8 +169,8 @@ The structure of the C files in r2 must be like this:
#include <r_core.h> ## includes
static int globals ## const, define, global variables
static void helper(void) {} ## static functions
R_IPI void internal(void) {} ## internal apis (used only inside the library)
R_API void public(void) {} ## public apis starting with constructor/destructor
RZ_IPI void internal(void) {} ## internal apis (used only inside the library)
RZ_API void public(void) {} ## public apis starting with constructor/destructor
```
@@ -193,7 +193,7 @@ r_core_wrap.cxx:32103:61: error: assigning to 'RDebugReasonType' from incompatib
* Do not use assert.h, use r_util/r_assert.h instead.
* You can use `export R2_DEBUG_ASSERT=1` to set a breakpoint when hitting an assert.
* You can use `export RZ_DEBUG_ASSERT=1` to set a breakpoint when hitting an assert.
* Do not use C99 variable declaration
- This way we reduce the number of local variables per function
@@ -206,7 +206,7 @@ r_core_wrap.cxx:32103:61: error: assigning to 'RDebugReasonType' from incompatib
* Function names should be explicit enough to not require a comment
explaining what it does when seen elsewhere in code.
* Use 'R_API' define to mark exportable (public) methods only for module APIs
* Use 'RZ_API' define to mark exportable (public) methods only for module APIs
* The rest of functions must be static, to avoid polluting the global space.
@@ -334,18 +334,18 @@ into `.dir-locals.el`.
## Packed structures
Due to the various differences between platforms and compilers rizin
has a special helper macro - `R_PACKED()`. Instead of non-portable
has a special helper macro - `RZ_PACKED()`. Instead of non-portable
`#pragma pack` or `__attribute__((packed))` it is advised to use this macro
instead. To wrap the code inside of it you just need to write:
```c
R_PACKED (union mystruct {
RZ_PACKED (union mystruct {
int a;
char b;
})
```
or in case of typedef:
```c
R_PACKED (typedef structmystruct {
RZ_PACKED (typedef structmystruct {
int a;
char b;
})
+8 -8
View File
@@ -35,16 +35,16 @@ FROM debian:10
LABEL r2docker latest
# Radare version
ARG R2_VERSION=master
ARG RZ_VERSION=master
# R2pipe python version
ARG R2_PIPE_PY_VERSION=1.4.2
ARG RZ_PIPE_PY_VERSION=1.4.2
ENV R2_VERSION ${R2_VERSION}
ENV R2_PIPE_PY_VERSION ${R2_PIPE_PY_VERSION}
ENV RZ_VERSION ${RZ_VERSION}
ENV RZ_PIPE_PY_VERSION ${RZ_PIPE_PY_VERSION}
RUN echo -e "Building versions:\n\
R2_VERSION=$R2_VERSION\n\
R2_PIPE_PY_VERSION=${R2_PIPE_PY_VERSION}"
RZ_VERSION=$RZ_VERSION\n\
RZ_PIPE_PY_VERSION=${RZ_PIPE_PY_VERSION}"
# Build rizin in a volume to minimize space used by build
VOLUME ["/mnt"]
@@ -70,9 +70,9 @@ RUN DEBIAN_FRONTEND=noninteractive dpkg --add-architecture i386 && \
libstdc++6:i386 \
gnupg2 \
python-pip && \
pip install rzpipe=="$R2_PIPE_PY_VERSION" && \
pip install rzpipe=="$RZ_PIPE_PY_VERSION" && \
cd /mnt && \
git clone -b "$R2_VERSION" -q --depth 1 https://github.com/rizinorg/rizin.git && \
git clone -b "$RZ_VERSION" -q --depth 1 https://github.com/rizinorg/rizin.git && \
cd rizin && \
./configure && \
make && \
+14 -14
View File
@@ -7,7 +7,7 @@ B=$(DESTDIR)$(BINDIR)
L=$(DESTDIR)$(LIBDIR)
MESON?=meson
PYTHON?=python
R2R=test
RZ_TEST=test
R2BINS=$(shell cd binrz ; echo r*2 rz_agent rz-pm r2-indent rz_test)
ifdef SOURCE_DATE_EPOCH
BUILDSEC=$(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+__%H:%M:%S" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+__%H:%M:%S" 2>/dev/null || date -u "+__%H:%M:%S")
@@ -64,7 +64,7 @@ all: plugins.cfg librz/include/rz_version.h
#.PHONY: librz/include/rz_version.h
GIT_TAP=$(shell git describe --tags --match "[0-9]*" 2>/dev/null || echo $(VERSION))
GIT_TIP=$(shell git rev-parse HEAD 2>/dev/null || echo HEAD)
R2_VER=$(shell grep VERSION configure.acr | head -n1 | awk '{print $$2}')
RZ_VER=$(shell grep VERSION configure.acr | head -n1 | awk '{print $$2}')
ifdef SOURCE_DATE_EPOCH
GIT_NOW=$(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+%Y-%m-%d" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+%Y-%m-%d" 2>/dev/null || date -u "+%Y-%m-%d")
else
@@ -73,17 +73,17 @@ endif
librz/include/rz_version.h:
@echo Generating rz_version.h file
@echo $(Q)#ifndef R_VERSION_H$(Q) > [email protected]
@echo $(Q)#define R_VERSION_H 1$(Q) >> [email protected]
@echo $(Q)#define R2_VERSION_COMMIT $(R2VC)$(Q) >> [email protected]
@echo $(Q)#define R2_VERSION $(ESC)"$(R2_VERSION)$(ESC)"$(Q) >> [email protected]
@echo $(Q)#define R2_VERSION_MAJOR $(R2_VERSION_MAJOR)$(Q) >> [email protected]
@echo $(Q)#define R2_VERSION_MINOR $(R2_VERSION_MINOR)$(Q) >> [email protected]
@echo $(Q)#define R2_VERSION_PATCH $(R2_VERSION_PATCH)$(Q) >> [email protected]
@echo $(Q)#define R2_VERSION_NUMBER $(R2_VERSION_NUMBER)$(Q) >> [email protected]
@echo $(Q)#define R2_GITTAP $(ESC)"$(GIT_TAP)$(ESC)"$(Q) >> [email protected]
@echo $(Q)#define R2_GITTIP $(ESC)"$(GIT_TIP)$(ESC)"$(Q) >> [email protected]
@echo $(Q)#define R2_BIRTH $(ESC)"$(GIT_NOW)$(BUILDSEC)$(ESC)"$(Q) >> [email protected]
@echo $(Q)#ifndef RZ_VERSION_H$(Q) > [email protected]
@echo $(Q)#define RZ_VERSION_H 1$(Q) >> [email protected]
@echo $(Q)#define RZ_VERSION_COMMIT $(R2VC)$(Q) >> [email protected]
@echo $(Q)#define RZ_VERSION $(ESC)"$(RZ_VERSION)$(ESC)"$(Q) >> [email protected]
@echo $(Q)#define RZ_VERSION_MAJOR $(RZ_VERSION_MAJOR)$(Q) >> [email protected]
@echo $(Q)#define RZ_VERSION_MINOR $(RZ_VERSION_MINOR)$(Q) >> [email protected]
@echo $(Q)#define RZ_VERSION_PATCH $(RZ_VERSION_PATCH)$(Q) >> [email protected]
@echo $(Q)#define RZ_VERSION_NUMBER $(RZ_VERSION_NUMBER)$(Q) >> [email protected]
@echo $(Q)#define RZ_GITTAP $(ESC)"$(GIT_TAP)$(ESC)"$(Q) >> [email protected]
@echo $(Q)#define RZ_GITTIP $(ESC)"$(GIT_TIP)$(ESC)"$(Q) >> [email protected]
@echo $(Q)#define RZ_BIRTH $(ESC)"$(GIT_NOW)$(BUILDSEC)$(ESC)"$(Q) >> [email protected]
@echo $(Q)#endif$(Q) >> [email protected]
@mv -f $@.tmp $@
@rm -f $@.tmp
@@ -387,7 +387,7 @@ shot:
radare.org:/srv/http/rizinorg/get/shot
tests:
$(MAKE) -C $(R2R)
$(MAKE) -C $(RZ_TEST)
macos-sign:
$(MAKE) -C binrz/rizin macos-sign
+1 -1
View File
@@ -8,7 +8,7 @@ BTOP=$(shell pwd)
BINS=rz-ax rz-asm rz-bin rz-hash rz-diff rizin rz-find rz-run rz-gg rz-agent rz-sign
ifeq ($(WANT_R2R),1)
ifeq ($(WANT_RZ_TEST),1)
BINS+=rz-test
endif
+8 -8
View File
@@ -1,5 +1,5 @@
#define RZ_API
#define R_ALLOC_USE_MMAP 1
#define RZ_ALLOC_USE_MMAP 1
#define USE_MALLOC 0
#include <stdio.h>
@@ -103,21 +103,21 @@ void rz_free(void *p) {
#if __MAIN__
int main() {
#define MB 1024*1024
#define R_MALLOC_MAX 2*MB
#define RZ_MALLOC_MAX 2*MB
#if R_ALLOC_USE_STACK
char B[R_MALLOC_MAX];
#if RZ_ALLOC_USE_STACK
char B[RZ_MALLOC_MAX];
#endif
#if R_ALLOC_USE_MMAP
#if RZ_ALLOC_USE_MMAP
int fd = open (".mem", O_CREAT|O_RDWR, 0600);
ftruncate (fd, R_MALLOC_MAX);
char *B = mmap (NULL, R_MALLOC_MAX, PROT_WRITE|PROT_READ,
ftruncate (fd, RZ_MALLOC_MAX);
char *B = mmap (NULL, RZ_MALLOC_MAX, PROT_WRITE|PROT_READ,
MAP_FILE|MAP_PRIVATE, fd, 0);
unlink (".mem");
close (fd);
#endif
InitMem (B, R_MALLOC_MAX);
InitMem (B, RZ_MALLOC_MAX);
char *a = rz_malloc (10);
if (!a) {
+4 -4
View File
@@ -16,7 +16,7 @@ static RzCoreFile *openself(void) {
char *out = rz_core_cmd_str (core, "o");
if (out) {
if (!strstr (out, "self://")) {
fd = rz_core_file_open (core, "self://", R_PERM_RW, 0);
fd = rz_core_file_open (core, "self://", RZ_PERM_RW, 0);
}
free (out);
}
@@ -44,7 +44,7 @@ static void _libwrap_init(void) {
fflush (stdout);
web = rz_sys_getenv ("RZ_RUN_WEB");
core = rz_core_new ();
rz_core_loadlibs (core, R_CORE_LOADLIBS_ALL, NULL);
rz_core_loadlibs (core, RZ_CORE_LOADLIBS_ALL, NULL);
if (web) {
rz_core_cmd0 (core, "=H&");
rz_sys_setenv ("RZ_RUN_WEB", NULL);
@@ -73,8 +73,8 @@ void alloc_console(void) {
static void start_rz(void) {
core = rz_core_new ();
rz_core_loadlibs (core, R_CORE_LOADLIBS_ALL, NULL);
RzCoreFile *fd = rz_core_file_open (core, "self://", R_PERM_RW, 0);
rz_core_loadlibs (core, RZ_CORE_LOADLIBS_ALL, NULL);
RzCoreFile *fd = rz_core_file_open (core, "self://", RZ_PERM_RW, 0);
rz_core_prompt_loop (core);
rz_core_file_close (core, fd);
}
+14 -14
View File
@@ -21,9 +21,9 @@ export GLOBAL=0
export RZPM_JOBS=4
export RZPMCACHE="$HOME/.rz-pm.cache"
# Set R2_* Vars
# Set RZ_* Vars
eval $(r2 -H)
export R2_VERSION
export RZ_VERSION
RZPM=$0
RZPMCACHE_LOADED=0
@@ -41,11 +41,11 @@ if [ -f ~/.rz-pm.cache ]; then
fi
fi
if [ "${RZPMCACHE_LOADED}" != 1 ]; then
export LIBEXT="$R2_LIBEXT"
LIBDIR="$R2_LIBDIR"
export R2CONFIGHOME="$R2_RCONFIGHOME"
export R2DATAHOME="$R2_RDATAHOME"
PREFIX="$R2_PREFIX"
export LIBEXT="$RZ_LIBEXT"
LIBDIR="$RZ_LIBDIR"
export R2CONFIGHOME="$RZ_RCONFIGHOME"
export R2DATAHOME="$RZ_RDATAHOME"
PREFIX="$RZ_PREFIX"
fi
BINDIR="${PREFIX}/bin/"
WRKDIR="$PWD"
@@ -66,8 +66,8 @@ export RZPM_BINDIR
export RZPM_SYSLIBDIR="${LIBDIR}"
# plugdir
export RZPM_SYSPLUGIN_DIR="$R2_LIBR_PLUGINS"
export RZPM_USRPLUGIN_DIR="$R2_USER_PLUGINS"
export RZPM_SYSPLUGIN_DIR="$RZ_LIBR_PLUGINS"
export RZPM_USRPLUGIN_DIR="$RZ_USER_PLUGINS"
[ -z "${RZPM_PLUGDIR}" ] && RZPM_PLUGDIR="${RZPM_USRPLUGIN_DIR}"
[ -z "${RZPM_PLUGDIR}" ] && RZPM_PLUGDIR="${R2DATAHOME}/plugins"
@@ -84,7 +84,7 @@ export LDFLAGS="-L${RZPM_HOMEPREFIX}/lib"
export RZPM_PYPATH="${RZPM_PREFIX}/python"
export RZPM_OLDPWD="${PWD}"
export RHOMEDIR="$R2_RCONFIGHOME"
export RHOMEDIR="$RZ_RCONFIGHOME"
if [ "`uname`" = Darwin ]; then
export LD_LIBRARY_PATH="${RZPM_HOMEPREFIX}/lib"
@@ -337,7 +337,7 @@ RZPM_GIT() {
cd "${DIR}" || RZPM_FAIL "Oops"
fi
r2 -qv | grep -q git || { # r2 >= 4.5
git checkout "r2-${R2_VERSION}"
git checkout "r2-${RZ_VERSION}"
git pull
}
}
@@ -532,12 +532,12 @@ case "$1" in
PATH="${RZPM_BINDIR}:${PATH}" "$@"
;;
-v|version)
echo "rz-pm ${R2_VERSION}"
echo "rz-pm ${RZ_VERSION}"
;;
-gi|global-install)
GLOBAL=1
RZPM_PREFIX="${RZPM_SYSPREFIX}"
#RZPM_PLUGDIR="${RZPM_SYSLIBDIR}/rizin/${R2_VERSION}/"
#RZPM_PLUGDIR="${RZPM_SYSLIBDIR}/rizin/${RZ_VERSION}/"
RZPM_PLUGDIR="${RZPM_SYSPLUGIN_DIR}"
RZPM_BINDIR="${RZPM_SYSBINDIR}"
RZPM_WWWROOT="${RZPM_SYSWWWROOT}"
@@ -550,7 +550,7 @@ case "$1" in
-gu|global-uninstall)
GLOBAL=1
RZPM_PREFIX="${RZPM_SYSPREFIX}"
#RZPM_PLUGDIR="${RZPM_SYSLIBDIR}/rizin/${R2_VERSION}/"
#RZPM_PLUGDIR="${RZPM_SYSLIBDIR}/rizin/${RZ_VERSION}/"
RZPM_PLUGDIR="${RZPM_SYSPLUGIN_DIR}"
RZPM_BINDIR="${RZPM_SYSBINDIR}"
RZPM_WWWROOT="${RZPM_SYSWWWROOT}"
+58 -58
View File
@@ -6,16 +6,16 @@
#define LINEFMT "%s, line %"PFMT64u": "
RZ_API R2RzCmdTest *rz_test_cmd_test_new(void) {
return R_NEW0 (R2RzCmdTest);
RZ_API RzCmdTest *rz_test_cmd_test_new(void) {
return RZ_NEW0 (RzCmdTest);
}
RZ_API void rz_test_cmd_test_free(R2RzCmdTest *test) {
RZ_API void rz_test_cmd_test_free(RzCmdTest *test) {
if (!test) {
return;
}
#define DO_KEY_STR(key, field) free (test->field.value);
R2R_CMD_TEST_FOREACH_RECORD(DO_KEY_STR, R2R_CMD_TEST_FOREACH_RECORD_NOP, R2R_CMD_TEST_FOREACH_RECORD_NOP)
RZ_CMD_TEST_FOREACH_RECORD(DO_KEY_STR, RZ_CMD_TEST_FOREACH_RECORD_NOP, RZ_CMD_TEST_FOREACH_RECORD_NOP)
#undef DO_KEY_STR
free (test);
}
@@ -113,7 +113,7 @@ RZ_API RPVector *rz_test_load_cmd_test_file(const char *file) {
free (contents);
return NULL;
}
R2RzCmdTest *test = rz_test_cmd_test_new ();
RzCmdTest *test = rz_test_cmd_test_new ();
if (!test) {
free (contents);
rz_pvector_free (ret);
@@ -231,7 +231,7 @@ RZ_API RPVector *rz_test_load_cmd_test_file(const char *file) {
continue; \
}
R2R_CMD_TEST_FOREACH_RECORD(DO_KEY_STR, DO_KEY_BOOL, DO_KEY_NUM)
RZ_CMD_TEST_FOREACH_RECORD(DO_KEY_STR, DO_KEY_BOOL, DO_KEY_NUM)
#undef DO_KEY_STR
#undef DO_KEY_BOOL
#undef DO_KEY_NUM
@@ -254,11 +254,11 @@ fail:
goto beach;
}
RZ_API R2RzAsmTest *rz_test_asm_test_new(void) {
return R_NEW0 (R2RzAsmTest);
RZ_API RzAsmTest *rz_test_asm_test_new(void) {
return RZ_NEW0 (RzAsmTest);
}
RZ_API void rz_test_asm_test_free(R2RzAsmTest *test) {
RZ_API void rz_test_asm_test_free(RzAsmTest *test) {
if (!test) {
return;
}
@@ -268,7 +268,7 @@ RZ_API void rz_test_asm_test_free(R2RzAsmTest *test) {
}
static bool parse_asm_path(const char *path, RStrConstPool *strpool, const char **arch_out, const char **cpuout, int *bitsout) {
RzList *file_tokens = rz_str_split_duplist (path, R_SYS_DIR, true);
RzList *file_tokens = rz_str_split_duplist (path, RZ_SYS_DIR, true);
if (!file_tokens || rz_list_empty (file_tokens)) {
rz_list_free (file_tokens);
return false;
@@ -345,16 +345,16 @@ RZ_API RPVector *rz_test_load_asm_test_file(RStrConstPool *strpool, const char *
while (*line && *line != ' ') {
switch (*line) {
case 'a':
mode |= R2R_ASM_TEST_MODE_ASSEMBLE;
mode |= RZ_ASM_TEST_MODE_ASSEMBLE;
break;
case 'd':
mode |= R2R_ASM_TEST_MODE_DISASSEMBLE;
mode |= RZ_ASM_TEST_MODE_DISASSEMBLE;
break;
case 'E':
mode |= R2R_ASM_TEST_MODE_BIG_ENDIAN;
mode |= RZ_ASM_TEST_MODE_BIG_ENDIAN;
break;
case 'B':
mode |= R2R_ASM_TEST_MODE_BROKEN;
mode |= RZ_ASM_TEST_MODE_BROKEN;
break;
default:
eprintf (LINEFMT "Warning: Invalid mode char '%c'\n", file, linenum, *line);
@@ -362,7 +362,7 @@ RZ_API RPVector *rz_test_load_asm_test_file(RStrConstPool *strpool, const char *
}
line++;
}
if (!(mode & R2R_ASM_TEST_MODE_ASSEMBLE) && !(mode & R2R_ASM_TEST_MODE_DISASSEMBLE)) {
if (!(mode & RZ_ASM_TEST_MODE_ASSEMBLE) && !(mode & RZ_ASM_TEST_MODE_DISASSEMBLE)) {
eprintf (LINEFMT "Warning: Mode specifies neither assemble nor disassemble.\n", file, linenum);
continue;
}
@@ -411,7 +411,7 @@ RZ_API RPVector *rz_test_load_asm_test_file(RStrConstPool *strpool, const char *
goto fail;
}
R2RzAsmTest *test = rz_test_asm_test_new ();
RzAsmTest *test = rz_test_asm_test_new ();
if (!test) {
free (bytes);
goto fail;
@@ -437,11 +437,11 @@ fail:
goto beach;
}
RZ_API R2RJsonTest *rz_test_json_test_new(void) {
return R_NEW0 (R2RJsonTest);
RZ_API RzJsonTest *rz_test_json_test_new(void) {
return RZ_NEW0 (RzJsonTest);
}
RZ_API void rz_test_json_test_free(R2RJsonTest *test) {
RZ_API void rz_test_json_test_free(RzJsonTest *test) {
if (!test) {
return;
}
@@ -487,7 +487,7 @@ RZ_API RPVector *rz_test_load_json_test_file(const char *file) {
continue;
}
R2RJsonTest *test = rz_test_json_test_new ();
RzJsonTest *test = rz_test_json_test_new ();
if (!test) {
break;
}
@@ -505,7 +505,7 @@ RZ_API RPVector *rz_test_load_json_test_file(const char *file) {
return ret;
}
RZ_API void rz_test_fuzz_test_free(R2RFuzzTest *test) {
RZ_API void rz_test_fuzz_test_free(RzFuzzTest *test) {
if (!test) {
return;
}
@@ -513,29 +513,29 @@ RZ_API void rz_test_fuzz_test_free(R2RFuzzTest *test) {
free (test);
}
RZ_API void rz_test_test_free(R2RTest *test) {
RZ_API void rz_test_test_free(RzTest *test) {
if (!test) {
return;
}
switch (test->type) {
case R2R_TEST_TYPE_CMD:
case RZ_TEST_TYPE_CMD:
rz_test_cmd_test_free (test->cmd_test);
break;
case R2R_TEST_TYPE_ASM:
case RZ_TEST_TYPE_ASM:
rz_test_asm_test_free (test->asm_test);
break;
case R2R_TEST_TYPE_JSON:
case RZ_TEST_TYPE_JSON:
rz_test_json_test_free (test->json_test);
break;
case R2R_TEST_TYPE_FUZZ:
case RZ_TEST_TYPE_FUZZ:
rz_test_fuzz_test_free (test->fuzz_test);
break;
}
free (test);
}
RZ_API R2RTestDatabase *rz_test_test_database_new(void) {
R2RTestDatabase *db = R_NEW (R2RTestDatabase);
RZ_API RzTestDatabase *rz_test_test_database_new(void) {
RzTestDatabase *db = RZ_NEW (RzTestDatabase);
if (!db) {
return NULL;
}
@@ -544,7 +544,7 @@ RZ_API R2RTestDatabase *rz_test_test_database_new(void) {
return db;
}
RZ_API void rz_test_test_database_free(R2RTestDatabase *db) {
RZ_API void rz_test_test_database_free(RzTestDatabase *db) {
if (!db) {
return;
}
@@ -553,10 +553,10 @@ RZ_API void rz_test_test_database_free(R2RTestDatabase *db) {
free (db);
}
static R2RTestType test_type_for_path(const char *path, bool *load_plugins) {
R2RTestType ret = R2R_TEST_TYPE_CMD;
static RzTestType test_type_for_path(const char *path, bool *load_plugins) {
RzTestType ret = RZ_TEST_TYPE_CMD;
char *pathdup = strdup (path);
RzList *tokens = rz_str_split_list (pathdup, R_SYS_DIR, 0);
RzList *tokens = rz_str_split_list (pathdup, RZ_SYS_DIR, 0);
if (!tokens) {
return ret;
}
@@ -568,11 +568,11 @@ static R2RTestType test_type_for_path(const char *path, bool *load_plugins) {
*load_plugins = false;
rz_list_foreach (tokens, it, token) {
if (!strcmp (token, "asm")) {
ret = R2R_TEST_TYPE_ASM;
ret = RZ_TEST_TYPE_ASM;
continue;
}
if (!strcmp (token, "json")) {
ret = R2R_TEST_TYPE_JSON;
ret = RZ_TEST_TYPE_JSON;
continue;
}
if (!strcmp (token, "extras")) {
@@ -584,7 +584,7 @@ static R2RTestType test_type_for_path(const char *path, bool *load_plugins) {
return ret;
}
static bool database_load(R2RTestDatabase *db, const char *path, int depth) {
static bool database_load(RzTestDatabase *db, const char *path, int depth) {
if (depth <= 0) {
eprintf ("Directories for loading tests too deep: %s\n", path);
return false;
@@ -605,15 +605,15 @@ static bool database_load(R2RTestDatabase *db, const char *path, int depth) {
}
if (!strcmp (subname, "extras")) {
// Only load "extras" dirs if explicitly specified
eprintf ("Skipping %s"R_SYS_DIR"%s because it requires additional dependencies.\n", path, subname);
eprintf ("Skipping %s"RZ_SYS_DIR"%s because it requires additional dependencies.\n", path, subname);
continue;
}
if ((!strcmp (path, "archos") || rz_str_endswith (path, R_SYS_DIR"archos"))
&& strcmp (subname, R2R_ARCH_OS)) {
eprintf ("Skipping %s"R_SYS_DIR"%s because it does not match the current platform.\n", path, subname);
if ((!strcmp (path, "archos") || rz_str_endswith (path, RZ_SYS_DIR"archos"))
&& strcmp (subname, RZ_TEST_ARCH_OS)) {
eprintf ("Skipping %s"RZ_SYS_DIR"%s because it does not match the current platform.\n", path, subname);
continue;
}
rz_strbuf_setf (&subpath, "%s%s%s", path, R_SYS_DIR, subname);
rz_strbuf_setf (&subpath, "%s%s%s", path, RZ_SYS_DIR, subname);
if (!database_load (db, rz_strbuf_get (&subpath), depth - 1)) {
ret = false;
break;
@@ -632,20 +632,20 @@ static bool database_load(R2RTestDatabase *db, const char *path, int depth) {
// Not a directory but exists, load a file
const char *pooled_path = rz_str_constpool_get (&db->strpool, path);
bool load_plugins = false;
R2RTestType test_type = test_type_for_path (path, &load_plugins);
RzTestType test_type = test_type_for_path (path, &load_plugins);
switch (test_type) {
case R2R_TEST_TYPE_CMD: {
case RZ_TEST_TYPE_CMD: {
RPVector *cmd_tests = rz_test_load_cmd_test_file (path);
if (!cmd_tests) {
return false;
}
void **it;
rz_pvector_foreach (cmd_tests, it) {
R2RTest *test = R_NEW (R2RTest);
RzTest *test = RZ_NEW (RzTest);
if (!test) {
continue;
}
test->type = R2R_TEST_TYPE_CMD;
test->type = RZ_TEST_TYPE_CMD;
test->path = pooled_path;
test->cmd_test = *it;
test->cmd_test->load_plugins = load_plugins;
@@ -654,18 +654,18 @@ static bool database_load(R2RTestDatabase *db, const char *path, int depth) {
rz_pvector_free (cmd_tests);
break;
}
case R2R_TEST_TYPE_ASM: {
case RZ_TEST_TYPE_ASM: {
RPVector *asm_tests = rz_test_load_asm_test_file (&db->strpool, path);
if (!asm_tests) {
return false;
}
void **it;
rz_pvector_foreach (asm_tests, it) {
R2RTest *test = R_NEW (R2RTest);
RzTest *test = RZ_NEW (RzTest);
if (!test) {
continue;
}
test->type = R2R_TEST_TYPE_ASM;
test->type = RZ_TEST_TYPE_ASM;
test->path = pooled_path;
test->asm_test = *it;
rz_pvector_push (&db->tests, test);
@@ -673,18 +673,18 @@ static bool database_load(R2RTestDatabase *db, const char *path, int depth) {
rz_pvector_free (asm_tests);
break;
}
case R2R_TEST_TYPE_JSON: {
case RZ_TEST_TYPE_JSON: {
RPVector *json_tests = rz_test_load_json_test_file (path);
if (!json_tests) {
return false;
}
void **it;
rz_pvector_foreach (json_tests, it) {
R2RTest *test = R_NEW (R2RTest);
RzTest *test = RZ_NEW (RzTest);
if (!test) {
continue;
}
test->type = R2R_TEST_TYPE_JSON;
test->type = RZ_TEST_TYPE_JSON;
test->path = pooled_path;
test->json_test = *it;
test->json_test->load_plugins = load_plugins;
@@ -693,7 +693,7 @@ static bool database_load(R2RTestDatabase *db, const char *path, int depth) {
rz_pvector_free (json_tests);
break;
}
case R2R_TEST_TYPE_FUZZ:
case RZ_TEST_TYPE_FUZZ:
// shouldn't come here, fuzz tests are loaded differently
break;
}
@@ -701,12 +701,12 @@ static bool database_load(R2RTestDatabase *db, const char *path, int depth) {
return true;
}
RZ_API bool rz_test_test_database_load(R2RTestDatabase *db, const char *path) {
RZ_API bool rz_test_test_database_load(RzTestDatabase *db, const char *path) {
return database_load (db, path, 4);
}
static void database_load_fuzz_file(R2RTestDatabase *db, const char *path, const char *file) {
R2RFuzzTest *fuzz_test = R_NEW (R2RFuzzTest);
static void database_load_fuzz_file(RzTestDatabase *db, const char *path, const char *file) {
RzFuzzTest *fuzz_test = RZ_NEW (RzFuzzTest);
if (!fuzz_test) {
return;
}
@@ -715,19 +715,19 @@ static void database_load_fuzz_file(R2RTestDatabase *db, const char *path, const
free (fuzz_test);
return;
}
R2RTest *test = R_NEW (R2RTest);
RzTest *test = RZ_NEW (RzTest);
if (!test) {
free (fuzz_test->file);
free (fuzz_test);
return;
}
test->type = R2R_TEST_TYPE_FUZZ;
test->type = RZ_TEST_TYPE_FUZZ;
test->fuzz_test = fuzz_test;
test->path = rz_str_constpool_get (&db->strpool, path);
rz_pvector_push (&db->tests, test);
}
RZ_API bool rz_test_test_database_load_fuzz(R2RTestDatabase *db, const char *path) {
RZ_API bool rz_test_test_database_load_fuzz(RzTestDatabase *db, const char *path) {
if (rz_file_is_directory (path)) {
RzList *dir = rz_sys_dir (path);
if (!dir) {
@@ -742,7 +742,7 @@ RZ_API bool rz_test_test_database_load_fuzz(R2RTestDatabase *db, const char *pat
if (*subname == '.') {
continue;
}
rz_strbuf_setf (&subpath, "%s%s%s", path, R_SYS_DIR, subname);
rz_strbuf_setf (&subpath, "%s%s%s", path, RZ_SYS_DIR, subname);
if (rz_file_is_directory (rz_strbuf_get (&subpath))) {
// only load 1 level deep
continue;
+90 -90
View File
@@ -125,10 +125,10 @@ error:
return ret;
}
RZ_API R2RSubprocess *rz_test_subprocess_start(
RZ_API RzTestSubprocess *rz_test_subprocess_start(
const char *file, const char *args[], size_t args_size,
const char *envvars[], const char *envvals[], size_t env_size) {
R2RSubprocess *proc = NULL;
RzTestSubprocess *proc = NULL;
HANDLE stdin_read = NULL;
HANDLE stdout_write = NULL;
HANDLE stderr_write = NULL;
@@ -147,7 +147,7 @@ RZ_API R2RSubprocess *rz_test_subprocess_start(
return NULL;
}
proc = R_NEW0 (R2RSubprocess);
proc = RZ_NEW0 (RzTestSubprocess);
if (!proc) {
goto error;
}
@@ -230,7 +230,7 @@ error:
goto beach;
}
RZ_API bool rz_test_subprocess_wait(R2RSubprocess *proc, ut64 timeout_ms) {
RZ_API bool rz_test_subprocess_wait(RzTestSubprocess *proc, ut64 timeout_ms) {
OVERLAPPED stdout_overlapped = { 0 };
stdout_overlapped.hEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
if (!stdout_overlapped.hEvent) {
@@ -245,7 +245,7 @@ RZ_API bool rz_test_subprocess_wait(R2RSubprocess *proc, ut64 timeout_ms) {
ut64 timeout_us_abs = UT64_MAX;
if (timeout_ms != UT64_MAX) {
timeout_us_abs = rz_time_now_mono () + timeout_ms * R_USEC_PER_MSEC;
timeout_us_abs = rz_time_now_mono () + timeout_ms * RZ_USEC_PER_MSEC;
}
ut8 stdout_buf[0x500];
@@ -291,7 +291,7 @@ RZ_API bool rz_test_subprocess_wait(R2RSubprocess *proc, ut64 timeout_ms) {
if (now >= timeout_us_abs) {
return false;
}
timeout = (DWORD)((timeout_us_abs - now) / R_USEC_PER_MSEC);
timeout = (DWORD)((timeout_us_abs - now) / RZ_USEC_PER_MSEC);
}
DWORD signaled = WaitForMultipleObjects (handles.len, handles.a, FALSE, timeout);
if (!stdout_eof && signaled == stdout_index) {
@@ -338,18 +338,18 @@ RZ_API bool rz_test_subprocess_wait(R2RSubprocess *proc, ut64 timeout_ms) {
return stdout_eof && stderr_eof && child_dead;
}
RZ_API void rz_test_subprocess_kill(R2RSubprocess *proc) {
RZ_API void rz_test_subprocess_kill(RzTestSubprocess *proc) {
TerminateProcess (proc->proc, 255);
}
RZ_API void rz_test_subprocess_stdin_write(R2RSubprocess *proc, const ut8 *buf, size_t buf_size) {
RZ_API void rz_test_subprocess_stdin_write(RzTestSubprocess *proc, const ut8 *buf, size_t buf_size) {
DWORD read;
WriteFile (proc->stdin_write, buf, buf_size, &read, NULL);
}
RZ_API R2RProcessOutput *rz_test_subprocess_drain(R2RSubprocess *proc) {
R2RProcessOutput *out = R_NEW (R2RProcessOutput);
RZ_API RzTestProcessOutput *rz_test_subprocess_drain(RzTestSubprocess *proc) {
RzTestProcessOutput *out = RZ_NEW (RzTestProcessOutput);
if (!out) {
return NULL;
}
@@ -359,7 +359,7 @@ RZ_API R2RProcessOutput *rz_test_subprocess_drain(R2RSubprocess *proc) {
return out;
}
RZ_API void rz_test_subprocess_free(R2RSubprocess *proc) {
RZ_API void rz_test_subprocess_free(RzTestSubprocess *proc) {
if (!proc) {
return;
}
@@ -419,9 +419,9 @@ static RzThreadFunctionRet sigchld_th(RzThread *th) {
rz_th_lock_enter (subprocs_mutex);
void **it;
R2RSubprocess *proc = NULL;
RzTestSubprocess *proc = NULL;
rz_pvector_foreach (&subprocs, it) {
R2RSubprocess *p = *it;
RzTestSubprocess *p = *it;
if (p->pid == pid) {
proc = p;
break;
@@ -442,7 +442,7 @@ static RzThreadFunctionRet sigchld_th(RzThread *th) {
rz_th_lock_leave (subprocs_mutex);
}
}
return R_TH_STOP;
return RZ_TH_STOP;
}
RZ_API bool rz_test_subprocess_init(void) {
@@ -484,7 +484,7 @@ RZ_API void rz_test_subprocess_fini(void) {
rz_th_lock_free (subprocs_mutex);
}
RZ_API R2RSubprocess *rz_test_subprocess_start(
RZ_API RzTestSubprocess *rz_test_subprocess_start(
const char *file, const char *args[], size_t args_size,
const char *envvars[], const char *envvals[], size_t env_size) {
char **argv = calloc (args_size + 2, sizeof (char *));
@@ -497,7 +497,7 @@ RZ_API R2RSubprocess *rz_test_subprocess_start(
}
// done by calloc: argv[args_size + 1] = NULL;
rz_th_lock_enter (subprocs_mutex);
R2RSubprocess *proc = R_NEW0 (R2RSubprocess);
RzTestSubprocess *proc = RZ_NEW0 (RzTestSubprocess);
if (!proc) {
goto error;
}
@@ -615,10 +615,10 @@ error:
return NULL;
}
RZ_API bool rz_test_subprocess_wait(R2RSubprocess *proc, ut64 timeout_ms) {
RZ_API bool rz_test_subprocess_wait(RzTestSubprocess *proc, ut64 timeout_ms) {
ut64 timeout_abs;
if (timeout_ms != UT64_MAX) {
timeout_abs = rz_time_now_mono () + timeout_ms * R_USEC_PER_MSEC;
timeout_abs = rz_time_now_mono () + timeout_ms * RZ_USEC_PER_MSEC;
}
int r = 0;
@@ -657,8 +657,8 @@ RZ_API bool rz_test_subprocess_wait(R2RSubprocess *proc, ut64 timeout_ms) {
break;
}
ut64 usec_diff = timeout_abs - rz_time_now_mono ();
timeout_s.tv_sec = usec_diff / R_USEC_PER_SEC;
timeout_s.tv_usec = usec_diff % R_USEC_PER_SEC;
timeout_s.tv_sec = usec_diff / RZ_USEC_PER_SEC;
timeout_s.tv_usec = usec_diff % RZ_USEC_PER_SEC;
timeout = &timeout_s;
}
r = select (nfds, &rfds, NULL, NULL, timeout);
@@ -709,19 +709,19 @@ RZ_API bool rz_test_subprocess_wait(R2RSubprocess *proc, ut64 timeout_ms) {
return child_dead;
}
RZ_API void rz_test_subprocess_kill(R2RSubprocess *proc) {
RZ_API void rz_test_subprocess_kill(RzTestSubprocess *proc) {
kill (proc->pid, SIGKILL);
}
RZ_API void rz_test_subprocess_stdin_write(R2RSubprocess *proc, const ut8 *buf, size_t buf_size) {
RZ_API void rz_test_subprocess_stdin_write(RzTestSubprocess *proc, const ut8 *buf, size_t buf_size) {
write (proc->stdin_fd, buf, buf_size);
close (proc->stdin_fd);
proc->stdin_fd = -1;
}
RZ_API R2RProcessOutput *rz_test_subprocess_drain(R2RSubprocess *proc) {
RZ_API RzTestProcessOutput *rz_test_subprocess_drain(RzTestSubprocess *proc) {
rz_th_lock_enter (subprocs_mutex);
R2RProcessOutput *out = R_NEW (R2RProcessOutput);
RzTestProcessOutput *out = RZ_NEW (RzTestProcessOutput);
if (out) {
out->out = rz_strbuf_drain_nofree (&proc->out);
out->err = rz_strbuf_drain_nofree (&proc->err);
@@ -732,7 +732,7 @@ RZ_API R2RProcessOutput *rz_test_subprocess_drain(R2RSubprocess *proc) {
return out;
}
RZ_API void rz_test_subprocess_free(R2RSubprocess *proc) {
RZ_API void rz_test_subprocess_free(RzTestSubprocess *proc) {
if (!proc) {
return;
}
@@ -752,7 +752,7 @@ RZ_API void rz_test_subprocess_free(R2RSubprocess *proc) {
}
#endif
RZ_API void rz_test_process_output_free(R2RProcessOutput *out) {
RZ_API void rz_test_process_output_free(RzTestProcessOutput *out) {
if (!out) {
return;
}
@@ -761,9 +761,9 @@ RZ_API void rz_test_process_output_free(R2RProcessOutput *out) {
free (out);
}
static R2RProcessOutput *subprocess_runner(const char *file, const char *args[], size_t args_size,
static RzTestProcessOutput *subprocess_runner(const char *file, const char *args[], size_t args_size,
const char *envvars[], const char *envvals[], size_t env_size, ut64 timeout_ms, void *user) {
R2RSubprocess *proc = rz_test_subprocess_start (file, args, args_size, envvars, envvals, env_size);
RzTestSubprocess *proc = rz_test_subprocess_start (file, args, args_size, envvars, envvals, env_size);
if (!proc) {
return NULL;
}
@@ -771,7 +771,7 @@ static R2RProcessOutput *subprocess_runner(const char *file, const char *args[],
if (timeout) {
rz_test_subprocess_kill (proc);
}
R2RProcessOutput *out = rz_test_subprocess_drain (proc);
RzTestProcessOutput *out = rz_test_subprocess_drain (proc);
if (out) {
out->timeout = timeout;
}
@@ -845,7 +845,7 @@ static char *convert_win_cmds(const char *cmds) {
}
#endif
static R2RProcessOutput *run_rz_test(R2RRunConfig *config, ut64 timeout_ms, const char *cmds, RzList *files, RzList *extra_args, bool load_plugins, R2RzCmdRunner runner, void *user) {
static RzTestProcessOutput *run_rz_test(RzTestRunConfig *config, ut64 timeout_ms, const char *cmds, RzList *files, RzList *extra_args, bool load_plugins, RzTestCmdRunner runner, void *user) {
RPVector args;
rz_pvector_init (&args, NULL);
rz_pvector_push (&args, "-escr.utf8=0");
@@ -872,7 +872,7 @@ static R2RProcessOutput *run_rz_test(R2RRunConfig *config, ut64 timeout_ms, cons
#if __WINDOWS__
"ANSICON",
#endif
"R2_NOPLUGINS"
"RZ_NOPLUGINS"
};
const char *envvals[] = {
#if __WINDOWS__
@@ -885,7 +885,7 @@ static R2RProcessOutput *run_rz_test(R2RRunConfig *config, ut64 timeout_ms, cons
#else
size_t env_size = load_plugins ? 0 : 1;
#endif
R2RProcessOutput *out = runner (config->r2_cmd, args.v.a, rz_pvector_len (&args), envvars, envvals, env_size, timeout_ms, user);
RzTestProcessOutput *out = runner (config->r2_cmd, args.v.a, rz_pvector_len (&args), envvars, envvals, env_size, timeout_ms, user);
rz_pvector_clear (&args);
#if __WINDOWS__
free (wcmds);
@@ -893,7 +893,7 @@ static R2RProcessOutput *run_rz_test(R2RRunConfig *config, ut64 timeout_ms, cons
return out;
}
RZ_API R2RProcessOutput *rz_test_run_cmd_test(R2RRunConfig *config, R2RzCmdTest *test, R2RzCmdRunner runner, void *user) {
RZ_API RzTestProcessOutput *rz_test_run_cmd_test(RzTestRunConfig *config, RzCmdTest *test, RzTestCmdRunner runner, void *user) {
RzList *extra_args = test->args.value ? rz_str_split_duplist (test->args.value, " ", true) : NULL;
RzList *files = rz_str_split_duplist (test->file.value, "\n", true);
RzListIter *it;
@@ -918,13 +918,13 @@ RZ_API R2RProcessOutput *rz_test_run_cmd_test(R2RRunConfig *config, R2RzCmdTest
rz_list_push (files, "-");
}
ut64 timeout_ms = test->timeout.set? test->timeout.value * 1000: config->timeout_ms;
R2RProcessOutput *out = run_rz_test (config, timeout_ms, test->cmds.value, files, extra_args, test->load_plugins, runner, user);
RzTestProcessOutput *out = run_rz_test (config, timeout_ms, test->cmds.value, files, extra_args, test->load_plugins, runner, user);
rz_list_free (extra_args);
rz_list_free (files);
return out;
}
RZ_API bool rz_test_check_cmd_test(R2RProcessOutput *out, R2RzCmdTest *test) {
RZ_API bool rz_test_check_cmd_test(RzTestProcessOutput *out, RzCmdTest *test) {
if (!out || out->ret != 0 || !out->out || !out->err || out->timeout) {
return false;
}
@@ -944,7 +944,7 @@ RZ_API bool rz_test_check_cmd_test(R2RProcessOutput *out, R2RzCmdTest *test) {
RZ_API bool rz_test_check_jq_available(void) {
const char *args[] = {"."};
const char *invalid_json = "this is not json lol";
R2RSubprocess *proc = rz_test_subprocess_start (JQ_CMD, args, 1, NULL, NULL, 0);
RzTestSubprocess *proc = rz_test_subprocess_start (JQ_CMD, args, 1, NULL, NULL, 0);
if (proc) {
rz_test_subprocess_stdin_write (proc, (const ut8 *)invalid_json, strlen (invalid_json));
rz_test_subprocess_wait (proc, UT64_MAX);
@@ -964,20 +964,20 @@ RZ_API bool rz_test_check_jq_available(void) {
return invalid_detected && valid_detected;
}
RZ_API R2RProcessOutput *rz_test_run_json_test(R2RRunConfig *config, R2RJsonTest *test, R2RzCmdRunner runner, void *user) {
RZ_API RzTestProcessOutput *rz_test_run_json_test(RzTestRunConfig *config, RzJsonTest *test, RzTestCmdRunner runner, void *user) {
RzList *files = rz_list_new ();
rz_list_push (files, (void *)config->json_test_file);
R2RProcessOutput *ret = run_rz_test (config, config->timeout_ms, test->cmd, files, NULL, test->load_plugins, runner, user);
RzTestProcessOutput *ret = run_rz_test (config, config->timeout_ms, test->cmd, files, NULL, test->load_plugins, runner, user);
rz_list_free (files);
return ret;
}
RZ_API bool rz_test_check_json_test(R2RProcessOutput *out, R2RJsonTest *test) {
RZ_API bool rz_test_check_json_test(RzTestProcessOutput *out, RzJsonTest *test) {
if (!out || out->ret != 0 || !out->out || !out->err || out->timeout) {
return false;
}
const char *args[] = {"."};
R2RSubprocess *proc = rz_test_subprocess_start (JQ_CMD, args, 1, NULL, NULL, 0);
RzTestSubprocess *proc = rz_test_subprocess_start (JQ_CMD, args, 1, NULL, NULL, 0);
rz_test_subprocess_stdin_write (proc, (const ut8 *)out->out, strlen (out->out));
rz_test_subprocess_wait (proc, UT64_MAX);
bool ret = proc->ret == 0;
@@ -985,8 +985,8 @@ RZ_API bool rz_test_check_json_test(R2RProcessOutput *out, R2RJsonTest *test) {
return ret;
}
RZ_API R2RzAsmTestOutput *rz_test_run_asm_test(R2RRunConfig *config, R2RzAsmTest *test) {
R2RzAsmTestOutput *out = R_NEW0 (R2RzAsmTestOutput);
RZ_API RzAsmTestOutput *rz_test_run_asm_test(RzTestRunConfig *config, RzAsmTest *test) {
RzAsmTestOutput *out = RZ_NEW0 (RzAsmTestOutput);
if (!out) {
return NULL;
}
@@ -1011,7 +1011,7 @@ RZ_API R2RzAsmTestOutput *rz_test_run_asm_test(R2RRunConfig *config, R2RzAsmTest
rz_pvector_push (&args, bits);
}
if (test->mode & R2R_ASM_TEST_MODE_BIG_ENDIAN) {
if (test->mode & RZ_ASM_TEST_MODE_BIG_ENDIAN) {
rz_pvector_push (&args, "-e");
}
@@ -1024,9 +1024,9 @@ RZ_API R2RzAsmTestOutput *rz_test_run_asm_test(R2RRunConfig *config, R2RzAsmTest
RStrBuf cmd_buf;
rz_strbuf_init (&cmd_buf);
if (test->mode & R2R_ASM_TEST_MODE_ASSEMBLE) {
if (test->mode & RZ_ASM_TEST_MODE_ASSEMBLE) {
rz_pvector_push (&args, test->disasm);
R2RSubprocess *proc = rz_test_subprocess_start (config->rz_asm_cmd, args.v.a, rz_pvector_len (&args), NULL, NULL, 0);
RzTestSubprocess *proc = rz_test_subprocess_start (config->rz_asm_cmd, args.v.a, rz_pvector_len (&args), NULL, NULL, 0);
if (!rz_test_subprocess_wait (proc, config->timeout_ms)) {
rz_test_subprocess_kill (proc);
out->as_timeout = true;
@@ -1052,14 +1052,14 @@ rip:
rz_pvector_pop (&args);
rz_test_subprocess_free (proc);
}
if (test->mode & R2R_ASM_TEST_MODE_DISASSEMBLE) {
if (test->mode & RZ_ASM_TEST_MODE_DISASSEMBLE) {
char *hex = rz_hex_bin2strdup (test->bytes, test->bytes_size);
if (!hex) {
goto beach;
}
rz_pvector_push (&args, "-d");
rz_pvector_push (&args, hex);
R2RSubprocess *proc = rz_test_subprocess_start (config->rz_asm_cmd, args.v.a, rz_pvector_len (&args), NULL, NULL, 0);
RzTestSubprocess *proc = rz_test_subprocess_start (config->rz_asm_cmd, args.v.a, rz_pvector_len (&args), NULL, NULL, 0);
if (!rz_test_subprocess_wait (proc, config->timeout_ms)) {
rz_test_subprocess_kill (proc);
out->disas_timeout = true;
@@ -1084,11 +1084,11 @@ beach:
return out;
}
RZ_API bool rz_test_check_asm_test(R2RzAsmTestOutput *out, R2RzAsmTest *test) {
RZ_API bool rz_test_check_asm_test(RzAsmTestOutput *out, RzAsmTest *test) {
if (!out) {
return false;
}
if (test->mode & R2R_ASM_TEST_MODE_ASSEMBLE) {
if (test->mode & RZ_ASM_TEST_MODE_ASSEMBLE) {
if (!out->bytes || !test->bytes || out->bytes_size != test->bytes_size || out->as_timeout) {
return false;
}
@@ -1096,7 +1096,7 @@ RZ_API bool rz_test_check_asm_test(R2RzAsmTestOutput *out, R2RzAsmTest *test) {
return false;
}
}
if (test->mode & R2R_ASM_TEST_MODE_DISASSEMBLE) {
if (test->mode & RZ_ASM_TEST_MODE_DISASSEMBLE) {
if (!out->disasm || !test->disasm || out->as_timeout) {
return false;
}
@@ -1107,7 +1107,7 @@ RZ_API bool rz_test_check_asm_test(R2RzAsmTestOutput *out, R2RzAsmTest *test) {
return true;
}
RZ_API void rz_test_asm_test_output_free(R2RzAsmTestOutput *out) {
RZ_API void rz_test_asm_test_output_free(RzAsmTestOutput *out) {
if (!out) {
return;
}
@@ -1116,87 +1116,87 @@ RZ_API void rz_test_asm_test_output_free(R2RzAsmTestOutput *out) {
free (out);
}
RZ_API R2RProcessOutput *rz_test_run_fuzz_test(R2RRunConfig *config, R2RFuzzTest *test, R2RzCmdRunner runner, void *user) {
RZ_API RzTestProcessOutput *rz_test_run_fuzz_test(RzTestRunConfig *config, RzFuzzTest *test, RzTestCmdRunner runner, void *user) {
RzList *files = rz_list_new ();
rz_list_push (files, test->file);
R2RProcessOutput *ret = run_rz_test (config, config->timeout_ms, "aaa", files, NULL, false, runner, user);
RzTestProcessOutput *ret = run_rz_test (config, config->timeout_ms, "aaa", files, NULL, false, runner, user);
rz_list_free (files);
return ret;
}
RZ_API bool rz_test_check_fuzz_test(R2RProcessOutput *out) {
RZ_API bool rz_test_check_fuzz_test(RzTestProcessOutput *out) {
return out && out->ret == 0 && out->out && out->err && !out->timeout;
}
RZ_API char *rz_test_test_name(R2RTest *test) {
RZ_API char *rz_test_test_name(RzTest *test) {
switch (test->type) {
case R2R_TEST_TYPE_CMD:
case RZ_TEST_TYPE_CMD:
if (test->cmd_test->name.value) {
return strdup (test->cmd_test->name.value);
}
return strdup ("<unnamed>");
case R2R_TEST_TYPE_ASM:
case RZ_TEST_TYPE_ASM:
return rz_str_newf ("<asm> %s", test->asm_test->disasm ? test->asm_test->disasm : "");
case R2R_TEST_TYPE_JSON:
case RZ_TEST_TYPE_JSON:
return rz_str_newf ("<json> %s", test->json_test->cmd ? test->json_test->cmd: "");
case R2R_TEST_TYPE_FUZZ:
case RZ_TEST_TYPE_FUZZ:
return rz_str_newf ("<fuzz> %s", test->fuzz_test->file);
}
return NULL;
}
RZ_API bool rz_test_test_broken(R2RTest *test) {
RZ_API bool rz_test_test_broken(RzTest *test) {
switch (test->type) {
case R2R_TEST_TYPE_CMD:
case RZ_TEST_TYPE_CMD:
return test->cmd_test->broken.value;
case R2R_TEST_TYPE_ASM:
return test->asm_test->mode & R2R_ASM_TEST_MODE_BROKEN ? true : false;
case R2R_TEST_TYPE_JSON:
case RZ_TEST_TYPE_ASM:
return test->asm_test->mode & RZ_ASM_TEST_MODE_BROKEN ? true : false;
case RZ_TEST_TYPE_JSON:
return test->json_test->broken;
case R2R_TEST_TYPE_FUZZ:
case RZ_TEST_TYPE_FUZZ:
return false;
}
return false;
}
RZ_API R2RTestResultInfo *rz_test_run_test(R2RRunConfig *config, R2RTest *test) {
R2RTestResultInfo *ret = R_NEW0 (R2RTestResultInfo);
RZ_API RzTestResultInfo *rz_test_run_test(RzTestRunConfig *config, RzTest *test) {
RzTestResultInfo *ret = RZ_NEW0 (RzTestResultInfo);
if (!ret) {
return NULL;
}
ret->test = test;
bool success = false;
switch (test->type) {
case R2R_TEST_TYPE_CMD: {
R2RzCmdTest *cmd_test = test->cmd_test;
R2RProcessOutput *out = rz_test_run_cmd_test (config, cmd_test, subprocess_runner, NULL);
case RZ_TEST_TYPE_CMD: {
RzCmdTest *cmd_test = test->cmd_test;
RzTestProcessOutput *out = rz_test_run_cmd_test (config, cmd_test, subprocess_runner, NULL);
success = rz_test_check_cmd_test (out, cmd_test);
ret->proc_out = out;
ret->timeout = out && out->timeout;
ret->run_failed = !out;
break;
}
case R2R_TEST_TYPE_ASM: {
R2RzAsmTest *asm_test = test->asm_test;
R2RzAsmTestOutput *out = rz_test_run_asm_test (config, asm_test);
case RZ_TEST_TYPE_ASM: {
RzAsmTest *asm_test = test->asm_test;
RzAsmTestOutput *out = rz_test_run_asm_test (config, asm_test);
success = rz_test_check_asm_test (out, asm_test);
ret->asm_out = out;
ret->timeout = out->as_timeout || out->disas_timeout;
ret->run_failed = !out;
break;
}
case R2R_TEST_TYPE_JSON: {
R2RJsonTest *json_test = test->json_test;
R2RProcessOutput *out = rz_test_run_json_test (config, json_test, subprocess_runner, NULL);
case RZ_TEST_TYPE_JSON: {
RzJsonTest *json_test = test->json_test;
RzTestProcessOutput *out = rz_test_run_json_test (config, json_test, subprocess_runner, NULL);
success = rz_test_check_json_test (out, json_test);
ret->proc_out = out;
ret->timeout = out->timeout;
ret->run_failed = !out;
break;
}
case R2R_TEST_TYPE_FUZZ: {
R2RFuzzTest *fuzz_test = test->fuzz_test;
R2RProcessOutput *out = rz_test_run_fuzz_test (config, fuzz_test, subprocess_runner, NULL);
case RZ_TEST_TYPE_FUZZ: {
RzFuzzTest *fuzz_test = test->fuzz_test;
RzTestProcessOutput *out = rz_test_run_fuzz_test (config, fuzz_test, subprocess_runner, NULL);
success = rz_test_check_fuzz_test (out);
ret->proc_out = out;
ret->timeout = out->timeout;
@@ -1205,11 +1205,11 @@ RZ_API R2RTestResultInfo *rz_test_run_test(R2RRunConfig *config, R2RTest *test)
}
bool broken = rz_test_test_broken (test);
#if ASAN
# if !R2_ASSERT_STDOUT
# error R2_ASSERT_STDOUT undefined or 0
# if !RZ_ASSERT_STDOUT
# error RZ_ASSERT_STDOUT undefined or 0
# endif
R2RProcessOutput *out = ret->proc_out;
if (!success && test->type == R2R_TEST_TYPE_CMD && strstr (test->path, "/dbg")
RzTestProcessOutput *out = ret->proc_out;
if (!success && test->type == RZ_TEST_TYPE_CMD && strstr (test->path, "/dbg")
&& (!out->out ||
(!strstr (out->out, "WARNING:") && !strstr (out->out, "ERROR:") && !strstr (out->out, "FATAL:")))
&& (!out->err ||
@@ -1218,25 +1218,25 @@ RZ_API R2RTestResultInfo *rz_test_run_test(R2RRunConfig *config, R2RTest *test)
}
#endif
if (!success) {
ret->result = broken ? R2R_TEST_RESULT_BROKEN : R2R_TEST_RESULT_FAILED;
ret->result = broken ? RZ_TEST_RESULT_BROKEN : RZ_TEST_RESULT_FAILED;
} else {
ret->result = broken ? R2R_TEST_RESULT_FIXED : R2R_TEST_RESULT_OK;
ret->result = broken ? RZ_TEST_RESULT_FIXED : RZ_TEST_RESULT_OK;
}
return ret;
}
RZ_API void rz_test_test_result_info_free(R2RTestResultInfo *result) {
RZ_API void rz_test_test_result_info_free(RzTestResultInfo *result) {
if (!result) {
return;
}
if (result->test) {
switch (result->test->type) {
case R2R_TEST_TYPE_CMD:
case R2R_TEST_TYPE_JSON:
case R2R_TEST_TYPE_FUZZ:
case RZ_TEST_TYPE_CMD:
case RZ_TEST_TYPE_JSON:
case RZ_TEST_TYPE_FUZZ:
rz_test_process_output_free (result->proc_out);
break;
case R2R_TEST_TYPE_ASM:
case RZ_TEST_TYPE_ASM:
rz_test_asm_test_output_free (result->asm_out);
break;
}
+68 -68
View File
@@ -15,9 +15,9 @@
#define TIMEOUT_DEFAULT_STR STR(TIMEOUT_DEFAULT)
typedef struct rz_test_state_t {
R2RRunConfig run_config;
RzTestRunConfig run_config;
bool verbose;
R2RTestDatabase *db;
RzTestDatabase *db;
RzThreadCond *cond; // signaled from workers to main thread to update status
RzThreadLock *lock; // protects everything below
@@ -29,16 +29,16 @@ typedef struct rz_test_state_t {
ut64 fx_count;
RPVector queue;
RPVector results;
} R2RState;
} RzTestState;
static RzThreadFunctionRet worker_th(RzThread *th);
static void print_state(R2RState *state, ut64 prev_completed);
static void print_log(R2RState *state, ut64 prev_completed, ut64 prev_paths_completed);
static void interact(R2RState *state);
static void interact_fix(R2RTestResultInfo *result, RPVector *fixup_results);
static void interact_break(R2RTestResultInfo *result, RPVector *fixup_results);
static void interact_commands(R2RTestResultInfo *result, RPVector *fixup_results);
static void interact_diffchar(R2RTestResultInfo *result);
static void print_state(RzTestState *state, ut64 prev_completed);
static void print_log(RzTestState *state, ut64 prev_completed, ut64 prev_paths_completed);
static void interact(RzTestState *state);
static void interact_fix(RzTestResultInfo *result, RPVector *fixup_results);
static void interact_break(RzTestResultInfo *result, RPVector *fixup_results);
static void interact_commands(RzTestResultInfo *result, RPVector *fixup_results);
static void interact_diffchar(RzTestResultInfo *result);
static int help(bool verbose) {
printf ("Usage: rz-test [-qvVnL] [-j threads] [test file/dir | @test-type]\n");
@@ -60,7 +60,7 @@ static int help(bool verbose) {
" -t [seconds] timeout per test (default is "TIMEOUT_DEFAULT_STR")\n"
"\n"
"Supported test types: @json @unit @fuzz @cmds\n"
"OS/Arch for archos tests: "R2R_ARCH_OS"\n");
"OS/Arch for archos tests: "RZ_TEST_ARCH_OS"\n");
}
return 1;
}
@@ -78,10 +78,10 @@ static bool rz_test_chdir(const char *argv0) {
char *rz_test_path = rz_file_path (argv0);
bool found = false;
if (readlink (rz_test_path, src_path, sizeof (src_path)) != -1) {
char *p = strstr (src_path, R_SYS_DIR "binrz"R_SYS_DIR"rz_test"R_SYS_DIR"rz_test");
char *p = strstr (src_path, RZ_SYS_DIR "binrz"RZ_SYS_DIR"rz_test"RZ_SYS_DIR"rz_test");
if (p) {
*p = 0;
strcat (src_path, R_SYS_DIR"test"R_SYS_DIR);
strcat (src_path, RZ_SYS_DIR"test"RZ_SYS_DIR);
if (rz_file_is_directory (src_path)) {
if (chdir (src_path) != -1) {
eprintf ("Running from %s\n", src_path);
@@ -109,7 +109,7 @@ static bool rz_test_chdir_fromtest(const char *test_path) {
}
char *abs_test_path = rz_file_abspath (test_path);
if (!rz_file_is_directory (abs_test_path)) {
char *last_slash = (char *)rz_str_lchr (abs_test_path, R_SYS_DIR[0]);
char *last_slash = (char *)rz_str_lchr (abs_test_path, RZ_SYS_DIR[0]);
if (last_slash) {
*last_slash = 0;
}
@@ -174,7 +174,7 @@ int main(int argc, char **argv) {
HANDLE streams[] = { GetStdHandle (STD_OUTPUT_HANDLE), GetStdHandle (STD_ERROR_HANDLE) };
DWORD mode;
int i;
for (i = 0; i < R_ARRAY_SIZE (streams); i++) {
for (i = 0; i < RZ_ARRAY_SIZE (streams); i++) {
GetConsoleMode (streams[i], &mode);
SetConsoleMode (streams[i],
mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
@@ -196,7 +196,7 @@ int main(int argc, char **argv) {
break;
case 'v':
if (quiet) {
printf (R2_VERSION "\n");
printf (RZ_VERSION "\n");
} else {
char *s = rz_str_version ("rz_test");
printf ("%s\n", s);
@@ -283,7 +283,7 @@ int main(int argc, char **argv) {
atexit (rz_test_subprocess_fini);
ut64 time_start = rz_time_now_mono ();
R2RState state = {{0}};
RzTestState state = {{0}};
state.run_config.r2_cmd = rizin_cmd ? rizin_cmd : RIZIN_CMD_DEFAULT;
state.run_config.rz_asm_cmd = rz_asm_cmd ? rz_asm_cmd : RZ_ASM_CMD_DEFAULT;
state.run_config.json_test_file = json_test_file ? json_test_file : JSON_TEST_FILE_DEFAULT;
@@ -358,7 +358,7 @@ int main(int argc, char **argv) {
}
}
R_FREE (cwd);
RZ_FREE (cwd);
uint32_t loaded_tests = rz_pvector_len (&state.db->tests);
printf ("Loaded %u tests.\n", loaded_tests);
if (nothing) {
@@ -370,8 +370,8 @@ int main(int argc, char **argv) {
eprintf ("Skipping json tests because jq is not available.\n");
size_t i;
for (i = 0; i < rz_pvector_len (&state.db->tests);) {
R2RTest *test = rz_pvector_at (&state.db->tests, i);
if (test->type == R2R_TEST_TYPE_JSON) {
RzTest *test = rz_pvector_at (&state.db->tests, i);
if (test->type == RZ_TEST_TYPE_JSON) {
rz_test_test_free (test);
rz_pvector_remove_at (&state.db->tests, i);
continue;
@@ -389,7 +389,7 @@ int main(int argc, char **argv) {
if (state.path_left) {
void **it;
rz_pvector_foreach (&state.queue, it) {
R2RTest *test = *it;
RzTest *test = *it;
ut64 *count = ht_pp_find (state.path_left, test->path, NULL);
if (!count) {
count = malloc (sizeof (ut64));
@@ -484,30 +484,30 @@ beach:
}
static RzThreadFunctionRet worker_th(RzThread *th) {
R2RState *state = th->user;
RzTestState *state = th->user;
rz_th_lock_enter (state->lock);
while (true) {
if (rz_pvector_empty (&state->queue)) {
break;
}
R2RTest *test = rz_pvector_pop (&state->queue);
RzTest *test = rz_pvector_pop (&state->queue);
rz_th_lock_leave (state->lock);
R2RTestResultInfo *result = rz_test_run_test (&state->run_config, test);
RzTestResultInfo *result = rz_test_run_test (&state->run_config, test);
rz_th_lock_enter (state->lock);
rz_pvector_push (&state->results, result);
switch (result->result) {
case R2R_TEST_RESULT_OK:
case RZ_TEST_RESULT_OK:
state->ok_count++;
break;
case R2R_TEST_RESULT_FAILED:
case RZ_TEST_RESULT_FAILED:
state->xx_count++;
break;
case R2R_TEST_RESULT_BROKEN:
case RZ_TEST_RESULT_BROKEN:
state->br_count++;
break;
case R2R_TEST_RESULT_FIXED:
case RZ_TEST_RESULT_FIXED:
state->fx_count++;
break;
}
@@ -523,7 +523,7 @@ static RzThreadFunctionRet worker_th(RzThread *th) {
rz_th_cond_signal (state->cond);
}
rz_th_lock_leave (state->lock);
return R_TH_STOP;
return RZ_TH_STOP;
}
static void print_diff(const char *actual, const char *expected, bool diffchar) {
@@ -589,7 +589,7 @@ static void print_diff(const char *actual, const char *expected, bool diffchar)
printf ("\n");
}
static R2RProcessOutput *print_runner(const char *file, const char *args[], size_t args_size,
static RzTestProcessOutput *print_runner(const char *file, const char *args[], size_t args_size,
const char *envvars[], const char *envvals[], size_t env_size, ut64 timeout_ms, void *user) {
size_t i;
for (i = 0; i < env_size; i++) {
@@ -608,13 +608,13 @@ static R2RProcessOutput *print_runner(const char *file, const char *args[], size
return NULL;
}
static void print_result_diff(R2RRunConfig *config, R2RTestResultInfo *result) {
static void print_result_diff(RzTestRunConfig *config, RzTestResultInfo *result) {
if (result->run_failed) {
printf (Color_RED "RUN FAILED (e.g. wrong rizin path)" Color_RESET "\n");
return;
}
switch (result->test->type) {
case R2R_TEST_TYPE_CMD: {
case RZ_TEST_TYPE_CMD: {
rz_test_run_cmd_test (config, result->test->cmd_test, print_runner, NULL);
const char *expect = result->test->cmd_test->expect.value;
if (expect && strcmp (result->proc_out->out, expect)) {
@@ -634,12 +634,12 @@ static void print_result_diff(R2RRunConfig *config, R2RTestResultInfo *result) {
}
break;
}
case R2R_TEST_TYPE_ASM:
case RZ_TEST_TYPE_ASM:
// TODO
break;
case R2R_TEST_TYPE_JSON:
case RZ_TEST_TYPE_JSON:
break;
case R2R_TEST_TYPE_FUZZ:
case RZ_TEST_TYPE_FUZZ:
rz_test_run_fuzz_test (config, result->test->fuzz_test, print_runner, NULL);
printf ("-- stdout\n%s\n", result->proc_out->out);
printf ("-- stderr\n%s\n", result->proc_out->err);
@@ -648,31 +648,31 @@ static void print_result_diff(R2RRunConfig *config, R2RTestResultInfo *result) {
}
}
static void print_new_results(R2RState *state, ut64 prev_completed) {
static void print_new_results(RzTestState *state, ut64 prev_completed) {
// Detailed test result (with diff if necessary)
ut64 completed = (ut64)rz_pvector_len (&state->results);
ut64 i;
for (i = prev_completed; i < completed; i++) {
R2RTestResultInfo *result = rz_pvector_at (&state->results, (size_t)i);
if (!state->verbose && (result->result == R2R_TEST_RESULT_OK || result->result == R2R_TEST_RESULT_FIXED || result->result == R2R_TEST_RESULT_BROKEN)) {
RzTestResultInfo *result = rz_pvector_at (&state->results, (size_t)i);
if (!state->verbose && (result->result == RZ_TEST_RESULT_OK || result->result == RZ_TEST_RESULT_FIXED || result->result == RZ_TEST_RESULT_BROKEN)) {
continue;
}
char *name = rz_test_test_name (result->test);
if (!name) {
continue;
}
printf ("\n"R_CONS_CURSOR_UP R_CONS_CLEAR_LINE);
printf ("\n"RZ_CONS_CURSOR_UP RZ_CONS_CLEAR_LINE);
switch (result->result) {
case R2R_TEST_RESULT_OK:
case RZ_TEST_RESULT_OK:
printf (Color_GREEN"[OK]"Color_RESET);
break;
case R2R_TEST_RESULT_FAILED:
case RZ_TEST_RESULT_FAILED:
printf (Color_RED"[XX]"Color_RESET);
break;
case R2R_TEST_RESULT_BROKEN:
case RZ_TEST_RESULT_BROKEN:
printf (Color_BLUE"[BR]"Color_RESET);
break;
case R2R_TEST_RESULT_FIXED:
case RZ_TEST_RESULT_FIXED:
printf (Color_CYAN"[FX]"Color_RESET);
break;
}
@@ -680,26 +680,26 @@ static void print_new_results(R2RState *state, ut64 prev_completed) {
printf (Color_CYAN" TIMEOUT"Color_RESET);
}
printf (" %s "Color_YELLOW"%s"Color_RESET"\n", result->test->path, name);
if (result->result == R2R_TEST_RESULT_FAILED || (state->verbose && result->result == R2R_TEST_RESULT_BROKEN)) {
if (result->result == RZ_TEST_RESULT_FAILED || (state->verbose && result->result == RZ_TEST_RESULT_BROKEN)) {
print_result_diff (&state->run_config, result);
}
free (name);
}
}
static void print_state_counts(R2RState *state) {
static void print_state_counts(RzTestState *state) {
printf ("%8"PFMT64u" OK %8"PFMT64u" BR %8"PFMT64u" XX %8"PFMT64u" FX",
state->ok_count, state->br_count, state->xx_count, state->fx_count);
}
static void print_state(R2RState *state, ut64 prev_completed) {
static void print_state(RzTestState *state, ut64 prev_completed) {
#if __WINDOWS__
setvbuf (stdout, NULL, _IOFBF, 8192);
#endif
print_new_results (state, prev_completed);
// [x/x] OK 42 BR 0 ...
printf (R_CONS_CLEAR_LINE);
printf (RZ_CONS_CLEAR_LINE);
int w = printf ("[%"PFMT64u"/%"PFMT64u"]", (ut64)rz_pvector_len (&state->results), (ut64)rz_pvector_len (&state->db->tests));
while (w >= 0 && w < 20) {
printf (" ");
@@ -713,7 +713,7 @@ static void print_state(R2RState *state, ut64 prev_completed) {
#endif
}
static void print_log(R2RState *state, ut64 prev_completed, ut64 prev_paths_completed) {
static void print_log(RzTestState *state, ut64 prev_completed, ut64 prev_paths_completed) {
print_new_results (state, prev_completed);
ut64 paths_completed = rz_pvector_len (&state->completed_paths);
for (; prev_paths_completed < paths_completed; prev_paths_completed++) {
@@ -723,13 +723,13 @@ static void print_log(R2RState *state, ut64 prev_completed, ut64 prev_paths_comp
}
}
static void interact(R2RState *state) {
static void interact(RzTestState *state) {
void **it;
RPVector failed_results;
rz_pvector_init (&failed_results, NULL);
rz_pvector_foreach (&state->results, it) {
R2RTestResultInfo *result = *it;
if (result->result == R2R_TEST_RESULT_FAILED) {
RzTestResultInfo *result = *it;
if (result->result == RZ_TEST_RESULT_FAILED) {
rz_pvector_push (&failed_results, result);
}
}
@@ -746,8 +746,8 @@ static void interact(R2RState *state) {
(ut64)rz_pvector_len (&failed_results));
rz_pvector_foreach (&failed_results, it) {
R2RTestResultInfo *result = *it;
if (result->test->type != R2R_TEST_TYPE_CMD) {
RzTestResultInfo *result = *it;
if (result->test->type != RZ_TEST_TYPE_CMD) {
// TODO: other types of tests
continue;
}
@@ -852,14 +852,14 @@ static char *replace_lines(const char *src, size_t from, size_t to, const char *
static void fixup_tests(RPVector *results, const char *edited_file, ut64 start_line, st64 delta) {
void **it;
rz_pvector_foreach (results, it) {
R2RTestResultInfo *result = *it;
if (result->test->type != R2R_TEST_TYPE_CMD) {
RzTestResultInfo *result = *it;
if (result->test->type != RZ_TEST_TYPE_CMD) {
continue;
}
if (result->test->path != edited_file) { // this works because all the paths come from the string pool
continue;
}
R2RzCmdTest *test = result->test->cmd_test;
RzCmdTest *test = result->test->cmd_test;
test->run_line += delta;
#define DO_KEY_STR(key, field) \
@@ -882,7 +882,7 @@ static void fixup_tests(RPVector *results, const char *edited_file, ut64 start_l
test->field.line += delta; \
}
R2R_CMD_TEST_FOREACH_RECORD(DO_KEY_STR, DO_KEY_BOOL, DO_KEY_NUM)
RZ_CMD_TEST_FOREACH_RECORD(DO_KEY_STR, DO_KEY_BOOL, DO_KEY_NUM)
#undef DO_KEY_STR
#undef DO_KEY_BOOL
#undef DO_KEY_NUM
@@ -930,10 +930,10 @@ static void replace_cmd_kv_file(const char *path, ut64 line_begin, ut64 line_end
free (newc);
}
static void interact_fix(R2RTestResultInfo *result, RPVector *fixup_results) {
assert (result->test->type == R2R_TEST_TYPE_CMD);
R2RzCmdTest *test = result->test->cmd_test;
R2RProcessOutput *out = result->proc_out;
static void interact_fix(RzTestResultInfo *result, RPVector *fixup_results) {
assert (result->test->type == RZ_TEST_TYPE_CMD);
RzCmdTest *test = result->test->cmd_test;
RzTestProcessOutput *out = result->proc_out;
if (test->expect.value && out->out) {
replace_cmd_kv_file (result->test->path, test->expect.line_begin, test->expect.line_end, "EXPECT", out->out, fixup_results);
}
@@ -942,9 +942,9 @@ static void interact_fix(R2RTestResultInfo *result, RPVector *fixup_results) {
}
}
static void interact_break(R2RTestResultInfo *result, RPVector *fixup_results) {
assert (result->test->type == R2R_TEST_TYPE_CMD);
R2RzCmdTest *test = result->test->cmd_test;
static void interact_break(RzTestResultInfo *result, RPVector *fixup_results) {
assert (result->test->type == RZ_TEST_TYPE_CMD);
RzCmdTest *test = result->test->cmd_test;
ut64 line_begin;
ut64 line_end;
if (test->broken.set) {
@@ -956,9 +956,9 @@ static void interact_break(R2RTestResultInfo *result, RPVector *fixup_results) {
replace_cmd_kv_file (result->test->path, line_begin, line_end, "BROKEN", "1", fixup_results);
}
static void interact_commands(R2RTestResultInfo *result, RPVector *fixup_results) {
assert (result->test->type == R2R_TEST_TYPE_CMD);
R2RzCmdTest *test = result->test->cmd_test;
static void interact_commands(RzTestResultInfo *result, RPVector *fixup_results) {
assert (result->test->type == RZ_TEST_TYPE_CMD);
RzCmdTest *test = result->test->cmd_test;
if (!test->cmds.value) {
return;
}
@@ -1014,7 +1014,7 @@ static void interact_commands(R2RTestResultInfo *result, RPVector *fixup_results
free (newcmds);
}
static void interact_diffchar(R2RTestResultInfo *result) {
static void interact_diffchar(RzTestResultInfo *result) {
const char *actual = result->proc_out->out;
const char *expected = result->test->cmd_test->expect.value;
printf ("-- stdout\n");
+88 -88
View File
@@ -6,61 +6,61 @@
#include <rz_util.h>
#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
#define R2R_OS "freebsd"
#define RZ_TEST_OS "freebsd"
#elif defined(__linux__)
#define R2R_OS "linux"
#define RZ_TEST_OS "linux"
#elif defined(__APPLE__)
#define R2R_OS "darwin"
#define RZ_TEST_OS "darwin"
#elif __WINDOWS__
#define R2R_OS "windows"
#define RZ_TEST_OS "windows"
#else
#define R2R_OS "unknown"
#define RZ_TEST_OS "unknown"
#endif
#if __i386__
#define R2R_ARCH "x86"
#define RZ_TEST_ARCH "x86"
#elif __x86_64__
#define R2R_ARCH "x64"
#define RZ_TEST_ARCH "x64"
#else
#define R2R_ARCH "unknown"
#define RZ_TEST_ARCH "unknown"
#endif
#define R2R_ARCH_OS R2R_OS"-"R2R_ARCH
#define RZ_TEST_ARCH_OS RZ_TEST_OS"-"RZ_TEST_ARCH
typedef struct rz_test_cmd_test_string_record {
char *value;
ut64 line_begin; // inclusive
ut64 line_end; // exclusive
} R2RzCmdTestStringRecord;
} RzCmdTestStringRecord;
typedef struct rz_test_cmd_test_bool_record {
bool value;
ut64 line; // bools are always oneliners (e.g. BROKEN=1)
bool set;
} R2RzCmdTestBoolRecord;
} RzCmdTestBoolRecord;
typedef struct rz_test_cmd_test_num_record {
ut64 value;
ut64 line; // nums are always oneliners (e.g. TIMEOUT=10)
bool set;
} R2RzCmdTestNumRecord;
} RzCmdTestNumRecord;
typedef struct rz_test_cmd_test_t {
R2RzCmdTestStringRecord name;
R2RzCmdTestStringRecord file;
R2RzCmdTestStringRecord args;
R2RzCmdTestStringRecord source;
R2RzCmdTestStringRecord cmds;
R2RzCmdTestStringRecord expect;
R2RzCmdTestStringRecord expect_err;
R2RzCmdTestBoolRecord broken;
R2RzCmdTestNumRecord timeout;
RzCmdTestStringRecord name;
RzCmdTestStringRecord file;
RzCmdTestStringRecord args;
RzCmdTestStringRecord source;
RzCmdTestStringRecord cmds;
RzCmdTestStringRecord expect;
RzCmdTestStringRecord expect_err;
RzCmdTestBoolRecord broken;
RzCmdTestNumRecord timeout;
ut64 run_line;
bool load_plugins;
} R2RzCmdTest;
} RzCmdTest;
#define R2R_CMD_TEST_FOREACH_RECORD_NOP(name, field)
#define R2R_CMD_TEST_FOREACH_RECORD(macro_str, macro_bool, macro_int) \
#define RZ_CMD_TEST_FOREACH_RECORD_NOP(name, field)
#define RZ_CMD_TEST_FOREACH_RECORD(macro_str, macro_bool, macro_int) \
macro_str ("NAME", name) \
macro_str ("FILE", file) \
macro_str ("ARGS", args) \
@@ -72,11 +72,11 @@ typedef struct rz_test_cmd_test_t {
macro_bool ("BROKEN", broken)
typedef enum rz_test_asm_test_mode_t {
R2R_ASM_TEST_MODE_ASSEMBLE = 1,
R2R_ASM_TEST_MODE_DISASSEMBLE = (1 << 1),
R2R_ASM_TEST_MODE_BIG_ENDIAN = (1 << 2),
R2R_ASM_TEST_MODE_BROKEN = (1 << 3)
} R2RzAsmTestMode;
RZ_ASM_TEST_MODE_ASSEMBLE = 1,
RZ_ASM_TEST_MODE_DISASSEMBLE = (1 << 1),
RZ_ASM_TEST_MODE_BIG_ENDIAN = (1 << 2),
RZ_ASM_TEST_MODE_BROKEN = (1 << 3)
} RzAsmTestMode;
typedef struct rz_test_asm_test_t {
ut64 line;
@@ -88,55 +88,55 @@ typedef struct rz_test_asm_test_t {
char *disasm;
ut8 *bytes;
size_t bytes_size;
} R2RzAsmTest;
} RzAsmTest;
typedef struct rz_test_json_test_t {
ut64 line;
char *cmd;
bool broken;
bool load_plugins;
} R2RJsonTest;
} RzJsonTest;
typedef struct rz_test_fuzz_test_t {
char *file;
} R2RFuzzTest;
} RzFuzzTest;
typedef enum rz_test_test_type_t {
R2R_TEST_TYPE_CMD,
R2R_TEST_TYPE_ASM,
R2R_TEST_TYPE_JSON,
R2R_TEST_TYPE_FUZZ
} R2RTestType;
RZ_TEST_TYPE_CMD,
RZ_TEST_TYPE_ASM,
RZ_TEST_TYPE_JSON,
RZ_TEST_TYPE_FUZZ
} RzTestType;
typedef struct rz_test_test_t {
const char *path;
R2RTestType type;
RzTestType type;
union {
R2RzCmdTest *cmd_test;
R2RzAsmTest *asm_test;
R2RJsonTest *json_test;
R2RFuzzTest *fuzz_test;
RzCmdTest *cmd_test;
RzAsmTest *asm_test;
RzJsonTest *json_test;
RzFuzzTest *fuzz_test;
};
} R2RTest;
} RzTest;
typedef struct rz_test_test_database_t {
RPVector tests;
RStrConstPool strpool;
} R2RTestDatabase;
} RzTestDatabase;
typedef struct rz_test_run_config_t {
const char *r2_cmd;
const char *rz_asm_cmd;
const char *json_test_file;
ut64 timeout_ms;
} R2RRunConfig;
} RzTestRunConfig;
typedef struct rz_test_process_output_t {
char *out; // stdout
char *err; // stderr
int ret; // exit code of the process
bool timeout;
} R2RProcessOutput;
} RzTestProcessOutput;
typedef struct rz_test_asm_test_output_t {
char *disasm;
@@ -144,72 +144,72 @@ typedef struct rz_test_asm_test_output_t {
size_t bytes_size;
bool as_timeout;
bool disas_timeout;
} R2RzAsmTestOutput;
} RzAsmTestOutput;
typedef enum rz_test_test_result_t {
R2R_TEST_RESULT_OK,
R2R_TEST_RESULT_FAILED,
R2R_TEST_RESULT_BROKEN,
R2R_TEST_RESULT_FIXED
} R2RTestResult;
RZ_TEST_RESULT_OK,
RZ_TEST_RESULT_FAILED,
RZ_TEST_RESULT_BROKEN,
RZ_TEST_RESULT_FIXED
} RzTestResult;
typedef struct rz_test_test_result_info_t {
R2RTest *test;
R2RTestResult result;
RzTest *test;
RzTestResult result;
bool timeout;
bool run_failed; // something went seriously wrong (e.g. r2 not found)
union {
R2RProcessOutput *proc_out; // for test->type == R2R_TEST_TYPE_CMD, R2R_TEST_TYPE_JSON or R2R_TEST_TYPE_FUZZ
R2RzAsmTestOutput *asm_out; // for test->type == R2R_TEST_TYPE_ASM
RzTestProcessOutput *proc_out; // for test->type == RZ_TEST_TYPE_CMD, RZ_TEST_TYPE_JSON or RZ_TEST_TYPE_FUZZ
RzAsmTestOutput *asm_out; // for test->type == RZ_TEST_TYPE_ASM
};
} R2RTestResultInfo;
} RzTestResultInfo;
RZ_API R2RzCmdTest *rz_test_cmd_test_new(void);
RZ_API void rz_test_cmd_test_free(R2RzCmdTest *test);
RZ_API RzCmdTest *rz_test_cmd_test_new(void);
RZ_API void rz_test_cmd_test_free(RzCmdTest *test);
RZ_API RPVector *rz_test_load_cmd_test_file(const char *file);
RZ_API R2RzAsmTest *rz_test_asm_test_new(void);
RZ_API void rz_test_asm_test_free(R2RzAsmTest *test);
RZ_API RzAsmTest *rz_test_asm_test_new(void);
RZ_API void rz_test_asm_test_free(RzAsmTest *test);
RZ_API RPVector *rz_test_load_asm_test_file(RStrConstPool *strpool, const char *file);
RZ_API R2RJsonTest *rz_test_json_test_new(void);
RZ_API void rz_test_json_test_free(R2RJsonTest *test);
RZ_API RzJsonTest *rz_test_json_test_new(void);
RZ_API void rz_test_json_test_free(RzJsonTest *test);
RZ_API RPVector *rz_test_load_json_test_file(const char *file);
RZ_API R2RTestDatabase *rz_test_test_database_new(void);
RZ_API void rz_test_test_database_free(R2RTestDatabase *db);
RZ_API bool rz_test_test_database_load(R2RTestDatabase *db, const char *path);
RZ_API bool rz_test_test_database_load_fuzz(R2RTestDatabase *db, const char *path);
RZ_API RzTestDatabase *rz_test_test_database_new(void);
RZ_API void rz_test_test_database_free(RzTestDatabase *db);
RZ_API bool rz_test_test_database_load(RzTestDatabase *db, const char *path);
RZ_API bool rz_test_test_database_load_fuzz(RzTestDatabase *db, const char *path);
typedef struct rz_test_subprocess_t R2RSubprocess;
typedef struct rz_test_subprocess_t RzTestSubprocess;
RZ_API bool rz_test_subprocess_init(void);
RZ_API void rz_test_subprocess_fini(void);
RZ_API R2RSubprocess *rz_test_subprocess_start(
RZ_API RzTestSubprocess *rz_test_subprocess_start(
const char *file, const char *args[], size_t args_size,
const char *envvars[], const char *envvals[], size_t env_size);
RZ_API bool rz_test_subprocess_wait(R2RSubprocess *proc, ut64 timeout_ms);
RZ_API void rz_test_subprocess_free(R2RSubprocess *proc);
RZ_API bool rz_test_subprocess_wait(RzTestSubprocess *proc, ut64 timeout_ms);
RZ_API void rz_test_subprocess_free(RzTestSubprocess *proc);
typedef R2RProcessOutput *(*R2RzCmdRunner)(const char *file, const char *args[], size_t args_size,
typedef RzTestProcessOutput *(*RzTestCmdRunner)(const char *file, const char *args[], size_t args_size,
const char *envvars[], const char *envvals[], size_t env_size, ut64 timeout_ms, void *user);
RZ_API void rz_test_process_output_free(R2RProcessOutput *out);
RZ_API R2RProcessOutput *rz_test_run_cmd_test(R2RRunConfig *config, R2RzCmdTest *test, R2RzCmdRunner runner, void *user);
RZ_API bool rz_test_check_cmd_test(R2RProcessOutput *out, R2RzCmdTest *test);
RZ_API void rz_test_process_output_free(RzTestProcessOutput *out);
RZ_API RzTestProcessOutput *rz_test_run_cmd_test(RzTestRunConfig *config, RzCmdTest *test, RzTestCmdRunner runner, void *user);
RZ_API bool rz_test_check_cmd_test(RzTestProcessOutput *out, RzCmdTest *test);
RZ_API bool rz_test_check_jq_available(void);
RZ_API R2RProcessOutput *rz_test_run_json_test(R2RRunConfig *config, R2RJsonTest *test, R2RzCmdRunner runner, void *user);
RZ_API bool rz_test_check_json_test(R2RProcessOutput *out, R2RJsonTest *test);
RZ_API R2RzAsmTestOutput *rz_test_run_asm_test(R2RRunConfig *config, R2RzAsmTest *test);
RZ_API bool rz_test_check_asm_test(R2RzAsmTestOutput *out, R2RzAsmTest *test);
RZ_API void rz_test_asm_test_output_free(R2RzAsmTestOutput *out);
RZ_API R2RProcessOutput *rz_test_run_fuzz_test(R2RRunConfig *config, R2RFuzzTest *test, R2RzCmdRunner runner, void *user);
RZ_API bool rz_test_check_fuzz_test(R2RProcessOutput *out);
RZ_API RzTestProcessOutput *rz_test_run_json_test(RzTestRunConfig *config, RzJsonTest *test, RzTestCmdRunner runner, void *user);
RZ_API bool rz_test_check_json_test(RzTestProcessOutput *out, RzJsonTest *test);
RZ_API RzAsmTestOutput *rz_test_run_asm_test(RzTestRunConfig *config, RzAsmTest *test);
RZ_API bool rz_test_check_asm_test(RzAsmTestOutput *out, RzAsmTest *test);
RZ_API void rz_test_asm_test_output_free(RzAsmTestOutput *out);
RZ_API RzTestProcessOutput *rz_test_run_fuzz_test(RzTestRunConfig *config, RzFuzzTest *test, RzTestCmdRunner runner, void *user);
RZ_API bool rz_test_check_fuzz_test(RzTestProcessOutput *out);
RZ_API void rz_test_test_free(R2RTest *test);
RZ_API char *rz_test_test_name(R2RTest *test);
RZ_API bool rz_test_test_broken(R2RTest *test);
RZ_API R2RTestResultInfo *rz_test_run_test(R2RRunConfig *config, R2RTest *test);
RZ_API void rz_test_test_result_info_free(R2RTestResultInfo *result);
RZ_API void rz_test_test_free(RzTest *test);
RZ_API char *rz_test_test_name(RzTest *test);
RZ_API bool rz_test_test_broken(RzTest *test);
RZ_API RzTestResultInfo *rz_test_run_test(RzTestRunConfig *config, RzTest *test);
RZ_API void rz_test_test_result_info_free(RzTestResultInfo *result);
#endif //RADARE2_R2R_H
#endif // RIZIN_RZTEST_H
+6 -6
View File
@@ -19,7 +19,7 @@ HAVE_JEMALLOC=@HAVE_JEMALLOC@
HAVE_FORK=@HAVE_FORK@
WANT_DYLINK=@WANT_DYLINK@
WITH_LIBR=@WITH_LIBR@
WANT_R2R=@WANT_R2R@
WANT_RZ_TEST=@WANT_RZ_TEST@
MKPLUGINS=mk/stat.mk mk/sloc.mk
@@ -36,11 +36,11 @@ INSTALL_MAN=@INSTALL_MAN@
INSTALL_LIB=@INSTALL_LIB@
VERSION=@VERSION@
R2_VERSION=@VERSION@
R2_VERSION_MAJOR=@VERSION_MAJOR@
R2_VERSION_MINOR=@VERSION_MINOR@
R2_VERSION_PATCH=@VERSION_PATCH@
R2_VERSION_NUMBER=@VERSION_NUMBER@
RZ_VERSION=@VERSION@
RZ_VERSION_MAJOR=@VERSION_MAJOR@
RZ_VERSION_MINOR=@VERSION_MINOR@
RZ_VERSION_PATCH=@VERSION_PATCH@
RZ_VERSION_NUMBER=@VERSION_NUMBER@
LIBVERSION=@LIBVERSION@
# ./configure --with-ostype=[linux,osx,solaris,windows] # TODO: rename to w32, w64?
Vendored
+7 -7
View File
@@ -37,8 +37,8 @@ USE_RPATH=0
[ -z "${USEROSTYPE}" ] && USEROSTYPE="auto"
[ -z "${LIBVERSION}" ] && LIBVERSION="xxx"
HAVE_JEMALLOC=1
WANT_R2R=1
[ -z "${R_CHECKS_LEVEL}" ] && R_CHECKS_LEVEL="2"
WANT_RZ_TEST=1
[ -z "${RZ_CHECKS_LEVEL}" ] && RZ_CHECKS_LEVEL="2"
split_host() {
S="$"
while : ; do
@@ -190,7 +190,7 @@ printf "\nOptional Features:
--with-libversion specify different libversion (LIBVERSION=xxx)
--without-jemalloc build without jemalloc
--without-rz-test build without rz-test for regression testing
--with-checks-level value between 0 and 3 to enable different level of assert (see R_CHECKS_LEVEL) (R_CHECKS_LEVEL=2)\n"
--with-checks-level value between 0 and 3 to enable different level of assert (see RZ_CHECKS_LEVEL) (RZ_CHECKS_LEVEL=2)\n"
printf "\nSome influential environment variables:
CC C compiler command
CFLAGS C compiler flags
@@ -307,8 +307,8 @@ echo "FLAGS: --disable-debugger --with-sysmagic --with-capstone5 --disable-l
--with-ostype) if [ -z "${value}" ]; then USEROSTYPE="auto"; else USEROSTYPE="${value}" ; fi ;;
--with-libversion) if [ -z "${value}" ]; then LIBVERSION="xxx"; else LIBVERSION="${value}" ; fi ;;
"--without-jemalloc") HAVE_JEMALLOC="0"; ;;
"--without-rz-test") WANT_R2R="0"; ;;
--with-checks-level) if [ -z "${value}" ]; then R_CHECKS_LEVEL="2"; else R_CHECKS_LEVEL="${value}" ; fi ;;
"--without-rz-test") WANT_RZ_TEST="0"; ;;
--with-checks-level) if [ -z "${value}" ]; then RZ_CHECKS_LEVEL="2"; else RZ_CHECKS_LEVEL="${value}" ; fi ;;
*) if [ "$value" ]; then eval "`echo $flag2=$value`" ;
else echo ; echo "WARNING: Unknown flag '$flag'." >&2 ; echo ; fi ;;
esac
@@ -326,7 +326,7 @@ parse_options "$1"
shift
done
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR 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 HAVE_PATCH PATCH HAVE_GIT GIT HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC CSNEXT LOADLIBS WANT_DYLINK HAVE_FORK WANT_PTRACE_WRAP WITH_LIBR 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 NEWSHELL_CFLAGS SUPPORT_C99 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 WANT_R2R R_CHECKS_LEVEL"
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR 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 HAVE_PATCH PATCH HAVE_GIT GIT HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC CSNEXT LOADLIBS WANT_DYLINK HAVE_FORK WANT_PTRACE_WRAP WITH_LIBR 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 NEWSHELL_CFLAGS SUPPORT_C99 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 WANT_RZ_TEST RZ_CHECKS_LEVEL"
create_environ
@@ -738,7 +738,7 @@ done
do_remove
echo
echo "Final report:"
for A in R_CHECKS_LEVEL WANT_R2R PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET WANT_DYLINK USEROSTYPE LIBVERSION BUILD HOST TARGET ; do # REPORT
for A in RZ_CHECKS_LEVEL WANT_RZ_TEST PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET WANT_DYLINK USEROSTYPE LIBVERSION BUILD HOST TARGET ; do # REPORT
eval VAL="\$${A}"
[ -z "${VAL}" ] && VAL="(null)"
echo " - ${A} = ${VAL}"
+3 -3
View File
@@ -67,7 +67,7 @@ generate_configh () {
uclib=$(echo $lib | tr '[a-z]' '[A-Z]')
fi
echo
echo "#define R_${uclib}_STATIC_PLUGINS \\"
echo "#define RZ_${uclib}_STATIC_PLUGINS \\"
plugins="${plugins} __${uclib}"
fi
echo " &rz_${lib}_plugin_${plg}, \\"
@@ -88,7 +88,7 @@ generate_configh () {
if [ -z "`echo ${plugins} | grep __${uclib}`" ]; then
plugins="${plugins} __${uclib}"
echo
echo "#define R_${uclib}_STATIC_PLUGINS 0"
echo "#define RZ_${uclib}_STATIC_PLUGINS 0"
fi
fi
done
@@ -134,7 +134,7 @@ generate_configmk () {
generate () {
echo "configure-plugins: Generating librz/config.h .."
cat librz/config.h.head > librz/config.h
echo "#define R2_LOADLIBS ${LOADLIBS}" >> librz/config.h
echo "#define RZ_LOADLIBS ${LOADLIBS}" >> librz/config.h
generate_configh >> librz/config.h
cat librz/config.h.tail >> librz/config.h
+3 -3
View File
@@ -238,11 +238,11 @@ IFEQ WANT_PTRACE_WRAP 0 ; {
USE_PTRACE_WRAP = 0 ;
}
ARG_WITHOUT WANT_R2R rz-test build without rz-test for regression testing ;
ARG_WITHOUT WANT_RZ_TEST rz-test build without rz-test for regression testing ;
ARG_WITH R_CHECKS_LEVEL=2 checks-level value between 0 and 3 to enable different level of assert (see R_CHECKS_LEVEL) ;
ARG_WITH RZ_CHECKS_LEVEL=2 checks-level value between 0 and 3 to enable different level of assert (see RZ_CHECKS_LEVEL) ;
REPORT R_CHECKS_LEVEL WANT_R2R PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK
REPORT RZ_CHECKS_LEVEL WANT_RZ_TEST PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK
VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM
HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET WANT_DYLINK USEROSTYPE LIBVERSION BUILD HOST TARGET ;
+1 -1
View File
@@ -13,7 +13,7 @@ Attribute list
Note that you will substitute `x` for the calling convention name you will use.
`default.cc=x` : used to set the default calling convention used for all functions in `RAnal` instance for which this key is set, string of this calling convention `"x"` will be returned for every call of `R_API const char *r_anal_cc_default(RAnal *anal)`.
`default.cc=x` : used to set the default calling convention used for all functions in `RAnal` instance for which this key is set, string of this calling convention `"x"` will be returned for every call of `RZ_API const char *r_anal_cc_default(RAnal *anal)`.
`x=cc`: used to initialize calling convention (think of it as their is calling convention called x).
+1 -1
View File
@@ -22,7 +22,7 @@ export CC="emcc --ignore-dynamic-linking"
emmake make -j4
cd binrz/rizin
emcc ../../librz/*/*.o rizin.c -I ../../librz/include/ -DR2_BIRTH=\"pop\" -DR2_GITTIP=\"123\" ../../librz/db/sdb/src/*.o
emcc ../../librz/*/*.o rizin.c -I ../../librz/include/ -DRZ_BIRTH=\"pop\" -DRZ_GITTIP=\"123\" ../../librz/db/sdb/src/*.o
binrz/rz_ax/rz_ax.js:
Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

+1 -1
View File
@@ -9,7 +9,7 @@ Libraries can be compiled:
./configure-plugins --enable-shared --enable-dynamic
R2_LIBR_PLUGINS environment variable is honored as another search path for plugins
RZ_LIBR_PLUGINS environment variable is honored as another search path for plugins
Plugins can be:
- not compiled
+1 -1
View File
@@ -6,6 +6,6 @@ STATIC_ASM_PLUGINS=p/java.mk p/mips.mk
In librz/config.h define the list of struct plugins
#define R_ASM_STATIC_PLUGINS \
#define RZ_ASM_STATIC_PLUGINS \
&r_asm_plugin_java, 0
+3 -3
View File
@@ -23,8 +23,8 @@ if [ -d "$pfx/usr/bin" ]; then
fi
new_env='
R2_ENV_IS_SET=1
R2_LIBR_PLUGINS=${pfx}/lib/rizin
RZ_ENV_IS_SET=1
RZ_LIBR_PLUGINS=${pfx}/lib/rizin
PATH=$pfx/bin:${PATH}
LD_LIBRARY_PATH=$pfx/lib:$LD_LIBRARY_PATH
DYLD_LIBRARY_PATH=$pfx/lib:$DYLD_LIBRARY_PATH
@@ -32,7 +32,7 @@ PKG_CONFIG_PATH=$pfx/lib/pkgconfig:$PKG_CONFIG_PATH
'
shift
if [ "$R2_ENV_IS_SET" = 1 ]; then
if [ "$RZ_ENV_IS_SET" = 1 ]; then
echo "Nested call"
exec $*
exit $?
+1 -1
View File
@@ -6,7 +6,7 @@ CFLAGS+=-I..
NAME=rz_anal
R2DEPS=rz_util rz_reg rz_syscall rz_search rz_cons rz_flag rz_hash rz_crypto rz_parse
CFLAGS+=-DR2_PLUGIN_INCORE -Iarch -I$(TOP)/shlr
CFLAGS+=-DRZ_PLUGIN_INCORE -Iarch -I$(TOP)/shlr
CFLAGS+=-I$(LTOP)/asm/arch/include
LDFLAGS+=${BN_LIBS}
+42 -42
View File
@@ -6,15 +6,15 @@
#include <rz_io.h>
#include <config.h>
R_LIB_VERSION(rz_anal);
RZ_LIB_VERSION(rz_anal);
static RzAnalPlugin *anal_static_plugins[] = {
R_ANAL_STATIC_PLUGINS
RZ_ANAL_STATIC_PLUGINS
};
RZ_API void rz_anal_set_limits(RzAnal *anal, ut64 from, ut64 to) {
free (anal->limit);
anal->limit = R_NEW0 (RzAnalRange);
anal->limit = RZ_NEW0 (RzAnalRange);
if (anal->limit) {
anal->limit->from = from;
anal->limit->to = to;
@@ -22,7 +22,7 @@ RZ_API void rz_anal_set_limits(RzAnal *anal, ut64 from, ut64 to) {
}
RZ_API void rz_anal_unset_limits(RzAnal *anal) {
R_FREE (anal->limit);
RZ_FREE (anal->limit);
}
static void meta_unset_for(REvent *ev, int type, void *user, void *data) {
@@ -78,7 +78,7 @@ static void rz_meta_item_free(void *_item) {
RZ_API RzAnal *rz_anal_new(void) {
int i;
RzAnal *anal = R_NEW0 (RzAnal);
RzAnal *anal = RZ_NEW0 (RzAnal);
if (!anal) {
return NULL;
}
@@ -89,23 +89,23 @@ RZ_API RzAnal *rz_anal_new(void) {
anal->bb_tree = NULL;
anal->ht_addr_fun = ht_up_new0 ();
anal->ht_name_fun = ht_pp_new0 ();
anal->os = strdup (R_SYS_OS);
anal->esil_goto_limit = R_ANAL_ESIL_GOTO_LIMIT;
anal->os = strdup (RZ_SYS_OS);
anal->esil_goto_limit = RZ_ANAL_ESIL_GOTO_LIMIT;
anal->opt.nopskip = true; // skip nops in code analysis
anal->opt.hpskip = false; // skip `mov reg,reg` and `lea reg,[reg]`
anal->gp = 0LL;
anal->sdb = sdb_new0 ();
anal->cpp_abi = R_ANAL_CPP_ABI_ITANIUM;
anal->cpp_abi = RZ_ANAL_CPP_ABI_ITANIUM;
anal->opt.depth = 32;
anal->opt.noncode = false; // do not analyze data by default
rz_spaces_init (&anal->meta_spaces, "CS");
rz_event_hook (anal->meta_spaces.event, R_SPACE_EVENT_UNSET, meta_unset_for, NULL);
rz_event_hook (anal->meta_spaces.event, R_SPACE_EVENT_COUNT, meta_count_for, NULL);
rz_event_hook (anal->meta_spaces.event, RZ_SPACE_EVENT_UNSET, meta_unset_for, NULL);
rz_event_hook (anal->meta_spaces.event, RZ_SPACE_EVENT_COUNT, meta_count_for, NULL);
rz_spaces_init (&anal->zign_spaces, "zs");
rz_event_hook (anal->zign_spaces.event, R_SPACE_EVENT_UNSET, zign_unset_for, NULL);
rz_event_hook (anal->zign_spaces.event, R_SPACE_EVENT_COUNT, zign_count_for, NULL);
rz_event_hook (anal->zign_spaces.event, R_SPACE_EVENT_RENAME, zign_rename_for, NULL);
rz_event_hook (anal->zign_spaces.event, RZ_SPACE_EVENT_UNSET, zign_unset_for, NULL);
rz_event_hook (anal->zign_spaces.event, RZ_SPACE_EVENT_COUNT, zign_count_for, NULL);
rz_event_hook (anal->zign_spaces.event, RZ_SPACE_EVENT_RENAME, zign_rename_for, NULL);
rz_anal_hint_storage_init (anal);
rz_interval_tree_init (&anal->meta, rz_meta_item_free);
anal->sdb_types = sdb_ns (anal->sdb, "types", 1);
@@ -118,8 +118,8 @@ RZ_API RzAnal *rz_anal_new(void) {
anal->cb_printf = (PrintfCallback) printf;
(void)rz_anal_pin_init (anal);
(void)rz_anal_xrefs_init (anal);
anal->diff_thbb = R_ANAL_THRESHOLDBB;
anal->diff_thfcn = R_ANAL_THRESHOLDFCN;
anal->diff_thbb = RZ_ANAL_THRESHOLDBB;
anal->diff_thfcn = RZ_ANAL_THRESHOLDFCN;
anal->syscall = rz_syscall_new ();
rz_io_bind_init (anal->iob);
rz_flag_bind_init (anal->flb);
@@ -243,10 +243,10 @@ RZ_API bool rz_anal_set_reg_profile(RzAnal *anal) {
RZ_API bool rz_anal_set_triplet(RzAnal *anal, const char *os, const char *arch, int bits) {
rz_return_val_if_fail (anal, false);
if (!os || !*os) {
os = R_SYS_OS;
os = RZ_SYS_OS;
}
if (!arch || !*arch) {
arch = anal->cur? anal->cur->arch: R_SYS_ARCH;
arch = anal->cur? anal->cur->arch: RZ_SYS_ARCH;
}
if (bits < 1) {
bits = anal->bits;
@@ -268,7 +268,7 @@ static void sdb_concat_by_path(Sdb *s, const char *path) {
RZ_API bool rz_anal_set_os(RzAnal *anal, const char *os) {
Sdb *types = anal->sdb_types;
const char *dir_prefix = rz_sys_prefix (NULL);
const char *dbpath = sdb_fmt (R_JOIN_3_PATHS ("%s", R2_SDB_FCNSIGN, "types-%s.sdb"),
const char *dbpath = sdb_fmt (RZ_JOIN_3_PATHS ("%s", RZ_SDB_FCNSIGN, "types-%s.sdb"),
dir_prefix, os);
if (rz_file_exists (dbpath)) {
sdb_concat_by_path (types, dbpath);
@@ -295,7 +295,7 @@ RZ_API bool rz_anal_set_bits(RzAnal *anal, int bits) {
RZ_API void rz_anal_set_cpu(RzAnal *anal, const char *cpu) {
free (anal->cpu);
anal->cpu = cpu ? strdup (cpu) : NULL;
int v = rz_anal_archinfo (anal, R_ANAL_ARCHINFO_ALIGN);
int v = rz_anal_archinfo (anal, RZ_ANAL_ARCHINFO_ALIGN);
if (v != -1) {
anal->pcalign = v;
}
@@ -332,7 +332,7 @@ RZ_API ut8 *rz_anal_mask(RzAnal *anal, int size, const ut8 *data, ut64 at) {
memset (ret, 0xff, size);
while (idx < size) {
if ((oplen = rz_anal_op (anal, op, at, data + idx, size - idx, R_ANAL_OP_MASK_BASIC)) < 1) {
if ((oplen = rz_anal_op (anal, op, at, data + idx, size - idx, RZ_ANAL_OP_MASK_BASIC)) < 1) {
break;
}
if ((op->ptr != UT64_MAX || op->jump != UT64_MAX) && op->nopcode != 0) {
@@ -377,7 +377,7 @@ RZ_API RzList* rz_anal_get_fcns (RzAnal *anal) {
}
RZ_API RzAnalOp *rz_anal_op_hexstr(RzAnal *anal, ut64 addr, const char *str) {
RzAnalOp *op = R_NEW0 (RzAnalOp);
RzAnalOp *op = RZ_NEW0 (RzAnalOp);
if (!op) {
return NULL;
}
@@ -387,7 +387,7 @@ RZ_API RzAnalOp *rz_anal_op_hexstr(RzAnal *anal, ut64 addr, const char *str) {
return NULL;
}
int len = rz_hex_str2bin (str, buf);
rz_anal_op (anal, op, addr, buf, len, R_ANAL_OP_MASK_BASIC);
rz_anal_op (anal, op, addr, buf, len, RZ_ANAL_OP_MASK_BASIC);
free (buf);
return op;
}
@@ -397,14 +397,14 @@ RZ_API bool rz_anal_op_is_eob(RzAnalOp *op) {
return true;
}
switch (op->type) {
case R_ANAL_OP_TYPE_JMP:
case R_ANAL_OP_TYPE_UJMP:
case R_ANAL_OP_TYPE_RJMP:
case R_ANAL_OP_TYPE_IJMP:
case R_ANAL_OP_TYPE_IRJMP:
case R_ANAL_OP_TYPE_CJMP:
case R_ANAL_OP_TYPE_RET:
case R_ANAL_OP_TYPE_TRAP:
case RZ_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_UJMP:
case RZ_ANAL_OP_TYPE_RJMP:
case RZ_ANAL_OP_TYPE_IJMP:
case RZ_ANAL_OP_TYPE_IRJMP:
case RZ_ANAL_OP_TYPE_CJMP:
case RZ_ANAL_OP_TYPE_RET:
case RZ_ANAL_OP_TYPE_TRAP:
return true;
default:
return false;
@@ -430,9 +430,9 @@ RZ_API void rz_anal_purge(RzAnal *anal) {
RZ_API int rz_anal_archinfo(RzAnal *anal, int query) {
rz_return_val_if_fail (anal, -1);
switch (query) {
case R_ANAL_ARCHINFO_MIN_OP_SIZE:
case R_ANAL_ARCHINFO_MAX_OP_SIZE:
case R_ANAL_ARCHINFO_ALIGN:
case RZ_ANAL_ARCHINFO_MIN_OP_SIZE:
case RZ_ANAL_ARCHINFO_MAX_OP_SIZE:
case RZ_ANAL_ARCHINFO_ALIGN:
if (anal->cur && anal->cur->archinfo) {
return anal->cur->archinfo (anal, query);
}
@@ -608,25 +608,25 @@ static bool noreturn_recurse(RzAnal *anal, ut64 addr) {
eprintf ("Couldn't read buffer\n");
return false;
}
if (rz_anal_op (anal, &op, addr, bbuf, sizeof (bbuf), R_ANAL_OP_MASK_BASIC | R_ANAL_OP_MASK_VAL) < 1) {
if (rz_anal_op (anal, &op, addr, bbuf, sizeof (bbuf), RZ_ANAL_OP_MASK_BASIC | RZ_ANAL_OP_MASK_VAL) < 1) {
return false;
}
switch (op.type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_JMP:
switch (op.type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_JMP:
if (op.jump == UT64_MAX) {
recurse_addr = op.ptr;
} else {
recurse_addr = op.jump;
}
break;
case R_ANAL_OP_TYPE_UCALL:
case R_ANAL_OP_TYPE_RCALL:
case R_ANAL_OP_TYPE_ICALL:
case R_ANAL_OP_TYPE_IRCALL:
case RZ_ANAL_OP_TYPE_UCALL:
case RZ_ANAL_OP_TYPE_RCALL:
case RZ_ANAL_OP_TYPE_ICALL:
case RZ_ANAL_OP_TYPE_IRCALL:
recurse_addr = op.ptr;
break;
case R_ANAL_OP_TYPE_CCALL:
case R_ANAL_OP_TYPE_CALL:
case RZ_ANAL_OP_TYPE_CCALL:
case RZ_ANAL_OP_TYPE_CALL:
recurse_addr = op.jump;
break;
}
+2 -2
View File
@@ -5,7 +5,7 @@
void meta_gb_bankswitch_cmt(RzAnal *a, ut64 addr, ut16 ldarg) {
if(0x1fff <ldarg && ldarg < 0x4000 && addr < 0x4000)
rz_meta_set_string (a, R_META_TYPE_COMMENT, addr, "Bankswitch");
rz_meta_set_string (a, RZ_META_TYPE_COMMENT, addr, "Bankswitch");
if(0x6000 > ldarg && ldarg > 0x3fff)
rz_meta_set_string(a, R_META_TYPE_COMMENT, addr, "Ramswitch");
rz_meta_set_string(a, RZ_META_TYPE_COMMENT, addr, "Ramswitch");
}
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,5 +1,5 @@
#ifndef R_BASE_TYPES_H
#define R_BASE_TYPES_H
#ifndef RZ_BASE_TYPES_H
#define RZ_BASE_TYPES_H
#include "rz_util.h"
@@ -7,9 +7,9 @@
extern "C" {
#endif
R_IPI void enum_type_case_free(void *e, void *user);
R_IPI void struct_type_member_free(void *e, void *user);
R_IPI void union_type_member_free(void *e, void *user);
RZ_IPI void enum_type_case_free(void *e, void *user);
RZ_IPI void struct_type_member_free(void *e, void *user);
RZ_IPI void union_type_member_free(void *e, void *user);
#ifdef __cplusplus
}
+5 -5
View File
@@ -43,7 +43,7 @@ RZ_API void rz_anal_block_ref(RzAnalBlock *bb) {
#define DFLT_NINSTR 3
static RzAnalBlock *block_new(RzAnal *a, ut64 addr, ut64 size) {
RzAnalBlock *block = R_NEW0 (RzAnalBlock);
RzAnalBlock *block = RZ_NEW0 (RzAnalBlock);
if (!block) {
return NULL;
}
@@ -53,7 +53,7 @@ static RzAnalBlock *block_new(RzAnal *a, ut64 addr, ut64 size) {
block->ref = 1;
block->jump = UT64_MAX;
block->fail = UT64_MAX;
block->op_pos = R_NEWS0 (ut16, DFLT_NINSTR);
block->op_pos = RZ_NEWS0 (ut16, DFLT_NINSTR);
block->op_pos_size = DFLT_NINSTR;
block->stackptr = 0;
block->parent_stackptr = INT_MAX;
@@ -471,7 +471,7 @@ typedef struct {
RzListIter *switch_it;
} RecurseDepthFirstCtx;
RZ_API bool rz_anal_block_recurse_depth_first(RzAnalBlock *block, RzAnalBlockCb cb, R_NULLABLE RzAnalBlockCb on_exit, void *user) {
RZ_API bool rz_anal_block_recurse_depth_first(RzAnalBlock *block, RzAnalBlockCb cb, RZ_NULLABLE RzAnalBlockCb on_exit, void *user) {
bool breaked = false;
HtUP *visited = ht_up_new0 ();
if (!visited) {
@@ -596,7 +596,7 @@ static bool shortest_path_successor_cb(ut64 addr, void *user) {
}
RZ_API R_NULLABLE RzList/*<RzAnalBlock *>*/ *rz_anal_block_shortest_path(RzAnalBlock *block, ut64 dst) {
RZ_API RZ_NULLABLE RzList/*<RzAnalBlock *>*/ *rz_anal_block_shortest_path(RzAnalBlock *block, ut64 dst) {
RzList *ret = NULL;
PathContext ctx;
ctx.anal = block->anal;
@@ -667,7 +667,7 @@ static void noreturn_successor_free(HtUPKv *kv) {
static bool noreturn_successors_cb(RzAnalBlock *block, void *user) {
HtUP *succs = user;
NoreturnSuccessor *succ = R_NEW0 (NoreturnSuccessor);
NoreturnSuccessor *succ = RZ_NEW0 (NoreturnSuccessor);
if (!succ) {
return false;
}
+3 -3
View File
@@ -11,7 +11,7 @@ RZ_API void rz_anal_cc_del(RzAnal *anal, const char *name) {
sdb_unset (DB, rz_strbuf_initf (&sb, "%s", name), 0);
sdb_unset (DB, rz_strbuf_setf (&sb, "cc.%s.ret", name), 0);
sdb_unset (DB, rz_strbuf_setf (&sb, "cc.%s.argn", name), 0);
for (i = 0; i < R_ANAL_CC_MAXARG; i++) {
for (i = 0; i < RZ_ANAL_CC_MAXARG; i++) {
sdb_unset (DB, rz_strbuf_setf (&sb, "cc.%s.arg%d", name, i), 0);
}
sdb_unset (DB, rz_strbuf_setf (&sb, "cc.%s.self", name), 0);
@@ -84,7 +84,7 @@ RZ_API char *rz_anal_cc_get(RzAnal *anal, const char *name) {
const char *self = rz_anal_cc_self (anal, name);
rz_strbuf_appendf (sb, "%s %s%s%s (", ret, self? self: "", self? ".": "", name);
bool isFirst = true;
for (i = 0; i < R_ANAL_CC_MAXARG; i++) {
for (i = 0; i < RZ_ANAL_CC_MAXARG; i++) {
const char *k = sdb_fmt ("cc.%s.arg%d", name, i);
const char *arg = sdb_const_get (DB, k, 0);
if (!arg) {
@@ -174,7 +174,7 @@ RZ_API int rz_anal_cc_max_arg(RzAnal *anal, const char *cc) {
oldDB = DB;
free (oldCC);
oldCC = strdup (cc);
for (i = 0; i < R_ANAL_CC_MAXARG; i++) {
for (i = 0; i < RZ_ANAL_CC_MAXARG; i++) {
const char *query = sdb_fmt ("cc.%s.arg%d", cc, i);
const char *res = sdb_const_get (DB, query, 0);
if (!res) {
+86 -86
View File
@@ -33,18 +33,18 @@ static char *key_attr_content_specific(const char *class_name, const char *attr_
}
typedef enum {
R_ANAL_CLASS_ATTR_TYPE_METHOD,
R_ANAL_CLASS_ATTR_TYPE_VTABLE,
R_ANAL_CLASS_ATTR_TYPE_BASE
RZ_ANAL_CLASS_ATTR_TYPE_METHOD,
RZ_ANAL_CLASS_ATTR_TYPE_VTABLE,
RZ_ANAL_CLASS_ATTR_TYPE_BASE
} RzAnalClassAttrType;
static const char *attr_type_id(RzAnalClassAttrType attr_type) {
switch (attr_type) {
case R_ANAL_CLASS_ATTR_TYPE_METHOD:
case RZ_ANAL_CLASS_ATTR_TYPE_METHOD:
return "method";
case R_ANAL_CLASS_ATTR_TYPE_VTABLE:
case RZ_ANAL_CLASS_ATTR_TYPE_VTABLE:
return "vtable";
case R_ANAL_CLASS_ATTR_TYPE_BASE:
case RZ_ANAL_CLASS_ATTR_TYPE_BASE:
return "base";
default:
return NULL;
@@ -62,7 +62,7 @@ RZ_API void rz_anal_class_create(RzAnal *anal, const char *name) {
}
REventClass event = { .name = name_sanitized };
rz_event_send (anal->ev, R_EVENT_CLASS_NEW, &event);
rz_event_send (anal->ev, RZ_EVENT_CLASS_NEW, &event);
free (name_sanitized);
}
@@ -109,7 +109,7 @@ RZ_API void rz_anal_class_delete(RzAnal *anal, const char *name) {
sdb_remove (anal->sdb_classes_attrs, key_attr_types (class_name_sanitized), 0);
REventClass event = { .name = class_name_sanitized };
rz_event_send (anal->ev, R_EVENT_CLASS_DEL, &event);
rz_event_send (anal->ev, RZ_EVENT_CLASS_DEL, &event);
free (class_name_sanitized);
}
@@ -149,27 +149,27 @@ static bool rename_key(Sdb *sdb, const char *key_old, const char *key_new) {
RZ_API RzAnalClassErr rz_anal_class_rename(RzAnal *anal, const char *old_name, const char *new_name) {
if (rz_anal_class_exists (anal, new_name)) {
return R_ANAL_CLASS_ERR_CLASH;
return RZ_ANAL_CLASS_ERR_CLASH;
}
char *old_name_sanitized = rz_str_sanitize_sdb_key (old_name);
if (!old_name_sanitized) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
char *new_name_sanitized = rz_str_sanitize_sdb_key (new_name);
if (!new_name_sanitized) {
free (old_name_sanitized);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
RzAnalClassErr err = R_ANAL_CLASS_ERR_SUCCESS;
RzAnalClassErr err = RZ_ANAL_CLASS_ERR_SUCCESS;
rz_anal_class_base_rename_class (anal, old_name, new_name);
rz_anal_class_method_rename_class (anal, old_name, new_name);
rz_anal_class_vtable_rename_class (anal, old_name, new_name);
if (!rename_key (anal->sdb_classes, key_class (old_name_sanitized), key_class (new_name_sanitized))) {
err = R_ANAL_CLASS_ERR_NONEXISTENT_CLASS;
err = RZ_ANAL_CLASS_ERR_NONEXISTENT_CLASS;
goto beach;
}
@@ -198,7 +198,7 @@ RZ_API RzAnalClassErr rz_anal_class_rename(RzAnal *anal, const char *old_name, c
.name_old = old_name_sanitized,
.name_new = new_name_sanitized
};
rz_event_send (anal->ev, R_EVENT_CLASS_RENAME, &event);
rz_event_send (anal->ev, RZ_EVENT_CLASS_RENAME, &event);
beach:
free (old_name_sanitized);
@@ -241,7 +241,7 @@ static RzAnalClassErr rz_anal_class_set_attr_raw(RzAnal *anal, const char *class
const char *attr_type_str = attr_type_id (attr_type);
if (!rz_anal_class_exists_raw (anal, class_name)) {
return R_ANAL_CLASS_ERR_NONEXISTENT_CLASS;
return RZ_ANAL_CLASS_ERR_NONEXISTENT_CLASS;
}
sdb_array_add (anal->sdb_classes_attrs, key_attr_types (class_name), attr_type_str, 0);
@@ -256,22 +256,22 @@ static RzAnalClassErr rz_anal_class_set_attr_raw(RzAnal *anal, const char *class
},
.content = content
};
rz_event_send (anal->ev, R_EVENT_CLASS_ATTR_SET, &event);
rz_event_send (anal->ev, RZ_EVENT_CLASS_ATTR_SET, &event);
return R_ANAL_CLASS_ERR_SUCCESS;
return RZ_ANAL_CLASS_ERR_SUCCESS;
}
// ids will be sanitized automatically
static RzAnalClassErr rz_anal_class_set_attr(RzAnal *anal, const char *class_name, RzAnalClassAttrType attr_type, const char *attr_id, const char *content) {
char *class_name_sanitized = rz_str_sanitize_sdb_key (class_name);
if (!class_name_sanitized) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
char *attr_id_sanitized = rz_str_sanitize_sdb_key (attr_id);
if (!attr_id_sanitized) {
free (class_name_sanitized);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
RzAnalClassErr err = rz_anal_class_set_attr_raw (anal, class_name_sanitized, attr_type, attr_id_sanitized, content);
@@ -301,21 +301,21 @@ static RzAnalClassErr rz_anal_class_delete_attr_raw(RzAnal *anal, const char *cl
.attr_type = attr_type,
.attr_id = attr_id
};
rz_event_send (anal->ev, R_EVENT_CLASS_ATTR_DEL, &event);
rz_event_send (anal->ev, RZ_EVENT_CLASS_ATTR_DEL, &event);
return R_ANAL_CLASS_ERR_SUCCESS;
return RZ_ANAL_CLASS_ERR_SUCCESS;
}
static RzAnalClassErr rz_anal_class_delete_attr(RzAnal *anal, const char *class_name, RzAnalClassAttrType attr_type, const char *attr_id) {
char *class_name_sanitized = rz_str_sanitize_sdb_key (class_name);
if (!class_name_sanitized) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
char *attr_id_sanitized = rz_str_sanitize_sdb_key (attr_id);
if (!attr_id_sanitized) {
free (class_name_sanitized);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
RzAnalClassErr err = rz_anal_class_delete_attr_raw (anal, class_name_sanitized, attr_type, attr_id_sanitized);
@@ -330,11 +330,11 @@ static RzAnalClassErr rz_anal_class_rename_attr_raw(RzAnal *anal, const char *cl
char *key = key_attr_type_attrs (class_name, attr_type_str);
if (sdb_array_contains (anal->sdb_classes_attrs, key, attr_id_new, 0)) {
return R_ANAL_CLASS_ERR_CLASH;
return RZ_ANAL_CLASS_ERR_CLASH;
}
if (!sdb_array_remove (anal->sdb_classes_attrs, key, attr_id_old, 0)) {
return R_ANAL_CLASS_ERR_NONEXISTENT_ATTR;
return RZ_ANAL_CLASS_ERR_NONEXISTENT_ATTR;
}
sdb_array_add (anal->sdb_classes_attrs, key, attr_id_new, 0);
@@ -365,26 +365,26 @@ static RzAnalClassErr rz_anal_class_rename_attr_raw(RzAnal *anal, const char *cl
},
.attr_id_new = attr_id_new
};
rz_event_send (anal->ev, R_EVENT_CLASS_ATTR_RENAME, &event);
rz_event_send (anal->ev, RZ_EVENT_CLASS_ATTR_RENAME, &event);
return R_ANAL_CLASS_ERR_SUCCESS;
return RZ_ANAL_CLASS_ERR_SUCCESS;
}
static RzAnalClassErr rz_anal_class_rename_attr(RzAnal *anal, const char *class_name, RzAnalClassAttrType attr_type, const char *attr_id_old, const char *attr_id_new) {
char *class_name_sanitized = rz_str_sanitize_sdb_key (class_name);
if (!class_name_sanitized) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
char *attr_id_old_sanitized = rz_str_sanitize_sdb_key (attr_id_old);
if (!attr_id_old_sanitized) {
free (class_name_sanitized);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
char *attr_id_new_sanitized = rz_str_sanitize_sdb_key (attr_id_new);
if (!attr_id_new_sanitized) {
free (class_name_sanitized);
free (attr_id_old_sanitized);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
RzAnalClassErr ret = rz_anal_class_rename_attr_raw (anal, class_name_sanitized, attr_type, attr_id_old_sanitized, attr_id_new_sanitized);
free (class_name_sanitized);
@@ -452,7 +452,7 @@ static RzAnalClassErr rz_anal_class_add_attr_unique_raw(RzAnal *anal, const char
rz_anal_class_unique_attr_id_raw (anal, class_name, attr_type, attr_id, sizeof(attr_id));
RzAnalClassErr err = rz_anal_class_set_attr (anal, class_name, attr_type, attr_id, content);
if (err != R_ANAL_CLASS_ERR_SUCCESS) {
if (err != RZ_ANAL_CLASS_ERR_SUCCESS) {
return err;
}
@@ -460,13 +460,13 @@ static RzAnalClassErr rz_anal_class_add_attr_unique_raw(RzAnal *anal, const char
rz_str_ncpy (attr_id_out, attr_id, attr_id_out_size);
}
return R_ANAL_CLASS_ERR_SUCCESS;
return RZ_ANAL_CLASS_ERR_SUCCESS;
}
static RzAnalClassErr rz_anal_class_add_attr_unique(RzAnal *anal, const char *class_name, RzAnalClassAttrType attr_type, const char *content, char *attr_id_out, size_t attr_id_out_size) {
char *class_name_sanitized = rz_str_sanitize_sdb_key (class_name);
if (!class_name_sanitized) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
RzAnalClassErr err = rz_anal_class_add_attr_unique_raw (anal, class_name_sanitized, attr_type, content, attr_id_out, attr_id_out_size);
@@ -487,12 +487,12 @@ RZ_API void rz_anal_class_method_fini(RzAnalMethod *meth) {
free (meth->name);
}
// if the method exists: store it in *meth and return R_ANAL_CLASS_ERR_SUCCESS
// if the method exists: store it in *meth and return RZ_ANAL_CLASS_ERR_SUCCESS
// else return the error, contents of *meth are undefined
RZ_API RzAnalClassErr rz_anal_class_method_get(RzAnal *anal, const char *class_name, const char *meth_name, RzAnalMethod *meth) {
char *content = rz_anal_class_get_attr (anal, class_name, R_ANAL_CLASS_ATTR_TYPE_METHOD, meth_name, false);
char *content = rz_anal_class_get_attr (anal, class_name, RZ_ANAL_CLASS_ATTR_TYPE_METHOD, meth_name, false);
if (!content) {
return R_ANAL_CLASS_ERR_NONEXISTENT_ATTR;
return RZ_ANAL_CLASS_ERR_NONEXISTENT_ATTR;
}
char *cur = content;
@@ -504,7 +504,7 @@ RZ_API RzAnalClassErr rz_anal_class_method_get(RzAnal *anal, const char *class_n
cur = next;
if (!cur) {
free (content);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
sdb_anext (cur, NULL);
@@ -514,10 +514,10 @@ RZ_API RzAnalClassErr rz_anal_class_method_get(RzAnal *anal, const char *class_n
meth->name = rz_str_sanitize_sdb_key (meth_name);
if (!meth->name) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
return R_ANAL_CLASS_ERR_SUCCESS;
return RZ_ANAL_CLASS_ERR_SUCCESS;
}
static void rz_anal_class_method_fini_proxy(void *e, void *user) {
@@ -537,14 +537,14 @@ RZ_API RzVector/*<RzAnalMethod>*/ *rz_anal_class_method_get_all(RzAnal *anal, co
rz_vector_free (vec);
return NULL;
}
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (class_name_sanitized, attr_type_id (R_ANAL_CLASS_ATTR_TYPE_METHOD)), 0);
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (class_name_sanitized, attr_type_id (RZ_ANAL_CLASS_ATTR_TYPE_METHOD)), 0);
free (class_name_sanitized);
rz_vector_reserve (vec, (size_t) sdb_alen (array));
char *cur;
sdb_aforeach (cur, array) {
RzAnalMethod meth;
if (rz_anal_class_method_get (anal, class_name, cur, &meth) == R_ANAL_CLASS_ERR_SUCCESS) {
if (rz_anal_class_method_get (anal, class_name, cur, &meth) == RZ_ANAL_CLASS_ERR_SUCCESS) {
rz_vector_push (vec, &meth);
}
sdb_aforeach_next (cur);
@@ -556,27 +556,27 @@ RZ_API RzVector/*<RzAnalMethod>*/ *rz_anal_class_method_get_all(RzAnal *anal, co
RZ_API RzAnalClassErr rz_anal_class_method_set(RzAnal *anal, const char *class_name, RzAnalMethod *meth) {
char *content = sdb_fmt ("%"PFMT64u"%c%d", meth->addr, SDB_RS, meth->vtable_offset);
RzAnalClassErr err = rz_anal_class_set_attr (anal, class_name, R_ANAL_CLASS_ATTR_TYPE_METHOD, meth->name, content);
if (err != R_ANAL_CLASS_ERR_SUCCESS) {
RzAnalClassErr err = rz_anal_class_set_attr (anal, class_name, RZ_ANAL_CLASS_ATTR_TYPE_METHOD, meth->name, content);
if (err != RZ_ANAL_CLASS_ERR_SUCCESS) {
return err;
}
rz_anal_class_set_flag (anal, flagname_method (class_name, meth->name), meth->addr, 0);
return R_ANAL_CLASS_ERR_SUCCESS;
return RZ_ANAL_CLASS_ERR_SUCCESS;
}
RZ_API RzAnalClassErr rz_anal_class_method_rename(RzAnal *anal, const char *class_name, const char *old_meth_name, const char *new_meth_name) {
RzAnalClassErr err = rz_anal_class_rename_attr (anal, class_name, R_ANAL_CLASS_ATTR_TYPE_METHOD, old_meth_name, new_meth_name);
if (err != R_ANAL_CLASS_ERR_SUCCESS) {
RzAnalClassErr err = rz_anal_class_rename_attr (anal, class_name, RZ_ANAL_CLASS_ATTR_TYPE_METHOD, old_meth_name, new_meth_name);
if (err != RZ_ANAL_CLASS_ERR_SUCCESS) {
return err;
}
rz_anal_class_rename_flag (anal,
flagname_method (class_name, old_meth_name),
flagname_method (class_name, new_meth_name));
return R_ANAL_CLASS_ERR_SUCCESS;
return RZ_ANAL_CLASS_ERR_SUCCESS;
}
static void rz_anal_class_method_rename_class(RzAnal *anal, const char *old_class_name, const char *new_class_name) {
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (old_class_name, attr_type_id (R_ANAL_CLASS_ATTR_TYPE_METHOD)), 0);
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (old_class_name, attr_type_id (RZ_ANAL_CLASS_ATTR_TYPE_METHOD)), 0);
if (!array) {
return;
}
@@ -591,7 +591,7 @@ static void rz_anal_class_method_rename_class(RzAnal *anal, const char *old_clas
}
static void rz_anal_class_method_delete_class(RzAnal *anal, const char *class_name) {
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (class_name, attr_type_id (R_ANAL_CLASS_ATTR_TYPE_METHOD)), 0);
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (class_name, attr_type_id (RZ_ANAL_CLASS_ATTR_TYPE_METHOD)), 0);
if (!array) {
return;
}
@@ -606,15 +606,15 @@ static void rz_anal_class_method_delete_class(RzAnal *anal, const char *class_na
RZ_API RzAnalClassErr rz_anal_class_method_delete(RzAnal *anal, const char *class_name, const char *meth_name) {
char *class_name_sanitized = rz_str_sanitize_sdb_key (class_name);
if (!class_name_sanitized) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
char *meth_name_sanitized = rz_str_sanitize_sdb_key (meth_name);
if (!meth_name_sanitized) {
free (class_name_sanitized);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
RzAnalClassErr err = rz_anal_class_delete_attr_raw (anal, class_name_sanitized, R_ANAL_CLASS_ATTR_TYPE_METHOD, meth_name_sanitized);
if (err == R_ANAL_CLASS_ERR_SUCCESS) {
RzAnalClassErr err = rz_anal_class_delete_attr_raw (anal, class_name_sanitized, RZ_ANAL_CLASS_ATTR_TYPE_METHOD, meth_name_sanitized);
if (err == RZ_ANAL_CLASS_ERR_SUCCESS) {
rz_anal_class_unset_flag (anal, flagname_method (class_name_sanitized, meth_name_sanitized));
}
free (class_name_sanitized);
@@ -631,9 +631,9 @@ RZ_API void rz_anal_class_base_fini(RzAnalBaseClass *base) {
}
RZ_API RzAnalClassErr rz_anal_class_base_get(RzAnal *anal, const char *class_name, const char *base_id, RzAnalBaseClass *base) {
char *content = rz_anal_class_get_attr (anal, class_name, R_ANAL_CLASS_ATTR_TYPE_BASE, base_id, false);
char *content = rz_anal_class_get_attr (anal, class_name, RZ_ANAL_CLASS_ATTR_TYPE_BASE, base_id, false);
if (!content) {
return R_ANAL_CLASS_ERR_NONEXISTENT_ATTR;
return RZ_ANAL_CLASS_ERR_NONEXISTENT_ATTR;
}
char *cur = content;
@@ -643,14 +643,14 @@ RZ_API RzAnalClassErr rz_anal_class_base_get(RzAnal *anal, const char *class_nam
base->class_name = strdup (cur);
if (!base->class_name) {
free (content);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
cur = next;
if (!cur) {
free (content);
free (base->class_name);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
sdb_anext (cur, NULL);
@@ -661,10 +661,10 @@ RZ_API RzAnalClassErr rz_anal_class_base_get(RzAnal *anal, const char *class_nam
base->id = rz_str_sanitize_sdb_key (base_id);
if (!base->id) {
free (base->class_name);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
return R_ANAL_CLASS_ERR_SUCCESS;
return RZ_ANAL_CLASS_ERR_SUCCESS;
}
static void rz_anal_class_base_fini_proxy(void *e, void *user) {
@@ -684,14 +684,14 @@ RZ_API RzVector/*<RzAnalBaseClass>*/ *rz_anal_class_base_get_all(RzAnal *anal, c
rz_vector_free (vec);
return NULL;
}
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (class_name_sanitized, attr_type_id (R_ANAL_CLASS_ATTR_TYPE_BASE)), 0);
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (class_name_sanitized, attr_type_id (RZ_ANAL_CLASS_ATTR_TYPE_BASE)), 0);
free (class_name_sanitized);
rz_vector_reserve (vec, (size_t) sdb_alen (array));
char *cur;
sdb_aforeach (cur, array) {
RzAnalBaseClass base;
if (rz_anal_class_base_get (anal, class_name, cur, &base) == R_ANAL_CLASS_ERR_SUCCESS) {
if (rz_anal_class_base_get (anal, class_name, cur, &base) == RZ_ANAL_CLASS_ERR_SUCCESS) {
rz_vector_push (vec, &base);
}
sdb_aforeach_next (cur);
@@ -705,13 +705,13 @@ static RzAnalClassErr rz_anal_class_base_set_raw(RzAnal *anal, const char *class
char *content = sdb_fmt ("%s" SDB_SS "%"PFMT64u, base_class_name_sanitized, base->offset);
RzAnalClassErr err;
if (base->id) {
err = rz_anal_class_set_attr (anal, class_name, R_ANAL_CLASS_ATTR_TYPE_BASE, base->id, content);
err = rz_anal_class_set_attr (anal, class_name, RZ_ANAL_CLASS_ATTR_TYPE_BASE, base->id, content);
} else {
base->id = malloc(16);
if (base->id) {
err = rz_anal_class_add_attr_unique (anal, class_name, R_ANAL_CLASS_ATTR_TYPE_BASE, content, base->id, 16);
err = rz_anal_class_add_attr_unique (anal, class_name, RZ_ANAL_CLASS_ATTR_TYPE_BASE, content, base->id, 16);
} else {
err = R_ANAL_CLASS_ERR_OTHER;
err = RZ_ANAL_CLASS_ERR_OTHER;
}
}
return err;
@@ -720,12 +720,12 @@ static RzAnalClassErr rz_anal_class_base_set_raw(RzAnal *anal, const char *class
RZ_API RzAnalClassErr rz_anal_class_base_set(RzAnal *anal, const char *class_name, RzAnalBaseClass *base) {
char *base_class_name_sanitized = rz_str_sanitize_sdb_key (base->class_name);
if (!base_class_name_sanitized) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
if (!rz_anal_class_exists_raw (anal, base_class_name_sanitized)) {
free (base_class_name_sanitized);
return R_ANAL_CLASS_ERR_NONEXISTENT_CLASS;
return RZ_ANAL_CLASS_ERR_NONEXISTENT_CLASS;
}
RzVector /*<RzAnalBaseClass>*/ *bases = rz_anal_class_base_get_all (anal, class_name);
if (bases) {
@@ -734,7 +734,7 @@ RZ_API RzAnalClassErr rz_anal_class_base_set(RzAnal *anal, const char *class_nam
if (!strcmp (existing_base->class_name, base->class_name)) {
free (base_class_name_sanitized);
rz_vector_free (bases);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
}
}
@@ -745,7 +745,7 @@ RZ_API RzAnalClassErr rz_anal_class_base_set(RzAnal *anal, const char *class_nam
}
RZ_API RzAnalClassErr rz_anal_class_base_delete(RzAnal *anal, const char *class_name, const char *base_id) {
return rz_anal_class_delete_attr (anal, class_name, R_ANAL_CLASS_ATTR_TYPE_BASE, base_id);
return rz_anal_class_delete_attr (anal, class_name, RZ_ANAL_CLASS_ATTR_TYPE_BASE, base_id);
}
typedef struct {
@@ -808,9 +808,9 @@ RZ_API void rz_anal_class_vtable_fini(RzAnalVTable *vtable) {
}
RZ_API RzAnalClassErr rz_anal_class_vtable_get(RzAnal *anal, const char *class_name, const char *vtable_id, RzAnalVTable *vtable) {
char *content = rz_anal_class_get_attr (anal, class_name, R_ANAL_CLASS_ATTR_TYPE_VTABLE, vtable_id, false);
char *content = rz_anal_class_get_attr (anal, class_name, RZ_ANAL_CLASS_ATTR_TYPE_VTABLE, vtable_id, false);
if (!content) {
return R_ANAL_CLASS_ERR_NONEXISTENT_ATTR;
return RZ_ANAL_CLASS_ERR_NONEXISTENT_ATTR;
}
char *cur = content;
@@ -822,7 +822,7 @@ RZ_API RzAnalClassErr rz_anal_class_vtable_get(RzAnal *anal, const char *class_n
cur = next;
if (!cur) {
free (content);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
sdb_anext (cur, &next);
@@ -840,10 +840,10 @@ RZ_API RzAnalClassErr rz_anal_class_vtable_get(RzAnal *anal, const char *class_n
vtable->id = rz_str_sanitize_sdb_key (vtable_id);
if (!vtable->id) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
return R_ANAL_CLASS_ERR_SUCCESS;
return RZ_ANAL_CLASS_ERR_SUCCESS;
}
static void rz_anal_class_vtable_fini_proxy(void *e, void *user) {
@@ -863,14 +863,14 @@ RZ_API RzVector/*<RzAnalVTable>*/ *rz_anal_class_vtable_get_all(RzAnal *anal, co
rz_vector_free (vec);
return NULL;
}
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (class_name_sanitized, attr_type_id (R_ANAL_CLASS_ATTR_TYPE_VTABLE)), 0);
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (class_name_sanitized, attr_type_id (RZ_ANAL_CLASS_ATTR_TYPE_VTABLE)), 0);
free (class_name_sanitized);
rz_vector_reserve (vec, (size_t) sdb_alen (array));
char *cur;
sdb_aforeach (cur, array) {
RzAnalVTable vtable;
if (rz_anal_class_vtable_get (anal, class_name, cur, &vtable) == R_ANAL_CLASS_ERR_SUCCESS) {
if (rz_anal_class_vtable_get (anal, class_name, cur, &vtable) == RZ_ANAL_CLASS_ERR_SUCCESS) {
rz_vector_push (vec, &vtable);
}
sdb_aforeach_next (cur);
@@ -883,24 +883,24 @@ RZ_API RzVector/*<RzAnalVTable>*/ *rz_anal_class_vtable_get_all(RzAnal *anal, co
RZ_API RzAnalClassErr rz_anal_class_vtable_set(RzAnal *anal, const char *class_name, RzAnalVTable *vtable) {
char *content = sdb_fmt ("0x%"PFMT64x SDB_SS "%"PFMT64u SDB_SS "%"PFMT64u, vtable->addr, vtable->offset, vtable->size);
if (vtable->id) {
return rz_anal_class_set_attr (anal, class_name, R_ANAL_CLASS_ATTR_TYPE_VTABLE, vtable->id, content);
return rz_anal_class_set_attr (anal, class_name, RZ_ANAL_CLASS_ATTR_TYPE_VTABLE, vtable->id, content);
}
vtable->id = malloc(16);
if (!vtable->id) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
RzAnalClassErr err = rz_anal_class_add_attr_unique (anal, class_name, R_ANAL_CLASS_ATTR_TYPE_VTABLE, content, vtable->id, 16);
if (err != R_ANAL_CLASS_ERR_SUCCESS) {
RzAnalClassErr err = rz_anal_class_add_attr_unique (anal, class_name, RZ_ANAL_CLASS_ATTR_TYPE_VTABLE, content, vtable->id, 16);
if (err != RZ_ANAL_CLASS_ERR_SUCCESS) {
return err;
}
rz_anal_class_set_flag (anal, flagname_vtable (class_name, vtable->id), vtable->addr, vtable->size);
return R_ANAL_CLASS_ERR_SUCCESS;
return RZ_ANAL_CLASS_ERR_SUCCESS;
}
static void rz_anal_class_vtable_rename_class(RzAnal *anal, const char *old_class_name, const char *new_class_name) {
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (old_class_name, attr_type_id (R_ANAL_CLASS_ATTR_TYPE_VTABLE)), 0);
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (old_class_name, attr_type_id (RZ_ANAL_CLASS_ATTR_TYPE_VTABLE)), 0);
if (!array) {
return;
}
@@ -915,7 +915,7 @@ static void rz_anal_class_vtable_rename_class(RzAnal *anal, const char *old_clas
}
static void rz_anal_class_vtable_delete_class(RzAnal *anal, const char *class_name) {
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (class_name, attr_type_id (R_ANAL_CLASS_ATTR_TYPE_VTABLE)), 0);
char *array = sdb_get (anal->sdb_classes_attrs, key_attr_type_attrs (class_name, attr_type_id (RZ_ANAL_CLASS_ATTR_TYPE_VTABLE)), 0);
if (!array) {
return;
}
@@ -930,15 +930,15 @@ static void rz_anal_class_vtable_delete_class(RzAnal *anal, const char *class_na
RZ_API RzAnalClassErr rz_anal_class_vtable_delete(RzAnal *anal, const char *class_name, const char *vtable_id) {
char *class_name_sanitized = rz_str_sanitize_sdb_key (class_name);
if (!class_name_sanitized) {
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
char *vtable_id_sanitized = rz_str_sanitize_sdb_key (vtable_id);
if (!vtable_id_sanitized) {
free (class_name_sanitized);
return R_ANAL_CLASS_ERR_OTHER;
return RZ_ANAL_CLASS_ERR_OTHER;
}
RzAnalClassErr err = rz_anal_class_delete_attr_raw (anal, class_name_sanitized, R_ANAL_CLASS_ATTR_TYPE_VTABLE, vtable_id_sanitized);
if (err == R_ANAL_CLASS_ERR_SUCCESS) {
RzAnalClassErr err = rz_anal_class_delete_attr_raw (anal, class_name_sanitized, RZ_ANAL_CLASS_ATTR_TYPE_VTABLE, vtable_id_sanitized);
if (err == RZ_ANAL_CLASS_ERR_SUCCESS) {
rz_anal_class_unset_flag (anal, flagname_vtable (class_name_sanitized, vtable_id_sanitized));
}
free (class_name_sanitized);
+32 -32
View File
@@ -4,28 +4,28 @@
RZ_API const char *rz_anal_cond_tostring(int cc) {
switch (cc) {
case R_ANAL_COND_EQ: return "eq";
case R_ANAL_COND_NV: return "nv";
case R_ANAL_COND_NE: return "ne";
case R_ANAL_COND_HS: return "hs";
case R_ANAL_COND_LO: return "lo";
case R_ANAL_COND_MI: return "mi";
case R_ANAL_COND_PL: return "pl";
case R_ANAL_COND_VS: return "vs";
case R_ANAL_COND_VC: return "vc";
case R_ANAL_COND_HI: return "hi";
case R_ANAL_COND_LS: return "ls";
case R_ANAL_COND_GE: return "ge";
case R_ANAL_COND_LT: return "lt";
case R_ANAL_COND_GT: return "gt";
case R_ANAL_COND_LE: return "le";
case R_ANAL_COND_AL: return "al";
case RZ_ANAL_COND_EQ: return "eq";
case RZ_ANAL_COND_NV: return "nv";
case RZ_ANAL_COND_NE: return "ne";
case RZ_ANAL_COND_HS: return "hs";
case RZ_ANAL_COND_LO: return "lo";
case RZ_ANAL_COND_MI: return "mi";
case RZ_ANAL_COND_PL: return "pl";
case RZ_ANAL_COND_VS: return "vs";
case RZ_ANAL_COND_VC: return "vc";
case RZ_ANAL_COND_HI: return "hi";
case RZ_ANAL_COND_LS: return "ls";
case RZ_ANAL_COND_GE: return "ge";
case RZ_ANAL_COND_LT: return "lt";
case RZ_ANAL_COND_GT: return "gt";
case RZ_ANAL_COND_LE: return "le";
case RZ_ANAL_COND_AL: return "al";
}
return "??";
}
RZ_API RzAnalCond *rz_anal_cond_new(void) {
return R_NEW0 (RzAnalCond);
return RZ_NEW0 (RzAnalCond);
}
RZ_API void rz_anal_cond_fini (RzAnalCond *c) {
@@ -47,7 +47,7 @@ RZ_API void rz_anal_cond_free (RzAnalCond *c) {
// XXX?
RZ_API RzAnalCond *rz_anal_cond_clone(RzAnalCond *cond) {
RzAnalCond *c = R_NEW (RzAnalCond);
RzAnalCond *c = RZ_NEW (RzAnalCond);
if (!c) {
return NULL;
}
@@ -74,21 +74,21 @@ RZ_API int rz_anal_cond_eval(RzAnal *anal, RzAnalCond *cond) {
if (cond->arg[1]) {
st64 arg1 = (st64) rz_anal_value_to_ut64 (anal, cond->arg[1]);
switch (cond->type) {
case R_ANAL_COND_EQ: return arg0 == arg1;
case R_ANAL_COND_NE: return arg0 != arg1;
case R_ANAL_COND_GE: return arg0 >= arg1;
case R_ANAL_COND_GT: return arg0 > arg1;
case R_ANAL_COND_LE: return arg0 <= arg1;
case R_ANAL_COND_LT: return arg0 < arg1;
case RZ_ANAL_COND_EQ: return arg0 == arg1;
case RZ_ANAL_COND_NE: return arg0 != arg1;
case RZ_ANAL_COND_GE: return arg0 >= arg1;
case RZ_ANAL_COND_GT: return arg0 > arg1;
case RZ_ANAL_COND_LE: return arg0 <= arg1;
case RZ_ANAL_COND_LT: return arg0 < arg1;
}
} else {
switch (cond->type) {
case R_ANAL_COND_EQ: return !arg0;
case R_ANAL_COND_NE: return arg0;
case R_ANAL_COND_GT: return arg0>0;
case R_ANAL_COND_GE: return arg0>=0;
case R_ANAL_COND_LT: return arg0<0;
case R_ANAL_COND_LE: return arg0<=0;
case RZ_ANAL_COND_EQ: return !arg0;
case RZ_ANAL_COND_NE: return arg0;
case RZ_ANAL_COND_GT: return arg0>0;
case RZ_ANAL_COND_GE: return arg0>=0;
case RZ_ANAL_COND_LT: return arg0<0;
case RZ_ANAL_COND_LE: return arg0<=0;
}
}
return false;
@@ -105,7 +105,7 @@ RZ_API char *rz_anal_cond_to_string(RzAnalCond *cond) {
val0 = rz_anal_value_to_string (cond->arg[0]);
val1 = rz_anal_value_to_string (cond->arg[1]);
if (val0) {
if (R_ANAL_COND_SINGLE (cond)) {
if (RZ_ANAL_COND_SINGLE (cond)) {
int val0len = strlen (val0) + 10;
if ((out = malloc (val0len))) {
snprintf (out, val0len, "%s%s", cnd, val0);
@@ -141,7 +141,7 @@ RZ_API RzAnalCond *rz_anal_cond_new_from_op(RzAnalOp *op) {
}
RZ_API RzAnalCond *rz_anal_cond_new_from_string(const char *str) {
RzAnalCond *cond = R_NEW (RzAnalCond);
RzAnalCond *cond = RZ_NEW (RzAnalCond);
// TODO: find '<','=','>','!'...
return cond;
}
+2 -2
View File
@@ -5,10 +5,10 @@
#include <rz_types.h>
RZ_API RzAnalCycleFrame *rz_anal_cycle_frame_new(void) {
RzAnalCycleFrame *cf = R_NEW0 (RzAnalCycleFrame);
RzAnalCycleFrame *cf = RZ_NEW0 (RzAnalCycleFrame);
if (cf) {
if (!(cf->hooks = rz_list_new ())) {
R_FREE (cf);
RZ_FREE (cf);
}
}
return cf;
+42 -42
View File
@@ -117,7 +117,7 @@ RZ_API char *rz_anal_data_to_string(RzAnalData *d, RzConsPrintablePalette *pal)
rz_strbuf_appendf (sb, "0x%08" PFMT64x " ", d->addr);
}
n32 = (ut32)d->ptr;
len = R_MIN (d->len, 8);
len = RZ_MIN (d->len, 8);
for (i = 0; i < len; i++) {
rz_strbuf_appendf (sb, "%02x", d->buf[i]);
}
@@ -126,17 +126,17 @@ RZ_API char *rz_anal_data_to_string(RzAnalData *d, RzConsPrintablePalette *pal)
}
rz_strbuf_append (sb, " ");
switch (d->type) {
case R_ANAL_DATA_TYPE_STRING:
case RZ_ANAL_DATA_TYPE_STRING:
if (pal) {
rz_strbuf_appendf (sb, "%sstring \"%s\""Color_RESET, pal->comment, d->str);
} else {
rz_strbuf_appendf (sb, "string \"%s\"", d->str);
}
break;
case R_ANAL_DATA_TYPE_WIDE_STRING:
case RZ_ANAL_DATA_TYPE_WIDE_STRING:
rz_strbuf_append (sb, "wide string");
break;
case R_ANAL_DATA_TYPE_NUMBER:
case RZ_ANAL_DATA_TYPE_NUMBER:
if (pal) {
const char *k = pal->num;
if (n32 == d->ptr) {
@@ -154,7 +154,7 @@ RZ_API char *rz_anal_data_to_string(RzAnalData *d, RzConsPrintablePalette *pal)
}
}
break;
case R_ANAL_DATA_TYPE_POINTER:
case RZ_ANAL_DATA_TYPE_POINTER:
rz_strbuf_append (sb, "pointer ");
if (pal) {
const char *k = pal->offset;
@@ -163,23 +163,23 @@ RZ_API char *rz_anal_data_to_string(RzAnalData *d, RzConsPrintablePalette *pal)
rz_strbuf_appendf (sb, " 0x%08" PFMT64x, d->ptr);
}
break;
case R_ANAL_DATA_TYPE_INVALID:
case RZ_ANAL_DATA_TYPE_INVALID:
if (pal) {
rz_strbuf_appendf (sb, "%sinvalid"Color_RESET, pal->invalid);
} else {
rz_strbuf_append (sb, "invalid");
}
break;
case R_ANAL_DATA_TYPE_HEADER:
case RZ_ANAL_DATA_TYPE_HEADER:
rz_strbuf_append (sb, "header");
break;
case R_ANAL_DATA_TYPE_SEQUENCE:
case RZ_ANAL_DATA_TYPE_SEQUENCE:
rz_strbuf_append (sb, "sequence");
break;
case R_ANAL_DATA_TYPE_PATTERN:
case RZ_ANAL_DATA_TYPE_PATTERN:
rz_strbuf_append (sb, "pattern");
break;
case R_ANAL_DATA_TYPE_UNKNOWN:
case RZ_ANAL_DATA_TYPE_UNKNOWN:
if (pal) {
rz_strbuf_appendf (sb, "%sunknown"Color_RESET, pal->invalid);
} else {
@@ -198,7 +198,7 @@ RZ_API char *rz_anal_data_to_string(RzAnalData *d, RzConsPrintablePalette *pal)
}
RZ_API RzAnalData *rz_anal_data_new_string(ut64 addr, const char *p, int len, int type) {
RzAnalData *ad = R_NEW0 (RzAnalData);
RzAnalData *ad = RZ_NEW0 (RzAnalData);
if (!ad) {
return NULL;
}
@@ -209,7 +209,7 @@ RZ_API RzAnalData *rz_anal_data_new_string(ut64 addr, const char *p, int len, in
len = strlen (p);
}
if (type == R_ANAL_DATA_TYPE_WIDE_STRING) {
if (type == RZ_ANAL_DATA_TYPE_WIDE_STRING) {
/* TODO: add support for wide strings */
} else {
ad->str = malloc (len + 1);
@@ -233,8 +233,8 @@ RZ_API RzAnalData *rz_anal_data_new_string(ut64 addr, const char *p, int len, in
}
RZ_API RzAnalData *rz_anal_data_new(ut64 addr, int type, ut64 n, const ut8 *buf, int len) {
RzAnalData *ad = R_NEW0 (RzAnalData);
int l = R_MIN (len, 8);
RzAnalData *ad = RZ_NEW0 (RzAnalData);
int l = RZ_MIN (len, 8);
if (!ad) {
return NULL;
}
@@ -251,8 +251,8 @@ RZ_API RzAnalData *rz_anal_data_new(ut64 addr, int type, ut64 n, const ut8 *buf,
ad->type = type;
ad->str = NULL;
switch (type) {
case R_ANAL_DATA_TYPE_PATTERN:
case R_ANAL_DATA_TYPE_SEQUENCE:
case RZ_ANAL_DATA_TYPE_PATTERN:
case RZ_ANAL_DATA_TYPE_SEQUENCE:
ad->len = len;
break;
default:
@@ -276,16 +276,16 @@ RZ_API RzAnalData *rz_anal_data(RzAnal *anal, ut64 addr, const ut8 *buf, int siz
ut64 dst = 0;
int n, nsize = 0;
int bits = anal->bits;
int word = wordsize? wordsize: R_MIN (8, bits / 8);
int word = wordsize? wordsize: RZ_MIN (8, bits / 8);
if (size < 4) {
return NULL;
}
if (size >= word && is_invalid (buf, word)) {
return rz_anal_data_new (addr, R_ANAL_DATA_TYPE_INVALID, -1, buf, word);
return rz_anal_data_new (addr, RZ_ANAL_DATA_TYPE_INVALID, -1, buf, word);
}
{
int i, len = R_MIN (size, 64);
int i, len = RZ_MIN (size, 64);
int is_pattern = 0;
int is_sequence = 0;
char ch = buf[0];
@@ -302,37 +302,37 @@ RZ_API RzAnalData *rz_anal_data(RzAnal *anal, ut64 addr, const ut8 *buf, int siz
}
}
if (is_sequence > len - 2) {
return rz_anal_data_new (addr, R_ANAL_DATA_TYPE_SEQUENCE, -1,
return rz_anal_data_new (addr, RZ_ANAL_DATA_TYPE_SEQUENCE, -1,
buf, is_sequence);
}
if (is_pattern > len - 2) {
return rz_anal_data_new (addr, R_ANAL_DATA_TYPE_PATTERN, -1,
return rz_anal_data_new (addr, RZ_ANAL_DATA_TYPE_PATTERN, -1,
buf, is_pattern);
}
}
if (size >= word && is_null (buf, word)) {
return rz_anal_data_new (addr, R_ANAL_DATA_TYPE_NULL, -1, buf, word);
return rz_anal_data_new (addr, RZ_ANAL_DATA_TYPE_NULL, -1, buf, word);
}
if (is_bin (buf, size)) {
return rz_anal_data_new (addr, R_ANAL_DATA_TYPE_HEADER, -1, buf, word);
return rz_anal_data_new (addr, RZ_ANAL_DATA_TYPE_HEADER, -1, buf, word);
}
if (size >= word) {
dst = is_pointer (anal, buf, word);
if (dst) {
return rz_anal_data_new (addr, R_ANAL_DATA_TYPE_POINTER, dst, buf, word);
return rz_anal_data_new (addr, RZ_ANAL_DATA_TYPE_POINTER, dst, buf, word);
}
}
switch (is_string (buf, size, &nsize)) {
case 1: return rz_anal_data_new_string (addr, (const char *)buf, nsize, R_ANAL_DATA_TYPE_STRING);
case 2: return rz_anal_data_new_string (addr, (const char *)buf, nsize, R_ANAL_DATA_TYPE_WIDE_STRING);
case 1: return rz_anal_data_new_string (addr, (const char *)buf, nsize, RZ_ANAL_DATA_TYPE_STRING);
case 2: return rz_anal_data_new_string (addr, (const char *)buf, nsize, RZ_ANAL_DATA_TYPE_WIDE_STRING);
}
if (size >= word) {
n = is_number (buf, word);
if (n) {
return rz_anal_data_new (addr, R_ANAL_DATA_TYPE_NUMBER, n, buf, word);
return rz_anal_data_new (addr, RZ_ANAL_DATA_TYPE_NUMBER, n, buf, word);
}
}
return rz_anal_data_new (addr, R_ANAL_DATA_TYPE_UNKNOWN, dst, buf, R_MIN (word, size));
return rz_anal_data_new (addr, RZ_ANAL_DATA_TYPE_UNKNOWN, dst, buf, RZ_MIN (word, size));
}
RZ_API const char *rz_anal_data_kind(RzAnal *a, ut64 addr, const ut8 *buf, int len) {
@@ -353,21 +353,21 @@ RZ_API const char *rz_anal_data_kind(RzAnal *a, ut64 addr, const ut8 *buf, int l
continue;
}
switch (data->type) {
case R_ANAL_DATA_TYPE_INVALID:
case RZ_ANAL_DATA_TYPE_INVALID:
inv++;
i += word;
break;
case R_ANAL_DATA_TYPE_NUMBER:
case RZ_ANAL_DATA_TYPE_NUMBER:
if (data->ptr > 1000) {
num++;
}
i += word;
break;
case R_ANAL_DATA_TYPE_UNKNOWN:
case RZ_ANAL_DATA_TYPE_UNKNOWN:
unk++;
i += word;
break;
case R_ANAL_DATA_TYPE_STRING:
case RZ_ANAL_DATA_TYPE_STRING:
if (data->len > 0) {
i += data->len;
} else {
@@ -400,25 +400,25 @@ RZ_API const char *rz_anal_data_kind(RzAnal *a, ut64 addr, const ut8 *buf, int l
RZ_API const char *rz_anal_datatype_to_string(RzAnalDataType t) {
switch (t) {
case R_ANAL_DATATYPE_NULL:
case RZ_ANAL_DATATYPE_NULL:
return NULL;
case R_ANAL_DATATYPE_ARRAY:
case RZ_ANAL_DATATYPE_ARRAY:
return "array";
case R_ANAL_DATATYPE_OBJECT: // instance
case RZ_ANAL_DATATYPE_OBJECT: // instance
return "object";
case R_ANAL_DATATYPE_STRING:
case RZ_ANAL_DATATYPE_STRING:
return "string";
case R_ANAL_DATATYPE_CLASS:
case RZ_ANAL_DATATYPE_CLASS:
return "class";
case R_ANAL_DATATYPE_BOOLEAN:
case RZ_ANAL_DATATYPE_BOOLEAN:
return "boolean";
case R_ANAL_DATATYPE_INT16:
case RZ_ANAL_DATATYPE_INT16:
return "int16";
case R_ANAL_DATATYPE_INT32:
case RZ_ANAL_DATATYPE_INT32:
return "int32";
case R_ANAL_DATATYPE_INT64:
case RZ_ANAL_DATATYPE_INT64:
return "int64";
case R_ANAL_DATATYPE_FLOAT:
case RZ_ANAL_DATATYPE_FLOAT:
return "float";
}
return NULL;
+35 -35
View File
@@ -5,9 +5,9 @@
#include <rz_diff.h>
RZ_API RzAnalDiff *rz_anal_diff_new(void) {
RzAnalDiff *diff = R_NEW0 (RzAnalDiff);
RzAnalDiff *diff = RZ_NEW0 (RzAnalDiff);
if (diff) {
diff->type = R_ANAL_DIFF_TYPE_NULL;
diff->type = RZ_ANAL_DIFF_TYPE_NULL;
diff->addr = UT64_MAX;
diff->dist = 0;
diff->name = NULL;
@@ -18,7 +18,7 @@ RZ_API RzAnalDiff *rz_anal_diff_new(void) {
RZ_API void* rz_anal_diff_free(RzAnalDiff *diff) {
if (diff && diff->name) {
R_FREE (diff->name);
RZ_FREE (diff->name);
}
free (diff);
return NULL;
@@ -29,8 +29,8 @@ RZ_API void rz_anal_diff_setup(RzAnal *anal, int doops, double thbb, double thfc
if (doops >= 0) {
anal->diff_ops = doops;
}
anal->diff_thbb = (thbb>=0)? thbb: R_ANAL_THRESHOLDBB;
anal->diff_thfcn = (thfcn>=0)? thfcn: R_ANAL_THRESHOLDFCN;
anal->diff_thbb = (thbb>=0)? thbb: RZ_ANAL_THRESHOLDBB;
anal->diff_thfcn = (thfcn>=0)? thfcn: RZ_ANAL_THRESHOLDFCN;
}
/* 0-100 */
@@ -38,8 +38,8 @@ RZ_API void rz_anal_diff_setup_i(RzAnal *anal, int doops, int thbb, int thfcn) {
if (doops >= 0) {
anal->diff_ops = doops;
}
anal->diff_thbb = (thbb>=0)? ((double)thbb) / 100: R_ANAL_THRESHOLDBB;
anal->diff_thfcn = (thfcn>=0)? ((double)thfcn) / 100: R_ANAL_THRESHOLDFCN;
anal->diff_thbb = (thbb>=0)? ((double)thbb) / 100: RZ_ANAL_THRESHOLDBB;
anal->diff_thfcn = (thfcn>=0)? ((double)thfcn) / 100: RZ_ANAL_THRESHOLDFCN;
}
// Fingerprint function basic block
@@ -70,7 +70,7 @@ RZ_API int rz_anal_diff_fingerprint_bb(RzAnal *anal, RzAnalBlock *bb) {
return false;
}
while (idx < bb->size) {
if ((oplen = rz_anal_op (anal, op, 0, buf+idx, bb->size-idx, R_ANAL_OP_MASK_BASIC)) < 1) {
if ((oplen = rz_anal_op (anal, op, 0, buf+idx, bb->size-idx, RZ_ANAL_OP_MASK_BASIC)) < 1) {
break;
}
if (op->nopcode != 0) {
@@ -117,15 +117,15 @@ RZ_API bool rz_anal_diff_bb(RzAnal *anal, RzAnalFunction *fcn, RzAnalFunction *f
if (anal->cur && anal->cur->diff_bb) {
return (anal->cur->diff_bb (anal, fcn, fcn2));
}
fcn->diff->type = fcn2->diff->type = R_ANAL_DIFF_TYPE_MATCH;
fcn->diff->type = fcn2->diff->type = RZ_ANAL_DIFF_TYPE_MATCH;
rz_list_foreach (fcn->bbs, iter, bb) {
if (bb->diff && bb->diff->type != R_ANAL_DIFF_TYPE_NULL) {
if (bb->diff && bb->diff->type != RZ_ANAL_DIFF_TYPE_NULL) {
continue;
}
ot = 0;
mbb = mbb2 = NULL;
rz_list_foreach (fcn2->bbs, iter2, bb2) {
if (!bb2->diff || bb2->diff->type == R_ANAL_DIFF_TYPE_NULL) {
if (!bb2->diff || bb2->diff->type == RZ_ANAL_DIFF_TYPE_NULL) {
rz_diff_buffers_distance (NULL, bb->fingerprint, bb->size,
bb2->fingerprint, bb2->size, NULL, &t);
if (t > anal->diff_thbb && t > ot) {
@@ -149,22 +149,22 @@ RZ_API bool rz_anal_diff_bb(RzAnal *anal, RzAnalFunction *fcn, RzAnalFunction *f
return false;
}
if (ot == 1 || t > anal->diff_thfcn) {
mbb->diff->type = mbb2->diff->type = R_ANAL_DIFF_TYPE_MATCH;
mbb->diff->type = mbb2->diff->type = RZ_ANAL_DIFF_TYPE_MATCH;
} else {
mbb->diff->type = mbb2->diff->type = \
fcn->diff->type = fcn2->diff->type = \
R_ANAL_DIFF_TYPE_UNMATCH;
RZ_ANAL_DIFF_TYPE_UNMATCH;
}
R_FREE (mbb->fingerprint);
R_FREE (mbb2->fingerprint);
RZ_FREE (mbb->fingerprint);
RZ_FREE (mbb2->fingerprint);
mbb->diff->addr = mbb2->addr;
mbb2->diff->addr = mbb->addr;
mbb->diff->size = mbb2->size;
mbb2->diff->size = mbb->size;
} else {
fcn->diff->type = fcn2->diff->type = (fcn->diff->dist >= 0.6)
? R_ANAL_DIFF_TYPE_MATCH
: R_ANAL_DIFF_TYPE_UNMATCH;
? RZ_ANAL_DIFF_TYPE_MATCH
: RZ_ANAL_DIFF_TYPE_UNMATCH;
}
}
return true;
@@ -194,20 +194,20 @@ RZ_API int rz_anal_diff_fcn(RzAnal *anal, RzList *fcns, RzList *fcns2) {
NULL, &t);
/* Set flag in matched functions */
fcn->diff->type = fcn2->diff->type = (t >= 1)
? R_ANAL_DIFF_TYPE_MATCH
: R_ANAL_DIFF_TYPE_UNMATCH;
? RZ_ANAL_DIFF_TYPE_MATCH
: RZ_ANAL_DIFF_TYPE_UNMATCH;
fcn->diff->dist = fcn2->diff->dist = t;
R_FREE (fcn->fingerprint);
R_FREE (fcn2->fingerprint);
RZ_FREE (fcn->fingerprint);
RZ_FREE (fcn2->fingerprint);
fcn->diff->addr = fcn2->addr;
fcn2->diff->addr = fcn->addr;
fcn->diff->size = rz_anal_function_linear_size (fcn2);
fcn2->diff->size = rz_anal_function_linear_size (fcn);
R_FREE (fcn->diff->name);
RZ_FREE (fcn->diff->name);
if (fcn2->name) {
fcn->diff->name = strdup (fcn2->name);
}
R_FREE (fcn2->diff->name);
RZ_FREE (fcn2->diff->name);
if (fcn->name) {
fcn2->diff->name = strdup (fcn->name);
}
@@ -219,13 +219,13 @@ RZ_API int rz_anal_diff_fcn(RzAnal *anal, RzList *fcns, RzList *fcns2) {
/* Compare remaining functions */
rz_list_foreach (fcns, iter, fcn) {
/*
if ((fcn->type != R_ANAL_FCN_TYPE_FCN &&
fcn->type != R_ANAL_FCN_TYPE_SYM) ||
fcn->diff->type != R_ANAL_DIFF_TYPE_NULL) {
if ((fcn->type != RZ_ANAL_FCN_TYPE_FCN &&
fcn->type != RZ_ANAL_FCN_TYPE_SYM) ||
fcn->diff->type != RZ_ANAL_DIFF_TYPE_NULL) {
continue;
}
*/
if (fcn->diff->type != R_ANAL_DIFF_TYPE_NULL) {
if (fcn->diff->type != RZ_ANAL_DIFF_TYPE_NULL) {
continue;
}
ot = 0;
@@ -244,11 +244,11 @@ RZ_API int rz_anal_diff_fcn(RzAnal *anal, RzList *fcns, RzList *fcns2) {
eprintf ("Exceeded anal threshold while diffing %s and %s\n", fcn->name, fcn2->name);
continue;
}
if (fcn2->diff->type != R_ANAL_DIFF_TYPE_NULL) {
if (fcn2->diff->type != RZ_ANAL_DIFF_TYPE_NULL) {
eprintf ("Function %s already diffed\n", fcn2->name);
continue;
}
if ((fcn2->type != R_ANAL_FCN_TYPE_FCN && fcn2->type != R_ANAL_FCN_TYPE_SYM)) {
if ((fcn2->type != RZ_ANAL_FCN_TYPE_FCN && fcn2->type != RZ_ANAL_FCN_TYPE_SYM)) {
eprintf ("Function %s type not supported\n", fcn2->name);
continue;
}
@@ -266,19 +266,19 @@ RZ_API int rz_anal_diff_fcn(RzAnal *anal, RzList *fcns, RzList *fcns2) {
if (mfcn && mfcn2) {
/* Set flag in matched functions */
mfcn->diff->type = mfcn2->diff->type = (ot == 1)
? R_ANAL_DIFF_TYPE_MATCH
: R_ANAL_DIFF_TYPE_UNMATCH;
R_FREE (mfcn->fingerprint);
R_FREE (mfcn2->fingerprint);
? RZ_ANAL_DIFF_TYPE_MATCH
: RZ_ANAL_DIFF_TYPE_UNMATCH;
RZ_FREE (mfcn->fingerprint);
RZ_FREE (mfcn2->fingerprint);
mfcn->diff->addr = mfcn2->addr;
mfcn2->diff->addr = mfcn->addr;
mfcn->diff->size = rz_anal_function_linear_size (mfcn2);
mfcn2->diff->size = rz_anal_function_linear_size (mfcn);
R_FREE (mfcn->diff->name);
RZ_FREE (mfcn->diff->name);
if (mfcn2->name) {
mfcn->diff->name = strdup (mfcn2->name);
}
R_FREE (mfcn2->diff->name);
RZ_FREE (mfcn2->diff->name);
if (mfcn->name) {
mfcn2->diff->name = strdup (mfcn->name);
}
+8 -8
View File
@@ -495,9 +495,9 @@ static void parse_structure_type(Context *ctx, ut64 idx) {
RzAnalBaseTypeKind kind;
if (die->tag == DW_TAG_union_type) {
kind = R_ANAL_BASE_TYPE_KIND_UNION;
kind = RZ_ANAL_BASE_TYPE_KIND_UNION;
} else {
kind = R_ANAL_BASE_TYPE_KIND_STRUCT;
kind = RZ_ANAL_BASE_TYPE_KIND_STRUCT;
}
RzAnalBaseType *base_type = rz_anal_base_type_new (kind);
@@ -570,7 +570,7 @@ cleanup:
static void parse_enum_type(Context *ctx, ut64 idx) {
const RBinDwarfDie *die = &ctx->all_dies[idx];
RzAnalBaseType *base_type = rz_anal_base_type_new (R_ANAL_BASE_TYPE_KIND_ENUM);
RzAnalBaseType *base_type = rz_anal_base_type_new (RZ_ANAL_BASE_TYPE_KIND_ENUM);
if (!base_type) {
return;
}
@@ -665,7 +665,7 @@ static void parse_typedef(Context *ctx, ut64 idx) {
if (!name) { // type has to have a name for now
goto cleanup;
}
RzAnalBaseType *base_type = rz_anal_base_type_new (R_ANAL_BASE_TYPE_KIND_TYPEDEF);
RzAnalBaseType *base_type = rz_anal_base_type_new (RZ_ANAL_BASE_TYPE_KIND_TYPEDEF);
if (!base_type) {
goto cleanup;
}
@@ -715,7 +715,7 @@ static void parse_atomic_type(Context *ctx, ut64 idx) {
if (!name) { // type has to have a name for now
return;
}
RzAnalBaseType *base_type = rz_anal_base_type_new (R_ANAL_BASE_TYPE_KIND_ATOMIC);
RzAnalBaseType *base_type = rz_anal_base_type_new (RZ_ANAL_BASE_TYPE_KIND_ATOMIC);
if (!base_type) {
return;
}
@@ -1130,7 +1130,7 @@ static VariableLocation *parse_dwarf_location (Context *ctx, const RBinDwarfAttr
if (kind == LOCATION_UNKNOWN) {
return NULL;
}
VariableLocation *location = R_NEW0 (VariableLocation);
VariableLocation *location = RZ_NEW0 (VariableLocation);
if (location) {
location->reg_name = reg_name;
location->reg_num = reg_num;
@@ -1158,7 +1158,7 @@ static st32 parse_function_args_and_vars(Context *ctx, ut64 idx, RStrBuf *args,
rz_strbuf_init (&type);
const char *name = NULL;
if (child_die->tag == DW_TAG_formal_parameter || child_die->tag == DW_TAG_variable) {
Variable *var = R_NEW0 (Variable);
Variable *var = RZ_NEW0 (Variable);
size_t i;
for (i = 0; i < child_die->count; i++) {
const RBinDwarfAttrValue *val = &child_die->attr_values[i];
@@ -1593,7 +1593,7 @@ RZ_API void rz_anal_dwarf_integrate_functions(RzAnal *anal, RzFlag *flags, Sdb *
char *fcnstr = sdb_get (dwarf_sdb, tmp, 0);
free (tmp);
/* Apply signature as a comment at a function address */
rz_meta_set_string (anal, R_META_TYPE_COMMENT, faddr, fcnstr);
rz_meta_set_string (anal, RZ_META_TYPE_COMMENT, faddr, fcnstr);
free (fcnstr);
}
char *var_names_key = rz_str_newf ("fcn.%s.vars", func_sname);
+71 -71
View File
@@ -7,13 +7,13 @@
#define IFDBG if (esil && esil->verbose > 1)
#define IFVBS if (esil && esil->verbose > 0)
#define FLG(x) R_ANAL_ESIL_FLAG_##x
#define FLG(x) RZ_ANAL_ESIL_FLAG_##x
#define cpuflag(x, y)\
if (esil) {\
if (y) { \
R_BIT_SET (&esil->flags, FLG (x));\
RZ_BIT_SET (&esil->flags, FLG (x));\
} else { \
R_BIT_UNSET (&esil->flags, FLG (x));\
RZ_BIT_UNSET (&esil->flags, FLG (x));\
} \
}
@@ -72,7 +72,7 @@ static bool popRN(RzAnalEsil *esil, ut64 *n) {
return false;
}
/* R_ANAL_ESIL API */
/* RZ_ANAL_ESIL API */
static void esil_ops_free(HtPPKv *kv) {
free (kv->key);
@@ -80,7 +80,7 @@ static void esil_ops_free(HtPPKv *kv) {
}
RZ_API RzAnalEsil *rz_anal_esil_new(int stacksize, int iotrap, unsigned int addrsize) {
RzAnalEsil *esil = R_NEW0 (RzAnalEsil);
RzAnalEsil *esil = RZ_NEW0 (RzAnalEsil);
if (!esil) {
return NULL;
}
@@ -94,7 +94,7 @@ RZ_API RzAnalEsil *rz_anal_esil_new(int stacksize, int iotrap, unsigned int addr
}
esil->verbose = false;
esil->stacksize = stacksize;
esil->parse_goto_count = R_ANAL_ESIL_GOTO_LIMIT;
esil->parse_goto_count = RZ_ANAL_ESIL_GOTO_LIMIT;
esil->ops = ht_pp_new (NULL, esil_ops_free, NULL);
esil->iotrap = iotrap;
rz_anal_esil_sources_init (esil);
@@ -104,10 +104,10 @@ RZ_API RzAnalEsil *rz_anal_esil_new(int stacksize, int iotrap, unsigned int addr
}
RZ_API bool rz_anal_esil_set_op(RzAnalEsil *esil, const char *op, RzAnalEsilOpCb code, ut32 push, ut32 pop, ut32 type) {
rz_return_val_if_fail (code && R_STR_ISNOTEMPTY (op) && esil && esil->ops, false);
rz_return_val_if_fail (code && RZ_STR_ISNOTEMPTY (op) && esil && esil->ops, false);
RzAnalEsilOp *eop = ht_pp_find (esil->ops, op, NULL);
if (!eop) {
eop = R_NEW (RzAnalEsilOp);
eop = RZ_NEW (RzAnalEsilOp);
if (!eop) {
eprintf ("Cannot allocate esil-operation %s\n", op);
return false;
@@ -193,7 +193,7 @@ static ut8 esil_internal_sizeof_reg(RzAnalEsil *esil, const char *r) {
}
static bool alignCheck(RzAnalEsil *esil, ut64 addr) {
int dataAlign = rz_anal_archinfo (esil->anal, R_ANAL_ARCHINFO_DATA_ALIGN);
int dataAlign = rz_anal_archinfo (esil->anal, RZ_ANAL_ARCHINFO_DATA_ALIGN);
return !(dataAlign > 0 && addr % dataAlign);
}
@@ -202,7 +202,7 @@ static int internal_esil_mem_read(RzAnalEsil *esil, ut64 addr, ut8 *buf, int len
addr &= esil->addrmask;
if (!alignCheck (esil, addr)) {
esil->trap = R_ANAL_TRAP_READ_ERR;
esil->trap = RZ_ANAL_TRAP_READ_ERR;
esil->trap_code = addr;
return false;
}
@@ -219,7 +219,7 @@ static int internal_esil_mem_read(RzAnalEsil *esil, ut64 addr, ut8 *buf, int len
// now with siol, read_at return true/false can't be used to check error vs len
if (!esil->anal->iob.is_valid_offset (esil->anal->iob.io, addr, false)) {
if (esil->iotrap) {
esil->trap = R_ANAL_TRAP_READ_ERR;
esil->trap = RZ_ANAL_TRAP_READ_ERR;
esil->trap_code = addr;
}
if (esil->cmd && esil->cmd_ioer && *esil->cmd_ioer) {
@@ -234,7 +234,7 @@ static int internal_esil_mem_read_no_null(RzAnalEsil *esil, ut64 addr, ut8 *buf,
addr &= esil->addrmask;
if (!alignCheck (esil, addr)) {
esil->trap = R_ANAL_TRAP_READ_ERR;
esil->trap = RZ_ANAL_TRAP_READ_ERR;
esil->trap_code = addr;
return false;
}
@@ -244,7 +244,7 @@ static int internal_esil_mem_read_no_null(RzAnalEsil *esil, ut64 addr, ut8 *buf,
// now with siol, read_at return true/false can't be used to check error vs len
if (!esil->anal->iob.is_valid_offset (esil->anal->iob.io, addr, false)) {
if (esil->iotrap) {
esil->trap = R_ANAL_TRAP_READ_ERR;
esil->trap = RZ_ANAL_TRAP_READ_ERR;
esil->trap_code = addr;
}
}
@@ -259,7 +259,7 @@ RZ_API int rz_anal_esil_mem_read(RzAnalEsil *esil, ut64 addr, ut8 *buf, int len)
ret = esil->cb.hook_mem_read (esil, addr, buf, len);
}
if (!alignCheck (esil, addr)) {
esil->trap = R_ANAL_TRAP_READ_ERR;
esil->trap = RZ_ANAL_TRAP_READ_ERR;
esil->trap_code = addr;
return false;
}
@@ -267,7 +267,7 @@ RZ_API int rz_anal_esil_mem_read(RzAnalEsil *esil, ut64 addr, ut8 *buf, int len)
ret = esil->cb.mem_read (esil, addr, buf, len);
if (ret != len) {
if (esil->iotrap) {
esil->trap = R_ANAL_TRAP_READ_ERR;
esil->trap = RZ_ANAL_TRAP_READ_ERR;
esil->trap_code = addr;
}
}
@@ -289,7 +289,7 @@ static int internal_esil_mem_write(RzAnalEsil *esil, ut64 addr, const ut8 *buf,
}
addr &= esil->addrmask;
if (!alignCheck (esil, addr)) {
esil->trap = R_ANAL_TRAP_READ_ERR;
esil->trap = RZ_ANAL_TRAP_READ_ERR;
esil->trap_code = addr;
return false;
}
@@ -307,7 +307,7 @@ static int internal_esil_mem_write(RzAnalEsil *esil, ut64 addr, const ut8 *buf,
// now with siol, write_at return true/false can't be used to check error vs len
if (!esil->anal->iob.is_valid_offset (esil->anal->iob.io, addr, false)) {
if (esil->iotrap) {
esil->trap = R_ANAL_TRAP_WRITE_ERR;
esil->trap = RZ_ANAL_TRAP_WRITE_ERR;
esil->trap_code = addr;
}
if (esil->cmd && esil->cmd_ioer && *esil->cmd_ioer) {
@@ -333,7 +333,7 @@ static int internal_esil_mem_write_no_null(RzAnalEsil *esil, ut64 addr, const ut
// now with siol, write_at return true/false can't be used to check error vs len
if (!esil->anal->iob.is_valid_offset (esil->anal->iob.io, addr, false)) {
if (esil->iotrap) {
esil->trap = R_ANAL_TRAP_WRITE_ERR;
esil->trap = RZ_ANAL_TRAP_WRITE_ERR;
esil->trap_code = addr;
}
}
@@ -395,9 +395,9 @@ static int internal_esil_reg_write_no_null (RzAnalEsil *esil, const char *regnam
rz_return_val_if_fail (esil && esil->anal && esil->anal->reg, false);
RzRegItem *reg = rz_reg_get (esil->anal->reg, regname, -1);
const char *pc = rz_reg_get_name (esil->anal->reg, R_REG_NAME_PC);
const char *sp = rz_reg_get_name (esil->anal->reg, R_REG_NAME_SP);
const char *bp = rz_reg_get_name (esil->anal->reg, R_REG_NAME_BP);
const char *pc = rz_reg_get_name (esil->anal->reg, RZ_REG_NAME_PC);
const char *sp = rz_reg_get_name (esil->anal->reg, RZ_REG_NAME_SP);
const char *bp = rz_reg_get_name (esil->anal->reg, RZ_REG_NAME_BP);
if (!pc) {
eprintf ("Warning: RzReg profile does not contain PC register\n");
@@ -444,10 +444,10 @@ RZ_API int rz_anal_esil_get_parm_type(RzAnalEsil *esil, const char *str) {
int len, i;
if (!str || !(len = strlen (str))) {
return R_ANAL_ESIL_PARM_INVALID;
return RZ_ANAL_ESIL_PARM_INVALID;
}
if (!strncmp (str, "0x", 2)) {
return R_ANAL_ESIL_PARM_NUM;
return RZ_ANAL_ESIL_PARM_NUM;
}
if (!((IS_DIGIT (str[0])) || str[0] == '-')) {
goto not_a_number;
@@ -457,12 +457,12 @@ RZ_API int rz_anal_esil_get_parm_type(RzAnalEsil *esil, const char *str) {
goto not_a_number;
}
}
return R_ANAL_ESIL_PARM_NUM;
return RZ_ANAL_ESIL_PARM_NUM;
not_a_number:
if (rz_reg_get (esil->anal->reg, str, -1)) {
return R_ANAL_ESIL_PARM_REG;
return RZ_ANAL_ESIL_PARM_REG;
}
return R_ANAL_ESIL_PARM_INVALID;
return RZ_ANAL_ESIL_PARM_INVALID;
}
RZ_API int rz_anal_esil_get_parm_size(RzAnalEsil *esil, const char *str, ut64 *num, int *size) {
@@ -474,13 +474,13 @@ RZ_API int rz_anal_esil_get_parm_size(RzAnalEsil *esil, const char *str, ut64 *n
return false;
}
switch (parm_type) {
case R_ANAL_ESIL_PARM_NUM:
case RZ_ANAL_ESIL_PARM_NUM:
*num = rz_num_get (NULL, str);
if (size) {
*size = esil->anal->bits;
}
return true;
case R_ANAL_ESIL_PARM_REG:
case RZ_ANAL_ESIL_PARM_REG:
if (!rz_anal_esil_reg_read (esil, str, num, size)) {
break;
}
@@ -599,7 +599,7 @@ static bool esil_cf(RzAnalEsil *esil) {
return false;
}
if (rz_anal_esil_get_parm_type (esil, src) != R_ANAL_ESIL_PARM_NUM) {
if (rz_anal_esil_get_parm_type (esil, src) != RZ_ANAL_ESIL_PARM_NUM) {
//I'd wish we could enforce consts here
//I can't say why, but I feel like "al,$c" would be cancer af
// - condret
@@ -625,7 +625,7 @@ static bool esil_bf(RzAnalEsil *esil) {
return false;
}
if (rz_anal_esil_get_parm_type (esil, src) != R_ANAL_ESIL_PARM_NUM) {
if (rz_anal_esil_get_parm_type (esil, src) != RZ_ANAL_ESIL_PARM_NUM) {
free (src);
return false;
}
@@ -662,7 +662,7 @@ static bool esil_of(RzAnalEsil *esil) {
return false;
}
if (rz_anal_esil_get_parm_type (esil, p_bit) != R_ANAL_ESIL_PARM_NUM) {
if (rz_anal_esil_get_parm_type (esil, p_bit) != RZ_ANAL_ESIL_PARM_NUM) {
free (p_bit);
return false;
}
@@ -688,7 +688,7 @@ static bool esil_sf(RzAnalEsil *esil) {
char *p_size = rz_anal_esil_pop (esil);
rz_return_val_if_fail (p_size, false);
if (rz_anal_esil_get_parm_type (esil, p_size) != R_ANAL_ESIL_PARM_NUM) {
if (rz_anal_esil_get_parm_type (esil, p_size) != RZ_ANAL_ESIL_PARM_NUM) {
free (p_size);
return false;
}
@@ -744,7 +744,7 @@ static bool esil_weak_eq(RzAnalEsil *esil) {
char *dst = rz_anal_esil_pop (esil);
char *src = rz_anal_esil_pop (esil);
if (!(dst && src && (rz_anal_esil_get_parm_type(esil, dst) == R_ANAL_ESIL_PARM_REG))) {
if (!(dst && src && (rz_anal_esil_get_parm_type(esil, dst) == RZ_ANAL_ESIL_PARM_REG))) {
free (dst);
free (src);
return false;
@@ -918,14 +918,14 @@ static int esil_interrupt_linux_i386(RzAnalEsil *esil) { //move this into a pl
if (sn == 3) {
// trap
esil->trap = R_ANAL_TRAP_BREAKPOINT;
esil->trap = RZ_ANAL_TRAP_BREAKPOINT;
esil->trap_code = 3;
return -1;
}
if (sn != 0x80) {
eprintf ("Interrupt 0x%x not handled.", sn);
esil->trap = R_ANAL_TRAP_UNHANDLED;
esil->trap = RZ_ANAL_TRAP_UNHANDLED;
esil->trap_code = sn;
return -1;
}
@@ -1062,16 +1062,16 @@ static int esil_ifset(RzAnalEsil *esil) {
for (s=src; *s; s++) {
switch (*s) {
case 'z':
rz_anal_esil_reg_write (esil, "zf", R_BIT_CHK(&esil->flags, FLG(ZERO)));
rz_anal_esil_reg_write (esil, "zf", RZ_BIT_CHK(&esil->flags, FLG(ZERO)));
break;
case 'c':
rz_anal_esil_reg_write (esil, "cf", R_BIT_CHK(&esil->flags, FLG(CARRY)));
rz_anal_esil_reg_write (esil, "cf", RZ_BIT_CHK(&esil->flags, FLG(CARRY)));
break;
case 'o':
rz_anal_esil_reg_write (esil, "of", R_BIT_CHK(&esil->flags, FLG(OVERFLOW)));
rz_anal_esil_reg_write (esil, "of", RZ_BIT_CHK(&esil->flags, FLG(OVERFLOW)));
break;
case 'p':
rz_anal_esil_reg_write (esil, "pf", R_BIT_CHK(&esil->flags, FLG(PARITY)));
rz_anal_esil_reg_write (esil, "pf", RZ_BIT_CHK(&esil->flags, FLG(PARITY)));
break;
}
}
@@ -1161,7 +1161,7 @@ static bool esil_lsr(RzAnalEsil *esil) {
char *src = rz_anal_esil_pop (esil);
if (dst && rz_anal_esil_get_parm (esil, dst, &num)) {
if (src && rz_anal_esil_get_parm (esil, src, &num2)) {
ut64 res = num >> R_MIN (num2, 63);
ut64 res = num >> RZ_MIN (num2, 63);
rz_anal_esil_pushnum (esil, res);
ret = true;
} else {
@@ -1427,21 +1427,21 @@ static bool esil_or(RzAnalEsil *esil) {
RZ_API const char *rz_anal_esil_trapstr(int type) {
switch (type) {
case R_ANAL_TRAP_READ_ERR:
case RZ_ANAL_TRAP_READ_ERR:
return "read-err";
case R_ANAL_TRAP_WRITE_ERR:
case RZ_ANAL_TRAP_WRITE_ERR:
return "write-err";
case R_ANAL_TRAP_BREAKPOINT:
case RZ_ANAL_TRAP_BREAKPOINT:
return "breakpoint";
case R_ANAL_TRAP_UNHANDLED:
case RZ_ANAL_TRAP_UNHANDLED:
return "unhandled";
case R_ANAL_TRAP_DIVBYZERO:
case RZ_ANAL_TRAP_DIVBYZERO:
return "divbyzero";
case R_ANAL_TRAP_INVALID:
case RZ_ANAL_TRAP_INVALID:
return "invalid";
case R_ANAL_TRAP_UNALIGNED:
case RZ_ANAL_TRAP_UNALIGNED:
return "unaligned";
case R_ANAL_TRAP_TODO:
case RZ_ANAL_TRAP_TODO:
return "todo";
default:
return "unknown";
@@ -1525,7 +1525,7 @@ static bool esil_mod(RzAnalEsil *esil) {
if (esil->verbose > 0) {
eprintf ("0x%08"PFMT64x" esil_mod: Division by zero!\n", esil->address);
}
esil->trap = R_ANAL_TRAP_DIVBYZERO;
esil->trap = RZ_ANAL_TRAP_DIVBYZERO;
esil->trap_code = 0;
} else {
rz_anal_esil_pushnum (esil, d % s);
@@ -1551,7 +1551,7 @@ static bool esil_signed_mod(RzAnalEsil *esil) {
if (esil->verbose > 0) {
eprintf ("0x%08"PFMT64x" esil_mod: Division by zero!\n", esil->address);
}
esil->trap = R_ANAL_TRAP_DIVBYZERO;
esil->trap = RZ_ANAL_TRAP_DIVBYZERO;
esil->trap_code = 0;
} else {
rz_anal_esil_pushnum (esil, d % s);
@@ -1580,7 +1580,7 @@ static bool esil_modeq(RzAnalEsil *esil) {
rz_anal_esil_reg_write (esil, dst, d % s);
} else {
ERR ("esil_modeq: Division by zero!");
esil->trap = R_ANAL_TRAP_DIVBYZERO;
esil->trap = RZ_ANAL_TRAP_DIVBYZERO;
esil->trap_code = 0;
}
ret = true;
@@ -1604,7 +1604,7 @@ static bool esil_div(RzAnalEsil *esil) {
if (dst && rz_anal_esil_get_parm (esil, dst, &d)) {
if (s == 0) {
ERR ("esil_div: Division by zero!");
esil->trap = R_ANAL_TRAP_DIVBYZERO;
esil->trap = RZ_ANAL_TRAP_DIVBYZERO;
esil->trap_code = 0;
} else {
rz_anal_esil_pushnum (esil, d / s);
@@ -1628,7 +1628,7 @@ static bool esil_signed_div(RzAnalEsil *esil) {
if (dst && rz_anal_esil_get_parm (esil, dst, (ut64 *)&d)) {
if (s == 0) {
ERR ("esil_div: Division by zero!");
esil->trap = R_ANAL_TRAP_DIVBYZERO;
esil->trap = RZ_ANAL_TRAP_DIVBYZERO;
esil->trap_code = 0;
} else {
rz_anal_esil_pushnum (esil, d / s);
@@ -1657,7 +1657,7 @@ static bool esil_diveq(RzAnalEsil *esil) {
rz_anal_esil_reg_write (esil, dst, d / s);
} else {
// eprintf ("0x%08"PFMT64x" esil_diveq: Division by zero!\n", esil->address);
esil->trap = R_ANAL_TRAP_DIVBYZERO;
esil->trap = RZ_ANAL_TRAP_DIVBYZERO;
esil->trap_code = 0;
}
ret = true;
@@ -1768,7 +1768,7 @@ static bool esil_inceq(RzAnalEsil *esil) {
bool ret = false;
ut64 sd;
char *src_dst = rz_anal_esil_pop (esil);
if (src_dst && (rz_anal_esil_get_parm_type (esil, src_dst) == R_ANAL_ESIL_PARM_REG) && rz_anal_esil_get_parm (esil, src_dst, &sd)) {
if (src_dst && (rz_anal_esil_get_parm_type (esil, src_dst) == RZ_ANAL_ESIL_PARM_REG) && rz_anal_esil_get_parm (esil, src_dst, &sd)) {
// inc rax
esil->old = sd++;
esil->cur = sd;
@@ -1835,7 +1835,7 @@ static bool esil_deceq(RzAnalEsil *esil) {
bool ret = false;
ut64 sd;
char *src_dst = rz_anal_esil_pop (esil);
if (src_dst && (rz_anal_esil_get_parm_type (esil, src_dst) == R_ANAL_ESIL_PARM_REG) && rz_anal_esil_get_parm (esil, src_dst, &sd)) {
if (src_dst && (rz_anal_esil_get_parm_type (esil, src_dst) == RZ_ANAL_ESIL_PARM_REG) && rz_anal_esil_get_parm (esil, src_dst, &sd)) {
esil->old = sd;
sd--;
esil->cur = sd;
@@ -1857,7 +1857,7 @@ static bool esil_poke_n(RzAnalEsil *esil, int bits) {
ut64 n;
char *dst = rz_anal_esil_pop (esil);
char *src = rz_anal_esil_pop (esil);
int bytes = R_MIN (sizeof (b), bits / 8);
int bytes = RZ_MIN (sizeof (b), bits / 8);
if (bits % 8) {
free (src);
free (dst);
@@ -2333,7 +2333,7 @@ static bool esil_mem_modeq_n(RzAnalEsil *esil, int bits) {
if (src0 && rz_anal_esil_get_parm (esil, src0, &s)) {
if (s == 0) {
ERR ("esil_mem_modeq4: Division by zero!");
esil->trap = R_ANAL_TRAP_DIVBYZERO;
esil->trap = RZ_ANAL_TRAP_DIVBYZERO;
esil->trap_code = 0;
} else {
rz_anal_esil_push (esil, dst);
@@ -2386,7 +2386,7 @@ static bool esil_mem_diveq_n(RzAnalEsil *esil, int bits) {
if (src0 && rz_anal_esil_get_parm (esil, src0, &s)) {
if (s == 0) {
ERR ("esil_mem_diveq8: Division by zero!");
esil->trap = R_ANAL_TRAP_DIVBYZERO;
esil->trap = RZ_ANAL_TRAP_DIVBYZERO;
esil->trap_code = 0;
} else {
rz_anal_esil_push (esil, dst);
@@ -2851,7 +2851,7 @@ static bool esil_set_jump_target(RzAnalEsil *esil) {
esil->jump_target_set = 1;
ret = true;
} else {
R_FREE (src);
RZ_FREE (src);
ERR ("esil_set_jump_target: empty stack");
}
free (src);
@@ -2866,7 +2866,7 @@ static bool esil_set_jump_target_set(RzAnalEsil *esil) {
esil->jump_target_set = s;
ret = true;
} else {
R_FREE (src);
RZ_FREE (src);
ERR ("esil_set_jump_target_set: empty stack");
}
free (src);
@@ -2881,7 +2881,7 @@ static bool esil_set_delay_slot(RzAnalEsil *esil) {
esil->delay = s;
ret = true;
} else {
R_FREE (src);
RZ_FREE (src);
ERR ("esil_set_delay_slot: empty stack");
}
free (src);
@@ -3061,7 +3061,7 @@ RZ_API bool rz_anal_esil_parse(RzAnalEsil *esil, const char *str) {
int dorunword;
char word[64];
const char *ostr = str;
rz_return_val_if_fail (esil && R_STR_ISNOTEMPTY (str), 0);
rz_return_val_if_fail (esil && RZ_STR_ISNOTEMPTY (str), 0);
if (__stepOut (esil, esil->cmd_step)) {
(void)__stepOut (esil, esil->cmd_step_out);
@@ -3081,7 +3081,7 @@ loop:
esil->parse_stop = 0;
// memleak or failing aetr test. wat du
// rz_anal_esil_stack_free (esil);
esil->parse_goto_count = esil->anal? esil->anal->esil_goto_limit: R_ANAL_ESIL_GOTO_LIMIT;
esil->parse_goto_count = esil->anal? esil->anal->esil_goto_limit: RZ_ANAL_ESIL_GOTO_LIMIT;
str = ostr;
repeat:
wordi = 0;
@@ -3172,7 +3172,7 @@ RZ_API void rz_anal_esil_stack_free(RzAnalEsil *esil) {
int i;
if (esil) {
for (i = 0; i < esil->stackptr; i++) {
R_FREE (esil->stack[i]);
RZ_FREE (esil->stack[i]);
}
esil->stackptr = 0;
}
@@ -3206,12 +3206,12 @@ RZ_API int rz_anal_esil_condition(RzAnalEsil *esil, const char *str) {
static void rz_anal_esil_setup_ops(RzAnalEsil *esil) {
#define OP(v, w, x, y, z) rz_anal_esil_set_op (esil, v, w, x, y, z)
#define OT_UNK R_ANAL_ESIL_OP_TYPE_UNKNOWN
#define OT_CTR R_ANAL_ESIL_OP_TYPE_CONTROL_FLOW
#define OT_MATH R_ANAL_ESIL_OP_TYPE_MATH
#define OT_REGW R_ANAL_ESIL_OP_TYPE_REG_WRITE
#define OT_MEMW R_ANAL_ESIL_OP_TYPE_MEM_WRITE
#define OT_MEMR R_ANAL_ESIL_OP_TYPE_MEM_READ
#define OT_UNK RZ_ANAL_ESIL_OP_TYPE_UNKNOWN
#define OT_CTR RZ_ANAL_ESIL_OP_TYPE_CONTROL_FLOW
#define OT_MATH RZ_ANAL_ESIL_OP_TYPE_MATH
#define OT_REGW RZ_ANAL_ESIL_OP_TYPE_REG_WRITE
#define OT_MEMW RZ_ANAL_ESIL_OP_TYPE_MEM_WRITE
#define OT_MEMR RZ_ANAL_ESIL_OP_TYPE_MEM_READ
OP ("$", esil_interrupt, 0, 1, OT_UNK); //hm, type seems a bit wrong
OP ("$z", esil_zf, 1, 0, OT_UNK);
+94 -94
View File
@@ -27,9 +27,9 @@ RzAnalReilArgType reil_get_arg_type(RzAnalEsil *esil, char *s) {
}
int type = rz_anal_esil_get_parm_type(esil, s);
switch (type) {
case R_ANAL_ESIL_PARM_REG:
case RZ_ANAL_ESIL_PARM_REG:
return ARG_REG;
case R_ANAL_ESIL_PARM_NUM:
case RZ_ANAL_ESIL_PARM_NUM:
return ARG_CONST;
default:
return ARG_NONE;
@@ -53,7 +53,7 @@ RzAnalReilArg *reil_pop_arg(RzAnalEsil *esil) {
return NULL;
}
len = strlen (buf);
op = R_NEW0(RzAnalReilArg);
op = RZ_NEW0(RzAnalReilArg);
for (i = 0; i < len; i++) {
if (buf[i] == ':') {
tmp_buf[j] = '\0';
@@ -113,10 +113,10 @@ void reil_free_inst(RzAnalReilInst *ins) {
if (!ins) {
return;
}
if (ins->arg[0]) { R_FREE (ins->arg[0]); }
if (ins->arg[1]) { R_FREE (ins->arg[1]); }
if (ins->arg[2]) { R_FREE (ins->arg[2]); }
R_FREE(ins);
if (ins->arg[0]) { RZ_FREE (ins->arg[0]); }
if (ins->arg[1]) { RZ_FREE (ins->arg[1]); }
if (ins->arg[2]) { RZ_FREE (ins->arg[2]); }
RZ_FREE(ins);
}
// Automatically increments the seq_num of the instruction.
@@ -166,14 +166,14 @@ void reil_cast_size(RzAnalEsil *esil, RzAnalReilArg *src, RzAnalReilArg *dst) {
}
snprintf (tmp_buf, REGBUFSZ-1, "0:%d", dst->size);
rz_anal_esil_push (esil, tmp_buf);
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
return;
}
ins->opcode = REIL_OR;
ins->arg[0] = src;
ins->arg[1] = reil_pop_arg (esil);
ins->arg[2] = R_NEW0(RzAnalReilArg);
ins->arg[2] = RZ_NEW0(RzAnalReilArg);
get_next_temp_reg (esil, tmp_buf);
reil_make_arg (esil, ins->arg[2], tmp_buf);
if (ins->arg[2]) {
@@ -199,7 +199,7 @@ static bool reil_eq(RzAnalEsil *esil) {
}
src = reil_pop_arg (esil);
if (!src) {
R_FREE (dst);
RZ_FREE (dst);
return false;
}
@@ -207,11 +207,11 @@ static bool reil_eq(RzAnalEsil *esil) {
// Check if the src is an internal var. If it is, we need to resolve it.
if (src_type == ARG_ESIL_INTERNAL) {
reil_flag_spew_inst (esil, src->name + 1);
R_FREE (src);
RZ_FREE (src);
src = reil_pop_arg (esil);
} else if (src_type == ARG_REG) {
// No direct register to register transfer.
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
free (src);
free (dst);
@@ -219,12 +219,12 @@ static bool reil_eq(RzAnalEsil *esil) {
}
ins->opcode = REIL_STR;
ins->arg[0] = src;
ins->arg[1] = R_NEW0 (RzAnalReilArg);
ins->arg[1] = RZ_NEW0 (RzAnalReilArg);
if (!ins->arg[1]) {
reil_free_inst (ins);
return false;
}
ins->arg[2] = R_NEW0(RzAnalReilArg);
ins->arg[2] = RZ_NEW0(RzAnalReilArg);
if (!ins->arg[2]) {
reil_free_inst (ins);
return false;
@@ -240,26 +240,26 @@ static bool reil_eq(RzAnalEsil *esil) {
}
// First, make a copy of the dst. We will need this to set the flags later on.
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
R_FREE (dst);
R_FREE (src);
RZ_FREE (dst);
RZ_FREE (src);
return false;
}
dst_type = dst->type;
if (src_type != ARG_ESIL_INTERNAL && dst_type == ARG_REG) {
ins->opcode = REIL_STR;
ins->arg[0] = dst;
ins->arg[1] = R_NEW0 (RzAnalReilArg);
ins->arg[1] = RZ_NEW0 (RzAnalReilArg);
if (!ins->arg[1]) {
reil_free_inst (ins);
R_FREE (src);
RZ_FREE (src);
return false;
}
ins->arg[2] = R_NEW0 (RzAnalReilArg);
ins->arg[2] = RZ_NEW0 (RzAnalReilArg);
if (!ins->arg[2]) {
reil_free_inst (ins);
R_FREE (src);
RZ_FREE (src);
return false;
}
reil_make_arg (esil, ins->arg[1], " ");
@@ -275,8 +275,8 @@ static bool reil_eq(RzAnalEsil *esil) {
dst->size);
esil->Reil->lastsz = dst->size;
R_FREE (ins->arg[1]);
R_FREE (ins->arg[2]);
RZ_FREE (ins->arg[1]);
RZ_FREE (ins->arg[2]);
}
// If we are modifying the Instruction Pointer, then we need to emit JCC instead.
@@ -284,12 +284,12 @@ static bool reil_eq(RzAnalEsil *esil) {
ins->opcode = REIL_JCC;
rz_anal_esil_push (esil, "1:1");
ins->arg[0] = reil_pop_arg (esil);
ins->arg[1] = R_NEW0 (RzAnalReilArg);
ins->arg[1] = RZ_NEW0 (RzAnalReilArg);
reil_make_arg (esil, ins->arg[1], " ");
ins->arg[2] = src;
reil_print_inst (esil, ins);
reil_free_inst (ins);
R_FREE (dst);
RZ_FREE (dst);
return true;
}
@@ -297,13 +297,13 @@ static bool reil_eq(RzAnalEsil *esil) {
ins->opcode = REIL_STR;
ins->arg[0] = reil_pop_arg (esil);
if (!ins->arg[0]) {
R_FREE (dst);
RZ_FREE (dst);
reil_free_inst (ins);
return false;
}
ins->arg[2] = dst;
ins->arg[1] = R_NEW0 (RzAnalReilArg);
ins->arg[1] = RZ_NEW0 (RzAnalReilArg);
reil_make_arg (esil, ins->arg[1], " ");
reil_print_inst (esil, ins);
reil_free_inst (ins);
@@ -323,14 +323,14 @@ static int reil_binop(RzAnalEsil *esil, RzAnalReilOpcode opcode) {
}
op1 = reil_pop_arg(esil);
if (!op1) {
R_FREE (op2);
RZ_FREE (op2);
return false;
}
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
R_FREE (op1);
R_FREE (op2);
RZ_FREE (op1);
RZ_FREE (op2);
return false;
}
ins->opcode = opcode;
@@ -340,7 +340,7 @@ static int reil_binop(RzAnalEsil *esil, RzAnalReilOpcode opcode) {
reil_free_inst (ins);
return false;
}
ins->arg[2] = R_NEW0(RzAnalReilArg);
ins->arg[2] = RZ_NEW0(RzAnalReilArg);
if (!ins->arg[2]) {
reil_free_inst (ins);
return false;
@@ -375,7 +375,7 @@ static int reil_bineqop(RzAnalEsil *esil, RzAnalReilOpcode opcode) {
ret &= reil_binop(esil, opcode);
reil_push_arg(esil, op);
ret &= reil_eq(esil);
R_FREE(op);
RZ_FREE(op);
return ret;
}
@@ -410,20 +410,20 @@ static bool reil_cmp(RzAnalEsil *esil) {
}
op1 = reil_pop_arg (esil);
if (!op1) {
R_FREE (op2);
RZ_FREE (op2);
return false;
}
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
R_FREE (op1);
R_FREE (op2);
RZ_FREE (op1);
RZ_FREE (op2);
return false;
}
ins->opcode = REIL_EQ;
ins->arg[0] = op2;
ins->arg[1] = op1;
ins->arg[2] = R_NEW0 (RzAnalReilArg);
ins->arg[2] = RZ_NEW0 (RzAnalReilArg);
if (!ins->arg[2]) {
reil_free_inst (ins);
return false;
@@ -456,7 +456,7 @@ static bool reil_smaller_equal(RzAnalEsil *esil) {
}
op1 = reil_pop_arg(esil);
if (!op1) {
R_FREE (op2);
RZ_FREE (op2);
return false;
}
@@ -468,8 +468,8 @@ static bool reil_smaller_equal(RzAnalEsil *esil) {
reil_cmp(esil);
reil_or(esil);
R_FREE(op1);
R_FREE(op2);
RZ_FREE(op1);
RZ_FREE(op2);
return true;
}
@@ -480,14 +480,14 @@ static bool reil_larger(RzAnalEsil *esil) {
}
RzAnalReilArg *op1 = reil_pop_arg(esil);
if (!op1) {
R_FREE (op2);
RZ_FREE (op2);
return false;
}
reil_push_arg (esil, op2);
reil_push_arg (esil, op1);
reil_smaller (esil);
R_FREE (op1);
R_FREE (op2);
RZ_FREE (op1);
RZ_FREE (op2);
return true;
}
@@ -500,15 +500,15 @@ static bool reil_larger_equal(RzAnalEsil *esil) {
}
op1 = reil_pop_arg(esil);
if (!op1) {
R_FREE (op2);
RZ_FREE (op2);
return false;
}
reil_push_arg (esil, op2);
reil_push_arg (esil, op1);
reil_smaller_equal (esil);
R_FREE (op1);
R_FREE (op2);
RZ_FREE (op1);
RZ_FREE (op2);
return true;
}
@@ -520,7 +520,7 @@ static bool reil_dec(RzAnalEsil *esil) {
rz_anal_esil_pushnum (esil, 1);
reil_push_arg (esil, op);
reil_sub (esil);
R_FREE (op);
RZ_FREE (op);
return true;
}
@@ -533,7 +533,7 @@ static bool reil_deceq(RzAnalEsil *esil) {
reil_dec (esil);
reil_push_arg (esil, op1);
reil_eq (esil);
R_FREE (op1);
RZ_FREE (op1);
return true;
}
@@ -546,7 +546,7 @@ static bool reil_inc(RzAnalEsil *esil) {
rz_anal_esil_pushnum(esil, 1);
reil_push_arg(esil, op);
reil_add(esil);
R_FREE(op);
RZ_FREE(op);
return true;
}
@@ -559,7 +559,7 @@ static bool reil_inceq(RzAnalEsil *esil) {
reil_inc (esil);
reil_push_arg (esil, op);
reil_eq (esil);
R_FREE (op);
RZ_FREE (op);
return true;
}
@@ -570,9 +570,9 @@ static bool reil_neg(RzAnalEsil *esil) {
if (!op) {
return false;
}
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
R_FREE (op);
RZ_FREE (op);
return false;
}
ins->opcode = REIL_EQ;
@@ -583,7 +583,7 @@ static bool reil_neg(RzAnalEsil *esil) {
reil_free_inst (ins);
return false;
}
ins->arg[2] = R_NEW0 (RzAnalReilArg);
ins->arg[2] = RZ_NEW0 (RzAnalReilArg);
if (!ins->arg[2]) {
reil_free_inst (ins);
return false;
@@ -622,19 +622,19 @@ static bool reil_not(RzAnalEsil *esil) {
return false;
}
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
R_FREE (op);
RZ_FREE (op);
return false;
}
ins->opcode = REIL_NOT;
ins->arg[0] = op;
ins->arg[1] = R_NEW0 (RzAnalReilArg);
ins->arg[1] = RZ_NEW0 (RzAnalReilArg);
if (!ins->arg[1]) {
reil_free_inst (ins);
return false;
}
ins->arg[2] = R_NEW0 (RzAnalReilArg);
ins->arg[2] = RZ_NEW0 (RzAnalReilArg);
if (!ins->arg[2]) {
reil_free_inst (ins);
return false;
@@ -659,20 +659,20 @@ static bool reil_if(RzAnalEsil *esil) {
}
op1 = reil_pop_arg (esil);
if (!op1) {
R_FREE (op2);
RZ_FREE (op2);
return false;
}
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
R_FREE (op2);
R_FREE (op1);
RZ_FREE (op2);
RZ_FREE (op1);
return false;
}
ins->opcode = REIL_JCC;
ins->arg[0] = op1;
ins->arg[2] = op2;
ins->arg[1] = R_NEW0 (RzAnalReilArg);
ins->arg[1] = RZ_NEW0 (RzAnalReilArg);
if (!ins->arg[1]) {
reil_free_inst (ins);
return false;
@@ -693,19 +693,19 @@ static bool reil_peek(RzAnalEsil *esil) {
return false;
}
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
R_FREE (op1);
RZ_FREE (op1);
return false;
}
ins->opcode = REIL_LDM;
ins->arg[0] = op1;
ins->arg[1] = R_NEW0(RzAnalReilArg);
ins->arg[1] = RZ_NEW0(RzAnalReilArg);
if (!ins->arg[1]) {
reil_free_inst (ins);
return false;
}
ins->arg[2] = R_NEW0(RzAnalReilArg);
ins->arg[2] = RZ_NEW0(RzAnalReilArg);
if (!ins->arg[2]) {
reil_free_inst (ins);
return false;
@@ -732,19 +732,19 @@ static bool reil_peekn(RzAnalEsil *esil, ut8 n) {
reil_peek (esil);
// No need to cast if n = 0
if (n == 0) {
R_FREE (op1);
RZ_FREE (op1);
return true;
}
R_FREE (op1);
RZ_FREE (op1);
op1 = reil_pop_arg (esil);
if (!op1) {
return false;
}
op2 = R_NEW0 (RzAnalReilArg);
op2 = RZ_NEW0 (RzAnalReilArg);
if (!op2) {
R_FREE (op1);
RZ_FREE (op1);
return false;
}
op2->size = n * 8;
@@ -753,7 +753,7 @@ static bool reil_peekn(RzAnalEsil *esil, ut8 n) {
reil_cast_size (esil, op1, op2);
esil->Reil->lastsz = 8 * n;
R_FREE (op2);
RZ_FREE (op2);
return true;
}
@@ -774,28 +774,28 @@ static bool reil_poken(RzAnalEsil *esil, ut8 n) {
}
op1 = reil_pop_arg (esil);
if (!op1) {
R_FREE (op2);
RZ_FREE (op2);
return false;
}
if (op1->type != ARG_ESIL_INTERNAL) {
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
R_FREE (op2);
R_FREE (op1);
RZ_FREE (op2);
RZ_FREE (op1);
return false;
}
ins->opcode = REIL_LDM;
ins->arg[0] = op2;
ins->arg[1] = R_NEW0(RzAnalReilArg);
ins->arg[1] = RZ_NEW0(RzAnalReilArg);
if (!ins->arg[1]) {
R_FREE (op1);
RZ_FREE (op1);
reil_free_inst (ins);
return false;
}
ins->arg[2] = R_NEW0(RzAnalReilArg);
ins->arg[2] = RZ_NEW0(RzAnalReilArg);
if (!ins->arg[2]) {
R_FREE (op1);
RZ_FREE (op1);
reil_free_inst (ins);
return false;
}
@@ -811,26 +811,26 @@ static bool reil_poken(RzAnalEsil *esil, ut8 n) {
esil->lastsz = n * 8;
reil_push_arg (esil, op1);
reil_push_arg (esil, op2);
R_FREE (op1);
RZ_FREE (op1);
reil_free_inst (ins);
} else {
reil_flag_spew_inst (esil, op1->name + 1);
R_FREE (op1);
RZ_FREE (op1);
op1 = reil_pop_arg (esil);
reil_push_arg (esil, op2);
reil_push_arg (esil, op1);
R_FREE (op2);
R_FREE (op1);
RZ_FREE (op2);
RZ_FREE (op1);
}
ins = R_NEW0 (RzAnalReilInst);
ins = RZ_NEW0 (RzAnalReilInst);
if (!ins) {
return false;
}
ins->opcode = REIL_STM;
ins->arg[2] = reil_pop_arg (esil);
ins->arg[0] = reil_pop_arg (esil);
ins->arg[1] = R_NEW0 (RzAnalReilArg);
ins->arg[1] = RZ_NEW0 (RzAnalReilArg);
if (!ins->arg[1]) {
reil_free_inst (ins);
return false;
@@ -861,7 +861,7 @@ static bool reil_mem_bineq_n(RzAnalEsil *esil, RzAnalReilOpcode opcode, ut8 size
}
op1 = reil_pop_arg (esil);
if (!op1) {
R_FREE (op2);
RZ_FREE (op2);
return false;
}
@@ -1153,7 +1153,7 @@ RZ_API int rz_anal_esil_to_reil_setup(RzAnalEsil *esil, RzAnal *anal, int romem,
/* Set up a callback for hook_command */
esil->cb.hook_command = setup_reil_ins;
esil->Reil = R_NEW0(RzAnalReil);
esil->Reil = RZ_NEW0(RzAnalReil);
if (!esil->Reil) {
return false;
}
@@ -1168,12 +1168,12 @@ RZ_API int rz_anal_esil_to_reil_setup(RzAnalEsil *esil, RzAnal *anal, int romem,
rz_anal_esil_mem_ro(esil, romem);
#define OT_UNK R_ANAL_ESIL_OP_TYPE_UNKNOWN
#define OT_CTR R_ANAL_ESIL_OP_TYPE_CONTROL_FLOW
#define OT_MATH R_ANAL_ESIL_OP_TYPE_MATH
#define OT_REGW R_ANAL_ESIL_OP_TYPE_REG_WRITE
#define OT_MEMW R_ANAL_ESIL_OP_TYPE_MEM_WRITE
#define OT_MEMR R_ANAL_ESIL_OP_TYPE_MEM_READ
#define OT_UNK RZ_ANAL_ESIL_OP_TYPE_UNKNOWN
#define OT_CTR RZ_ANAL_ESIL_OP_TYPE_CONTROL_FLOW
#define OT_MATH RZ_ANAL_ESIL_OP_TYPE_MATH
#define OT_REGW RZ_ANAL_ESIL_OP_TYPE_REG_WRITE
#define OT_MEMW RZ_ANAL_ESIL_OP_TYPE_MEM_WRITE
#define OT_MEMR RZ_ANAL_ESIL_OP_TYPE_MEM_READ
rz_anal_esil_set_op(esil, "=", reil_eq, 0, 2, OT_REGW);
rz_anal_esil_set_op(esil, ":=", reil_eq, 0, 2, OT_REGW);
+23 -23
View File
@@ -71,7 +71,7 @@ static char *condrets_strtok(char *str, const char tok) {
}
RzAnalEsilOp *esil_get_op (RzAnalEsil *esil, const char *op) {
rz_return_val_if_fail (R_STR_ISNOTEMPTY (op) && esil && esil->ops, NULL);
rz_return_val_if_fail (RZ_STR_ISNOTEMPTY (op) && esil && esil->ops, NULL);
return ht_pp_find (esil->ops, op, NULL);
}
@@ -154,16 +154,16 @@ void _handle_if_enter (EsilCfgGen *gen, ut32 id, const bool has_next) {
return;
}
// TODO: check allocation here
EsilCfgScopeCookie *cookie = R_NEW0 (EsilCfgScopeCookie);
EsilCfgScopeCookie *cookie = RZ_NEW0 (EsilCfgScopeCookie);
// get current bb
// RzAnalEsilBB *bb = (RzAnalEsilBB *)gen->cur->data;
// create if-enter-bb
RzAnalEsilBB *entered_bb = R_NEW0 (RzAnalEsilBB);
RzAnalEsilBB *entered_bb = RZ_NEW0 (RzAnalEsilBB);
entered_bb->first.off = entered_bb->last.off = gen->off;
entered_bb->first.idx = entered_bb->last.idx = id + 1;
entered_bb->enter = R_ANAL_ESIL_BLOCK_ENTER_TRUE;
entered_bb->enter = RZ_ANAL_ESIL_BLOCK_ENTER_TRUE;
// create if-entered-graph-node
RGraphNode *entered_node = rz_graph_add_node (gen->cfg->g, entered_bb);
@@ -188,7 +188,7 @@ void _handle_else_enter (EsilCfgGen *gen, ut32 id, const bool has_next) {
EsilCfgScopeCookie *cookie = (EsilCfgScopeCookie *)rz_stack_peek (gen->ifelse);
// create if-enter-bb
RzAnalEsilBB *entered_bb = R_NEW0 (RzAnalEsilBB);
RzAnalEsilBB *entered_bb = RZ_NEW0 (RzAnalEsilBB);
entered_bb->first.off = entered_bb->last.off = gen->off;
entered_bb->first.idx = entered_bb->last.idx = id + 1;
@@ -198,13 +198,13 @@ void _handle_else_enter (EsilCfgGen *gen, ut32 id, const bool has_next) {
rz_rbtree_cont_insert (gen->blocks, entered_node, _graphnode_esilbb_insert_cmp, NULL);
if (cookie->is_else) {
entered_bb->enter = R_ANAL_ESIL_BLOCK_ENTER_TRUE;
entered_bb->enter = RZ_ANAL_ESIL_BLOCK_ENTER_TRUE;
rz_graph_add_edge (gen->cfg->g, cookie->if_block, entered_node);
cookie->if_block = entered_node;
cookie->else_block = gen->cur;
cookie->is_else = false;
} else {
entered_bb->enter = R_ANAL_ESIL_BLOCK_ENTER_FALSE;
entered_bb->enter = RZ_ANAL_ESIL_BLOCK_ENTER_FALSE;
rz_graph_add_edge (gen->cfg->g, cookie->else_block, entered_node);
cookie->else_block = entered_node;
cookie->if_block = gen->cur;
@@ -225,7 +225,7 @@ void _handle_fi_leave (EsilCfgGen *gen, ut32 id, const bool has_next) {
if (memcmp (&cur_bb->first, &cur_bb->last, sizeof (RzAnalEsilEOffset))) {
// TODO: add some thoughts in comments here
cur_bb->last.idx--;
RzAnalEsilBB *leaving_bb = R_NEW0 (RzAnalEsilBB);
RzAnalEsilBB *leaving_bb = RZ_NEW0 (RzAnalEsilBB);
leaving_bb->first.off = leaving_bb->last.off = gen->off;
leaving_bb->first.idx = leaving_bb->last.idx = id;
RGraphNode *leaving_node = rz_graph_add_node (gen->cfg->g, leaving_bb);
@@ -265,7 +265,7 @@ bool _round_0_cb (void *user, void *data, ut32 id) {
RzAnalEsilBB *bb = (RzAnalEsilBB *)gen->cur->data;
RzAnalEsilOp *op = esil_get_op (gen->esil, atom);
bb->last.idx = (ut16)id;
if (op && op->type == R_ANAL_ESIL_OP_TYPE_CONTROL_FLOW) {
if (op && op->type == RZ_ANAL_ESIL_OP_TYPE_CONTROL_FLOW) {
_handle_control_flow_ifelsefi (gen, atom, id);
}
return true;
@@ -276,7 +276,7 @@ RGraphNode *_common_break_goto (EsilCfgGen *gen, ut32 id) {
RGraphNode *gnode = rz_rbtree_cont_find (gen->blocks, &off, _graphnode_esilbb_find_cmp, NULL);
RzAnalEsilBB *bb = (RzAnalEsilBB *)gnode->data;
if (id != bb->last.idx) {
RzAnalEsilBB *next_bb = R_NEW0 (RzAnalEsilBB);
RzAnalEsilBB *next_bb = RZ_NEW0 (RzAnalEsilBB);
// split blocks
next_bb->first.off = gen->off;
next_bb->first.idx = id + 1;
@@ -326,12 +326,12 @@ void _handle_goto (EsilCfgGen *gen, ut32 idx) {
free (rz_stack_pop (gen->vals));
}
for (j = 0; j < op->push; j++) {
EsilVal *val = R_NEW (EsilVal);
EsilVal *val = RZ_NEW (EsilVal);
val->type = ESIL_VAL_RESULT;
rz_stack_push (gen->vals, val);
}
} else {
EsilVal *val = R_NEW (EsilVal);
EsilVal *val = RZ_NEW (EsilVal);
if (rz_reg_get (gen->esil->anal->reg, atom, -1)) {
val->type = ESIL_VAL_REG;
} else {
@@ -358,7 +358,7 @@ void _handle_goto (EsilCfgGen *gen, ut32 idx) {
} else {
RzAnalEsilBB *dst_bb = (RzAnalEsilBB *)dst_node->data;
if (dst_bb->first.idx != v->val) {
RzAnalEsilBB *split_bb = R_NEW0 (RzAnalEsilBB);
RzAnalEsilBB *split_bb = RZ_NEW0 (RzAnalEsilBB);
split_bb[0] = dst_bb[0];
dst_bb->last.idx = v->val - 1;
split_bb->first.idx = v->val;
@@ -379,7 +379,7 @@ bool _round_1_cb (void *user, void *data, ut32 id) {
EsilCfgGen *gen = (EsilCfgGen *)user;
char *atom = (char *)data;
RzAnalEsilOp *op = esil_get_op (gen->esil, atom);
if (op && op->type == R_ANAL_ESIL_OP_TYPE_CONTROL_FLOW) {
if (op && op->type == RZ_ANAL_ESIL_OP_TYPE_CONTROL_FLOW) {
if (!strcmp ("BREAK", atom)) {
_handle_break (gen, id);
}
@@ -418,7 +418,7 @@ static RzAnalEsilCFG *esil_cfg_gen(RzAnalEsilCFG *cfg, RzAnal *anal, RIDStorage
if (!_expr) {
return cfg; //NULL?
}
RzAnalEsilBB *end_bb = R_NEW0 (RzAnalEsilBB);
RzAnalEsilBB *end_bb = RZ_NEW0 (RzAnalEsilBB);
if (!end_bb) {
free (_expr);
return cfg;
@@ -499,9 +499,9 @@ static RzAnalEsilCFG *esil_cfg_gen(RzAnalEsilCFG *cfg, RzAnal *anal, RIDStorage
}
RZ_API RzAnalEsilCFG *rz_anal_esil_cfg_new(void) {
RzAnalEsilCFG *cf = R_NEW0 (RzAnalEsilCFG);
RzAnalEsilCFG *cf = RZ_NEW0 (RzAnalEsilCFG);
if (cf) {
RzAnalEsilBB *p = R_NEW0 (RzAnalEsilBB);
RzAnalEsilBB *p = RZ_NEW0 (RzAnalEsilBB);
if (!p) {
free (cf);
return NULL;
@@ -575,7 +575,7 @@ RZ_API RzAnalEsilCFG *rz_anal_esil_cfg_op(RzAnalEsilCFG *cfg, RzAnal *anal, RzAn
if (!op || !anal || !anal->reg || !anal->esil) {
return NULL;
}
RzAnalEsilBB *glue_bb = R_NEW0 (RzAnalEsilBB);
RzAnalEsilBB *glue_bb = RZ_NEW0 (RzAnalEsilBB);
if (!glue_bb) {
eprintf ("Couldn't allocate glue_bb\n");
return NULL;
@@ -586,7 +586,7 @@ RZ_API RzAnalEsilCFG *rz_anal_esil_cfg_op(RzAnalEsilCFG *cfg, RzAnal *anal, RzAn
eprintf ("Couldn't allocate glue\n");
return NULL;
}
const char *pc = rz_reg_get_name (anal->reg, R_REG_NAME_PC);
const char *pc = rz_reg_get_name (anal->reg, RZ_REG_NAME_PC);
rz_strbuf_setf (glue, "0x%" PFMT64x ",%s,:=,", op->addr + op->size, pc);
glue_bb->expr = strdup (rz_strbuf_get (glue));
rz_strbuf_free (glue);
@@ -595,7 +595,7 @@ RZ_API RzAnalEsilCFG *rz_anal_esil_cfg_op(RzAnalEsilCFG *cfg, RzAnal *anal, RzAn
eprintf ("Couldn't strdup\n");
return NULL;
}
glue_bb->enter = R_ANAL_ESIL_BLOCK_ENTER_GLUE;
glue_bb->enter = RZ_ANAL_ESIL_BLOCK_ENTER_GLUE;
glue_bb->first.off = glue_bb->last.off = op->addr;
glue_bb->first.idx = glue_bb->last.idx = 0;
@@ -634,10 +634,10 @@ static void merge_2_blocks(RzAnalEsilCFG *cfg, RGraphNode *node, RGraphNode *blo
}
RzAnalEsilBB *block_bb, *node_bb = (RzAnalEsilBB *)node->data;
block_bb = (RzAnalEsilBB *)block->data;
if ((block_bb->enter == R_ANAL_ESIL_BLOCK_ENTER_TRUE) || (block_bb->enter == R_ANAL_ESIL_BLOCK_ENTER_FALSE)) {
if ((block_bb->enter == RZ_ANAL_ESIL_BLOCK_ENTER_TRUE) || (block_bb->enter == RZ_ANAL_ESIL_BLOCK_ENTER_FALSE)) {
node_bb->enter = block_bb->enter;
} else {
node_bb->enter = R_ANAL_ESIL_BLOCK_ENTER_NORMAL;
node_bb->enter = RZ_ANAL_ESIL_BLOCK_ENTER_NORMAL;
}
RStrBuf *buf = rz_strbuf_new (block_bb->expr);
node_bb->first = block_bb->first;
@@ -662,7 +662,7 @@ RZ_API void rz_anal_esil_cfg_merge_blocks(RzAnalEsilCFG *cfg) {
RzAnalEsilBB *bb = (RzAnalEsilBB *)node->data;
RGraphNode *top = (RGraphNode *)rz_list_get_top (node->out_nodes);
// segfaults here ?
if (!(top && bb->enter == R_ANAL_ESIL_BLOCK_ENTER_GLUE && (rz_list_length (top->in_nodes) > 1))) {
if (!(top && bb->enter == RZ_ANAL_ESIL_BLOCK_ENTER_GLUE && (rz_list_length (top->in_nodes) > 1))) {
RGraphNode *block = (RGraphNode *)rz_list_get_top (node->in_nodes);
if (rz_list_length (block->out_nodes) == 1) {
merge_2_blocks (cfg, node, block);
+97 -97
View File
@@ -20,7 +20,7 @@ typedef struct rz_anal_esil_dfg_filter_t {
// TODO: simple const propagation - use node->type of srcs to propagate consts of pushed vars
RZ_API RzAnalEsilDFGNode *rz_anal_esil_dfg_node_new(RzAnalEsilDFG *edf, const char *c) {
RzAnalEsilDFGNode *ret = R_NEW0 (RzAnalEsilDFGNode);
RzAnalEsilDFGNode *ret = RZ_NEW0 (RzAnalEsilDFGNode);
ret->content = rz_strbuf_new (c);
ret->idx = edf->idx++;
return ret;
@@ -67,7 +67,7 @@ static int _rv_del_alloc_cmp (void *incoming, void *in, void *user) {
*/
if (rv_in->from < rv_incoming->from && rv_incoming->to < rv_in->to) {
EsilDFGRegVar *rv = R_NEW (EsilDFGRegVar);
EsilDFGRegVar *rv = RZ_NEW (EsilDFGRegVar);
if (!rv) {
dfg->malloc_failed = true;
return -1;
@@ -88,7 +88,7 @@ static int _rv_del_alloc_cmp (void *incoming, void *in, void *user) {
if (rv_incoming->from < rv_in->from && rv_in->to < rv_incoming->to) {
// lower part
EsilDFGRegVar *rv = R_NEW (EsilDFGRegVar);
EsilDFGRegVar *rv = RZ_NEW (EsilDFGRegVar);
if (!rv) {
dfg->malloc_failed = true;
return -1;
@@ -97,7 +97,7 @@ static int _rv_del_alloc_cmp (void *incoming, void *in, void *user) {
rv->to = rv_in->from - 1;
rz_queue_enqueue (dfg->todo, rv);
// upper part
rv = R_NEW (EsilDFGRegVar);
rv = RZ_NEW (EsilDFGRegVar);
if (!rv) {
dfg->malloc_failed = true;
return -1;
@@ -116,7 +116,7 @@ static int _rv_del_alloc_cmp (void *incoming, void *in, void *user) {
*/
if (rv_incoming->from == rv_in->from && rv_in->to < rv_incoming->to) {
EsilDFGRegVar *rv = R_NEW (EsilDFGRegVar);
EsilDFGRegVar *rv = RZ_NEW (EsilDFGRegVar);
if (!rv) {
dfg->malloc_failed = true;
return -1;
@@ -133,7 +133,7 @@ static int _rv_del_alloc_cmp (void *incoming, void *in, void *user) {
*/
if (rv_incoming->from < rv_in->from && rv_in->to == rv_incoming->to) {
EsilDFGRegVar *rv = R_NEW (EsilDFGRegVar);
EsilDFGRegVar *rv = RZ_NEW (EsilDFGRegVar);
if (!rv) {
dfg->malloc_failed = true;
return -1;
@@ -182,7 +182,7 @@ static int _rv_ins_cmp (void *incoming, void *in, void *user) {
static bool _edf_reg_set (RzAnalEsilDFG *dfg, const char *reg, RGraphNode *node) {
rz_return_val_if_fail (dfg && !dfg->malloc_failed && reg, false);
const ut32 _reg_strlen = 4 + strlen (reg);
char *_reg = R_NEWS0 (char, _reg_strlen + 1);
char *_reg = RZ_NEWS0 (char, _reg_strlen + 1);
if (!_reg) {
// no need for assert here, it's not a bug if malloc fails
return false;
@@ -194,7 +194,7 @@ static bool _edf_reg_set (RzAnalEsilDFG *dfg, const char *reg, RGraphNode *node)
free (_reg);
return false;
}
EsilDFGRegVar *rv = R_NEW0 (EsilDFGRegVar);
EsilDFGRegVar *rv = RZ_NEW0 (EsilDFGRegVar);
if (!rv) {
free (_reg);
return false;
@@ -221,7 +221,7 @@ static bool _edf_reg_set (RzAnalEsilDFG *dfg, const char *reg, RGraphNode *node)
}
return false;
}
rv = R_NEW0 (EsilDFGRegVar);
rv = RZ_NEW0 (EsilDFGRegVar);
rv->from = (v & (UT64_MAX ^ UT32_MAX)) >> 32;
rv->to = v & UT32_MAX;
rv->node = node;
@@ -262,7 +262,7 @@ static int _rv_find_cmp (void *incoming, void *in, void *user) {
*/
if (rv_incoming->from < rv_in->from && rv_in->to < rv_incoming->to) {
// lower part
EsilDFGRegVar *rv = R_NEW (EsilDFGRegVar);
EsilDFGRegVar *rv = RZ_NEW (EsilDFGRegVar);
if (!rv) {
dfg->malloc_failed = true;
return -1;
@@ -271,7 +271,7 @@ static int _rv_find_cmp (void *incoming, void *in, void *user) {
rv->to = rv_in->from - 1;
rz_queue_enqueue (dfg->todo, rv);
// upper part
rv = R_NEW (EsilDFGRegVar);
rv = RZ_NEW (EsilDFGRegVar);
if (!rv) {
dfg->malloc_failed = true;
return -1;
@@ -289,7 +289,7 @@ static int _rv_find_cmp (void *incoming, void *in, void *user) {
similar to the previous case, but this time only enqueue 1 half
*/
if (rv_in->from <= rv_incoming->from && rv_in->to < rv_incoming->to) {
EsilDFGRegVar *rv = R_NEW (EsilDFGRegVar);
EsilDFGRegVar *rv = RZ_NEW (EsilDFGRegVar);
if (!rv) {
dfg->malloc_failed = true;
return -1;
@@ -304,7 +304,7 @@ static int _rv_find_cmp (void *incoming, void *in, void *user) {
=incoming=
=in=
*/
EsilDFGRegVar *rv = R_NEW (EsilDFGRegVar);
EsilDFGRegVar *rv = RZ_NEW (EsilDFGRegVar);
if (!rv) {
dfg->malloc_failed = true;
return -1;
@@ -318,7 +318,7 @@ static int _rv_find_cmp (void *incoming, void *in, void *user) {
static RGraphNode *_edf_origin_reg_get(RzAnalEsilDFG *dfg, const char *reg) {
rz_return_val_if_fail (dfg && reg, NULL);
const ut32 _reg_strlen = 4 + strlen (reg);
char *_reg = R_NEWS0 (char, _reg_strlen + 1);
char *_reg = RZ_NEWS0 (char, _reg_strlen + 1);
if (!_reg) {
return NULL;
}
@@ -330,7 +330,7 @@ static RGraphNode *_edf_origin_reg_get(RzAnalEsilDFG *dfg, const char *reg) {
}
free (_reg);
const ut32 origin_reg_strlen = 4 + strlen (reg);
char *origin_reg = R_NEWS0 (char, origin_reg_strlen + 1);
char *origin_reg = RZ_NEWS0 (char, origin_reg_strlen + 1);
if (!origin_reg) {
return NULL;
}
@@ -344,7 +344,7 @@ static RGraphNode *_edf_origin_reg_get(RzAnalEsilDFG *dfg, const char *reg) {
RGraphNode *reg_node = rz_graph_add_node (dfg->flow, rz_anal_esil_dfg_node_new (dfg, reg));
RzAnalEsilDFGNode *_origin_reg_node = rz_anal_esil_dfg_node_new (dfg, reg);
rz_strbuf_appendf (_origin_reg_node->content, ":var_%d", dfg->idx++);
_origin_reg_node->type = R_ANAL_ESIL_DFG_BLOCK_VAR;
_origin_reg_node->type = RZ_ANAL_ESIL_DFG_BLOCK_VAR;
origin_reg_node = rz_graph_add_node (dfg->flow, _origin_reg_node);
rz_graph_add_edge (dfg->flow, reg_node, origin_reg_node);
sdb_ptr_set (dfg->regs, origin_reg, origin_reg_node, 0);
@@ -356,7 +356,7 @@ static RGraphNode *_edf_origin_reg_get(RzAnalEsilDFG *dfg, const char *reg) {
static RGraphNode *_edf_reg_get(RzAnalEsilDFG *dfg, const char *reg) {
rz_return_val_if_fail (dfg && reg, NULL);
const ut32 _reg_strlen = 4 + strlen (reg);
char *_reg = R_NEWS0 (char, _reg_strlen + 1);
char *_reg = RZ_NEWS0 (char, _reg_strlen + 1);
if (!_reg) {
return NULL;
}
@@ -366,7 +366,7 @@ static RGraphNode *_edf_reg_get(RzAnalEsilDFG *dfg, const char *reg) {
free (_reg);
return NULL;
}
EsilDFGRegVar *rv = R_NEW0 (EsilDFGRegVar);
EsilDFGRegVar *rv = RZ_NEW0 (EsilDFGRegVar);
if (!rv) {
free (_reg);
return NULL;
@@ -394,9 +394,9 @@ static RGraphNode *_edf_reg_get(RzAnalEsilDFG *dfg, const char *reg) {
} else if (!reg_node) {
reg_node = _edf_origin_reg_get (dfg, reg);
//insert in the gap
part_rv = R_NEW (EsilDFGRegVar);
part_rv = RZ_NEW (EsilDFGRegVar);
if (!part_rv) {
R_FREE (rv);
RZ_FREE (rv);
dfg->malloc_failed = true;
break;
}
@@ -408,9 +408,9 @@ static RGraphNode *_edf_reg_get(RzAnalEsilDFG *dfg, const char *reg) {
} else {
//initial regnode was already created
//only need to insert in the tree
part_rv = R_NEW (EsilDFGRegVar);
part_rv = RZ_NEW (EsilDFGRegVar);
if (!part_rv) {
R_FREE (part_rv);
RZ_FREE (part_rv);
dfg->malloc_failed = true;
break;
}
@@ -469,7 +469,7 @@ beach:
static bool _edf_var_set (RzAnalEsilDFG *dfg, const char *var, RGraphNode *node) {
rz_return_val_if_fail (dfg && var, false);
const ut32 _var_strlen = 4 + strlen (var);
char *_var = R_NEWS0 (char, _var_strlen + 1);
char *_var = RZ_NEWS0 (char, _var_strlen + 1);
if (!_var) {
return false;
}
@@ -484,7 +484,7 @@ static bool _edf_var_set (RzAnalEsilDFG *dfg, const char *var, RGraphNode *node)
static RGraphNode *_edf_var_get (RzAnalEsilDFG *dfg, const char *var) {
rz_return_val_if_fail (dfg && var, NULL);
const ut32 _var_strlen = 4 + strlen (var);
char *_var = R_NEWS0 (char, _var_strlen + 1);
char *_var = RZ_NEWS0 (char, _var_strlen + 1);
if (!_var) {
return NULL;
}
@@ -563,7 +563,7 @@ static bool _edf_consume_2_set_reg(RzAnalEsil *esil, const bool use_origin) {
}
int dst_type = rz_anal_esil_get_parm_type (esil, dst);
if (dst_type == R_ANAL_ESIL_PARM_INVALID) {
if (dst_type == RZ_ANAL_ESIL_PARM_INVALID) {
free (dst);
free (src);
return false;
@@ -571,12 +571,12 @@ static bool _edf_consume_2_set_reg(RzAnalEsil *esil, const bool use_origin) {
const int src_type = rz_anal_esil_get_parm_type (esil, src);
RGraphNode *src_node = NULL;
if (src_type == R_ANAL_ESIL_PARM_REG) {
if (src_type == RZ_ANAL_ESIL_PARM_REG) {
src_node = _edf_reg_get (edf, src);
} else if (src_type == R_ANAL_ESIL_PARM_NUM) {
} else if (src_type == RZ_ANAL_ESIL_PARM_NUM) {
RGraphNode *n_value = rz_graph_add_node (edf->flow, rz_anal_esil_dfg_node_new (edf, src));
RzAnalEsilDFGNode *ec_node = rz_anal_esil_dfg_node_new (edf, src);
ec_node->type = R_ANAL_ESIL_DFG_BLOCK_CONST;
ec_node->type = RZ_ANAL_ESIL_DFG_BLOCK_CONST;
rz_strbuf_appendf (ec_node->content, ":const_%d", edf->idx++);
src_node = rz_graph_add_node (edf->flow, ec_node);
rz_graph_add_edge (edf->flow, n_value, src_node);
@@ -595,7 +595,7 @@ static bool _edf_consume_2_set_reg(RzAnalEsil *esil, const bool use_origin) {
RzAnalEsilDFGNode *eop_node = rz_anal_esil_dfg_node_new (edf, src);
rz_strbuf_appendf (eop_node->content, ",%s,%s", dst, op_string);
eop_node->type = R_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
eop_node->type = RZ_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
free (src);
RGraphNode *op_node = rz_graph_add_node (edf->flow, eop_node);
@@ -603,7 +603,7 @@ static bool _edf_consume_2_set_reg(RzAnalEsil *esil, const bool use_origin) {
rz_graph_add_edge (edf->flow, src_node, op_node);
edf->old = old_dst_node;
RzAnalEsilDFGNode *result = rz_anal_esil_dfg_node_new (edf, dst);
result->type = R_ANAL_ESIL_DFG_BLOCK_RESULT | R_ANAL_ESIL_DFG_BLOCK_VAR;
result->type = RZ_ANAL_ESIL_DFG_BLOCK_RESULT | RZ_ANAL_ESIL_DFG_BLOCK_VAR;
rz_strbuf_appendf (result->content, ":var_%d", edf->idx++);
dst_node = rz_graph_add_node (edf->flow, result);
@@ -634,18 +634,18 @@ static bool edf_consume_2_push_1(RzAnalEsil *esil) {
}
RzAnalEsilDFGNode *eop_node = rz_anal_esil_dfg_node_new (edf, src[1]);
rz_strbuf_appendf (eop_node->content, ",%s,%s", src[0], op_string);
eop_node->type = R_ANAL_ESIL_DFG_BLOCK_RESULT | R_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
eop_node->type = RZ_ANAL_ESIL_DFG_BLOCK_RESULT | RZ_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
RGraphNode *op_node = rz_graph_add_node (edf->flow, eop_node);
RGraphNode *src_node[2];
ut32 i;
for (i = 0; i < 2; i++) {
const int src_type = rz_anal_esil_get_parm_type (esil, src[i]);
if (src_type == R_ANAL_ESIL_PARM_REG) {
if (src_type == RZ_ANAL_ESIL_PARM_REG) {
src_node[i] = _edf_reg_get (edf, src[i]);
} else if (src_type == R_ANAL_ESIL_PARM_NUM) {
} else if (src_type == RZ_ANAL_ESIL_PARM_NUM) {
RGraphNode *n_value = rz_graph_add_node (edf->flow, rz_anal_esil_dfg_node_new (edf, src[i]));
RzAnalEsilDFGNode *ec_node = rz_anal_esil_dfg_node_new (edf, src[i]);
ec_node->type = R_ANAL_ESIL_DFG_BLOCK_CONST;
ec_node->type = RZ_ANAL_ESIL_DFG_BLOCK_CONST;
rz_strbuf_appendf (ec_node->content, ":const_%d", edf->idx++);
src_node[i] = rz_graph_add_node (edf->flow, ec_node);
rz_graph_add_edge (edf->flow, n_value, src_node[i]);
@@ -659,7 +659,7 @@ static bool edf_consume_2_push_1(RzAnalEsil *esil) {
free (src[1]);
RzAnalEsilDFGNode *result = rz_anal_esil_dfg_node_new (edf, "result_");
result->type = R_ANAL_ESIL_DFG_BLOCK_RESULT;
result->type = RZ_ANAL_ESIL_DFG_BLOCK_RESULT;
rz_strbuf_appendf (result->content, "%d", edf->idx++);
RGraphNode *result_node = rz_graph_add_node (edf->flow, result);
rz_graph_add_edge (edf->flow, op_node, result_node);
@@ -677,16 +677,16 @@ static bool edf_consume_1_push_1(RzAnalEsil *esil) {
}
RzAnalEsilDFGNode *eop_node = rz_anal_esil_dfg_node_new (edf, src);
rz_strbuf_appendf (eop_node->content, ",%s", op_string);
eop_node->type = R_ANAL_ESIL_DFG_BLOCK_RESULT | R_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
eop_node->type = RZ_ANAL_ESIL_DFG_BLOCK_RESULT | RZ_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
RGraphNode *op_node = rz_graph_add_node (edf->flow, eop_node);
const int src_type = rz_anal_esil_get_parm_type (esil, src);
RGraphNode *src_node = NULL;
if (src_type == R_ANAL_ESIL_PARM_REG) {
if (src_type == RZ_ANAL_ESIL_PARM_REG) {
src_node = _edf_reg_get (edf, src);
} else if (src_type == R_ANAL_ESIL_PARM_NUM) {
} else if (src_type == RZ_ANAL_ESIL_PARM_NUM) {
RGraphNode *n_value = rz_graph_add_node (edf->flow, rz_anal_esil_dfg_node_new (edf, src));
RzAnalEsilDFGNode *ec_node = rz_anal_esil_dfg_node_new (edf, src);
ec_node->type = R_ANAL_ESIL_DFG_BLOCK_CONST;
ec_node->type = RZ_ANAL_ESIL_DFG_BLOCK_CONST;
rz_strbuf_appendf (ec_node->content, ":const_%d", edf->idx++);
src_node = rz_graph_add_node (edf->flow, ec_node);
rz_graph_add_edge (edf->flow, n_value, src_node);
@@ -699,7 +699,7 @@ static bool edf_consume_1_push_1(RzAnalEsil *esil) {
rz_graph_add_edge (edf->flow, src_node, op_node);
RzAnalEsilDFGNode *result = rz_anal_esil_dfg_node_new (edf, "result_");
result->type = R_ANAL_ESIL_DFG_BLOCK_RESULT; //TODO: propgate type from src here
result->type = RZ_ANAL_ESIL_DFG_BLOCK_RESULT; //TODO: propgate type from src here
rz_strbuf_appendf (result->content, "%d", edf->idx++);
RGraphNode *result_node = rz_graph_add_node (edf->flow, result);
rz_graph_add_edge (edf->flow, op_node, result_node);
@@ -724,12 +724,12 @@ static bool edf_consume_2_set_mem(RzAnalEsil *esil) {
const int src_type = rz_anal_esil_get_parm_type (esil, src);
RGraphNode *src_node = NULL;
if (src_type == R_ANAL_ESIL_PARM_REG) {
if (src_type == RZ_ANAL_ESIL_PARM_REG) {
src_node = _edf_reg_get (edf, src);
} else if (src_type == R_ANAL_ESIL_PARM_NUM) {
} else if (src_type == RZ_ANAL_ESIL_PARM_NUM) {
RGraphNode *n_value = rz_graph_add_node (edf->flow, rz_anal_esil_dfg_node_new (edf, src));
RzAnalEsilDFGNode *ec_node = rz_anal_esil_dfg_node_new (edf, src);
ec_node->type = R_ANAL_ESIL_DFG_BLOCK_CONST;
ec_node->type = RZ_ANAL_ESIL_DFG_BLOCK_CONST;
rz_strbuf_appendf (ec_node->content, ":const_%d", edf->idx++);
src_node = rz_graph_add_node (edf->flow, ec_node);
rz_graph_add_edge (edf->flow, n_value, src_node);
@@ -743,10 +743,10 @@ static bool edf_consume_2_set_mem(RzAnalEsil *esil) {
}
//probably dead code
if (!dst_node) {
if (dst_type == R_ANAL_ESIL_PARM_REG) {
if (dst_type == RZ_ANAL_ESIL_PARM_REG) {
RGraphNode *n_reg = rz_graph_add_node (edf->flow, rz_anal_esil_dfg_node_new (edf, dst));
RzAnalEsilDFGNode *ev_node = rz_anal_esil_dfg_node_new (edf, dst);
ev_node->type = R_ANAL_ESIL_DFG_BLOCK_VAR | R_ANAL_ESIL_DFG_BLOCK_PTR;
ev_node->type = RZ_ANAL_ESIL_DFG_BLOCK_VAR | RZ_ANAL_ESIL_DFG_BLOCK_PTR;
rz_strbuf_appendf (ev_node->content, ":var_ptr_%d", edf->idx++);
dst_node = rz_graph_add_node (edf->flow, ev_node);
// _edf_reg_set (edf, dst, ev_node);
@@ -763,15 +763,15 @@ static bool edf_consume_2_set_mem(RzAnalEsil *esil) {
RzAnalEsilDFGNode *eop_node = rz_anal_esil_dfg_node_new (edf, src);
rz_strbuf_appendf (eop_node->content, ",%s,%s", dst, op_string);
eop_node->type = R_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
eop_node->type = RZ_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
free (src);
RGraphNode *op_node = rz_graph_add_node (edf->flow, eop_node);
rz_graph_add_edge (edf->flow, dst_node, op_node);
rz_graph_add_edge (edf->flow, src_node, op_node);
RzAnalEsilDFGNode *result = rz_anal_esil_dfg_node_new (edf, dst);
// result->type = R_ANAL_ESIL_DFG_BLOCK_RESULT | R_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
result->type = R_ANAL_ESIL_DFG_BLOCK_VAR;
// result->type = RZ_ANAL_ESIL_DFG_BLOCK_RESULT | RZ_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
result->type = RZ_ANAL_ESIL_DFG_BLOCK_VAR;
rz_strbuf_appendf (result->content, ":var_mem_%d", edf->idx++);
dst_node = rz_graph_add_node (edf->flow, result);
rz_graph_add_edge (edf->flow, op_node, dst_node);
@@ -787,7 +787,7 @@ static bool edf_use_new_push_1(RzAnalEsil *esil, const char *op_string, AddConst
return 0;
}
RzAnalEsilDFGNode *result = rz_anal_esil_dfg_node_new (edf, "result_");
result->type = R_ANAL_ESIL_DFG_BLOCK_RESULT; // is this generative?
result->type = RZ_ANAL_ESIL_DFG_BLOCK_RESULT; // is this generative?
rz_strbuf_appendf (result->content, "%d", edf->idx++);
if (cb) {
RzAnalEsilDFGNode *e_new_node = (RzAnalEsilDFGNode *)latest_new->data;
@@ -809,18 +809,18 @@ static bool edf_consume_1_use_old_new_push_1(RzAnalEsil *esil, const char *op_st
}
RzAnalEsilDFGNode *eop_node = rz_anal_esil_dfg_node_new (edf, src);
#if 0
eop_node->type = R_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
eop_node->type = RZ_ANAL_ESIL_DFG_BLOCK_GENERATIVE;
#endif
rz_strbuf_appendf (eop_node->content, ",%s", op_string);
RGraphNode *op_node = rz_graph_add_node (edf->flow, eop_node);
const int src_type = rz_anal_esil_get_parm_type (esil, src);
RGraphNode *src_node = NULL;
if (src_type == R_ANAL_ESIL_PARM_REG) {
if (src_type == RZ_ANAL_ESIL_PARM_REG) {
src_node = _edf_reg_get (edf, src);
} else if (src_type == R_ANAL_ESIL_PARM_NUM) {
} else if (src_type == RZ_ANAL_ESIL_PARM_NUM) {
RGraphNode *n_value = rz_graph_add_node (edf->flow, rz_anal_esil_dfg_node_new (edf, src));
RzAnalEsilDFGNode *ec_node = rz_anal_esil_dfg_node_new (edf, src);
ec_node->type = R_ANAL_ESIL_DFG_BLOCK_CONST;
ec_node->type = RZ_ANAL_ESIL_DFG_BLOCK_CONST;
rz_strbuf_appendf (ec_node->content, ":const_%d", edf->idx++);
src_node = rz_graph_add_node (edf->flow, ec_node);
rz_graph_add_edge (edf->flow, n_value, src_node);
@@ -834,7 +834,7 @@ static bool edf_consume_1_use_old_new_push_1(RzAnalEsil *esil, const char *op_st
RGraphNode *latest_new = edf->cur;
RGraphNode *latest_old = edf->old;
RzAnalEsilDFGNode *result = rz_anal_esil_dfg_node_new (edf, "result_");
result->type = R_ANAL_ESIL_DFG_BLOCK_RESULT; // propagate type here
result->type = RZ_ANAL_ESIL_DFG_BLOCK_RESULT; // propagate type here
rz_strbuf_appendf (result->content, "%d", edf->idx++);
if (cb) {
RzAnalEsilDFGNode *e_src_node = (RzAnalEsilDFGNode *)src_node->data;
@@ -855,7 +855,7 @@ RZ_API RzAnalEsilDFG *rz_anal_esil_dfg_new(RzReg *regs) {
if (!regs) {
return NULL;
}
RzAnalEsilDFG *dfg = R_NEW0 (RzAnalEsilDFG);
RzAnalEsilDFG *dfg = RZ_NEW0 (RzAnalEsilDFG);
if (!dfg) {
return NULL;
}
@@ -897,7 +897,7 @@ RZ_API RzAnalEsilDFG *rz_anal_esil_dfg_new(RzReg *regs) {
const ut32 to = from + ri->size - 1; // closed intervals because of FUCK YOU
const ut64 v = to | (((ut64)from) << 32);
const ut32 reg_strlen = 4 + strlen (ri->name) + 1;
char *reg = R_NEWS0 (char, reg_strlen);
char *reg = RZ_NEWS0 (char, reg_strlen);
strncat (reg, "reg.", reg_strlen);
strncat (reg, ri->name, reg_strlen);
sdb_num_set (dfg->regs, reg, v, 0);
@@ -939,42 +939,42 @@ RZ_API RzAnalEsilDFG *rz_anal_esil_dfg_expr(RzAnal *anal, RzAnalEsilDFG *dfg, co
return NULL;
}
rz_anal_esil_set_op (esil, "=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, ":=", edf_eq_weak, 0, 2, R_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "$z", edf_zf, 1, 0, R_ANAL_ESIL_OP_TYPE_UNKNOWN);
rz_anal_esil_set_op (esil, "$p", edf_pf, 1, 0, R_ANAL_ESIL_OP_TYPE_UNKNOWN);
rz_anal_esil_set_op (esil, "$c", edf_cf, 1, 1, R_ANAL_ESIL_OP_TYPE_UNKNOWN);
rz_anal_esil_set_op (esil, "$b", edf_bf, 1, 1, R_ANAL_ESIL_OP_TYPE_UNKNOWN);
rz_anal_esil_set_op (esil, "^=", edf_consume_2_use_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "-=", edf_consume_2_use_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "+=", edf_consume_2_use_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "*=", edf_consume_2_use_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "/=", edf_consume_2_use_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "&=", edf_consume_2_use_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "|=", edf_consume_2_use_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "^=", edf_consume_2_use_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "+", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "-", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "&", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "|", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "^", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "%", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "*", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "/", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, ">>", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "<<", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, ">>>", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, ">>>", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "!", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "[1]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
rz_anal_esil_set_op (esil, "[2]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
rz_anal_esil_set_op (esil, "[4]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
rz_anal_esil_set_op (esil, "[8]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
rz_anal_esil_set_op (esil, "[16]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
rz_anal_esil_set_op (esil, "=[1]", edf_consume_2_set_mem, 0, 2, R_ANAL_ESIL_OP_TYPE_MEM_WRITE);
rz_anal_esil_set_op (esil, "=[2]", edf_consume_2_set_mem, 0, 2, R_ANAL_ESIL_OP_TYPE_MEM_WRITE);
rz_anal_esil_set_op (esil, "=[4]", edf_consume_2_set_mem, 0, 2, R_ANAL_ESIL_OP_TYPE_MEM_WRITE);
rz_anal_esil_set_op (esil, "=[8]", edf_consume_2_set_mem, 0, 2, R_ANAL_ESIL_OP_TYPE_MEM_WRITE);
rz_anal_esil_set_op (esil, "=", edf_consume_2_set_reg, 0, 2, RZ_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, ":=", edf_eq_weak, 0, 2, RZ_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "$z", edf_zf, 1, 0, RZ_ANAL_ESIL_OP_TYPE_UNKNOWN);
rz_anal_esil_set_op (esil, "$p", edf_pf, 1, 0, RZ_ANAL_ESIL_OP_TYPE_UNKNOWN);
rz_anal_esil_set_op (esil, "$c", edf_cf, 1, 1, RZ_ANAL_ESIL_OP_TYPE_UNKNOWN);
rz_anal_esil_set_op (esil, "$b", edf_bf, 1, 1, RZ_ANAL_ESIL_OP_TYPE_UNKNOWN);
rz_anal_esil_set_op (esil, "^=", edf_consume_2_use_set_reg, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MATH | RZ_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "-=", edf_consume_2_use_set_reg, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MATH | RZ_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "+=", edf_consume_2_use_set_reg, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MATH | RZ_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "*=", edf_consume_2_use_set_reg, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MATH | RZ_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "/=", edf_consume_2_use_set_reg, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MATH | RZ_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "&=", edf_consume_2_use_set_reg, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MATH | RZ_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "|=", edf_consume_2_use_set_reg, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MATH | RZ_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "^=", edf_consume_2_use_set_reg, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MATH | RZ_ANAL_ESIL_OP_TYPE_REG_WRITE);
rz_anal_esil_set_op (esil, "+", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "-", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "&", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "|", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "^", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "%", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "*", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "/", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, ">>", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "<<", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, ">>>", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, ">>>", edf_consume_2_push_1, 1, 2, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "!", edf_consume_1_push_1, 1, 1, RZ_ANAL_ESIL_OP_TYPE_MATH);
rz_anal_esil_set_op (esil, "[1]", edf_consume_1_push_1, 1, 1, RZ_ANAL_ESIL_OP_TYPE_MEM_READ);
rz_anal_esil_set_op (esil, "[2]", edf_consume_1_push_1, 1, 1, RZ_ANAL_ESIL_OP_TYPE_MEM_READ);
rz_anal_esil_set_op (esil, "[4]", edf_consume_1_push_1, 1, 1, RZ_ANAL_ESIL_OP_TYPE_MEM_READ);
rz_anal_esil_set_op (esil, "[8]", edf_consume_1_push_1, 1, 1, RZ_ANAL_ESIL_OP_TYPE_MEM_READ);
rz_anal_esil_set_op (esil, "[16]", edf_consume_1_push_1, 1, 1, RZ_ANAL_ESIL_OP_TYPE_MEM_READ);
rz_anal_esil_set_op (esil, "=[1]", edf_consume_2_set_mem, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MEM_WRITE);
rz_anal_esil_set_op (esil, "=[2]", edf_consume_2_set_mem, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MEM_WRITE);
rz_anal_esil_set_op (esil, "=[4]", edf_consume_2_set_mem, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MEM_WRITE);
rz_anal_esil_set_op (esil, "=[8]", edf_consume_2_set_mem, 0, 2, RZ_ANAL_ESIL_OP_TYPE_MEM_WRITE);
esil->user = edf;
@@ -993,14 +993,14 @@ static void _dfg_rev_dfs_cb(RGraphNode *n, RGraphVisitor *vi) {
RzAnalEsilDFGNode *node = (RzAnalEsilDFGNode *)n->data;
RzAnalEsilDFGFilter *filter = (RzAnalEsilDFGFilter *)vi->data;
switch (node->type) {
case R_ANAL_ESIL_DFG_BLOCK_CONST:
case R_ANAL_ESIL_DFG_BLOCK_VAR:
case R_ANAL_ESIL_DFG_BLOCK_PTR:
case RZ_ANAL_ESIL_DFG_BLOCK_CONST:
case RZ_ANAL_ESIL_DFG_BLOCK_VAR:
case RZ_ANAL_ESIL_DFG_BLOCK_PTR:
break;
case R_ANAL_ESIL_DFG_BLOCK_GENERATIVE:
case RZ_ANAL_ESIL_DFG_BLOCK_GENERATIVE:
rz_rbtree_cont_insert (filter->tree, node, _dfg_node_filter_insert_cmp, NULL);
break;
case R_ANAL_ESIL_DFG_BLOCK_RESULT: // outnode must be result generator here
case RZ_ANAL_ESIL_DFG_BLOCK_RESULT: // outnode must be result generator here
{
RGraphNode *previous = (RGraphNode *)rz_list_get_top (n->in_nodes);
if (previous) {
+1 -1
View File
@@ -39,7 +39,7 @@ RZ_API void rz_anal_esil_interrupts_init(RzAnalEsil *esil) {
RZ_API RzAnalEsilInterrupt *rz_anal_esil_interrupt_new(RzAnalEsil *esil, ut32 src_id, RzAnalEsilInterruptHandler *ih) {
rz_return_val_if_fail (esil && ih && ih->cb, NULL);
RzAnalEsilInterrupt *intr = R_NEW0 (RzAnalEsilInterrupt);
RzAnalEsilInterrupt *intr = RZ_NEW0 (RzAnalEsilInterrupt);
if (!intr) {
return NULL;
}
+1 -1
View File
@@ -16,7 +16,7 @@ RZ_API ut32 rz_anal_esil_load_source(RzAnalEsil *esil, const char *path) {
return 0;
}
src = R_NEW0 (RzAnalEsilSource);
src = RZ_NEW0 (RzAnalEsilSource);
src->content = rz_lib_dl_open(path);
if (!src->content) {
eprintf ("no content\n");
+6 -6
View File
@@ -19,7 +19,7 @@ static void htup_vector_free(HtUPKv *kv) {
RZ_API RzAnalEsilTrace *rz_anal_esil_trace_new(RzAnalEsil *esil) {
rz_return_val_if_fail (esil && esil->stack_addr && esil->stack_size, NULL);
size_t i;
RzAnalEsilTrace *trace = R_NEW0 (RzAnalEsilTrace);
RzAnalEsilTrace *trace = RZ_NEW0 (RzAnalEsilTrace);
if (!trace) {
return NULL;
}
@@ -45,7 +45,7 @@ RZ_API RzAnalEsilTrace *rz_anal_esil_trace_new(RzAnalEsil *esil) {
esil->anal->iob.read_at (esil->anal->iob.io, trace->stack_addr,
trace->stack_data, trace->stack_size);
// Save initial registers arenas
for (i = 0; i < R_REG_TYPE_LAST; i++) {
for (i = 0; i < RZ_REG_TYPE_LAST; i++) {
RzRegArena *a = esil->anal->reg->regset[i].arena;
RzRegArena *b = rz_reg_arena_new (a->size);
if (!b) {
@@ -66,12 +66,12 @@ RZ_API void rz_anal_esil_trace_free(RzAnalEsilTrace *trace) {
if (trace) {
ht_up_free (trace->registers);
ht_up_free (trace->memory);
for (i = 0; i < R_REG_TYPE_LAST; i++) {
for (i = 0; i < RZ_REG_TYPE_LAST; i++) {
rz_reg_arena_free (trace->arena[i]);
}
free (trace->stack_data);
sdb_free (trace->db);
R_FREE (trace);
RZ_FREE (trace);
}
}
@@ -192,7 +192,7 @@ static int trace_hook_mem_write(RzAnalEsil *esil, ut64 addr, const ut8 *buf, int
RZ_API void rz_anal_esil_trace_op(RzAnalEsil *esil, RzAnalOp *op) {
rz_return_if_fail (esil && op);
const char *expr = rz_strbuf_get (&op->esil);
if (R_STR_ISEMPTY (expr)) {
if (RZ_STR_ISEMPTY (expr)) {
// do nothing
return;
}
@@ -274,7 +274,7 @@ RZ_API void rz_anal_esil_trace_restore(RzAnalEsil *esil, int idx) {
// Restore initial state when going backward
if (idx < esil->trace->idx) {
// Restore initial registers value
for (i = 0; i < R_REG_TYPE_LAST; i++) {
for (i = 0; i < RZ_REG_TYPE_LAST; i++) {
RzRegArena *a = esil->anal->reg->regset[i].arena;
RzRegArena *b = trace->arena[i];
if (a && b) {
+177 -177
View File
@@ -34,18 +34,18 @@
typedef struct fcn_tree_iter_t {
int len;
RBNode *cur;
RBNode *path[R_RBTREE_MAX_HEIGHT];
RBNode *path[RZ_RBTREE_MAX_HEIGHT];
} FcnTreeIter;
RZ_API const char *rz_anal_fcntype_tostring(int type) {
switch (type) {
case R_ANAL_FCN_TYPE_NULL: return "null";
case R_ANAL_FCN_TYPE_FCN: return "fcn";
case R_ANAL_FCN_TYPE_LOC: return "loc";
case R_ANAL_FCN_TYPE_SYM: return "sym";
case R_ANAL_FCN_TYPE_IMP: return "imp";
case R_ANAL_FCN_TYPE_INT: return "int"; // interrupt
case R_ANAL_FCN_TYPE_ROOT: return "root";
case RZ_ANAL_FCN_TYPE_NULL: return "null";
case RZ_ANAL_FCN_TYPE_FCN: return "fcn";
case RZ_ANAL_FCN_TYPE_LOC: return "loc";
case RZ_ANAL_FCN_TYPE_SYM: return "sym";
case RZ_ANAL_FCN_TYPE_IMP: return "imp";
case RZ_ANAL_FCN_TYPE_INT: return "int"; // interrupt
case RZ_ANAL_FCN_TYPE_ROOT: return "root";
}
return "unk";
}
@@ -150,7 +150,7 @@ static RzAnalBlock *fcn_append_basic_block(RzAnal *anal, RzAnalFunction *fcn, ut
static bool isInvalidMemory(RzAnal *anal, const ut8 *buf, int len) {
if (anal->opt.nonull > 0) {
int i;
const int count = R_MIN (len, anal->opt.nonull);
const int count = RZ_MIN (len, anal->opt.nonull);
for (i = 0; i < count; i++) {
if (buf[i]) {
break;
@@ -160,7 +160,7 @@ static bool isInvalidMemory(RzAnal *anal, const ut8 *buf, int len) {
return true;
}
}
return !memcmp (buf, "\xff\xff\xff\xff", R_MIN (len, 4));
return !memcmp (buf, "\xff\xff\xff\xff", RZ_MIN (len, 4));
}
static bool isSymbolNextInstruction(RzAnal *anal, RzAnalOp *op) {
@@ -187,15 +187,15 @@ static bool is_delta_pointer_table(RzAnal *anal, RzAnalFunction *fcn, ut64 addr,
for (i = 0; i + 8 < JMPTBL_LEA_SEARCH_SZ; i++) {
ut64 at = addr + i;
int left = JMPTBL_LEA_SEARCH_SZ - i;
int len = rz_anal_op (anal, aop, at, buf + i, left, R_ANAL_OP_MASK_BASIC | R_ANAL_OP_MASK_HINT | R_ANAL_OP_MASK_VAL);
int len = rz_anal_op (anal, aop, at, buf + i, left, RZ_ANAL_OP_MASK_BASIC | RZ_ANAL_OP_MASK_HINT | RZ_ANAL_OP_MASK_VAL);
if (len < 1) {
len = 1;
}
if (aop->type == R_ANAL_OP_TYPE_UJMP || aop->type == R_ANAL_OP_TYPE_RJMP) {
if (aop->type == RZ_ANAL_OP_TYPE_UJMP || aop->type == RZ_ANAL_OP_TYPE_RJMP) {
isValid = true;
break;
}
if (aop->type == R_ANAL_OP_TYPE_MOV) {
if (aop->type == RZ_ANAL_OP_TYPE_MOV) {
omov_aop = mov_aop;
mov_aop = *aop;
o_reg_dst = cur_dst.reg;
@@ -207,7 +207,7 @@ static bool is_delta_pointer_table(RzAnal *anal, RzAnalFunction *fcn, ut64 addr,
reg_src = cur_scr.regdelta;
}
}
if (aop->type == R_ANAL_OP_TYPE_ADD) {
if (aop->type == RZ_ANAL_OP_TYPE_ADD) {
add_aop = *aop;
}
rz_anal_op_fini (aop);
@@ -269,7 +269,7 @@ static ut64 try_get_cmpval_from_parents(RzAnal * anal, RzAnalFunction *fcn, RzAn
if (tmp_bb->jump == my_bb->addr || tmp_bb->fail == my_bb->addr) {
if (tmp_bb->cmpreg == cmp_reg) {
if (tmp_bb->cond) {
if (tmp_bb->cond->type == R_ANAL_COND_HI || tmp_bb->cond->type == R_ANAL_COND_GT) {
if (tmp_bb->cond->type == RZ_ANAL_COND_HI || tmp_bb->cond->type == RZ_ANAL_COND_GT) {
return tmp_bb->cmpval + 1;
}
}
@@ -324,7 +324,7 @@ static void check_purity(HtUP *ht, RzAnalFunction *fcn) {
ht_up_insert (ht, fcn->addr, NULL);
fcn->is_pure = true;
rz_list_foreach (refs, iter, ref) {
if (ref->type == R_ANAL_REF_TYPE_CALL || ref->type == R_ANAL_REF_TYPE_CODE) {
if (ref->type == RZ_ANAL_REF_TYPE_CALL || ref->type == RZ_ANAL_REF_TYPE_CODE) {
RzAnalFunction *called_fcn = rz_anal_get_fcn_in (fcn->anal, ref->addr, 0);
if (!called_fcn) {
continue;
@@ -337,7 +337,7 @@ static void check_purity(HtUP *ht, RzAnalFunction *fcn) {
break;
}
}
if (ref->type == R_ANAL_REF_TYPE_DATA) {
if (ref->type == RZ_ANAL_REF_TYPE_DATA) {
fcn->is_pure = false;
break;
}
@@ -374,7 +374,7 @@ static RzAnalBlock *bbget(RzAnal *anal, ut64 addr, bool jumpmid) {
continue;
}
RzAnalOp op;
int size = rz_anal_op (anal, &op, at, buf + off, bb->size - off, R_ANAL_OP_MASK_BASIC);
int size = rz_anal_op (anal, &op, at, buf + off, bb->size - off, RZ_ANAL_OP_MASK_BASIC);
if (size > 0 && op.delay) {
if (op.delay >= last_instr_idx - i) {
in_delay_slot = true;
@@ -426,7 +426,7 @@ static bool fcn_takeover_block_recursive_followthrough_cb(RzAnalBlock *block, vo
void **it;
rz_pvector_foreach (cloned_vars_used, it) {
RzAnalVar *other_var = *it;
const int actual_delta = other_var->kind == R_ANAL_VAR_KIND_SPV
const int actual_delta = other_var->kind == RZ_ANAL_VAR_KIND_SPV
? other_var->delta + ctx->stack_diff
: other_var->delta + (other_fcn->bp_off - our_fcn->bp_off);
RzAnalVar *our_var = rz_anal_function_get_var (our_fcn, other_var->kind, actual_delta);
@@ -494,7 +494,7 @@ static void analyze_retpoline(RzAnal *anal, RzAnalOp *op) {
if (anal->opt.retpoline) {
const char *rr = retpoline_reg (anal, op->jump);
if (rr) {
op->type = R_ANAL_OP_TYPE_RJMP;
op->type = RZ_ANAL_OP_TYPE_RJMP;
op->reg = rr;
}
}
@@ -519,7 +519,7 @@ static int fcn_recurse(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
char *last_reg_mov_lea_name = NULL;
RzAnalBlock *bb = NULL;
RzAnalBlock *bbg = NULL;
int ret = R_ANAL_RET_END, skip_ret = 0;
int ret = RZ_ANAL_RET_END, skip_ret = 0;
bool overlapped = false;
RzAnalOp op = {0};
int oplen, idx = 0;
@@ -543,12 +543,12 @@ static int fcn_recurse(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
bool is_dalvik = is_x86? false: anal->cur->arch && !strncmp (anal->cur->arch, "dalvik", 6);
RzRegItem *variadic_reg = NULL;
if (is_amd64) {
variadic_reg = rz_reg_get (anal->reg, "rax", R_REG_TYPE_GPR);
variadic_reg = rz_reg_get (anal->reg, "rax", RZ_REG_TYPE_GPR);
}
bool has_variadic_reg = !!variadic_reg;
if (rz_cons_is_breaked ()) {
return R_ANAL_RET_END;
return RZ_ANAL_RET_END;
}
if (anal->sleep) {
rz_sys_usleep (anal->sleep);
@@ -558,7 +558,7 @@ static int fcn_recurse(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
if (anal->verbose) {
eprintf ("Anal went too deep at address 0x%"PFMT64x ".\n", addr);
}
return R_ANAL_RET_ERROR; // MUST BE TOO DEEP
return RZ_ANAL_RET_ERROR; // MUST BE TOO DEEP
}
// check if address is readable //:
@@ -568,12 +568,12 @@ static int fcn_recurse(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
eprintf ("Invalid address 0x%"PFMT64x ". Try with io.va=true\n", addr);
}
}
return R_ANAL_RET_ERROR; // MUST BE TOO DEEP
return RZ_ANAL_RET_ERROR; // MUST BE TOO DEEP
}
RzAnalFunction *fcn_at_addr = rz_anal_get_function_at (anal, addr);
if (fcn_at_addr && fcn_at_addr != fcn) {
return R_ANAL_RET_ERROR; // MUST BE NOT FOUND
return RZ_ANAL_RET_ERROR; // MUST BE NOT FOUND
}
RzAnalBlock *existing_bb = bbget (anal, addr, anal->opt.jmpmid && is_x86);
@@ -590,23 +590,23 @@ static int fcn_recurse(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
rz_anal_block_unref (existing_bb);
}
if (anal->opt.recont) {
return R_ANAL_RET_END;
return RZ_ANAL_RET_END;
}
if (anal->verbose) {
eprintf ("rz_anal_fcn_bb() fails at 0x%"PFMT64x ".\n", addr);
}
return R_ANAL_RET_ERROR; // MUST BE NOT DUP
return RZ_ANAL_RET_ERROR; // MUST BE NOT DUP
}
bb = fcn_append_basic_block (anal, fcn, addr);
// we checked before whether there is a bb at addr, so the create should have succeeded
rz_return_val_if_fail (bb, R_ANAL_RET_ERROR);
rz_return_val_if_fail (bb, RZ_ANAL_RET_ERROR);
if (!anal->leaddrs) {
anal->leaddrs = rz_list_newf (free);
if (!anal->leaddrs) {
eprintf ("Cannot create leaddr list\n");
gotoBeach (R_ANAL_RET_ERROR);
gotoBeach (RZ_ANAL_RET_ERROR);
}
}
static ut64 lea_jmptbl_ip = UT64_MAX;
@@ -616,7 +616,7 @@ static int fcn_recurse(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
bool last_is_mov_lr_pc = false;
ut64 last_push_addr = UT64_MAX;
if (anal->limit && addr + idx < anal->limit->from) {
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
RzAnalFunction *tmp_fcn = rz_anal_get_fcn_in (anal, addr, 0);
if (tmp_fcn) {
@@ -641,7 +641,7 @@ static int fcn_recurse(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
}
if (skipAnalysis) {
ret = 0;
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
}
if ((maxlen - (addrbytes * idx)) > MAX_SCAN_SIZE) {
@@ -665,7 +665,7 @@ repeat:
}
ut32 at_delta = addrbytes * idx;
ut64 at = addr + at_delta;
ut64 bytes_read = R_MIN (len - at_delta, sizeof (buf));
ut64 bytes_read = RZ_MIN (len - at_delta, sizeof (buf));
ret = read_ahead (anal, at, buf, bytes_read);
if (ret < 0) {
@@ -676,19 +676,19 @@ repeat:
if (anal->verbose) {
eprintf ("Warning: FFFF opcode at 0x%08"PFMT64x "\n", at);
}
gotoBeach (R_ANAL_RET_ERROR)
gotoBeach (RZ_ANAL_RET_ERROR)
}
rz_anal_op_fini (&op);
if ((oplen = rz_anal_op (anal, &op, at, buf, bytes_read, R_ANAL_OP_MASK_ESIL | R_ANAL_OP_MASK_VAL | R_ANAL_OP_MASK_HINT)) < 1) {
if ((oplen = rz_anal_op (anal, &op, at, buf, bytes_read, RZ_ANAL_OP_MASK_ESIL | RZ_ANAL_OP_MASK_VAL | RZ_ANAL_OP_MASK_HINT)) < 1) {
if (anal->verbose) {
eprintf ("Invalid instruction at 0x%"PFMT64x" with %d bits\n", at, anal->bits);
}
// gotoBeach (R_ANAL_RET_ERROR);
// gotoBeach (RZ_ANAL_RET_ERROR);
// RET_END causes infinite loops somehow
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
const char *bp_reg = anal->reg->name[R_REG_NAME_BP];
const char *sp_reg = anal->reg->name[R_REG_NAME_SP];
const char *bp_reg = anal->reg->name[RZ_REG_NAME_BP];
const char *sp_reg = anal->reg->name[RZ_REG_NAME_SP];
bool has_stack_regs = bp_reg && sp_reg;
if (anal->opt.nopskip && fcn->addr == at) {
@@ -702,10 +702,10 @@ repeat:
}
}
}
switch (op.type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_TRAP:
case R_ANAL_OP_TYPE_ILL:
case R_ANAL_OP_TYPE_NOP:
switch (op.type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_TRAP:
case RZ_ANAL_OP_TYPE_ILL:
case RZ_ANAL_OP_TYPE_NOP:
if (rz_anal_block_relocate (bb, at + op.size, bb->size)) {
addr = at + op.size;
fcn->addr = addr;
@@ -736,7 +736,7 @@ repeat:
if (!overlapped) {
ut64 newbbsize = bb->size + oplen;
if (newbbsize > MAX_FCN_SIZE) {
gotoBeach (R_ANAL_RET_ERROR);
gotoBeach (RZ_ANAL_RET_ERROR);
}
rz_anal_bb_set_offset (bb, bb->ninstr++, at - bb->addr);
rz_anal_block_set_size (bb, newbbsize);
@@ -762,7 +762,7 @@ repeat:
rz_anal_block_unref (bb);
bb = fcn_append_basic_block (anal, fcn, addr);
if (!bb) {
gotoBeach (R_ANAL_RET_ERROR);
gotoBeach (RZ_ANAL_RET_ERROR);
}
}
}
@@ -825,8 +825,8 @@ repeat:
// Note: if we got two branch delay instructions in a row due to an
// compiler bug or junk or something it wont get treated as a delay
switch (op.stackop) {
case R_ANAL_STACK_INC:
if (R_ABS (op.stackptr) < 8096) {
case RZ_ANAL_STACK_INC:
if (RZ_ABS (op.stackptr) < 8096) {
fcn->stack += op.stackptr;
if (fcn->stack > fcn->maxstack) {
fcn->maxstack = fcn->stack;
@@ -834,7 +834,7 @@ repeat:
}
bb->stackptr += op.stackptr;
break;
case R_ANAL_STACK_RESET:
case RZ_ANAL_STACK_RESET:
bb->stackptr = 0;
break;
default:
@@ -842,12 +842,12 @@ repeat:
}
if (op.ptr && op.ptr != UT64_MAX && op.ptr != UT32_MAX) {
// swapped parameters wtf
rz_anal_xrefs_set (anal, op.addr, op.ptr, R_ANAL_REF_TYPE_DATA);
rz_anal_xrefs_set (anal, op.addr, op.ptr, RZ_ANAL_REF_TYPE_DATA);
}
analyze_retpoline (anal, &op);
switch (op.type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_CMOV:
case R_ANAL_OP_TYPE_MOV:
switch (op.type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_CMOV:
case RZ_ANAL_OP_TYPE_MOV:
last_is_reg_mov_lea = false;
if (is_arm) { // mov lr, pc
const char *esil = rz_strbuf_get (&op.esil);
@@ -879,21 +879,21 @@ repeat:
goto repeat;
}
if (skip_ret == 2) {
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
}
break;
case R_ANAL_OP_TYPE_LEA:
case RZ_ANAL_OP_TYPE_LEA:
last_is_reg_mov_lea = false;
// if first byte in op.ptr is 0xff, then set leaddr assuming its a jumptable
{
ut8 buf[4];
anal->iob.read_at (anal->iob.io, op.ptr, buf, sizeof (buf));
if ((buf[2] == 0xff || buf[2] == 0xfe) && buf[3] == 0xff) {
leaddr_pair *pair = R_NEW (leaddr_pair);
leaddr_pair *pair = RZ_NEW (leaddr_pair);
if (!pair) {
eprintf ("Cannot create leaddr_pair\n");
gotoBeach (R_ANAL_RET_ERROR);
gotoBeach (RZ_ANAL_RET_ERROR);
}
pair->op_addr = op.addr;
pair->leaddr = op.ptr; // XXX movdisp is dupped but seems to be trashed sometimes(?), better track leaddr separately
@@ -918,7 +918,7 @@ repeat:
goto repeat;
}
if (skip_ret == 2) {
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
}
if (anal->opt.jmptbl) {
@@ -946,51 +946,51 @@ repeat:
rz_anal_op_fini (&jmp_aop);
}
break;
case R_ANAL_OP_TYPE_LOAD:
case RZ_ANAL_OP_TYPE_LOAD:
if (anal->opt.loads) {
if (anal->iob.is_valid_offset (anal->iob.io, op.ptr, 0)) {
rz_meta_set (anal, R_META_TYPE_DATA, op.ptr, 4, "");
rz_meta_set (anal, RZ_META_TYPE_DATA, op.ptr, 4, "");
}
}
break;
// Case of valid but unused "add [rax], al"
case R_ANAL_OP_TYPE_ADD:
case RZ_ANAL_OP_TYPE_ADD:
if (anal->opt.ijmp) {
if ((op.size + 4 <= bytes_read) && !memcmp (buf + op.size, "\x00\x00\x00\x00", 4)) {
rz_anal_block_set_size (bb, bb->size - oplen);
op.type = R_ANAL_OP_TYPE_RET;
gotoBeach (R_ANAL_RET_END);
op.type = RZ_ANAL_OP_TYPE_RET;
gotoBeach (RZ_ANAL_RET_END);
}
}
break;
case R_ANAL_OP_TYPE_ILL:
gotoBeach (R_ANAL_RET_END);
case R_ANAL_OP_TYPE_TRAP:
gotoBeach (R_ANAL_RET_END);
case R_ANAL_OP_TYPE_NOP:
case RZ_ANAL_OP_TYPE_ILL:
gotoBeach (RZ_ANAL_RET_END);
case RZ_ANAL_OP_TYPE_TRAP:
gotoBeach (RZ_ANAL_RET_END);
case RZ_ANAL_OP_TYPE_NOP:
// do nothing, because the nopskip goes before this switch
break;
case R_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_JMP:
if (op.jump == UT64_MAX) {
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
{
RzFlagItem *fi = anal->flb.get_at (anal->flb.f, op.jump, false);
if (fi && strstr (fi->name, "imp.")) {
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
}
if (rz_cons_is_breaked ()) {
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
if (anal->opt.jmpref) {
(void) rz_anal_xrefs_set (anal, op.addr, op.jump, R_ANAL_REF_TYPE_CODE);
(void) rz_anal_xrefs_set (anal, op.addr, op.jump, RZ_ANAL_REF_TYPE_CODE);
}
if (!anal->opt.jmpabove && (op.jump < fcn->addr)) {
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
if (rz_anal_noreturn_at (anal, op.jump)) {
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
{
bool must_eob = true;
@@ -1000,14 +1000,14 @@ repeat:
}
if (must_eob) {
op.jump = UT64_MAX;
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
}
#if FIX_JMP_FWD
bb->jump = op.jump;
bb->fail = UT64_MAX;
FITFCNSZ ();
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
#else
if (!overlapped) {
bb->jump = op.jump;
@@ -1024,22 +1024,22 @@ repeat:
if (rz_anal_is_prelude (anal, buf, sizeof (buf))) {
fcn_recurse (anal, fcn, op.jump, anal->opt.bb_max_size, depth - 1);
}
} else if (R_ABS (diff) > tc) {
(void) rz_anal_xrefs_set (anal, op.addr, op.jump, R_ANAL_REF_TYPE_CALL);
} else if (RZ_ABS (diff) > tc) {
(void) rz_anal_xrefs_set (anal, op.addr, op.jump, RZ_ANAL_REF_TYPE_CALL);
fcn_recurse (anal, fcn, op.jump, anal->opt.bb_max_size, depth - 1);
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
}
goto beach;
#endif
break;
case R_ANAL_OP_TYPE_SUB:
case RZ_ANAL_OP_TYPE_SUB:
if (op.val != UT64_MAX && op.val > 0) {
// if register is not stack
cmpval = op.val;
}
break;
case R_ANAL_OP_TYPE_CMP: {
case RZ_ANAL_OP_TYPE_CMP: {
ut64 val = is_x86 ? op.val : op.ptr;
if (val) {
cmpval = val;
@@ -1049,12 +1049,12 @@ repeat:
}
}
break;
case R_ANAL_OP_TYPE_CJMP:
case R_ANAL_OP_TYPE_MCJMP:
case R_ANAL_OP_TYPE_RCJMP:
case R_ANAL_OP_TYPE_UCJMP:
case RZ_ANAL_OP_TYPE_CJMP:
case RZ_ANAL_OP_TYPE_MCJMP:
case RZ_ANAL_OP_TYPE_RCJMP:
case RZ_ANAL_OP_TYPE_UCJMP:
if (anal->opt.cjmpref) {
(void) rz_anal_xrefs_set (anal, op.addr, op.jump, R_ANAL_REF_TYPE_CODE);
(void) rz_anal_xrefs_set (anal, op.addr, op.jump, RZ_ANAL_REF_TYPE_CODE);
}
if (!overlapped) {
bb->jump = op.jump;
@@ -1101,7 +1101,7 @@ repeat:
bb->jump = op.jump;
bb->fail = UT64_MAX;
}
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
}
@@ -1113,47 +1113,47 @@ repeat:
goto beach;
// For some reason, branch delayed code (MIPS) needs to continue
break;
case R_ANAL_OP_TYPE_UCALL:
case R_ANAL_OP_TYPE_RCALL:
case R_ANAL_OP_TYPE_ICALL:
case R_ANAL_OP_TYPE_IRCALL:
case RZ_ANAL_OP_TYPE_UCALL:
case RZ_ANAL_OP_TYPE_RCALL:
case RZ_ANAL_OP_TYPE_ICALL:
case RZ_ANAL_OP_TYPE_IRCALL:
/* call [dst] */
// XXX: this is TYPE_MCALL or indirect-call
(void) rz_anal_xrefs_set (anal, op.addr, op.ptr, R_ANAL_REF_TYPE_CALL);
(void) rz_anal_xrefs_set (anal, op.addr, op.ptr, RZ_ANAL_REF_TYPE_CALL);
if (rz_anal_noreturn_at (anal, op.ptr)) {
RzAnalFunction *f = rz_anal_get_function_at (anal, op.ptr);
if (f) {
f->is_noreturn = true;
}
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
break;
case R_ANAL_OP_TYPE_CCALL:
case R_ANAL_OP_TYPE_CALL:
case RZ_ANAL_OP_TYPE_CCALL:
case RZ_ANAL_OP_TYPE_CALL:
/* call dst */
(void) rz_anal_xrefs_set (anal, op.addr, op.jump, R_ANAL_REF_TYPE_CALL);
(void) rz_anal_xrefs_set (anal, op.addr, op.jump, RZ_ANAL_REF_TYPE_CALL);
if (rz_anal_noreturn_at (anal, op.jump)) {
RzAnalFunction *f = rz_anal_get_function_at (anal, op.jump);
if (f) {
f->is_noreturn = true;
}
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
break;
case R_ANAL_OP_TYPE_UJMP:
case R_ANAL_OP_TYPE_RJMP:
case RZ_ANAL_OP_TYPE_UJMP:
case RZ_ANAL_OP_TYPE_RJMP:
if (is_arm && last_is_mov_lr_pc) {
break;
}
/* fall through */
case R_ANAL_OP_TYPE_MJMP:
case R_ANAL_OP_TYPE_IJMP:
case R_ANAL_OP_TYPE_IRJMP:
case RZ_ANAL_OP_TYPE_MJMP:
case RZ_ANAL_OP_TYPE_IJMP:
case RZ_ANAL_OP_TYPE_IRJMP:
// if the next instruction is a symbol
if (anal->opt.ijmp && isSymbolNextInstruction (anal, &op)) {
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
// switch statement
if (anal->opt.jmptbl && lea_jmptbl_ip != op.addr) {
@@ -1165,12 +1165,12 @@ repeat:
bool case_table = false;
RzAnalOp prev_op;
anal->iob.read_at (anal->iob.io, op.addr - op.size, buf, sizeof (buf));
if (rz_anal_op (anal, &prev_op, op.addr - op.size, buf, sizeof (buf), R_ANAL_OP_MASK_VAL) > 0) {
if (rz_anal_op (anal, &prev_op, op.addr - op.size, buf, sizeof (buf), RZ_ANAL_OP_MASK_VAL) > 0) {
bool prev_op_has_dst_name = prev_op.dst && prev_op.dst->reg && prev_op.dst->reg->name;
bool op_has_src_name = op.src[0] && op.src[0]->reg && op.src[0]->reg->name;
bool same_reg = (op.ireg && prev_op_has_dst_name && !strcmp (op.ireg, prev_op.dst->reg->name))
|| (op_has_src_name && prev_op_has_dst_name && !strcmp (op.src[0]->reg->name, prev_op.dst->reg->name));
if (prev_op.type == R_ANAL_OP_TYPE_MOV && prev_op.disp && prev_op.disp != UT64_MAX && same_reg) {
if (prev_op.type == RZ_ANAL_OP_TYPE_MOV && prev_op.disp && prev_op.disp != UT64_MAX && same_reg) {
// movzx reg, byte [reg + case_table]
// jmp dword [reg*4 + jump_table]
if (try_walkthrough_casetbl (anal, fcn, bb, depth, op.addr, op.ptr, prev_op.disp, op.ptr, anal->bits >> 3, table_size, default_case, ret)) {
@@ -1264,37 +1264,37 @@ repeat:
}
} else {
analopfinish:
if (op.type == R_ANAL_OP_TYPE_RJMP) {
gotoBeach (R_ANAL_RET_NOP);
if (op.type == RZ_ANAL_OP_TYPE_RJMP) {
gotoBeach (RZ_ANAL_RET_NOP);
} else {
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
}
break;
/* fallthru */
case R_ANAL_OP_TYPE_PUSH:
case RZ_ANAL_OP_TYPE_PUSH:
last_is_push = true;
last_push_addr = op.val;
if (anal->iob.is_valid_offset (anal->iob.io, last_push_addr, 1)) {
(void) rz_anal_xrefs_set (anal, op.addr, last_push_addr, R_ANAL_REF_TYPE_DATA);
(void) rz_anal_xrefs_set (anal, op.addr, last_push_addr, RZ_ANAL_REF_TYPE_DATA);
}
break;
case R_ANAL_OP_TYPE_UPUSH:
if ((op.type & R_ANAL_OP_TYPE_REG) && last_is_reg_mov_lea && op.src[0] && op.src[0]->reg
case RZ_ANAL_OP_TYPE_UPUSH:
if ((op.type & RZ_ANAL_OP_TYPE_REG) && last_is_reg_mov_lea && op.src[0] && op.src[0]->reg
&& op.src[0]->reg->name && !strcmp (op.src[0]->reg->name, last_reg_mov_lea_name)) {
last_is_push = true;
last_push_addr = last_reg_mov_lea_val;
if (anal->iob.is_valid_offset (anal->iob.io, last_push_addr, 1)) {
(void) rz_anal_xrefs_set (anal, op.addr, last_push_addr, R_ANAL_REF_TYPE_DATA);
(void) rz_anal_xrefs_set (anal, op.addr, last_push_addr, RZ_ANAL_REF_TYPE_DATA);
}
}
break;
case R_ANAL_OP_TYPE_RET:
if (op.family == R_ANAL_OP_FAMILY_PRIV) {
fcn->type = R_ANAL_FCN_TYPE_INT;
case RZ_ANAL_OP_TYPE_RET:
if (op.family == RZ_ANAL_OP_FAMILY_PRIV) {
fcn->type = RZ_ANAL_FCN_TYPE_INT;
}
if (last_is_push && anal->opt.pushret) {
op.type = R_ANAL_OP_TYPE_JMP;
op.type = RZ_ANAL_OP_TYPE_JMP;
op.jump = last_push_addr;
bb->jump = op.jump;
ret = rz_anal_fcn_bb (anal, fcn, op.jump, depth);
@@ -1306,17 +1306,17 @@ analopfinish:
addr + delay.un_idx - oplen, rz_str_bool (overlapped),
bb->size, rz_anal_function_linear_size (fcn));
}
gotoBeach (R_ANAL_RET_END);
gotoBeach (RZ_ANAL_RET_END);
}
break;
}
if (has_stack_regs && arch_destroys_dst) {
if (op_is_set_bp (&op, bp_reg, sp_reg) && op.src[1]) {
switch (op.type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_ADD:
switch (op.type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_ADD:
fcn->bp_off = fcn->stack - op.src[1]->imm;
break;
case R_ANAL_OP_TYPE_SUB:
case RZ_ANAL_OP_TYPE_SUB:
fcn->bp_off = fcn->stack + op.src[1]->imm;
break;
}
@@ -1325,20 +1325,20 @@ analopfinish:
if (anal->opt.vars && !varset) {
rz_anal_extract_vars (anal, fcn, &op);
}
if (op.type != R_ANAL_OP_TYPE_MOV && op.type != R_ANAL_OP_TYPE_CMOV && op.type != R_ANAL_OP_TYPE_LEA) {
if (op.type != RZ_ANAL_OP_TYPE_MOV && op.type != RZ_ANAL_OP_TYPE_CMOV && op.type != RZ_ANAL_OP_TYPE_LEA) {
last_is_reg_mov_lea = false;
}
if (op.type != R_ANAL_OP_TYPE_PUSH && op.type != R_ANAL_OP_TYPE_RPUSH) {
if (op.type != RZ_ANAL_OP_TYPE_PUSH && op.type != RZ_ANAL_OP_TYPE_RPUSH) {
last_is_push = false;
}
if (is_arm && op.type != R_ANAL_OP_TYPE_MOV) {
if (is_arm && op.type != RZ_ANAL_OP_TYPE_MOV) {
last_is_mov_lr_pc = false;
}
if (has_variadic_reg && !fcn->is_variadic) {
variadic_reg = rz_reg_get (anal->reg, "rax", R_REG_TYPE_GPR);
variadic_reg = rz_reg_get (anal->reg, "rax", RZ_REG_TYPE_GPR);
bool dst_is_variadic = op.dst && op.dst->reg
&& variadic_reg && op.dst->reg->offset == variadic_reg->offset;
bool op_is_cmp = (op.type == R_ANAL_OP_TYPE_CMP) || op.type == R_ANAL_OP_TYPE_ACMP;
bool op_is_cmp = (op.type == RZ_ANAL_OP_TYPE_CMP) || op.type == RZ_ANAL_OP_TYPE_ACMP;
if (dst_is_variadic && !op_is_cmp) {
has_variadic_reg = false;
} else if (op_is_cmp) {
@@ -1350,7 +1350,7 @@ analopfinish:
}
beach:
rz_anal_op_fini (&op);
R_FREE (last_reg_mov_lea_name);
RZ_FREE (last_reg_mov_lea_name);
if (bb && bb->size == 0) {
rz_anal_function_remove_block (fcn, bb);
}
@@ -1372,28 +1372,28 @@ RZ_API bool rz_anal_check_fcn(RzAnal *anal, ut8 *buf, ut16 bufsz, ut64 addr, ut6
}
for (i = 0; i < bufsz && opcnt < 10; i += oplen, opcnt++) {
rz_anal_op_fini (&op);
if ((oplen = rz_anal_op (anal, &op, addr + i, buf + i, bufsz - i, R_ANAL_OP_MASK_BASIC | R_ANAL_OP_MASK_HINT)) < 1) {
if ((oplen = rz_anal_op (anal, &op, addr + i, buf + i, bufsz - i, RZ_ANAL_OP_MASK_BASIC | RZ_ANAL_OP_MASK_HINT)) < 1) {
return false;
}
switch (op.type) {
case R_ANAL_OP_TYPE_PUSH:
case R_ANAL_OP_TYPE_UPUSH:
case R_ANAL_OP_TYPE_RPUSH:
case RZ_ANAL_OP_TYPE_PUSH:
case RZ_ANAL_OP_TYPE_UPUSH:
case RZ_ANAL_OP_TYPE_RPUSH:
pushcnt++;
break;
case R_ANAL_OP_TYPE_MOV:
case R_ANAL_OP_TYPE_CMOV:
case RZ_ANAL_OP_TYPE_MOV:
case RZ_ANAL_OP_TYPE_CMOV:
movcnt++;
break;
case R_ANAL_OP_TYPE_JMP:
case R_ANAL_OP_TYPE_CJMP:
case R_ANAL_OP_TYPE_CALL:
case RZ_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_CJMP:
case RZ_ANAL_OP_TYPE_CALL:
if (op.jump < low || op.jump >= high) {
return false;
}
brcnt++;
break;
case R_ANAL_OP_TYPE_UNK:
case RZ_ANAL_OP_TYPE_UNK:
return false;
default:
break;
@@ -1409,7 +1409,7 @@ RZ_API void rz_anal_trim_jmprefs(RzAnal *anal, RzAnalFunction *fcn) {
const bool is_x86 = anal->cur->arch && !strcmp (anal->cur->arch, "x86"); // HACK
rz_list_foreach (refs, iter, ref) {
if (ref->type == R_ANAL_REF_TYPE_CODE && rz_anal_function_contains (fcn, ref->addr)
if (ref->type == RZ_ANAL_REF_TYPE_CODE && rz_anal_function_contains (fcn, ref->addr)
&& (!is_x86 || !rz_anal_function_contains (fcn, ref->at))) {
rz_anal_xrefs_deln (anal, ref->at, ref->addr, ref->type);
}
@@ -1423,7 +1423,7 @@ RZ_API void rz_anal_del_jmprefs(RzAnal *anal, RzAnalFunction *fcn) {
RzListIter *iter;
rz_list_foreach (refs, iter, ref) {
if (ref->type == R_ANAL_REF_TYPE_CODE) {
if (ref->type == RZ_ANAL_REF_TYPE_CODE) {
rz_anal_xrefs_deln (anal, ref->at, ref->addr, ref->type);
}
}
@@ -1432,14 +1432,14 @@ RZ_API void rz_anal_del_jmprefs(RzAnal *anal, RzAnalFunction *fcn) {
/* Does NOT invalidate read-ahead cache. */
RZ_API int rz_anal_fcn(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, int reftype) {
RPVector *metas = rz_meta_get_all_in(anal, addr, R_META_TYPE_ANY);
RPVector *metas = rz_meta_get_all_in(anal, addr, RZ_META_TYPE_ANY);
void **it;
rz_pvector_foreach (metas, it) {
RzAnalMetaItem *meta = ((RIntervalNode *)*it)->data;
switch (meta->type) {
case R_META_TYPE_DATA:
case R_META_TYPE_STRING:
case R_META_TYPE_FORMAT:
case RZ_META_TYPE_DATA:
case RZ_META_TYPE_STRING:
case RZ_META_TYPE_FORMAT:
rz_pvector_free (metas);
return 0;
default:
@@ -1453,7 +1453,7 @@ RZ_API int rz_anal_fcn(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
}
if (set_u_contains (anal->visited, addr)) {
eprintf ("rz_anal_fcn: anal.norevisit at 0x%08"PFMT64x" %c\n", addr, reftype);
return R_ANAL_RET_END;
return RZ_ANAL_RET_END;
}
set_u_add (anal->visited, addr);
} else {
@@ -1463,7 +1463,7 @@ RZ_API int rz_anal_fcn(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
}
}
/* defines fcn. or loc. prefix */
fcn->type = (reftype == R_ANAL_REF_TYPE_CODE) ? R_ANAL_FCN_TYPE_LOC : R_ANAL_FCN_TYPE_FCN;
fcn->type = (reftype == RZ_ANAL_REF_TYPE_CODE) ? RZ_ANAL_FCN_TYPE_LOC : RZ_ANAL_FCN_TYPE_FCN;
if (fcn->addr == UT64_MAX) {
fcn->addr = addr;
}
@@ -1479,7 +1479,7 @@ RZ_API int rz_anal_fcn(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
eprintf ("Failed to analyze basic block at 0x%"PFMT64x"\n", addr);
}
}
if (anal->opt.endsize && ret == R_ANAL_RET_END && rz_anal_function_realsize (fcn)) { // cfg analysis completed
if (anal->opt.endsize && ret == RZ_ANAL_RET_END && rz_anal_function_realsize (fcn)) { // cfg analysis completed
RzListIter *iter;
RzAnalBlock *bb;
ut64 endaddr = fcn->addr;
@@ -1510,12 +1510,12 @@ RZ_API int rz_anal_fcn(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, ut64 len, i
// XXX deprecate
RZ_API int rz_anal_fcn_del_locs(RzAnal *anal, ut64 addr) {
RzListIter *iter, *iter2;
RzAnalFunction *fcn, *f = rz_anal_get_fcn_in (anal, addr, R_ANAL_FCN_TYPE_ROOT);
RzAnalFunction *fcn, *f = rz_anal_get_fcn_in (anal, addr, RZ_ANAL_FCN_TYPE_ROOT);
if (!f) {
return false;
}
rz_list_foreach_safe (anal->fcns, iter, iter2, fcn) {
if (fcn->type != R_ANAL_FCN_TYPE_LOC) {
if (fcn->type != RZ_ANAL_FCN_TYPE_LOC) {
continue;
}
if (rz_anal_function_contains (fcn, addr)) {
@@ -1542,7 +1542,7 @@ RZ_API RzAnalFunction *rz_anal_get_fcn_in(RzAnal *anal, ut64 addr, int type) {
RzList *list = rz_anal_get_functions_in (anal, addr);
RzAnalFunction *ret = NULL;
if (list && !rz_list_empty (list)) {
if (type == R_ANAL_FCN_TYPE_ROOT) {
if (type == RZ_ANAL_FCN_TYPE_ROOT) {
RzAnalFunction *fcn;
RzListIter *iter;
rz_list_foreach (list, iter, fcn) {
@@ -1562,7 +1562,7 @@ RZ_API RzAnalFunction *rz_anal_get_fcn_in(RzAnal *anal, ut64 addr, int type) {
RZ_API RzAnalFunction *rz_anal_get_fcn_in_bounds(RzAnal *anal, ut64 addr, int type) {
RzAnalFunction *fcn, *ret = NULL;
RzListIter *iter;
if (type == R_ANAL_FCN_TYPE_ROOT) {
if (type == RZ_ANAL_FCN_TYPE_ROOT) {
rz_list_foreach (anal->fcns, iter, fcn) {
if (addr == fcn->addr) {
return fcn;
@@ -1590,7 +1590,7 @@ RZ_API RzAnalFunction *rz_anal_get_function_byname(RzAnal *a, const char *name)
}
/* rename RzAnalFunctionBB.add() */
RZ_API bool rz_anal_fcn_add_bb(RzAnal *a, RzAnalFunction *fcn, ut64 addr, ut64 size, ut64 jump, ut64 fail, R_BORROW RzAnalDiff *diff) {
RZ_API bool rz_anal_fcn_add_bb(RzAnal *a, RzAnalFunction *fcn, ut64 addr, ut64 size, ut64 jump, ut64 fail, RZ_BORROW RzAnalDiff *diff) {
D eprintf ("Add bb\n");
if (size == 0) { // empty basic blocks allowed?
eprintf ("Warning: empty basic block at 0x%08"PFMT64x" is not allowed. pending discussion.\n", addr);
@@ -1640,7 +1640,7 @@ RZ_API bool rz_anal_fcn_add_bb(RzAnal *a, RzAnalFunction *fcn, ut64 addr, ut64 s
block->diff->type = diff->type;
block->diff->addr = diff->addr;
if (diff->name) {
R_FREE (block->diff->name);
RZ_FREE (block->diff->name);
block->diff->name = strdup (diff->name);
}
}
@@ -1756,7 +1756,7 @@ RZ_API char *rz_anal_function_get_signature(RzAnalFunction *function) {
const char *realname = NULL, *import_substring = NULL;
RzFlagItem *flag = a->flag_get (a->flb.f, function->addr);
// Can't access R_FLAGS_FS_IMPORTS, since it is defined in rz_core.h
// Can't access RZ_FLAGS_FS_IMPORTS, since it is defined in rz_core.h
if (flag && flag->space && !strcmp (flag->space->name, "imports")) {
// Get substring after last dot
import_substring = rz_str_rchr (function->name, NULL, '.');
@@ -1905,7 +1905,7 @@ RZ_API ut32 rz_anal_function_cost(RzAnalFunction *fcn) {
int idx = 0;
for (at = bb->addr; at < end;) {
memset (&op, 0, sizeof (op));
(void) rz_anal_op (anal, &op, at, buf + idx, bb->size - idx, R_ANAL_OP_MASK_BASIC);
(void) rz_anal_op (anal, &op, at, buf + idx, bb->size - idx, RZ_ANAL_OP_MASK_BASIC);
if (op.size < 1) {
op.size = 1;
}
@@ -1919,7 +1919,7 @@ RZ_API ut32 rz_anal_function_cost(RzAnalFunction *fcn) {
return totalCycles;
}
RZ_API int rz_anal_function_count_edges(const RzAnalFunction *fcn, R_NULLABLE int *ebbs) {
RZ_API int rz_anal_function_count_edges(const RzAnalFunction *fcn, RZ_NULLABLE int *ebbs) {
rz_return_val_if_fail (fcn, 0);
RzListIter *iter;
RzAnalBlock *bb;
@@ -1958,10 +1958,10 @@ static bool can_affect_bp(RzAnal *anal, RzAnalOp* op) {
RzAnalValue *src = op->src[0];
const char *opdreg = (dst && dst->reg) ? dst->reg->name : NULL;
const char *opsreg = (src && src->reg) ? src->reg->name : NULL;
const char *bp_name = anal->reg->name[R_REG_NAME_BP];
const char *bp_name = anal->reg->name[RZ_REG_NAME_BP];
bool is_bp_dst = opdreg && !dst->memref && !strcmp (opdreg, bp_name);
bool is_bp_src = opsreg && !src->memref && !strcmp (opsreg, bp_name);
if (op->type == R_ANAL_OP_TYPE_XCHG) {
if (op->type == RZ_ANAL_OP_TYPE_XCHG) {
return is_bp_src || is_bp_dst;
}
return is_bp_dst;
@@ -1976,7 +1976,7 @@ static void __anal_fcn_check_bp_use(RzAnal *anal, RzAnalFunction *fcn) {
RzAnalBlock *bb;
char str_to_find[40] = "\"type\":\"reg\",\"value\":\"";
char *pos;
strncat (str_to_find, anal->reg->name[R_REG_NAME_BP], 39);
strncat (str_to_find, anal->reg->name[RZ_REG_NAME_BP], 39);
if (!fcn) {
return;
}
@@ -1990,33 +1990,33 @@ static void __anal_fcn_check_bp_use(RzAnal *anal, RzAnalFunction *fcn) {
(void)anal->iob.read_at (anal->iob.io, bb->addr, (ut8 *) buf, bb->size);
int idx = 0;
for (at = bb->addr; at < end;) {
rz_anal_op (anal, &op, at, buf + idx, bb->size - idx, R_ANAL_OP_MASK_VAL | R_ANAL_OP_MASK_OPEX);
rz_anal_op (anal, &op, at, buf + idx, bb->size - idx, RZ_ANAL_OP_MASK_VAL | RZ_ANAL_OP_MASK_OPEX);
if (op.size < 1) {
op.size = 1;
}
switch (op.type) {
case R_ANAL_OP_TYPE_MOV:
case R_ANAL_OP_TYPE_LEA:
case RZ_ANAL_OP_TYPE_MOV:
case RZ_ANAL_OP_TYPE_LEA:
if (can_affect_bp (anal, &op) && op.src[0] && op.src[0]->reg && op.src[0]->reg->name
&& strcmp (op.src[0]->reg->name, anal->reg->name[R_REG_NAME_SP])) {
&& strcmp (op.src[0]->reg->name, anal->reg->name[RZ_REG_NAME_SP])) {
fcn->bp_frame = false;
rz_anal_op_fini (&op);
return;
}
break;
case R_ANAL_OP_TYPE_ADD:
case R_ANAL_OP_TYPE_AND:
case R_ANAL_OP_TYPE_CMOV:
case R_ANAL_OP_TYPE_NOT:
case R_ANAL_OP_TYPE_OR:
case R_ANAL_OP_TYPE_ROL:
case R_ANAL_OP_TYPE_ROR:
case R_ANAL_OP_TYPE_SAL:
case R_ANAL_OP_TYPE_SAR:
case R_ANAL_OP_TYPE_SHR:
case R_ANAL_OP_TYPE_SUB:
case R_ANAL_OP_TYPE_XOR:
case R_ANAL_OP_TYPE_SHL:
case RZ_ANAL_OP_TYPE_ADD:
case RZ_ANAL_OP_TYPE_AND:
case RZ_ANAL_OP_TYPE_CMOV:
case RZ_ANAL_OP_TYPE_NOT:
case RZ_ANAL_OP_TYPE_OR:
case RZ_ANAL_OP_TYPE_ROL:
case RZ_ANAL_OP_TYPE_ROR:
case RZ_ANAL_OP_TYPE_SAL:
case RZ_ANAL_OP_TYPE_SAR:
case RZ_ANAL_OP_TYPE_SHR:
case RZ_ANAL_OP_TYPE_SUB:
case RZ_ANAL_OP_TYPE_XOR:
case RZ_ANAL_OP_TYPE_SHL:
// op.dst is not filled for these operations, so for now, check for bp as dst looks like this; in the future it may be just replaced with call to can_affect_bp
pos = op.opex.ptr ? strstr (op.opex.ptr, str_to_find) : NULL;
if (pos && pos - op.opex.ptr < 60) {
@@ -2025,14 +2025,14 @@ static void __anal_fcn_check_bp_use(RzAnal *anal, RzAnalFunction *fcn) {
return;
}
break;
case R_ANAL_OP_TYPE_XCHG:
case RZ_ANAL_OP_TYPE_XCHG:
if (op.opex.ptr && strstr (op.opex.ptr, str_to_find)) {
fcn->bp_frame = false;
rz_anal_op_fini (&op);
return;
}
break;
case R_ANAL_OP_TYPE_POP:
case RZ_ANAL_OP_TYPE_POP:
break;
default:
break;
+20 -20
View File
@@ -284,7 +284,7 @@ static int header_size = 0;
// XXX need more infos on compression of version 5 sigs
// rz_inflate doesn't work with them
#define R_FLIRT_NAME_MAX 1024
#define RZ_FLIRT_NAME_MAX 1024
typedef struct RFlirtTailByte {
ut16 offset; // from pattern_size + crc_length
@@ -292,7 +292,7 @@ typedef struct RFlirtTailByte {
} RFlirtTailByte;
typedef struct RFlirtFunction {
char name[R_FLIRT_NAME_MAX];
char name[RZ_FLIRT_NAME_MAX];
ut16 offset; // function offset from the module start
ut8 negative_offset; // true if offset is negative, for referenced functions
ut8 is_local; // true if function is static
@@ -672,7 +672,7 @@ static int node_match_functions(RzAnal *anal, const RFlirtNode *root_node) {
RzListIter *it_func;
RzAnalFunction *func;
rz_list_foreach (anal->fcns, it_func, func) {
if (func->type != R_ANAL_FCN_TYPE_FCN && func->type != R_ANAL_FCN_TYPE_LOC) { // scan only for unknown functions
if (func->type != RZ_ANAL_FCN_TYPE_FCN && func->type != RZ_ANAL_FCN_TYPE_LOC) { // scan only for unknown functions
continue;
}
@@ -719,7 +719,7 @@ static ut8 read_module_tail_bytes(RFlirtModule *module, RBuffer *b) {
number_of_tail_bytes = 1;
}
for (i = 0; i < number_of_tail_bytes; i++) {
tail_byte = R_NEW0 (RFlirtTailByte);
tail_byte = RZ_NEW0 (RFlirtTailByte);
if (!tail_byte) {
return false;
}
@@ -773,7 +773,7 @@ static ut8 read_module_referenced_functions(RFlirtModule *module, RBuffer *b) {
}
for (i = 0; i < number_of_referenced_functions; i++) {
ref_function = R_NEW0 (RFlirtFunction);
ref_function = RZ_NEW0 (RFlirtFunction);
if (!ref_function) {
goto err_exit;
}
@@ -799,7 +799,7 @@ static ut8 read_module_referenced_functions(RFlirtModule *module, RBuffer *b) {
goto err_exit;
}
}
if ((int) ref_function_name_length < 0 || ref_function_name_length >= R_FLIRT_NAME_MAX) {
if ((int) ref_function_name_length < 0 || ref_function_name_length >= RZ_FLIRT_NAME_MAX) {
goto err_exit;
}
for (j = 0; j < ref_function_name_length; j++) {
@@ -838,7 +838,7 @@ static ut8 read_module_public_functions(RFlirtModule *module, RBuffer *b, ut8 *f
module->public_functions = rz_list_new ();
do {
function = R_NEW0 (RFlirtFunction);
function = RZ_NEW0 (RFlirtFunction);
if (version >= 9) { // seems like version 9 introduced some larger offsets
offset += read_multiple_bytes (b); // offsets are dependent of the previous ones
if (buf_eof || buf_err) {
@@ -877,7 +877,7 @@ static ut8 read_module_public_functions(RFlirtModule *module, RBuffer *b, ut8 *f
}
}
for (i = 0; current_byte >= 0x20 && i < R_FLIRT_NAME_MAX; i++) {
for (i = 0; current_byte >= 0x20 && i < RZ_FLIRT_NAME_MAX; i++) {
function->name[i] = current_byte;
current_byte = read_byte (b);
if (buf_eof || buf_err) {
@@ -885,9 +885,9 @@ static ut8 read_module_public_functions(RFlirtModule *module, RBuffer *b, ut8 *f
}
}
if (i == R_FLIRT_NAME_MAX) {
if (i == RZ_FLIRT_NAME_MAX) {
eprintf ("Function name too long\n");
function->name[R_FLIRT_NAME_MAX - 1] = '\0';
function->name[RZ_FLIRT_NAME_MAX - 1] = '\0';
} else {
function->name[i] = '\0';
}
@@ -934,7 +934,7 @@ static ut8 parse_leaf(const RzAnal *anal, RBuffer *b, RFlirtNode *node) {
#endif
do { // loop for all modules having the same crc
module = R_NEW0 (RFlirtModule);
module = RZ_NEW0 (RFlirtModule);
if (!module) {
goto err_exit;
}
@@ -1062,7 +1062,7 @@ static ut8 parse_tree(const RzAnal *anal, RBuffer *b, RFlirtNode *root_node) {
root_node->child_list = rz_list_new ();
for (i = 0; i < tree_nodes; i++) {
if (!(node = R_NEW0 (RFlirtNode))) {
if (!(node = RZ_NEW0 (RFlirtNode))) {
goto err_exit;
}
if (!read_node_length (node, b)) {
@@ -1225,7 +1225,7 @@ static void print_header(idasig_v5_t *header) {
#endif
static int parse_header(RBuffer *buf, idasig_v5_t *header) {
rz_buf_seek (buf, 0, R_BUF_SET);
rz_buf_seek (buf, 0, RZ_BUF_SET);
if (rz_buf_read (buf, header->magic, sizeof(header->magic)) != sizeof(header->magic)) {
return false;
}
@@ -1314,14 +1314,14 @@ static RFlirtNode *flirt_parse(const RzAnal *anal, RBuffer *flirt_buf) {
goto exit;
}
if (!(header = R_NEW0 (idasig_v5_t))) {
if (!(header = RZ_NEW0 (idasig_v5_t))) {
goto exit;
}
parse_header (flirt_buf, header);
if (version >= 6) {
if (!(v6_v7 = R_NEW0 (idasig_v6_v7_t))) {
if (!(v6_v7 = RZ_NEW0 (idasig_v6_v7_t))) {
goto exit;
}
if (!parse_v6_v7_header (flirt_buf, v6_v7)) {
@@ -1329,7 +1329,7 @@ static RFlirtNode *flirt_parse(const RzAnal *anal, RBuffer *flirt_buf) {
}
if (version >= 8) {
if (!(v8_v9 = R_NEW0 (idasig_v8_v9_t))) {
if (!(v8_v9 = RZ_NEW0 (idasig_v8_v9_t))) {
goto exit;
}
if (!parse_v8_v9_header (flirt_buf, v8_v9)) {
@@ -1337,7 +1337,7 @@ static RFlirtNode *flirt_parse(const RzAnal *anal, RBuffer *flirt_buf) {
}
if (version >= 10) {
if (!(v10 = R_NEW0 (idasig_v10_t))) {
if (!(v10 = RZ_NEW0 (idasig_v10_t))) {
goto exit;
}
if (!parse_v10_header (flirt_buf, v10)) {
@@ -1380,12 +1380,12 @@ static RFlirtNode *flirt_parse(const RzAnal *anal, RBuffer *flirt_buf) {
goto exit;
}
R_FREE (buf);
RZ_FREE (buf);
buf = decompressed_buf;
size = decompressed_size;
}
if (!(node = R_NEW0 (RFlirtNode))) {
if (!(node = RZ_NEW0 (RFlirtNode))) {
goto exit;
}
rz_buf = rz_buf_new_with_pointers (buf, size, false);
@@ -1412,7 +1412,7 @@ RZ_API int rz_sign_is_flirt(RBuffer *buf) {
/*if buf is a flirt signature, returns signature version, otherwise returns false*/
int ret = false;
idasig_v5_t *header = R_NEW0 (idasig_v5_t);
idasig_v5_t *header = RZ_NEW0 (idasig_v5_t);
if (rz_buf_read (buf, header->magic, sizeof(header->magic)) != sizeof(header->magic)) {
goto exit;
}
+3 -3
View File
@@ -52,7 +52,7 @@ static bool __fcn_exists(RzAnal *anal, const char *name, ut64 addr) {
return false;
}
R_IPI void rz_anal_var_free(RzAnalVar *av);
RZ_IPI void rz_anal_var_free(RzAnalVar *av);
static void inst_vars_kv_free(HtUPKv *kv) {
rz_pvector_free (kv->value);
@@ -68,7 +68,7 @@ static void label_addrs_kv_free(HtPPKv *kv) {
}
RZ_API RzAnalFunction *rz_anal_function_new(RzAnal *anal) {
RzAnalFunction *fcn = R_NEW0 (RzAnalFunction);
RzAnalFunction *fcn = RZ_NEW0 (RzAnalFunction);
if (!fcn) {
return NULL;
}
@@ -165,7 +165,7 @@ RZ_API RzAnalFunction *rz_anal_create_function(RzAnal *anal, const char *name, u
if (diff) {
fcn->diff->type = diff->type;
fcn->diff->addr = diff->addr;
R_FREE (fcn->diff->name);
RZ_FREE (fcn->diff->name);
if (diff->name) {
fcn->diff->name = strdup (diff->name);
}
+57 -57
View File
@@ -36,16 +36,16 @@ static void addr_hint_record_fini(void *element, void *user) {
(void)user;
RzAnalAddrHintRecord *record = element;
switch (record->type) {
case R_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET:
case RZ_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET:
free (record->type_offset);
break;
case R_ANAL_ADDR_HINT_TYPE_SYNTAX:
case RZ_ANAL_ADDR_HINT_TYPE_SYNTAX:
free (record->syntax);
break;
case R_ANAL_ADDR_HINT_TYPE_OPCODE:
case RZ_ANAL_ADDR_HINT_TYPE_OPCODE:
free (record->opcode);
break;
case R_ANAL_ADDR_HINT_TYPE_ESIL:
case RZ_ANAL_ADDR_HINT_TYPE_ESIL:
free (record->esil);
break;
default:
@@ -199,83 +199,83 @@ static RzAnalRangedHintRecordBase *ensure_ranged_hint_record(RBTree *tree, ut64
}
RZ_API void rz_anal_hint_set_offset(RzAnal *a, ut64 addr, const char *typeoff) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET,
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET,
free (r->type_offset);
r->type_offset = strdup (typeoff);
);
}
RZ_API void rz_anal_hint_set_nword(RzAnal *a, ut64 addr, int nword) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_NWORD, r->nword = nword;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_NWORD, r->nword = nword;);
}
RZ_API void rz_anal_hint_set_jump(RzAnal *a, ut64 addr, ut64 jump) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_JUMP, r->jump = jump;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_JUMP, r->jump = jump;);
}
RZ_API void rz_anal_hint_set_fail(RzAnal *a, ut64 addr, ut64 fail) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_FAIL, r->fail = fail;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_FAIL, r->fail = fail;);
}
RZ_API void rz_anal_hint_set_newbits(RzAnal *a, ut64 addr, int bits) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_NEW_BITS, r->newbits = bits;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_NEW_BITS, r->newbits = bits;);
}
RZ_API void rz_anal_hint_set_high(RzAnal *a, ut64 addr) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_HIGH,);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_HIGH,);
}
RZ_API void rz_anal_hint_set_immbase(RzAnal *a, ut64 addr, int base) {
if (base) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_IMMBASE, r->immbase = base;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_IMMBASE, r->immbase = base;);
} else {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_IMMBASE, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_IMMBASE, addr);
}
}
RZ_API void rz_anal_hint_set_pointer(RzAnal *a, ut64 addr, ut64 ptr) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_PTR, r->ptr = ptr;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_PTR, r->ptr = ptr;);
}
RZ_API void rz_anal_hint_set_ret(RzAnal *a, ut64 addr, ut64 val) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_RET, r->retval = val;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_RET, r->retval = val;);
}
RZ_API void rz_anal_hint_set_syntax(RzAnal *a, ut64 addr, const char *syn) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_SYNTAX,
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_SYNTAX,
free (r->syntax);
r->syntax = strdup (syn);
);
}
RZ_API void rz_anal_hint_set_opcode(RzAnal *a, ut64 addr, const char *opcode) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_OPCODE,
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_OPCODE,
free (r->opcode);
r->opcode = strdup (opcode);
);
}
RZ_API void rz_anal_hint_set_esil(RzAnal *a, ut64 addr, const char *esil) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_ESIL,
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_ESIL,
free (r->esil);
r->esil = strdup (esil);
);
}
RZ_API void rz_anal_hint_set_type (RzAnal *a, ut64 addr, int type) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_OPTYPE, r->optype = type;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_OPTYPE, r->optype = type;);
}
RZ_API void rz_anal_hint_set_size(RzAnal *a, ut64 addr, ut64 size) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_SIZE, r->size = size;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_SIZE, r->size = size;);
}
RZ_API void rz_anal_hint_set_stackframe(RzAnal *a, ut64 addr, ut64 size) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_STACKFRAME, r->stackframe = size;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_STACKFRAME, r->stackframe = size;);
}
RZ_API void rz_anal_hint_set_val(RzAnal *a, ut64 addr, ut64 v) {
SET_HINT (R_ANAL_ADDR_HINT_TYPE_VAL, r->val = v;);
SET_HINT (RZ_ANAL_ADDR_HINT_TYPE_VAL, r->val = v;);
}
RZ_API void rz_anal_hint_set_arch(RzAnal *a, ut64 addr, const char *arch) {
@@ -299,67 +299,67 @@ RZ_API void rz_anal_hint_set_bits(RzAnal *a, ut64 addr, int bits) {
}
RZ_API void rz_anal_hint_unset_size(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_SIZE, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_SIZE, addr);
}
RZ_API void rz_anal_hint_unset_esil(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_ESIL, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_ESIL, addr);
}
RZ_API void rz_anal_hint_unset_opcode(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_OPCODE, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_OPCODE, addr);
}
RZ_API void rz_anal_hint_unset_high(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_HIGH, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_HIGH, addr);
}
RZ_API void rz_anal_hint_unset_immbase(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_IMMBASE, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_IMMBASE, addr);
}
RZ_API void rz_anal_hint_unset_nword(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_NWORD, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_NWORD, addr);
}
RZ_API void rz_anal_hint_unset_syntax(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_SYNTAX, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_SYNTAX, addr);
}
RZ_API void rz_anal_hint_unset_pointer(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_PTR, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_PTR, addr);
}
RZ_API void rz_anal_hint_unset_ret(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_RET, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_RET, addr);
}
RZ_API void rz_anal_hint_unset_offset(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET, addr);
}
RZ_API void rz_anal_hint_unset_jump(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_JUMP, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_JUMP, addr);
}
RZ_API void rz_anal_hint_unset_fail(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_FAIL, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_FAIL, addr);
}
RZ_API void rz_anal_hint_unset_newbits(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_NEW_BITS, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_NEW_BITS, addr);
}
RZ_API void rz_anal_hint_unset_val (RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_VAL, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_VAL, addr);
}
RZ_API void rz_anal_hint_unset_type (RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_OPTYPE, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_OPTYPE, addr);
}
RZ_API void rz_anal_hint_unset_stackframe(RzAnal *a, ut64 addr) {
unset_addr_hint_record (a, R_ANAL_ADDR_HINT_TYPE_STACKFRAME, addr);
unset_addr_hint_record (a, RZ_ANAL_ADDR_HINT_TYPE_STACKFRAME, addr);
}
RZ_API void rz_anal_hint_unset_arch(RzAnal *a, ut64 addr) {
@@ -381,7 +381,7 @@ RZ_API void rz_anal_hint_free(RzAnalHint *h) {
}
}
RZ_API R_NULLABLE R_BORROW const char *rz_anal_hint_arch_at(RzAnal *anal, ut64 addr, R_NULLABLE ut64 *hint_addr) {
RZ_API RZ_NULLABLE RZ_BORROW const char *rz_anal_hint_arch_at(RzAnal *anal, ut64 addr, RZ_NULLABLE ut64 *hint_addr) {
RBNode *node = rz_rbtree_upper_bound (anal->arch_hints, &addr, ranged_hint_record_cmp, NULL);
if (!node) {
if (hint_addr) {
@@ -396,7 +396,7 @@ RZ_API R_NULLABLE R_BORROW const char *rz_anal_hint_arch_at(RzAnal *anal, ut64 a
return record->arch;
}
RZ_API int rz_anal_hint_bits_at(RzAnal *anal, ut64 addr, R_NULLABLE ut64 *hint_addr) {
RZ_API int rz_anal_hint_bits_at(RzAnal *anal, ut64 addr, RZ_NULLABLE ut64 *hint_addr) {
RBNode *node = rz_rbtree_upper_bound (anal->bits_hints, &addr, ranged_hint_record_cmp, NULL);
if (!node) {
if (hint_addr) {
@@ -411,7 +411,7 @@ RZ_API int rz_anal_hint_bits_at(RzAnal *anal, ut64 addr, R_NULLABLE ut64 *hint_a
return record->bits;
}
RZ_API R_NULLABLE const RzVector/*<const RzAnalAddrHintRecord>*/ *rz_anal_addr_hints_at(RzAnal *anal, ut64 addr) {
RZ_API RZ_NULLABLE const RzVector/*<const RzAnalAddrHintRecord>*/ *rz_anal_addr_hints_at(RzAnal *anal, ut64 addr) {
return ht_up_find (anal->addr_hints, addr, NULL);
}
@@ -454,59 +454,59 @@ RZ_API void rz_anal_bits_hints_foreach(RzAnal *anal, RzAnalBitsHintCb cb, void *
static void hint_merge(RzAnalHint *hint, RzAnalAddrHintRecord *record) {
switch (record->type) {
case R_ANAL_ADDR_HINT_TYPE_IMMBASE:
case RZ_ANAL_ADDR_HINT_TYPE_IMMBASE:
hint->immbase = record->immbase;
break;
case R_ANAL_ADDR_HINT_TYPE_JUMP:
case RZ_ANAL_ADDR_HINT_TYPE_JUMP:
hint->jump = record->jump;
break;
case R_ANAL_ADDR_HINT_TYPE_FAIL:
case RZ_ANAL_ADDR_HINT_TYPE_FAIL:
hint->fail = record->fail;
break;
case R_ANAL_ADDR_HINT_TYPE_STACKFRAME:
case RZ_ANAL_ADDR_HINT_TYPE_STACKFRAME:
hint->stackframe = record->stackframe;
break;
case R_ANAL_ADDR_HINT_TYPE_PTR:
case RZ_ANAL_ADDR_HINT_TYPE_PTR:
hint->ptr = record->ptr;
break;
case R_ANAL_ADDR_HINT_TYPE_NWORD:
case RZ_ANAL_ADDR_HINT_TYPE_NWORD:
hint->nword = record->nword;
break;
case R_ANAL_ADDR_HINT_TYPE_RET:
case RZ_ANAL_ADDR_HINT_TYPE_RET:
hint->ret = record->retval;
break;
case R_ANAL_ADDR_HINT_TYPE_NEW_BITS:
case RZ_ANAL_ADDR_HINT_TYPE_NEW_BITS:
hint->new_bits = record->newbits;
break;
case R_ANAL_ADDR_HINT_TYPE_SIZE:
case RZ_ANAL_ADDR_HINT_TYPE_SIZE:
hint->size = record->size;
break;
case R_ANAL_ADDR_HINT_TYPE_SYNTAX:
case RZ_ANAL_ADDR_HINT_TYPE_SYNTAX:
hint->syntax = record->syntax ? strdup (record->syntax) : NULL;
break;
case R_ANAL_ADDR_HINT_TYPE_OPTYPE:
case RZ_ANAL_ADDR_HINT_TYPE_OPTYPE:
hint->type = record->optype;
break;
case R_ANAL_ADDR_HINT_TYPE_OPCODE:
case RZ_ANAL_ADDR_HINT_TYPE_OPCODE:
hint->opcode = record->opcode ? strdup (record->opcode) : NULL;
break;
case R_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET:
case RZ_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET:
hint->offset = record->type_offset ? strdup (record->type_offset) : NULL;
break;
case R_ANAL_ADDR_HINT_TYPE_ESIL:
case RZ_ANAL_ADDR_HINT_TYPE_ESIL:
hint->esil = record->esil ? strdup (record->esil) : NULL;
break;
case R_ANAL_ADDR_HINT_TYPE_HIGH:
case RZ_ANAL_ADDR_HINT_TYPE_HIGH:
hint->high = true;
break;
case R_ANAL_ADDR_HINT_TYPE_VAL:
case RZ_ANAL_ADDR_HINT_TYPE_VAL:
hint->val = record->val;
break;
}
}
RZ_API RzAnalHint *rz_anal_hint_get(RzAnal *a, ut64 addr) {
RzAnalHint *hint = R_NEW0 (RzAnalHint);
RzAnalHint *hint = RZ_NEW0 (RzAnalHint);
if (!hint) {
return NULL;
}
+10 -10
View File
@@ -13,7 +13,7 @@ static void apply_case(RzAnal *anal, RzAnalBlock *block, ut64 switch_addr, ut64
// eprintf ("** apply_case: 0x%"PFMT64x " from 0x%"PFMT64x "\n", case_addr, case_addr_loc);
rz_meta_set_data_at (anal, case_addr_loc, offset_sz);
rz_anal_hint_set_immbase (anal, case_addr_loc, 10);
rz_anal_xrefs_set (anal, switch_addr, case_addr, R_ANAL_REF_TYPE_CODE);
rz_anal_xrefs_set (anal, switch_addr, case_addr, RZ_ANAL_REF_TYPE_CODE);
if (block) {
rz_anal_block_add_switch_case (block, switch_addr, id, case_addr);
}
@@ -27,12 +27,12 @@ static void apply_case(RzAnal *anal, RzAnalBlock *block, ut64 switch_addr, ut64
static void apply_switch(RzAnal *anal, ut64 switch_addr, ut64 jmptbl_addr, ut64 cases_count, ut64 default_case_addr) {
char tmp[0x30];
snprintf (tmp, sizeof (tmp), "switch table (%"PFMT64u" cases) at 0x%"PFMT64x, cases_count, jmptbl_addr);
rz_meta_set_string (anal, R_META_TYPE_COMMENT, switch_addr, tmp);
rz_meta_set_string (anal, RZ_META_TYPE_COMMENT, switch_addr, tmp);
if (anal->flb.set) {
snprintf (tmp, sizeof (tmp), "switch.0x%08"PFMT64x, switch_addr);
anal->flb.set (anal->flb.f, tmp, switch_addr, 1);
if (default_case_addr != UT64_MAX) {
rz_anal_xrefs_set (anal, switch_addr, default_case_addr, R_ANAL_REF_TYPE_CODE);
rz_anal_xrefs_set (anal, switch_addr, default_case_addr, RZ_ANAL_REF_TYPE_CODE);
snprintf (tmp, sizeof (tmp), "case.default.0x%"PFMT64x, switch_addr);
anal->flb.set (anal->flb.f, tmp, default_case_addr, 1);
}
@@ -231,13 +231,13 @@ RZ_API bool try_get_delta_jmptbl_info(RzAnal *anal, RzAnalFunction *fcn, ut64 jm
anal->iob.read_at (anal->iob.io, lea_addr, (ut8 *)buf, search_sz);
for (i = 0; i + 8 < search_sz; i++) {
int len = rz_anal_op (anal, &tmp_aop, lea_addr + i, buf + i, search_sz - i, R_ANAL_OP_MASK_BASIC);
int len = rz_anal_op (anal, &tmp_aop, lea_addr + i, buf + i, search_sz - i, RZ_ANAL_OP_MASK_BASIC);
if (len < 1) {
len = 1;
}
if (foundCmp) {
if (tmp_aop.type != R_ANAL_OP_TYPE_CJMP) {
if (tmp_aop.type != RZ_ANAL_OP_TYPE_CJMP) {
continue;
}
@@ -245,8 +245,8 @@ RZ_API bool try_get_delta_jmptbl_info(RzAnal *anal, RzAnalFunction *fcn, ut64 jm
break;
}
ut32 type = tmp_aop.type & R_ANAL_OP_TYPE_MASK;
if (type != R_ANAL_OP_TYPE_CMP) {
ut32 type = tmp_aop.type & RZ_ANAL_OP_TYPE_MASK;
if (type != RZ_ANAL_OP_TYPE_CMP) {
continue;
}
// get the value of the cmp
@@ -382,9 +382,9 @@ RZ_API bool try_get_jmptbl_info(RzAnal *anal, RzAnalFunction *fcn, ut64 addr, Rz
int buflen = prev_bb->size - prev_pos;
int len = rz_anal_op (anal, &tmp_aop, op_addr,
bb_buf + prev_pos, buflen,
R_ANAL_OP_MASK_BASIC | R_ANAL_OP_MASK_HINT);
ut32 type = tmp_aop.type & R_ANAL_OP_TYPE_MASK;
if (len < 1 || type != R_ANAL_OP_TYPE_CMP) {
RZ_ANAL_OP_MASK_BASIC | RZ_ANAL_OP_MASK_HINT);
ut32 type = tmp_aop.type & RZ_ANAL_OP_TYPE_MASK;
if (len < 1 || type != RZ_ANAL_OP_TYPE_CMP) {
rz_anal_op_fini (&tmp_aop);
continue;
}
+39 -39
View File
@@ -3,8 +3,8 @@
#include <rz_anal.h>
#include <rz_core.h>
static bool item_matches_filter(RzAnalMetaItem *item, RzAnalMetaType type, R_NULLABLE const RSpace *space) {
return (type == R_META_TYPE_ANY || item->type == type)
static bool item_matches_filter(RzAnalMetaItem *item, RzAnalMetaType type, RZ_NULLABLE const RSpace *space) {
return (type == RZ_META_TYPE_ANY || item->type == type)
&& (!space || item->space == space);
}
@@ -24,7 +24,7 @@ static bool find_node_cb(RIntervalNode *node, void *user) {
return true;
}
static RIntervalNode *find_node_at(RzAnal *anal, RzAnalMetaType type, R_NULLABLE const RSpace *space, ut64 addr) {
static RIntervalNode *find_node_at(RzAnal *anal, RzAnalMetaType type, RZ_NULLABLE const RSpace *space, ut64 addr) {
FindCtx ctx = {
.type = type,
.space = space,
@@ -34,7 +34,7 @@ static RIntervalNode *find_node_at(RzAnal *anal, RzAnalMetaType type, R_NULLABLE
return ctx.node;
}
static RIntervalNode *find_node_in(RzAnal *anal, RzAnalMetaType type, R_NULLABLE const RSpace *space, ut64 addr) {
static RIntervalNode *find_node_in(RzAnal *anal, RzAnalMetaType type, RZ_NULLABLE const RSpace *space, ut64 addr) {
FindCtx ctx = {
.type = type,
.space = space,
@@ -59,7 +59,7 @@ static bool collect_nodes_cb(RIntervalNode *node, void *user) {
return true;
}
static RPVector *collect_nodes_at(RzAnal *anal, RzAnalMetaType type, R_NULLABLE const RSpace *space, ut64 addr) {
static RPVector *collect_nodes_at(RzAnal *anal, RzAnalMetaType type, RZ_NULLABLE const RSpace *space, ut64 addr) {
CollectCtx ctx = {
.type = type,
.space = space,
@@ -72,7 +72,7 @@ static RPVector *collect_nodes_at(RzAnal *anal, RzAnalMetaType type, R_NULLABLE
return ctx.result;
}
static RPVector *collect_nodes_in(RzAnal *anal, RzAnalMetaType type, R_NULLABLE const RSpace *space, ut64 addr) {
static RPVector *collect_nodes_in(RzAnal *anal, RzAnalMetaType type, RZ_NULLABLE const RSpace *space, ut64 addr) {
CollectCtx ctx = {
.type = type,
.space = space,
@@ -85,7 +85,7 @@ static RPVector *collect_nodes_in(RzAnal *anal, RzAnalMetaType type, R_NULLABLE
return ctx.result;
}
static RPVector *collect_nodes_intersect(RzAnal *anal, RzAnalMetaType type, R_NULLABLE const RSpace *space, ut64 start, ut64 end) {
static RPVector *collect_nodes_intersect(RzAnal *anal, RzAnalMetaType type, RZ_NULLABLE const RSpace *space, ut64 start, ut64 end) {
CollectCtx ctx = {
.type = type,
.space = space,
@@ -104,7 +104,7 @@ static bool meta_set(RzAnal *a, RzAnalMetaType type, int subtype, ut64 from, ut6
}
RSpace *space = rz_spaces_current (&a->meta_spaces);
RIntervalNode *node = find_node_at (a, type, space, from);
RzAnalMetaItem *item = node ? node->data : R_NEW0 (RzAnalMetaItem);
RzAnalMetaItem *item = node ? node->data : RZ_NEW0 (RzAnalMetaItem);
if (!item) {
return false;
}
@@ -190,7 +190,7 @@ RZ_API bool rz_meta_set_with_subtype(RzAnal *m, RzAnalMetaType type, int subtype
return meta_set (m, type, subtype, addr, end, str);
}
RZ_API RzAnalMetaItem *rz_meta_get_at(RzAnal *a, ut64 addr, RzAnalMetaType type, R_OUT R_NULLABLE ut64 *size) {
RZ_API RzAnalMetaItem *rz_meta_get_at(RzAnal *a, ut64 addr, RzAnalMetaType type, RZ_OUT RZ_NULLABLE ut64 *size) {
RIntervalNode *node = find_node_at (a, type, rz_spaces_current (&a->meta_spaces), addr);
if (node && size) {
*size = rz_meta_item_size (node->start, node->end);
@@ -203,7 +203,7 @@ RZ_API RIntervalNode *rz_meta_get_in(RzAnal *a, ut64 addr, RzAnalMetaType type)
}
RZ_API RPVector/*<RIntervalNode<RMetaItem> *>*/ *rz_meta_get_all_at(RzAnal *a, ut64 at) {
return collect_nodes_at (a, R_META_TYPE_ANY, rz_spaces_current (&a->meta_spaces), at);
return collect_nodes_at (a, RZ_META_TYPE_ANY, rz_spaces_current (&a->meta_spaces), at);
}
RZ_API RPVector *rz_meta_get_all_in(RzAnal *a, ut64 at, RzAnalMetaType type) {
@@ -222,16 +222,16 @@ RZ_API RPVector *rz_meta_get_all_intersect(RzAnal *a, ut64 start, ut64 size, RzA
RZ_API const char *rz_meta_type_to_string(int type) {
// XXX: use type as '%c'
switch (type) {
case R_META_TYPE_DATA: return "Cd";
case R_META_TYPE_CODE: return "Cc";
case R_META_TYPE_STRING: return "Cs";
case R_META_TYPE_FORMAT: return "Cf";
case R_META_TYPE_MAGIC: return "Cm";
case R_META_TYPE_HIDE: return "Ch";
case R_META_TYPE_COMMENT: return "CCu";
case R_META_TYPE_RUN: return "Cr"; // not in C? help
case R_META_TYPE_HIGHLIGHT: return "ecHi"; // not in C?
case R_META_TYPE_VARTYPE: return "Ct";
case RZ_META_TYPE_DATA: return "Cd";
case RZ_META_TYPE_CODE: return "Cc";
case RZ_META_TYPE_STRING: return "Cs";
case RZ_META_TYPE_FORMAT: return "Cf";
case RZ_META_TYPE_MAGIC: return "Cm";
case RZ_META_TYPE_HIDE: return "Ch";
case RZ_META_TYPE_COMMENT: return "CCu";
case RZ_META_TYPE_RUN: return "Cr"; // not in C? help
case RZ_META_TYPE_HIGHLIGHT: return "ecHi"; // not in C?
case RZ_META_TYPE_VARTYPE: return "Ct";
}
return "# unknown meta # ";
}
@@ -247,8 +247,8 @@ RZ_API void rz_meta_print(RzAnal *a, RzAnalMetaItem *d, ut64 start, ut64 size, i
}
char *str = NULL;
if (d->str) {
if (d->type == R_META_TYPE_STRING) {
if (d->subtype == R_STRING_ENC_UTF8) {
if (d->type == RZ_META_TYPE_STRING) {
if (d->subtype == RZ_STRING_ENC_UTF8) {
str = rz_str_escape_utf8 (d->str, false, esc_bslash);
} else {
if (!d->subtype) { /* temporary legacy workaround */
@@ -260,8 +260,8 @@ RZ_API void rz_meta_print(RzAnal *a, RzAnalMetaItem *d, ut64 start, ut64 size, i
str = rz_str_escape (d->str);
}
}
if (str || d->type == R_META_TYPE_DATA) {
if (d->type == R_META_TYPE_STRING && !*str) {
if (str || d->type == RZ_META_TYPE_DATA) {
if (d->type == RZ_META_TYPE_STRING && !*str) {
free (str);
return;
}
@@ -321,7 +321,7 @@ RZ_API void rz_meta_print(RzAnal *a, RzAnalMetaItem *d, ut64 start, ut64 size, i
} else if (d->type == 's') {
const char *enc;
switch (d->subtype) {
case R_STRING_ENC_UTF8:
case RZ_STRING_ENC_UTF8:
enc = "utf8";
break;
case 0: /* temporary legacy encoding */
@@ -341,7 +341,7 @@ RZ_API void rz_meta_print(RzAnal *a, RzAnalMetaItem *d, ut64 start, ut64 size, i
case '*':
default:
switch (d->type) {
case R_META_TYPE_COMMENT:
case RZ_META_TYPE_COMMENT:
{
const char *type = rz_meta_type_to_string (d->type);
char *s = sdb_encode ((const ut8*)pstr, -1);
@@ -370,7 +370,7 @@ RZ_API void rz_meta_print(RzAnal *a, RzAnalMetaItem *d, ut64 start, ut64 size, i
free (s);
}
break;
case R_META_TYPE_STRING:
case RZ_META_TYPE_STRING:
if (rad) {
char cmd[] = "Cs#";
switch (d->subtype) {
@@ -401,8 +401,8 @@ RZ_API void rz_meta_print(RzAnal *a, RzAnalMetaItem *d, ut64 start, ut64 size, i
}
}
break;
case R_META_TYPE_HIDE:
case R_META_TYPE_DATA:
case RZ_META_TYPE_HIDE:
case RZ_META_TYPE_DATA:
if (rad) {
a->cb_printf ("%s %"PFMT64u" @ 0x%08"PFMT64x"\n",
rz_meta_type_to_string (d->type),
@@ -418,8 +418,8 @@ RZ_API void rz_meta_print(RzAnal *a, RzAnalMetaItem *d, ut64 start, ut64 size, i
}
}
break;
case R_META_TYPE_MAGIC:
case R_META_TYPE_FORMAT:
case RZ_META_TYPE_MAGIC:
case RZ_META_TYPE_FORMAT:
if (rad) {
a->cb_printf ("%s %"PFMT64u" %s @ 0x%08"PFMT64x"\n",
rz_meta_type_to_string (d->type),
@@ -434,7 +434,7 @@ RZ_API void rz_meta_print(RzAnal *a, RzAnalMetaItem *d, ut64 start, ut64 size, i
}
}
break;
case R_META_TYPE_VARTYPE:
case RZ_META_TYPE_VARTYPE:
if (rad) {
a->cb_printf ("%s %s @ 0x%08"PFMT64x"\n",
rz_meta_type_to_string (d->type), pstr, start);
@@ -442,7 +442,7 @@ RZ_API void rz_meta_print(RzAnal *a, RzAnalMetaItem *d, ut64 start, ut64 size, i
a->cb_printf ("0x%08"PFMT64x" %s\n", start, pstr);
}
break;
case R_META_TYPE_HIGHLIGHT:
case RZ_META_TYPE_HIGHLIGHT:
{
ut8 r = 0, g = 0, b = 0, A = 0;
const char *esc = strchr (d->str, '\x1b');
@@ -474,7 +474,7 @@ RZ_API void rz_meta_print(RzAnal *a, RzAnalMetaItem *d, ut64 start, ut64 size, i
}
RZ_API void rz_meta_print_list_at(RzAnal *a, ut64 addr, int rad) {
RPVector *nodes = collect_nodes_at (a, R_META_TYPE_ANY, rz_spaces_current (&a->meta_spaces), addr);
RPVector *nodes = collect_nodes_at (a, RZ_META_TYPE_ANY, rz_spaces_current (&a->meta_spaces), addr);
if (!nodes) {
return;
}
@@ -508,7 +508,7 @@ static void print_meta_list(RzAnal *a, int type, int rad, ut64 addr) {
RzAnalMetaItem *item;
rz_interval_tree_foreach (&a->meta, it, item) {
RIntervalNode *node = rz_interval_tree_iter_get (&it);
if (type != R_META_TYPE_ANY && item->type != type) {
if (type != RZ_META_TYPE_ANY && item->type != type) {
continue;
}
if (fcn && !rz_anal_function_contains (fcn, node->start)) {
@@ -557,7 +557,7 @@ RZ_API void rz_meta_rebase(RzAnal *anal, ut64 diff) {
}
RZ_API void rz_meta_space_unset_for(RzAnal *a, const RSpace *space) {
del (a, R_META_TYPE_ANY, space, 0, UT64_MAX);
del (a, RZ_META_TYPE_ANY, space, 0, UT64_MAX);
}
RZ_API ut64 rz_meta_get_size(RzAnal *a, RzAnalMetaType type) {
@@ -567,10 +567,10 @@ RZ_API ut64 rz_meta_get_size(RzAnal *a, RzAnalMetaType type) {
RIntervalNode *prev = NULL;
rz_interval_tree_foreach (&a->meta, it, item) {
RIntervalNode *node = rz_interval_tree_iter_get (&it);
if (type != R_META_TYPE_ANY && item->type != type) {
if (type != RZ_META_TYPE_ANY && item->type != type) {
continue;
}
ut64 start = R_MAX (prev ? prev->end : 0, node->start);
ut64 start = RZ_MAX (prev ? prev->end : 0, node->start);
sum += node->end - start + 1;
prev = node;
}
@@ -591,5 +591,5 @@ RZ_API int rz_meta_space_count_for(RzAnal *a, const RSpace *space) {
RZ_API void rz_meta_set_data_at(RzAnal *a, ut64 addr, ut64 wordsz) {
rz_return_if_fail (wordsz);
rz_meta_set (a, R_META_TYPE_DATA, addr, wordsz, NULL);
rz_meta_set (a, RZ_META_TYPE_DATA, addr, wordsz, NULL);
}
+242 -242
View File
@@ -5,7 +5,7 @@
#include <rz_list.h>
RZ_API RzAnalOp *rz_anal_op_new(void) {
RzAnalOp *op = R_NEW (RzAnalOp);
RzAnalOp *op = RZ_NEW (RzAnalOp);
rz_anal_op_init (op);
return op;
}
@@ -49,7 +49,7 @@ RZ_API bool rz_anal_op_fini(RzAnalOp *op) {
rz_strbuf_fini (&op->esil);
rz_anal_switch_op_free (op->switch_op);
op->switch_op = NULL;
R_FREE (op->mnemonic);
RZ_FREE (op->mnemonic);
return true;
}
@@ -64,24 +64,24 @@ RZ_API void rz_anal_op_free(void *_op) {
static int defaultCycles(RzAnalOp *op) {
switch (op->type) {
case R_ANAL_OP_TYPE_PUSH:
case R_ANAL_OP_TYPE_POP:
case R_ANAL_OP_TYPE_STORE:
case R_ANAL_OP_TYPE_LOAD:
case RZ_ANAL_OP_TYPE_PUSH:
case RZ_ANAL_OP_TYPE_POP:
case RZ_ANAL_OP_TYPE_STORE:
case RZ_ANAL_OP_TYPE_LOAD:
return 2;
case R_ANAL_OP_TYPE_LEA:
case R_ANAL_OP_TYPE_MOV:
case R_ANAL_OP_TYPE_NOP:
case RZ_ANAL_OP_TYPE_LEA:
case RZ_ANAL_OP_TYPE_MOV:
case RZ_ANAL_OP_TYPE_NOP:
return 1;
case R_ANAL_OP_TYPE_TRAP:
case R_ANAL_OP_TYPE_SWI:
case RZ_ANAL_OP_TYPE_TRAP:
case RZ_ANAL_OP_TYPE_SWI:
return 4;
case R_ANAL_OP_TYPE_SYNC:
case RZ_ANAL_OP_TYPE_SYNC:
return 4;
case R_ANAL_OP_TYPE_RET:
case R_ANAL_OP_TYPE_JMP:
case R_ANAL_OP_TYPE_RJMP:
case R_ANAL_OP_TYPE_CALL:
case RZ_ANAL_OP_TYPE_RET:
case RZ_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_RJMP:
case RZ_ANAL_OP_TYPE_CALL:
return 4;
default:
return 1;
@@ -92,7 +92,7 @@ RZ_API int rz_anal_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, in
rz_anal_op_init (op);
rz_return_val_if_fail (anal && op && len > 0, -1);
int ret = R_MIN (2, len);
int ret = RZ_MIN (2, len);
if (len > 0 && anal->cur && anal->cur->op) {
//use core binding to set asm.bits correctly based on the addr
//this is because of the hassle of arm/thumb
@@ -100,7 +100,7 @@ RZ_API int rz_anal_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, in
anal->coreb.archbits (anal->coreb.core, addr);
}
if (anal->pcalign && addr % anal->pcalign) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
op->addr = addr;
// eprintf ("Unaligned instruction for %d bits at 0x%"PFMT64x"\n", anal->bits, addr);
op->size = 1;
@@ -108,27 +108,27 @@ RZ_API int rz_anal_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, in
}
ret = anal->cur->op (anal, op, addr, data, len, mask);
if (ret < 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
}
op->addr = addr;
/* consider at least 1 byte to be part of the opcode */
if (op->nopcode < 1) {
op->nopcode = 1;
}
} else if (!memcmp (data, "\xff\xff\xff\xff", R_MIN (4, len))) {
op->type = R_ANAL_OP_TYPE_ILL;
} else if (!memcmp (data, "\xff\xff\xff\xff", RZ_MIN (4, len))) {
op->type = RZ_ANAL_OP_TYPE_ILL;
} else {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
if (op->cycles == 0) {
op->cycles = defaultCycles (op);
}
}
if (!op->mnemonic && (mask & R_ANAL_OP_MASK_DISASM)) {
if (!op->mnemonic && (mask & RZ_ANAL_OP_MASK_DISASM)) {
if (anal->verbose) {
eprintf ("Warning: unhandled R_ANAL_OP_MASK_DISASM in rz_anal_op\n");
eprintf ("Warning: unhandled RZ_ANAL_OP_MASK_DISASM in rz_anal_op\n");
}
}
if (mask & R_ANAL_OP_MASK_HINT) {
if (mask & RZ_ANAL_OP_MASK_HINT) {
RzAnalHint *hint = rz_anal_hint_get (anal, addr);
if (hint) {
rz_anal_op_hint (op, hint);
@@ -139,7 +139,7 @@ RZ_API int rz_anal_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, in
}
RZ_API RzAnalOp *rz_anal_op_copy(RzAnalOp *op) {
RzAnalOp *nop = R_NEW0 (RzAnalOp);
RzAnalOp *nop = RZ_NEW0 (RzAnalOp);
if (!nop) {
return NULL;
}
@@ -172,30 +172,30 @@ RZ_API RzAnalOp *rz_anal_op_copy(RzAnalOp *op) {
}
RZ_API bool rz_anal_op_nonlinear(int t) {
t &= R_ANAL_OP_TYPE_MASK;
t &= RZ_ANAL_OP_TYPE_MASK;
switch (t) {
//call
case R_ANAL_OP_TYPE_CALL:
case R_ANAL_OP_TYPE_RCALL:
case R_ANAL_OP_TYPE_ICALL:
case R_ANAL_OP_TYPE_UCALL:
case R_ANAL_OP_TYPE_IRCALL:
case R_ANAL_OP_TYPE_UCCALL:
case RZ_ANAL_OP_TYPE_CALL:
case RZ_ANAL_OP_TYPE_RCALL:
case RZ_ANAL_OP_TYPE_ICALL:
case RZ_ANAL_OP_TYPE_UCALL:
case RZ_ANAL_OP_TYPE_IRCALL:
case RZ_ANAL_OP_TYPE_UCCALL:
// jmp
case R_ANAL_OP_TYPE_JMP:
case R_ANAL_OP_TYPE_MJMP:
case R_ANAL_OP_TYPE_UJMP:
case R_ANAL_OP_TYPE_CJMP:
case R_ANAL_OP_TYPE_UCJMP:
case R_ANAL_OP_TYPE_RJMP:
case R_ANAL_OP_TYPE_IJMP:
case R_ANAL_OP_TYPE_IRJMP:
case RZ_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_MJMP:
case RZ_ANAL_OP_TYPE_UJMP:
case RZ_ANAL_OP_TYPE_CJMP:
case RZ_ANAL_OP_TYPE_UCJMP:
case RZ_ANAL_OP_TYPE_RJMP:
case RZ_ANAL_OP_TYPE_IJMP:
case RZ_ANAL_OP_TYPE_IRJMP:
// trap| ill| unk
case R_ANAL_OP_TYPE_TRAP:
case R_ANAL_OP_TYPE_ILL:
case R_ANAL_OP_TYPE_UNK:
case R_ANAL_OP_TYPE_SWI:
case R_ANAL_OP_TYPE_RET:
case RZ_ANAL_OP_TYPE_TRAP:
case RZ_ANAL_OP_TYPE_ILL:
case RZ_ANAL_OP_TYPE_UNK:
case RZ_ANAL_OP_TYPE_SWI:
case RZ_ANAL_OP_TYPE_RET:
return true;
default:
return false;
@@ -203,13 +203,13 @@ RZ_API bool rz_anal_op_nonlinear(int t) {
}
RZ_API bool rz_anal_op_ismemref(int t) {
t &= R_ANAL_OP_TYPE_MASK;
t &= RZ_ANAL_OP_TYPE_MASK;
switch (t) {
case R_ANAL_OP_TYPE_LOAD:
case R_ANAL_OP_TYPE_MOV:
case R_ANAL_OP_TYPE_STORE:
case R_ANAL_OP_TYPE_LEA:
case R_ANAL_OP_TYPE_CMP:
case RZ_ANAL_OP_TYPE_LOAD:
case RZ_ANAL_OP_TYPE_MOV:
case RZ_ANAL_OP_TYPE_STORE:
case RZ_ANAL_OP_TYPE_LEA:
case RZ_ANAL_OP_TYPE_CMP:
return true;
default:
return false;
@@ -220,67 +220,67 @@ static struct optype {
int type;
const char *name;
} optypes[] = {
{ R_ANAL_OP_TYPE_IO, "io" },
{ R_ANAL_OP_TYPE_ACMP, "acmp" },
{ R_ANAL_OP_TYPE_ADD, "add" },
{ R_ANAL_OP_TYPE_SYNC, "sync" },
{ R_ANAL_OP_TYPE_AND, "and" },
{ R_ANAL_OP_TYPE_CALL, "call" },
{ R_ANAL_OP_TYPE_CCALL, "ccall" },
{ R_ANAL_OP_TYPE_CJMP, "cjmp" },
{ R_ANAL_OP_TYPE_MJMP, "mjmp" },
{ R_ANAL_OP_TYPE_CMP, "cmp" },
{ R_ANAL_OP_TYPE_IO, "cret" },
{ R_ANAL_OP_TYPE_ILL, "ill" },
{ R_ANAL_OP_TYPE_JMP, "jmp" },
{ R_ANAL_OP_TYPE_LEA, "lea" },
{ R_ANAL_OP_TYPE_LEAVE, "leave" },
{ R_ANAL_OP_TYPE_LOAD, "load" },
{ R_ANAL_OP_TYPE_NEW, "new" },
{ R_ANAL_OP_TYPE_MOD, "mod" },
{ R_ANAL_OP_TYPE_CMOV, "cmov" },
{ R_ANAL_OP_TYPE_MOV, "mov" },
{ R_ANAL_OP_TYPE_CAST, "cast" },
{ R_ANAL_OP_TYPE_MUL, "mul" },
{ R_ANAL_OP_TYPE_DIV, "div" },
{ R_ANAL_OP_TYPE_NOP, "nop" },
{ R_ANAL_OP_TYPE_NOT, "not" },
{ R_ANAL_OP_TYPE_NULL , "null" },
{ R_ANAL_OP_TYPE_OR , "or" },
{ R_ANAL_OP_TYPE_POP , "pop" },
{ R_ANAL_OP_TYPE_PUSH , "push" },
{ R_ANAL_OP_TYPE_REP , "rep" },
{ R_ANAL_OP_TYPE_RET , "ret" },
{ R_ANAL_OP_TYPE_ROL , "rol" },
{ R_ANAL_OP_TYPE_ROR , "ror" },
{ R_ANAL_OP_TYPE_SAL , "sal" },
{ R_ANAL_OP_TYPE_SAR , "sar" },
{ R_ANAL_OP_TYPE_SHL , "shl" },
{ R_ANAL_OP_TYPE_SHR , "shr" },
{ R_ANAL_OP_TYPE_STORE , "store" },
{ R_ANAL_OP_TYPE_SUB , "sub" },
{ R_ANAL_OP_TYPE_SWI , "swi" },
{ R_ANAL_OP_TYPE_CSWI , "cswi" },
{ R_ANAL_OP_TYPE_SWITCH, "switch" },
{ R_ANAL_OP_TYPE_TRAP , "trap" },
{ R_ANAL_OP_TYPE_UCALL , "ucall" },
{ R_ANAL_OP_TYPE_RCALL , "rcall" }, // needs to be changed
{ R_ANAL_OP_TYPE_ICALL , "ucall" }, // needs to be changed
{ R_ANAL_OP_TYPE_IRCALL, "ucall" }, // needs to be changed
{ R_ANAL_OP_TYPE_UCCALL, "uccall" },
{ R_ANAL_OP_TYPE_UCJMP , "ucjmp" },
{ R_ANAL_OP_TYPE_UJMP , "ujmp" },
{ R_ANAL_OP_TYPE_RJMP , "rjmp" }, // needs to be changed
{ R_ANAL_OP_TYPE_IJMP , "ujmp" }, // needs to be changed
{ R_ANAL_OP_TYPE_IRJMP , "ujmp" }, // needs to be changed
{ R_ANAL_OP_TYPE_UNK , "unk" },
{ R_ANAL_OP_TYPE_UPUSH , "upush" },
{ R_ANAL_OP_TYPE_RPUSH , "rpush" },
{ R_ANAL_OP_TYPE_XCHG , "xchg" },
{ R_ANAL_OP_TYPE_XOR , "xor" },
{ R_ANAL_OP_TYPE_CASE , "case" },
{ R_ANAL_OP_TYPE_CPL , "cpl" },
{ R_ANAL_OP_TYPE_CRYPTO, "crypto" },
{ RZ_ANAL_OP_TYPE_IO, "io" },
{ RZ_ANAL_OP_TYPE_ACMP, "acmp" },
{ RZ_ANAL_OP_TYPE_ADD, "add" },
{ RZ_ANAL_OP_TYPE_SYNC, "sync" },
{ RZ_ANAL_OP_TYPE_AND, "and" },
{ RZ_ANAL_OP_TYPE_CALL, "call" },
{ RZ_ANAL_OP_TYPE_CCALL, "ccall" },
{ RZ_ANAL_OP_TYPE_CJMP, "cjmp" },
{ RZ_ANAL_OP_TYPE_MJMP, "mjmp" },
{ RZ_ANAL_OP_TYPE_CMP, "cmp" },
{ RZ_ANAL_OP_TYPE_IO, "cret" },
{ RZ_ANAL_OP_TYPE_ILL, "ill" },
{ RZ_ANAL_OP_TYPE_JMP, "jmp" },
{ RZ_ANAL_OP_TYPE_LEA, "lea" },
{ RZ_ANAL_OP_TYPE_LEAVE, "leave" },
{ RZ_ANAL_OP_TYPE_LOAD, "load" },
{ RZ_ANAL_OP_TYPE_NEW, "new" },
{ RZ_ANAL_OP_TYPE_MOD, "mod" },
{ RZ_ANAL_OP_TYPE_CMOV, "cmov" },
{ RZ_ANAL_OP_TYPE_MOV, "mov" },
{ RZ_ANAL_OP_TYPE_CAST, "cast" },
{ RZ_ANAL_OP_TYPE_MUL, "mul" },
{ RZ_ANAL_OP_TYPE_DIV, "div" },
{ RZ_ANAL_OP_TYPE_NOP, "nop" },
{ RZ_ANAL_OP_TYPE_NOT, "not" },
{ RZ_ANAL_OP_TYPE_NULL , "null" },
{ RZ_ANAL_OP_TYPE_OR , "or" },
{ RZ_ANAL_OP_TYPE_POP , "pop" },
{ RZ_ANAL_OP_TYPE_PUSH , "push" },
{ RZ_ANAL_OP_TYPE_REP , "rep" },
{ RZ_ANAL_OP_TYPE_RET , "ret" },
{ RZ_ANAL_OP_TYPE_ROL , "rol" },
{ RZ_ANAL_OP_TYPE_ROR , "ror" },
{ RZ_ANAL_OP_TYPE_SAL , "sal" },
{ RZ_ANAL_OP_TYPE_SAR , "sar" },
{ RZ_ANAL_OP_TYPE_SHL , "shl" },
{ RZ_ANAL_OP_TYPE_SHR , "shr" },
{ RZ_ANAL_OP_TYPE_STORE , "store" },
{ RZ_ANAL_OP_TYPE_SUB , "sub" },
{ RZ_ANAL_OP_TYPE_SWI , "swi" },
{ RZ_ANAL_OP_TYPE_CSWI , "cswi" },
{ RZ_ANAL_OP_TYPE_SWITCH, "switch" },
{ RZ_ANAL_OP_TYPE_TRAP , "trap" },
{ RZ_ANAL_OP_TYPE_UCALL , "ucall" },
{ RZ_ANAL_OP_TYPE_RCALL , "rcall" }, // needs to be changed
{ RZ_ANAL_OP_TYPE_ICALL , "ucall" }, // needs to be changed
{ RZ_ANAL_OP_TYPE_IRCALL, "ucall" }, // needs to be changed
{ RZ_ANAL_OP_TYPE_UCCALL, "uccall" },
{ RZ_ANAL_OP_TYPE_UCJMP , "ucjmp" },
{ RZ_ANAL_OP_TYPE_UJMP , "ujmp" },
{ RZ_ANAL_OP_TYPE_RJMP , "rjmp" }, // needs to be changed
{ RZ_ANAL_OP_TYPE_IJMP , "ujmp" }, // needs to be changed
{ RZ_ANAL_OP_TYPE_IRJMP , "ujmp" }, // needs to be changed
{ RZ_ANAL_OP_TYPE_UNK , "unk" },
{ RZ_ANAL_OP_TYPE_UPUSH , "upush" },
{ RZ_ANAL_OP_TYPE_RPUSH , "rpush" },
{ RZ_ANAL_OP_TYPE_XCHG , "xchg" },
{ RZ_ANAL_OP_TYPE_XOR , "xor" },
{ RZ_ANAL_OP_TYPE_CASE , "case" },
{ RZ_ANAL_OP_TYPE_CPL , "cpl" },
{ RZ_ANAL_OP_TYPE_CRYPTO, "crypto" },
{0,NULL}
};
@@ -299,71 +299,71 @@ RZ_API const char *rz_anal_optype_to_string(int t) {
repeat:
// TODO: delete
switch (t) {
case R_ANAL_OP_TYPE_IO : return "io";
case R_ANAL_OP_TYPE_ACMP : return "acmp";
case R_ANAL_OP_TYPE_ADD : return "add";
case R_ANAL_OP_TYPE_SYNC : return "sync";
case R_ANAL_OP_TYPE_AND : return "and";
case R_ANAL_OP_TYPE_CALL : return "call";
case R_ANAL_OP_TYPE_CCALL : return "ccall";
case R_ANAL_OP_TYPE_CJMP : return "cjmp";
case R_ANAL_OP_TYPE_MJMP : return "mjmp";
case R_ANAL_OP_TYPE_CMP : return "cmp";
case R_ANAL_OP_TYPE_CRET : return "cret";
case R_ANAL_OP_TYPE_DIV : return "div";
case R_ANAL_OP_TYPE_ILL : return "ill";
case R_ANAL_OP_TYPE_JMP : return "jmp";
case R_ANAL_OP_TYPE_LEA : return "lea";
case R_ANAL_OP_TYPE_LEAVE : return "leave";
case R_ANAL_OP_TYPE_LOAD : return "load";
case R_ANAL_OP_TYPE_NEW : return "new";
case R_ANAL_OP_TYPE_MOD : return "mod";
case R_ANAL_OP_TYPE_CMOV : return "cmov";
case R_ANAL_OP_TYPE_MOV : return "mov";
case R_ANAL_OP_TYPE_CAST : return "cast";
case R_ANAL_OP_TYPE_MUL : return "mul";
case R_ANAL_OP_TYPE_NOP : return "nop";
case R_ANAL_OP_TYPE_NOT : return "not";
case R_ANAL_OP_TYPE_NULL : return "null";
case R_ANAL_OP_TYPE_OR : return "or";
case R_ANAL_OP_TYPE_POP : return "pop";
case R_ANAL_OP_TYPE_PUSH : return "push";
case R_ANAL_OP_TYPE_RPUSH : return "rpush";
case R_ANAL_OP_TYPE_REP : return "rep";
case R_ANAL_OP_TYPE_RET : return "ret";
case R_ANAL_OP_TYPE_ROL : return "rol";
case R_ANAL_OP_TYPE_ROR : return "ror";
case R_ANAL_OP_TYPE_SAL : return "sal";
case R_ANAL_OP_TYPE_SAR : return "sar";
case R_ANAL_OP_TYPE_SHL : return "shl";
case R_ANAL_OP_TYPE_SHR : return "shr";
case R_ANAL_OP_TYPE_STORE : return "store";
case R_ANAL_OP_TYPE_SUB : return "sub";
case R_ANAL_OP_TYPE_SWI : return "swi";
case R_ANAL_OP_TYPE_CSWI : return "cswi";
case R_ANAL_OP_TYPE_SWITCH: return "switch";
case R_ANAL_OP_TYPE_TRAP : return "trap";
case R_ANAL_OP_TYPE_UCALL : return "ucall";
case R_ANAL_OP_TYPE_RCALL : return "rcall"; // needs to be changed
case R_ANAL_OP_TYPE_ICALL : return "ucall"; // needs to be changed
case R_ANAL_OP_TYPE_IRCALL: return "ucall"; // needs to be changed
case R_ANAL_OP_TYPE_UCCALL: return "uccall";
case R_ANAL_OP_TYPE_UCJMP : return "ucjmp";
case R_ANAL_OP_TYPE_UJMP : return "ujmp";
case R_ANAL_OP_TYPE_RJMP : return "rjmp"; // needs to be changed
case R_ANAL_OP_TYPE_IJMP : return "ujmp"; // needs to be changed
case R_ANAL_OP_TYPE_IRJMP : return "ujmp"; // needs to be changed
case R_ANAL_OP_TYPE_UNK : return "unk";
case R_ANAL_OP_TYPE_UPUSH : return "upush";
case R_ANAL_OP_TYPE_XCHG : return "xchg";
case R_ANAL_OP_TYPE_XOR : return "xor";
case R_ANAL_OP_TYPE_CASE : return "case";
case R_ANAL_OP_TYPE_CPL : return "cpl";
case R_ANAL_OP_TYPE_CRYPTO: return "crypto";
case RZ_ANAL_OP_TYPE_IO : return "io";
case RZ_ANAL_OP_TYPE_ACMP : return "acmp";
case RZ_ANAL_OP_TYPE_ADD : return "add";
case RZ_ANAL_OP_TYPE_SYNC : return "sync";
case RZ_ANAL_OP_TYPE_AND : return "and";
case RZ_ANAL_OP_TYPE_CALL : return "call";
case RZ_ANAL_OP_TYPE_CCALL : return "ccall";
case RZ_ANAL_OP_TYPE_CJMP : return "cjmp";
case RZ_ANAL_OP_TYPE_MJMP : return "mjmp";
case RZ_ANAL_OP_TYPE_CMP : return "cmp";
case RZ_ANAL_OP_TYPE_CRET : return "cret";
case RZ_ANAL_OP_TYPE_DIV : return "div";
case RZ_ANAL_OP_TYPE_ILL : return "ill";
case RZ_ANAL_OP_TYPE_JMP : return "jmp";
case RZ_ANAL_OP_TYPE_LEA : return "lea";
case RZ_ANAL_OP_TYPE_LEAVE : return "leave";
case RZ_ANAL_OP_TYPE_LOAD : return "load";
case RZ_ANAL_OP_TYPE_NEW : return "new";
case RZ_ANAL_OP_TYPE_MOD : return "mod";
case RZ_ANAL_OP_TYPE_CMOV : return "cmov";
case RZ_ANAL_OP_TYPE_MOV : return "mov";
case RZ_ANAL_OP_TYPE_CAST : return "cast";
case RZ_ANAL_OP_TYPE_MUL : return "mul";
case RZ_ANAL_OP_TYPE_NOP : return "nop";
case RZ_ANAL_OP_TYPE_NOT : return "not";
case RZ_ANAL_OP_TYPE_NULL : return "null";
case RZ_ANAL_OP_TYPE_OR : return "or";
case RZ_ANAL_OP_TYPE_POP : return "pop";
case RZ_ANAL_OP_TYPE_PUSH : return "push";
case RZ_ANAL_OP_TYPE_RPUSH : return "rpush";
case RZ_ANAL_OP_TYPE_REP : return "rep";
case RZ_ANAL_OP_TYPE_RET : return "ret";
case RZ_ANAL_OP_TYPE_ROL : return "rol";
case RZ_ANAL_OP_TYPE_ROR : return "ror";
case RZ_ANAL_OP_TYPE_SAL : return "sal";
case RZ_ANAL_OP_TYPE_SAR : return "sar";
case RZ_ANAL_OP_TYPE_SHL : return "shl";
case RZ_ANAL_OP_TYPE_SHR : return "shr";
case RZ_ANAL_OP_TYPE_STORE : return "store";
case RZ_ANAL_OP_TYPE_SUB : return "sub";
case RZ_ANAL_OP_TYPE_SWI : return "swi";
case RZ_ANAL_OP_TYPE_CSWI : return "cswi";
case RZ_ANAL_OP_TYPE_SWITCH: return "switch";
case RZ_ANAL_OP_TYPE_TRAP : return "trap";
case RZ_ANAL_OP_TYPE_UCALL : return "ucall";
case RZ_ANAL_OP_TYPE_RCALL : return "rcall"; // needs to be changed
case RZ_ANAL_OP_TYPE_ICALL : return "ucall"; // needs to be changed
case RZ_ANAL_OP_TYPE_IRCALL: return "ucall"; // needs to be changed
case RZ_ANAL_OP_TYPE_UCCALL: return "uccall";
case RZ_ANAL_OP_TYPE_UCJMP : return "ucjmp";
case RZ_ANAL_OP_TYPE_UJMP : return "ujmp";
case RZ_ANAL_OP_TYPE_RJMP : return "rjmp"; // needs to be changed
case RZ_ANAL_OP_TYPE_IJMP : return "ujmp"; // needs to be changed
case RZ_ANAL_OP_TYPE_IRJMP : return "ujmp"; // needs to be changed
case RZ_ANAL_OP_TYPE_UNK : return "unk";
case RZ_ANAL_OP_TYPE_UPUSH : return "upush";
case RZ_ANAL_OP_TYPE_XCHG : return "xchg";
case RZ_ANAL_OP_TYPE_XOR : return "xor";
case RZ_ANAL_OP_TYPE_CASE : return "case";
case RZ_ANAL_OP_TYPE_CPL : return "cpl";
case RZ_ANAL_OP_TYPE_CRYPTO: return "crypto";
}
if (once) {
once = false;
t &= R_ANAL_OP_TYPE_MASK; // ignore the modifier bits... we don't want this!
t &= RZ_ANAL_OP_TYPE_MASK; // ignore the modifier bits... we don't want this!
goto repeat;
}
return "undefined";
@@ -392,10 +392,10 @@ RZ_API char *rz_anal_op_to_string(RzAnal *anal, RzAnalOp *op) {
}
switch (op->type) {
case R_ANAL_OP_TYPE_MOV:
case RZ_ANAL_OP_TYPE_MOV:
snprintf (ret, sizeof (ret), "%s = %s", r0, a0);
break;
case R_ANAL_OP_TYPE_CJMP:
case RZ_ANAL_OP_TYPE_CJMP:
if ((bb = rz_anal_bb_from_offset (anal, op->addr))) {
cstr = rz_anal_cond_to_string (bb->cond);
snprintf (ret, sizeof (ret), "if (%s) goto 0x%"PFMT64x, cstr, op->jump);
@@ -404,39 +404,39 @@ RZ_API char *rz_anal_op_to_string(RzAnal *anal, RzAnalOp *op) {
snprintf (ret, sizeof (ret), "if (%s) goto 0x%"PFMT64x, "?", op->jump);
}
break;
case R_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_JMP:
snprintf (ret, sizeof (ret), "goto 0x%"PFMT64x, op->jump);
break;
case R_ANAL_OP_TYPE_UJMP:
case R_ANAL_OP_TYPE_RJMP:
case R_ANAL_OP_TYPE_IJMP:
case R_ANAL_OP_TYPE_IRJMP:
case RZ_ANAL_OP_TYPE_UJMP:
case RZ_ANAL_OP_TYPE_RJMP:
case RZ_ANAL_OP_TYPE_IJMP:
case RZ_ANAL_OP_TYPE_IRJMP:
snprintf (ret, sizeof (ret), "goto %s", r0);
break;
case R_ANAL_OP_TYPE_PUSH:
case R_ANAL_OP_TYPE_UPUSH:
case R_ANAL_OP_TYPE_RPUSH:
case RZ_ANAL_OP_TYPE_PUSH:
case RZ_ANAL_OP_TYPE_UPUSH:
case RZ_ANAL_OP_TYPE_RPUSH:
snprintf (ret, sizeof (ret), "push %s", a0);
break;
case R_ANAL_OP_TYPE_POP:
case RZ_ANAL_OP_TYPE_POP:
snprintf (ret, sizeof (ret), "pop %s", r0);
break;
case R_ANAL_OP_TYPE_UCALL:
case R_ANAL_OP_TYPE_RCALL:
case R_ANAL_OP_TYPE_ICALL:
case R_ANAL_OP_TYPE_IRCALL:
case RZ_ANAL_OP_TYPE_UCALL:
case RZ_ANAL_OP_TYPE_RCALL:
case RZ_ANAL_OP_TYPE_ICALL:
case RZ_ANAL_OP_TYPE_IRCALL:
snprintf (ret, sizeof (ret), "%s()", r0);
break;
case R_ANAL_OP_TYPE_CALL:
f = rz_anal_get_fcn_in (anal, op->jump, R_ANAL_FCN_TYPE_NULL);
case RZ_ANAL_OP_TYPE_CALL:
f = rz_anal_get_fcn_in (anal, op->jump, RZ_ANAL_FCN_TYPE_NULL);
if (f) {
snprintf (ret, sizeof (ret), "%s()", f->name);
} else {
snprintf (ret, sizeof (ret), "0x%"PFMT64x"()", op->jump);
}
break;
case R_ANAL_OP_TYPE_CCALL:
f = rz_anal_get_fcn_in (anal, op->jump, R_ANAL_FCN_TYPE_NULL);
case RZ_ANAL_OP_TYPE_CCALL:
f = rz_anal_get_fcn_in (anal, op->jump, RZ_ANAL_FCN_TYPE_NULL);
if ((bb = rz_anal_bb_from_offset (anal, op->addr))) {
cstr = rz_anal_cond_to_string (bb->cond);
if (f) {
@@ -453,68 +453,68 @@ RZ_API char *rz_anal_op_to_string(RzAnal *anal, RzAnalOp *op) {
}
}
break;
case R_ANAL_OP_TYPE_ADD:
case RZ_ANAL_OP_TYPE_ADD:
if (!a1 || !strcmp (a0, a1)) {
snprintf (ret, sizeof (ret), "%s += %s", r0, a0);
} else {
snprintf (ret, sizeof (ret), "%s = %s + %s", r0, a0, a1);
}
break;
case R_ANAL_OP_TYPE_SUB:
case RZ_ANAL_OP_TYPE_SUB:
if (!a1 || !strcmp (a0, a1)) {
snprintf (ret, sizeof (ret), "%s -= %s", r0, a0);
} else {
snprintf (ret, sizeof (ret), "%s = %s - %s", r0, a0, a1);
}
break;
case R_ANAL_OP_TYPE_MUL:
case RZ_ANAL_OP_TYPE_MUL:
if (!a1 || !strcmp (a0, a1)) {
snprintf (ret, sizeof (ret), "%s *= %s", r0, a0);
} else {
snprintf (ret, sizeof (ret), "%s = %s * %s", r0, a0, a1);
}
break;
case R_ANAL_OP_TYPE_DIV:
case RZ_ANAL_OP_TYPE_DIV:
if (!a1 || !strcmp (a0, a1)) {
snprintf (ret, sizeof (ret), "%s /= %s", r0, a0);
} else {
snprintf (ret, sizeof (ret), "%s = %s / %s", r0, a0, a1);
}
break;
case R_ANAL_OP_TYPE_AND:
case RZ_ANAL_OP_TYPE_AND:
if (!a1 || !strcmp (a0, a1)) {
snprintf (ret, sizeof (ret), "%s &= %s", r0, a0);
} else {
snprintf (ret, sizeof (ret), "%s = %s & %s", r0, a0, a1);
}
break;
case R_ANAL_OP_TYPE_OR:
case RZ_ANAL_OP_TYPE_OR:
if (!a1 || !strcmp (a0, a1)) {
snprintf (ret, sizeof (ret), "%s |= %s", r0, a0);
} else {
snprintf (ret, sizeof (ret), "%s = %s | %s", r0, a0, a1);
}
break;
case R_ANAL_OP_TYPE_XOR:
case RZ_ANAL_OP_TYPE_XOR:
if (!a1 || !strcmp (a0, a1)) {
snprintf (ret, sizeof (ret), "%s ^= %s", r0, a0);
} else {
snprintf (ret, sizeof (ret), "%s = %s ^ %s", r0, a0, a1);
}
break;
case R_ANAL_OP_TYPE_LEA:
case RZ_ANAL_OP_TYPE_LEA:
snprintf (ret, sizeof (ret), "%s -> %s", r0, a0);
break;
case R_ANAL_OP_TYPE_CMP:
case RZ_ANAL_OP_TYPE_CMP:
memcpy (ret, ";", 2);
break;
case R_ANAL_OP_TYPE_NOP:
case RZ_ANAL_OP_TYPE_NOP:
memcpy (ret, "nop", 4);
break;
case R_ANAL_OP_TYPE_RET:
case RZ_ANAL_OP_TYPE_RET:
memcpy (ret, "ret", 4);
break;
case R_ANAL_OP_TYPE_CRET:
case RZ_ANAL_OP_TYPE_CRET:
if ((bb = rz_anal_bb_from_offset (anal, op->addr))) {
cstr = rz_anal_cond_to_string (bb->cond);
snprintf (ret, sizeof (ret), "if (%s) ret", cstr);
@@ -523,27 +523,27 @@ RZ_API char *rz_anal_op_to_string(RzAnal *anal, RzAnalOp *op) {
strcpy (ret, "if (unk) ret");
}
break;
case R_ANAL_OP_TYPE_LEAVE:
case RZ_ANAL_OP_TYPE_LEAVE:
memcpy (ret, "leave", 6);
break;
case R_ANAL_OP_TYPE_MOD:
case RZ_ANAL_OP_TYPE_MOD:
if (!a1 || !strcmp (a0, a1)) {
snprintf (ret, sizeof (ret), "%s %%= %s", r0, a0);
} else {
snprintf (ret, sizeof (ret), "%s = %s %% %s", r0, a0, a1);
}
break;
case R_ANAL_OP_TYPE_XCHG:
case RZ_ANAL_OP_TYPE_XCHG:
if (!a1 || !strcmp (a0, a1)) {
snprintf (ret, sizeof (ret), "tmp = %s; %s = %s; %s = tmp", r0, r0, a0, a0);
} else {
snprintf (ret, sizeof (ret), "%s = %s ^ %s", r0, a0, a1);
}
break;
case R_ANAL_OP_TYPE_ROL:
case R_ANAL_OP_TYPE_ROR:
case R_ANAL_OP_TYPE_SWITCH:
case R_ANAL_OP_TYPE_CASE:
case RZ_ANAL_OP_TYPE_ROL:
case RZ_ANAL_OP_TYPE_ROR:
case RZ_ANAL_OP_TYPE_SWITCH:
case RZ_ANAL_OP_TYPE_CASE:
eprintf ("Command not implemented.\n");
free (r0);
free (a0);
@@ -563,17 +563,17 @@ RZ_API char *rz_anal_op_to_string(RzAnal *anal, RzAnalOp *op) {
RZ_API const char *rz_anal_stackop_tostring(int s) {
switch (s) {
case R_ANAL_STACK_NULL:
case RZ_ANAL_STACK_NULL:
return "null";
case R_ANAL_STACK_NOP:
case RZ_ANAL_STACK_NOP:
return "nop";
case R_ANAL_STACK_INC:
case RZ_ANAL_STACK_INC:
return "inc";
case R_ANAL_STACK_GET:
case RZ_ANAL_STACK_GET:
return "get";
case R_ANAL_STACK_SET:
case RZ_ANAL_STACK_SET:
return "set";
case R_ANAL_STACK_RESET:
case RZ_ANAL_STACK_RESET:
return "reset";
}
return "unk";
@@ -581,17 +581,17 @@ RZ_API const char *rz_anal_stackop_tostring(int s) {
RZ_API const char *rz_anal_op_family_to_string(int n) {
switch (n) {
case R_ANAL_OP_FAMILY_UNKNOWN: return "unk";
case R_ANAL_OP_FAMILY_CPU: return "cpu";
case R_ANAL_OP_FAMILY_SECURITY: return "sec";
case R_ANAL_OP_FAMILY_FPU: return "fpu";
case R_ANAL_OP_FAMILY_MMX: return "mmx";
case R_ANAL_OP_FAMILY_SSE: return "sse";
case R_ANAL_OP_FAMILY_PRIV: return "priv";
case R_ANAL_OP_FAMILY_THREAD: return "thrd";
case R_ANAL_OP_FAMILY_CRYPTO: return "crpt";
case R_ANAL_OP_FAMILY_IO: return "io";
case R_ANAL_OP_FAMILY_VIRT: return "virt";
case RZ_ANAL_OP_FAMILY_UNKNOWN: return "unk";
case RZ_ANAL_OP_FAMILY_CPU: return "cpu";
case RZ_ANAL_OP_FAMILY_SECURITY: return "sec";
case RZ_ANAL_OP_FAMILY_FPU: return "fpu";
case RZ_ANAL_OP_FAMILY_MMX: return "mmx";
case RZ_ANAL_OP_FAMILY_SSE: return "sse";
case RZ_ANAL_OP_FAMILY_PRIV: return "priv";
case RZ_ANAL_OP_FAMILY_THREAD: return "thrd";
case RZ_ANAL_OP_FAMILY_CRYPTO: return "crpt";
case RZ_ANAL_OP_FAMILY_IO: return "io";
case RZ_ANAL_OP_FAMILY_VIRT: return "virt";
}
return NULL;
}
@@ -602,16 +602,16 @@ RZ_API int rz_anal_op_family_from_string(const char *f) {
int id;
};
static const struct op_family of[] = {
{"cpu", R_ANAL_OP_FAMILY_CPU},
{"fpu", R_ANAL_OP_FAMILY_FPU},
{"mmx", R_ANAL_OP_FAMILY_MMX},
{"sse", R_ANAL_OP_FAMILY_SSE},
{"priv", R_ANAL_OP_FAMILY_PRIV},
{"virt", R_ANAL_OP_FAMILY_VIRT},
{"crpt", R_ANAL_OP_FAMILY_CRYPTO},
{"io", R_ANAL_OP_FAMILY_IO},
{"sec", R_ANAL_OP_FAMILY_SECURITY},
{"thread", R_ANAL_OP_FAMILY_THREAD},
{"cpu", RZ_ANAL_OP_FAMILY_CPU},
{"fpu", RZ_ANAL_OP_FAMILY_FPU},
{"mmx", RZ_ANAL_OP_FAMILY_MMX},
{"sse", RZ_ANAL_OP_FAMILY_SSE},
{"priv", RZ_ANAL_OP_FAMILY_PRIV},
{"virt", RZ_ANAL_OP_FAMILY_VIRT},
{"crpt", RZ_ANAL_OP_FAMILY_CRYPTO},
{"io", RZ_ANAL_OP_FAMILY_IO},
{"sec", RZ_ANAL_OP_FAMILY_SECURITY},
{"thread", RZ_ANAL_OP_FAMILY_THREAD},
};
int i;
@@ -620,7 +620,7 @@ RZ_API int rz_anal_op_family_from_string(const char *f) {
return of[i].id;
}
}
return R_ANAL_OP_FAMILY_UNKNOWN;
return RZ_ANAL_OP_FAMILY_UNKNOWN;
}
/* apply hint to op, return the number of hints applied */
@@ -668,7 +668,7 @@ RZ_API int rz_anal_op_reg_delta(RzAnal *anal, ut64 addr, const char *name) {
ut8 buf[32];
anal->iob.read_at (anal->iob.io, addr, buf, sizeof (buf));
RzAnalOp op = { 0 };
if (rz_anal_op (anal, &op, addr, buf, sizeof (buf), R_ANAL_OP_MASK_ALL) > 0) {
if (rz_anal_op (anal, &op, addr, buf, sizeof (buf), RZ_ANAL_OP_MASK_ALL) > 0) {
if (op.dst && op.dst->reg && op.dst->reg->name && (!name || !strcmp (op.dst->reg->name, name))) {
if (op.src[0]) {
return op.src[0]->delta;
+50 -50
View File
@@ -314,7 +314,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
op->size = snes_op_get_size (1, 1, &snes_op[data[0]]); //snes-arch is similar to nes/6502
op->addr = addr;
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
op->id = data[0];
rz_strbuf_init (&op->esil);
switch (data[0]) {
@@ -426,13 +426,13 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
// undocumented or not-implemented opcodes for 6502.
// some of them might be implemented in 65816
op->size = 1;
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
// BRK
case 0x00: // brk
op->cycles = 7;
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
// override 65816 code which seems to be wrong: size is 1, but pc = pc + 2
op->size = 1;
// PC + 2 to Stack, P to Stack B=1 D=0 I=1. "B" is not a flag. Only its bit is pushed on the stack
@@ -451,13 +451,13 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xb8: // clv
op->cycles = 2;
// FIXME: what opcode for this?
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
_6502_anal_esil_flags (op, data[0]);
break;
// BIT
case 0x24: // bit $ff
case 0x2c: // bit $ffff
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
_6502_anal_esil_get_addr_pattern3 (op, data, len, addrbuf, buffsize, 0);
rz_strbuf_setf (&op->esil, "%s,[1],0x80,&,!,!,N,=,%s,[1],0x40,&,!,!,V,=,a,%s,[1],&,0xff,&,!,Z,=", addrbuf, addrbuf, addrbuf);
break;
@@ -472,7 +472,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x71: // adc ($ff,y)
// FIXME: update V
// FIXME: support BCD mode
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
_6502_anal_esil_get_addr_pattern1 (op, data, len, addrbuf, buffsize);
if (data[0] == 0x69) { // immediate mode
rz_strbuf_setf (&op->esil, "%s,a,+=,7,$c,C,a,+=,7,$c,|,C,:=", addrbuf);
@@ -494,7 +494,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xf1: // sbc ($ff,y)
// FIXME: update V
// FIXME: support BCD mode
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
_6502_anal_esil_get_addr_pattern1 (op, data, len, addrbuf, buffsize);
if (data[0] == 0xe9) { // immediate mode
rz_strbuf_setf (&op->esil, "C,!,%s,+,a,-=", addrbuf);
@@ -514,7 +514,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x19: // ora $ffff,y
case 0x01: // ora ($ff,x)
case 0x11: // ora ($ff),y
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
_6502_anal_esil_get_addr_pattern1 (op, data, len, addrbuf, buffsize);
if (data[0] == 0x09) { // immediate mode
rz_strbuf_setf (&op->esil, "%s,a,|=", addrbuf);
@@ -532,7 +532,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x39: // and $ffff,y
case 0x21: // and ($ff,x)
case 0x31: // and ($ff),y
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
_6502_anal_esil_get_addr_pattern1 (op, data, len, addrbuf, buffsize);
if (data[0] == 0x29) { // immediate mode
rz_strbuf_setf (&op->esil, "%s,a,&=", addrbuf);
@@ -550,7 +550,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x59: // eor $ffff,y
case 0x41: // eor ($ff,x)
case 0x51: // eor ($ff),y
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
_6502_anal_esil_get_addr_pattern1 (op, data, len, addrbuf, buffsize);
if (data[0] == 0x49) { // immediate mode
rz_strbuf_setf (&op->esil, "%s,a,^=", addrbuf);
@@ -565,7 +565,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x16: // asl $ff,x
case 0x0e: // asl $ffff
case 0x1e: // asl $ffff,x
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
if (data[0] == 0x0a) {
rz_strbuf_set (&op->esil, "1,a,<<=,7,$c,C,:=,a,a,=");
} else {
@@ -580,7 +580,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x56: // lsr $ff,x
case 0x4e: // lsr $ffff
case 0x5e: // lsr $ffff,x
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
if (data[0] == 0x4a) {
rz_strbuf_set (&op->esil, "1,a,&,C,=,1,a,>>=");
} else {
@@ -595,7 +595,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x36: // rol $ff,x
case 0x2e: // rol $ffff
case 0x3e: // rol $ffff,x
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
if (data[0] == 0x2a) {
rz_strbuf_set (&op->esil, "1,a,<<,C,|,a,=,7,$c,C,:=,a,a,=");
} else {
@@ -612,7 +612,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x7e: // ror $ffff,x
// uses N as temporary to hold C value. but in fact,
// it is not temporary since in all ROR ops, N will have the value of C
op->type = R_ANAL_OP_TYPE_ROR;
op->type = RZ_ANAL_OP_TYPE_ROR;
if (data[0] == 0x6a) {
rz_strbuf_set (&op->esil, "C,N,=,1,a,&,C,=,1,a,>>,7,N,<<,|,a,=");
} else {
@@ -626,7 +626,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xf6: // inc $ff,x
case 0xee: // inc $ffff
case 0xfe: // inc $ffff,x
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
_6502_anal_esil_get_addr_pattern2 (op, data, len, addrbuf, buffsize, 'x');
rz_strbuf_setf (&op->esil, "%s,++=[1]", addrbuf);
_6502_anal_update_flags (op, _6502_FLAGS_NZ);
@@ -636,7 +636,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xd6: // dec $ff,x
case 0xce: // dec $ffff
case 0xde: // dec $ffff,x
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
_6502_anal_esil_get_addr_pattern2 (op, data, len, addrbuf, buffsize, 'x');
rz_strbuf_setf (&op->esil, "%s,--=[1]", addrbuf);
_6502_anal_update_flags (op, _6502_FLAGS_NZ);
@@ -645,14 +645,14 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xe8: // inx
case 0xc8: // iny
op->cycles = 2;
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
_6502_anal_esil_inc_reg (op, data[0], "+");
break;
// DEX, DEY
case 0xca: // dex
case 0x88: // dey
op->cycles = 2;
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
_6502_anal_esil_inc_reg (op, data[0], "-");
break;
// CMP
@@ -664,7 +664,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xd9: // cmp $ffff,y
case 0xc1: // cmp ($ff,x)
case 0xd1: // cmp ($ff),y
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
_6502_anal_esil_get_addr_pattern1 (op, data, len, addrbuf, buffsize);
if (data[0] == 0xc9) { // immediate mode
rz_strbuf_setf (&op->esil, "%s,a,==", addrbuf);
@@ -679,7 +679,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xe0: // cpx #$ff
case 0xe4: // cpx $ff
case 0xec: // cpx $ffff
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
_6502_anal_esil_get_addr_pattern3 (op, data, len, addrbuf, buffsize, 0);
if (data[0] == 0xe0) { // immediate mode
rz_strbuf_setf (&op->esil, "%s,x,==", addrbuf);
@@ -694,7 +694,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xc0: // cpy #$ff
case 0xc4: // cpy $ff
case 0xcc: // cpy $ffff
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
_6502_anal_esil_get_addr_pattern3 (op, data, len, addrbuf, buffsize, 0);
if (data[0] == 0xc0) { // immediate mode
rz_strbuf_setf (&op->esil, "%s,y,==", addrbuf);
@@ -718,7 +718,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
// FIXME: Add 2 if branch occurs to different page
op->cycles = 2;
op->failcycles = 3;
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
if (len > 1) {
if (data[1] <= 127) {
op->jump = addr + data[1] + op->size;
@@ -730,15 +730,15 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
}
op->fail = addr + op->size;
// FIXME: add a type of conditional
// op->cond = R_ANAL_COND_LE;
// op->cond = RZ_ANAL_COND_LE;
_6502_anal_esil_ccall (op, data[0]);
break;
// JSR
case 0x20: // jsr $ffff
op->cycles = 6;
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = (len > 2)? data[1] | data[2] << 8: 0;
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = 2;
// JSR pushes the address-1 of the next operation on to the stack before transferring program
// control to the following address
@@ -748,13 +748,13 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
// JMP
case 0x4c: // jmp $ffff
op->cycles = 3;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = (len > 2)? data[1] | data[2] << 8: 0;
rz_strbuf_setf (&op->esil, "0x%04x,pc,=", op->jump);
break;
case 0x6c: // jmp ($ffff)
op->cycles = 5;
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
// FIXME: how to read memory?
// op->jump = data[1] | data[2] << 8;
rz_strbuf_setf (&op->esil, "0x%04x,[2],pc,=", len > 2? data[1] | data[2] << 8: 0);
@@ -762,9 +762,9 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
// RTS
case 0x60: // rts
op->eob = true;
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->cycles = 6;
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -2;
// Operation: PC from Stack, PC + 1 -> PC
// stack is on page one and sp is an 8-bit reg: operations must be done like: sp + 0x100
@@ -773,9 +773,9 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
// RTI
case 0x40: // rti
op->eob = true;
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->cycles = 6;
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -3;
// Operation: P from Stack, PC from Stack
// stack is on page one and sp is an 8-bit reg: operations must be done like: sp + 0x100
@@ -783,7 +783,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
break;
// NOP
case 0xea: // nop
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
op->cycles = 2;
break;
// LDA
@@ -795,7 +795,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xb9: // lda $ffff,y
case 0xa1: // lda ($ff,x)
case 0xb1: // lda ($ff),y
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
_6502_anal_esil_get_addr_pattern1 (op, data, len, addrbuf, buffsize);
if (data[0] == 0xa9) { // immediate mode
rz_strbuf_setf (&op->esil, "%s,a,=", addrbuf);
@@ -810,7 +810,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xb6: // ldx $ff,y
case 0xae: // ldx $ffff
case 0xbe: // ldx $ffff,y
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
_6502_anal_esil_get_addr_pattern2 (op, data, len, addrbuf, buffsize, 'y');
if (data[0] == 0xa2) { // immediate mode
rz_strbuf_setf (&op->esil, "%s,x,=", addrbuf);
@@ -825,7 +825,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xb4: // ldy $ff,x
case 0xac: // ldy $ffff
case 0xbc: // ldy $ffff,x
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
_6502_anal_esil_get_addr_pattern3 (op, data, len, addrbuf, buffsize, 'x');
if (data[0] == 0xa0) { // immediate mode
rz_strbuf_setf (&op->esil, "%s,y,=", addrbuf);
@@ -842,7 +842,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x99: // sta $ffff,y
case 0x81: // sta ($ff,x)
case 0x91: // sta ($ff),y
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
_6502_anal_esil_get_addr_pattern1 (op, data, len, addrbuf, buffsize);
rz_strbuf_setf (&op->esil, "a,%s,=[1]", addrbuf);
break;
@@ -850,7 +850,7 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x86: // stx $ff
case 0x96: // stx $ff,y
case 0x8e: // stx $ffff
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
_6502_anal_esil_get_addr_pattern2 (op, data, len, addrbuf, buffsize, 'y');
rz_strbuf_setf (&op->esil, "x,%s,=[1]", addrbuf);
break;
@@ -858,25 +858,25 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x84: // sty $ff
case 0x94: // sty $ff,x
case 0x8c: // sty $ffff
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
_6502_anal_esil_get_addr_pattern3 (op, data, len, addrbuf, buffsize, 'x');
rz_strbuf_setf (&op->esil, "y,%s,=[1]", addrbuf);
break;
// PHP/PHA
case 0x08: // php
case 0x48: // pha
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
op->cycles = 3;
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = 1;
_6502_anal_esil_push (op, data[0]);
break;
// PLP,PLA
case 0x28: // plp
case 0x68: // plp
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
op->cycles = 4;
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -1;
_6502_anal_esil_pop (op, data[0]);
break;
@@ -885,22 +885,22 @@ static int _6502_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x8a: // txa
case 0xa8: // tay
case 0x98: // tya
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->cycles = 2;
_6502_anal_esil_mov (op, data[0]);
break;
case 0x9a: // txs
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->cycles = 2;
op->stackop = R_ANAL_STACK_SET;
op->stackop = RZ_ANAL_STACK_SET;
// FIXME: should I get register X a place it here?
// op->stackptr = get_register_x();
_6502_anal_esil_mov (op, data[0]);
break;
case 0xba: // tsx
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->cycles = 2;
op->stackop = R_ANAL_STACK_GET;
op->stackop = RZ_ANAL_STACK_GET;
_6502_anal_esil_mov (op, data[0]);
break;
}
@@ -959,10 +959,10 @@ RzAnalPlugin rz_anal_plugin_6502 = {
.esil_fini = esil_6502_fini,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_6502,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+25 -25
View File
@@ -56,26 +56,26 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
n = cs_disasm (handle, (const ut8*)buf, len, addr, 1, &insn);
#endif
if (n < 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
} else {
op->nopcode = 1;
op->size = insn->size;
op->id = insn->id;
op->family = R_ANAL_OP_FAMILY_CPU; // almost everything is CPU
op->family = RZ_ANAL_OP_FAMILY_CPU; // almost everything is CPU
op->prefix = 0;
op->cond = 0;
switch (insn->id) {
case MOS65XX_INS_INVALID:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case MOS65XX_INS_ADC:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case MOS65XX_INS_AND:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case MOS65XX_INS_ASL:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
break;
case MOS65XX_INS_BCC:
case MOS65XX_INS_BCS:
@@ -84,10 +84,10 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case MOS65XX_INS_BMI:
case MOS65XX_INS_BNE:
case MOS65XX_INS_BPL:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case MOS65XX_INS_BRK:
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
break;
case MOS65XX_INS_BVC:
case MOS65XX_INS_BVS:
@@ -99,38 +99,38 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case MOS65XX_INS_CPY:
break;
case MOS65XX_INS_CMP:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case MOS65XX_INS_DEC:
case MOS65XX_INS_DEX:
case MOS65XX_INS_DEY:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case MOS65XX_INS_EOR:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case MOS65XX_INS_INC:
case MOS65XX_INS_INX:
case MOS65XX_INS_INY:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case MOS65XX_INS_JMP:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case MOS65XX_INS_JSR:
op->type = R_ANAL_OP_TYPE_RJMP;
op->type = RZ_ANAL_OP_TYPE_RJMP;
break;
case MOS65XX_INS_LDA:
case MOS65XX_INS_LDX:
case MOS65XX_INS_LDY:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case MOS65XX_INS_LSR:
case MOS65XX_INS_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case MOS65XX_INS_ORA:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case MOS65XX_INS_PHA:
case MOS65XX_INS_PLA:
@@ -138,10 +138,10 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case MOS65XX_INS_PLP:
break;
case MOS65XX_INS_ROL:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case MOS65XX_INS_ROR:
op->type = R_ANAL_OP_TYPE_ROR;
op->type = RZ_ANAL_OP_TYPE_ROR;
break;
case MOS65XX_INS_RTI:
case MOS65XX_INS_RTS:
@@ -201,11 +201,11 @@ RzAnalPlugin rz_anal_plugin_6502_cs = {
.set_reg_profile = &set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_6502_cs,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
#else
@@ -218,10 +218,10 @@ RzAnalPlugin rz_anal_plugin_6502_cs = {
.bits = 8,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.version = R2_VERSION
.type = RZ_LIB_TYPE_ANAL,
.version = RZ_VERSION
};
#endif
#endif
+19 -19
View File
@@ -45,7 +45,7 @@ static const i8051_cpu_model *cpu_curr_model = NULL;
static bool i8051_reg_write (RzReg *reg, const char *regname, ut32 num) {
if (reg) {
RzRegItem *item = rz_reg_get (reg, regname, R_REG_TYPE_GPR);
RzRegItem *item = rz_reg_get (reg, regname, RZ_REG_TYPE_GPR);
if (item) {
rz_reg_set_value (reg, item, num);
return true;
@@ -56,7 +56,7 @@ static bool i8051_reg_write (RzReg *reg, const char *regname, ut32 num) {
static ut32 i8051_reg_read (RzReg *reg, const char *regname) {
if (reg) {
RzRegItem *item = rz_reg_get (reg, regname, R_REG_TYPE_GPR);
RzRegItem *item = rz_reg_get (reg, regname, RZ_REG_TYPE_GPR);
if (item) {
return rz_reg_get_value (reg, item);
}
@@ -90,7 +90,7 @@ static void map_cpu_memory (RzAnal *anal, int entry, ut32 addr, ut32 size, bool
} else {
// allocate memory for address space
char *mstr = rz_str_newf ("malloc://%d", size);
desc = anal->iob.open_at (anal->iob.io, mstr, R_PERM_RW, 0, addr);
desc = anal->iob.open_at (anal->iob.io, mstr, RZ_PERM_RW, 0, addr);
free (mstr);
// set 8051 address space as name of mapped memory
if (desc && anal->iob.fd_get_name (anal->iob.io, desc->fd)) {
@@ -806,7 +806,7 @@ static int esil_i8051_fini (RzAnalEsil *esil) {
if (!i8051_is_init) {
return false;
}
R_FREE (ocbs.user);
RZ_FREE (ocbs.user);
i8051_is_init = false;
return true;
}
@@ -894,27 +894,27 @@ static int i8051_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int l
op->nopcode = 1;
op->size = _8051_ops[i].len;
op->type = _8051_ops[i].type;
op->family = R_ANAL_OP_FAMILY_CPU; // maybe also FAMILY_IO...
op->family = RZ_ANAL_OP_FAMILY_CPU; // maybe also FAMILY_IO...
op->id = i;
switch (_8051_ops[i].instr) {
default:
op->cond = R_ANAL_COND_AL;
op->cond = RZ_ANAL_COND_AL;
break;
case OP_CJNE:
case OP_DJNZ:
case OP_JB:
case OP_JBC:
case OP_JNZ:
op->cond = R_ANAL_COND_NE;
op->cond = RZ_ANAL_COND_NE;
break;
case OP_JNB:
case OP_JZ:
op->cond = R_ANAL_COND_EQ;
op->cond = RZ_ANAL_COND_EQ;
break; case OP_JC:
op->cond = R_ANAL_COND_HS;
op->cond = RZ_ANAL_COND_HS;
break; case OP_JNC:
op->cond = R_ANAL_COND_LO;
op->cond = RZ_ANAL_COND_LO;
}
switch (_8051_ops[i].instr) {
@@ -967,16 +967,16 @@ static int i8051_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int l
switch(_8051_ops[i].instr) {
default:
break; case OP_PUSH:
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = 1;
break; case OP_POP:
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -1;
break; case OP_RET:
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -2;
break; case OP_CALL:
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = 2;
if (arg1 == A_ADDR11) {
op->jump = arg_addr11 (addr + op->size, buf);
@@ -1014,7 +1014,7 @@ static int i8051_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int l
op->refptr = 1;
}
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut8 copy[3] = {0, 0, 0};
memcpy (copy, buf, len >= 3 ? 3 : len);
analop_esil (anal, op, addr, copy);
@@ -1024,7 +1024,7 @@ static int i8051_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int l
op->mnemonic = rz_8051_disas (addr, buf, len, &olen);
op->size = olen;
if (mask & R_ANAL_OP_MASK_HINT) {
if (mask & RZ_ANAL_OP_MASK_HINT) {
// TODO: op->hint
}
@@ -1044,10 +1044,10 @@ RzAnalPlugin rz_anal_plugin_8051 = {
.esil_fini = esil_i8051_fini
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_8051,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+8 -8
View File
@@ -292,23 +292,23 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
if (amd29k_instr_decode (buf, len, &instruction, a->cpu)) {
op->type = instruction.op_type;
switch (op->type) {
case R_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_JMP:
op->jump = amd29k_instr_jump (addr, &instruction);
//op->delay = 1;
break;
case R_ANAL_OP_TYPE_CJMP:
case RZ_ANAL_OP_TYPE_CJMP:
op->jump = amd29k_instr_jump (addr, &instruction);
op->fail = addr + 4;
//op->delay = 1;
break;
case R_ANAL_OP_TYPE_ICALL:
case RZ_ANAL_OP_TYPE_ICALL:
if (amd29k_instr_is_ret (&instruction)) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->eob = true;
}
//op->delay = 1;
break;
case R_ANAL_OP_TYPE_RET:
case RZ_ANAL_OP_TYPE_RET:
op->eob = true;
//op->delay = 1;
break;
@@ -333,10 +333,10 @@ RzAnalPlugin rz_anal_plugin_amd29k = {
.set_reg_profile = &set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_amd29k,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+173 -173
View File
@@ -68,28 +68,28 @@ static int sex(int bits, int imm) {
static int map_cond2radare(ut8 cond) {
switch (cond) {
case 0: return R_ANAL_COND_AL;
case 1: return R_ANAL_COND_EQ;
case 2: return R_ANAL_COND_NE;
case 3: return R_ANAL_COND_PL;
case 4: return R_ANAL_COND_MI;
case 7: return R_ANAL_COND_VS;
case 8: return R_ANAL_COND_VC;
case 9: return R_ANAL_COND_GT;
case 0xa: return R_ANAL_COND_GE;
case 0xb: return R_ANAL_COND_LT;
case 0xc: return R_ANAL_COND_LE;
case 0xd: return R_ANAL_COND_HI;
case 0xe: return R_ANAL_COND_LS;
case 0: return RZ_ANAL_COND_AL;
case 1: return RZ_ANAL_COND_EQ;
case 2: return RZ_ANAL_COND_NE;
case 3: return RZ_ANAL_COND_PL;
case 4: return RZ_ANAL_COND_MI;
case 7: return RZ_ANAL_COND_VS;
case 8: return RZ_ANAL_COND_VC;
case 9: return RZ_ANAL_COND_GT;
case 0xa: return RZ_ANAL_COND_GE;
case 0xb: return RZ_ANAL_COND_LT;
case 0xc: return RZ_ANAL_COND_LE;
case 0xd: return RZ_ANAL_COND_HI;
case 0xe: return RZ_ANAL_COND_LS;
#if 0
/* TODO: */
/* - radare defines R_ANAL_COND_LO as carry clear and _HS as carry set */
/* - radare defines RZ_ANAL_COND_LO as carry clear and _HS as carry set */
/* which appears different to the ARC definitions. */
/* Need to do some math and double check the details */
case 5: return R_ANAL_COND_?? - CS,C,LO - Carry set & LO
case 6: return R_ANAL_COND_?? - CC,NC,HS - Carry clear & HS
case 5: return RZ_ANAL_COND_?? - CS,C,LO - Carry set & LO
case 6: return RZ_ANAL_COND_?? - CC,NC,HS - Carry clear & HS
/* - Positive non-zero doesnt map to any Radare cond code. Perhaps just add it? */
case 0xf: return R_ANAL_COND_?? - PNZ - Positive non-zero
case 0xf: return RZ_ANAL_COND_?? - PNZ - Positive non-zero
#endif
}
return -1;
@@ -116,7 +116,7 @@ static void map_zz2refptr(RzAnalOp *op, ut8 mode_zz) {
case 1: op->refptr = 1; break;
case 2: op->refptr = 2; break;
default:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
}
}
@@ -127,15 +127,15 @@ static int arcompact_genops_jmp(RzAnalOp *op, ut64 addr, arc_fields *f, ut64 bas
ut64 type_ucjmp;
switch (basic_type) {
case R_ANAL_OP_TYPE_JMP:
type_ujmp = R_ANAL_OP_TYPE_UJMP;
type_cjmp = R_ANAL_OP_TYPE_CJMP;
type_ucjmp = R_ANAL_OP_TYPE_UCJMP;
case RZ_ANAL_OP_TYPE_JMP:
type_ujmp = RZ_ANAL_OP_TYPE_UJMP;
type_cjmp = RZ_ANAL_OP_TYPE_CJMP;
type_ucjmp = RZ_ANAL_OP_TYPE_UCJMP;
break;
case R_ANAL_OP_TYPE_CALL:
type_ujmp = R_ANAL_OP_TYPE_UCALL;
type_cjmp = R_ANAL_OP_TYPE_CCALL;
type_ucjmp = R_ANAL_OP_TYPE_UCCALL;
case RZ_ANAL_OP_TYPE_CALL:
type_ujmp = RZ_ANAL_OP_TYPE_UCALL;
type_cjmp = RZ_ANAL_OP_TYPE_CCALL;
type_ucjmp = RZ_ANAL_OP_TYPE_UCCALL;
break;
default:
return -1; /* Should not happen */
@@ -154,7 +154,7 @@ static int arcompact_genops_jmp(RzAnalOp *op, ut64 addr, arc_fields *f, ut64 bas
if (f->c == ARC_REG_ILINK1 || f->c == ARC_REG_ILINK2 || f->c == ARC_REG_BLINK) {
/* ilink1, ilink2, blink */
/* Note: not valid for basic_type == CALL */
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->delay = f->mode_n;
return op->size;
}
@@ -180,7 +180,7 @@ static int arcompact_genops_jmp(RzAnalOp *op, ut64 addr, arc_fields *f, ut64 bas
if (f->c == ARC_REG_ILINK1 || f->c == ARC_REG_ILINK2 || f->c == ARC_REG_BLINK) {
/* ilink1, ilink2, blink */
/* Note: not valid for basic_type == CALL */
op->type = R_ANAL_OP_TYPE_CRET;
op->type = RZ_ANAL_OP_TYPE_CRET;
op->cond = map_cond2radare (f->cond);
op->delay = f->mode_n;
return op->size;
@@ -245,7 +245,7 @@ static int arcompact_genops(RzAnalOp *op, ut64 addr, ut32 words[2]) {
case 0x14: /* add with left shift by 1 */
case 0x15: /* add with left shift by 2 */
case 0x16: /* add with left shift by 3 */
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 0x02: /* subtract */
case 0x03: /* subtract with carry */
@@ -253,34 +253,34 @@ static int arcompact_genops(RzAnalOp *op, ut64 addr, ut32 words[2]) {
case 0x17: /* subtract with left shift by 1 */
case 0x18: /* subtract with left shift by 2 */
case 0x19: /* subtract with left shift by 3 */
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 0x04: /* logical bitwise AND */
case 0x06: /* logical bitwise AND with invert */
case 0x10: /* bit clear */
case 0x13: /* bit mask */
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case 0x05: /* logical bitwise OR */
case 0x0f: /* bit set */
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case 0x07: /* logical bitwise exclusive-OR */
case 0x12: /* bit xor */
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case 0x08: /* larger of 2 signed integers */
case 0x09: /* smaller of 2 signed integers */
op->type = R_ANAL_OP_TYPE_CMOV;
op->type = RZ_ANAL_OP_TYPE_CMOV;
break;
case 0x0a: /* move */
if (fields.format == 2) {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->val = SEX_S12 (fields.a << 6 | fields.c);
} else if (fields.format == 3) {
fields.cond = fields.a & 0x1f;
op->cond = map_cond2radare (fields.cond);
op->type = R_ANAL_OP_TYPE_CMOV;
op->type = RZ_ANAL_OP_TYPE_CMOV;
if ((fields.a & 0x20)) {
/* its a move from imm u6 */
op->val = fields.c;
@@ -294,27 +294,27 @@ static int arcompact_genops(RzAnalOp *op, ut64 addr, ut32 words[2]) {
case 0x0c: /* compare */
case 0x0d: /* reverse compare */
case 0x11: /* bit test */
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case 0x1a: /* 32 X 32 signed multiply */
case 0x1b: /* 32 X 32 signed multiply */
case 0x1c: /* 32 X 32 unsigned multiply */
case 0x1d: /* 32 X 32 unsigned multiply */
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case 0x21: /* Jump with delay slot */
fields.mode_n = 1;
/* fall through */
case 0x20: /* Jump */
fields.mode_m = (words[0] & 0x20) >> 5;
arcompact_genops_jmp (op, addr, &fields, R_ANAL_OP_TYPE_JMP);
arcompact_genops_jmp (op, addr, &fields, RZ_ANAL_OP_TYPE_JMP);
break;
case 0x23: /* jump and link with delay slot */
fields.mode_n = 1;
/* fall through */
case 0x22: /* jump and link */
fields.mode_m = (words[0] & 0x20) >> 5;
arcompact_genops_jmp (op, addr, &fields, R_ANAL_OP_TYPE_CALL);
arcompact_genops_jmp (op, addr, &fields, RZ_ANAL_OP_TYPE_CALL);
break;
case 0x1e: /* Reserved */
case 0x1f: /* Reserved */
@@ -333,7 +333,7 @@ static int arcompact_genops(RzAnalOp *op, ut64 addr, ut32 words[2]) {
case 0x3d: /* Reserved */
case 0x3e: /* Reserved */
case 0x3f: /* Reserved */
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case 0x28: /* loop (16-bit aligned target address) */
/* this is essentially a COME FROM instruction!! */
@@ -342,7 +342,7 @@ static int arcompact_genops(RzAnalOp *op, ut64 addr, ut32 words[2]) {
case 2: /* Loop Set Up (Unconditional) */
fields.imm = SEX_S13 ((fields.c | (fields.a << 6)) << 1);
op->jump = (addr & ~3) + fields.imm;
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->fail = addr + op->size;
break;
case 3: /* Loop Set Up (Conditional) */
@@ -350,82 +350,82 @@ static int arcompact_genops(RzAnalOp *op, ut64 addr, ut32 words[2]) {
fields.cond = fields.a & 0x1f;
op->cond = map_cond2radare (fields.a & 0x1f);
op->jump = (addr & ~3) + fields.imm;
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->fail = addr + op->size;
break;
default:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
}
break;
case 0x29: /* set status flags */
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x2a: /* load from auxiliary register. */
case 0x2b: /* store to auxiliary register. */
op->type = R_ANAL_OP_TYPE_IO;
op->type = RZ_ANAL_OP_TYPE_IO;
break;
case 0x2f: /* Single Operand Instructions, 0x04, [0x2F, 0x00 - 0x3F] */
switch (fields.a) {
case 0: /* Arithmetic shift left by one */
op->type = R_ANAL_OP_TYPE_SAL;
op->type = RZ_ANAL_OP_TYPE_SAL;
break;
case 1: /* Arithmetic shift right by one */
op->type = R_ANAL_OP_TYPE_SAR;
op->type = RZ_ANAL_OP_TYPE_SAR;
break;
case 2: /* Logical shift right by one */
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case 3: /* Rotate right */
case 4: /* Rotate right through carry */
op->type = R_ANAL_OP_TYPE_ROR;
op->type = RZ_ANAL_OP_TYPE_ROR;
break;
case 5: /* Sign extend byte */
case 6: /* Sign extend word */
case 7: /* Zero extend byte */
case 8: /* Zero extend word */
// op->type = R_ANAL_OP_TYPE_UNK;
op->type = R_ANAL_OP_TYPE_MOV;
// op->type = RZ_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_MOV;
/* TODO: a better encoding for SEX and EXT instructions */
break;
case 9: /* Absolute */
op->type = R_ANAL_OP_TYPE_ABS;
op->type = RZ_ANAL_OP_TYPE_ABS;
break;
case 0xa: /* Logical NOT */
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
break;
case 0xb: /* Rotate left through carry */
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
break;
case 0xc: /* Atomic Exchange */
op->type = R_ANAL_OP_TYPE_XCHG;
op->type = RZ_ANAL_OP_TYPE_XCHG;
break;
case 0x3f: /* See Zero operand (ZOP) table */
switch (fields.b) {
case 1: /* Sleep */
/* TODO: a better encoding for this */
op->type = R_ANAL_OP_TYPE_NULL;
op->type = RZ_ANAL_OP_TYPE_NULL;
break;
case 2: /* Software interrupt */
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
break;
case 3: /* Wait for all data-based memory transactions to complete */
/* TODO: a better encoding for this */
op->type = R_ANAL_OP_TYPE_NULL;
op->type = RZ_ANAL_OP_TYPE_NULL;
break;
case 4: /* Return from interrupt/exception */
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
case 5: /* Breakpoint instruction */
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
break;
default:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
}
break;
default:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
}
break;
@@ -437,7 +437,7 @@ static int arcompact_genops(RzAnalOp *op, ut64 addr, ut32 words[2]) {
case 0x35:
case 0x36:
case 0x37: /* Load Register-Register, 0x04, [0x30 - 0x37] */
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
}
@@ -455,7 +455,7 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
/* no unaligned code */
if (addr % 2 != 0) {
/* this fixes some of the reverse disassembly issues */
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
return 0;
}
if (len < 8) {
@@ -463,7 +463,7 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
return 0;
}
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
op->ptr = UT64_MAX;
op->val = UT64_MAX;
op->jump = UT64_MAX;
@@ -499,14 +499,14 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
fields.limm = SEX_S21 (fields.limm);
fields.cond = (words[0] & 0x1f);
op->cond = map_cond2radare (fields.cond);
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
} else {
/* Branch Unconditional Far 0x00 [0x1] */
fields.limm |= (fields.c & 0x0f) << 21;
/* the & 0xf clearly shows we don't overflow */
/* TODO: don't generate code to show this */
fields.limm = SEX_S25 (fields.limm);
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
}
arcompact_branch (op, addr, fields.limm, fields.mode_n);
break;
@@ -520,7 +520,7 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
fields.b = (words[0] & 0x07000000) >> 24 | (words[0] & 0x7000) >> 9;
fields.c = (words[0] & 0x00000fc0) >> 6;
fields.imm = SEX_S9 ((words[0] & 0x00fe0000) >> 16 | (words[0] & 0x8000) >> 7);
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
if (fields.format2 == 0) {
/* Branch on Compare Register-Register, 0x01, [0x1, 0x0] */
@@ -546,14 +546,14 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
fields.imm = SEX_S21 (fields.imm);
fields.cond = (words[0] & 0x1f);
op->cond = map_cond2radare (fields.cond);
op->type = R_ANAL_OP_TYPE_CCALL;
op->type = RZ_ANAL_OP_TYPE_CCALL;
} else {
/* Branch and Link Unconditional Far, 0x01, [0x0, 0x1] */
fields.imm |= (fields.c & 0x0f) << 21;
/* the & 0xf clearly shows we don't overflow */
/* TODO: don't generate code to show this */
fields.imm = SEX_S25 (fields.imm);
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
}
arcompact_branch (op, addr, fields.imm, fields.mode_n);
}
@@ -565,11 +565,11 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
/* fields.mode_aa = (words[0] & 0x600) >> 9; */
fields.mode_zz = (words[0] & 0x180) >> 7;
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
/* dst (fields.a) cannot be an extension core register */
if (fields.a == ARC_REG_PCL || fields.a == 61 || (fields.a >= 0x20 && fields.a <= 0x2b)) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
}
map_zz2refptr (op, fields.mode_zz);
@@ -591,7 +591,7 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
/* ut8 mode_aa = (words[0] & 0x18) >> 3; */
fields.mode_zz = (words[0] & 0x6) >> 1;
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
map_zz2refptr (op, fields.mode_zz);
@@ -611,7 +611,7 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
/* TODO: set op with GP,FP,SP src/dst details */
break;
case 4: /* General Operations */
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
return arcompact_genops (op, addr, words);
case 5:
case 6:
@@ -637,17 +637,17 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
fields.limm = words[1];
}
/* TODO: fill in the extansion functions */
// op->type = R_ANAL_OP_TYPE_UNK;
// op->type = R_ANAL_OP_TYPE_SHL;
op->type = R_ANAL_OP_TYPE_SHR;
// op->type = RZ_ANAL_OP_TYPE_UNK;
// op->type = RZ_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case 0x09:
case 0x0a:
case 0x0b: /* Market Specific Extension Instructions, 0x09 - 0x0B */
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case 0x0c: /* Load /Add Register-Register, 0x0C, [0x00 - 0x03] */
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
fields.subopcode = (words[0] & 0x00180000) >> 19;
/* fields.a = (words[0] & 0x00070000) >> 16; */
/* fields.c = (words[0] & 0x00e00000) >> 21; */
@@ -657,10 +657,10 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
case 0: /* Load long word (reg.+reg.) */
case 1: /* Load unsigned byte (reg.+reg.) */
case 2: /* Load unsigned word (reg.+reg.) */
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 3: /* Add */
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
}
break;
@@ -672,16 +672,16 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
switch (fields.subopcode) {
case 0: /* Add */
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 1: /* Subtract */
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 2: /* Multiple arithmetic shift left */
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
break;
case 3: /* Multiple arithmetic shift right */
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
}
break;
@@ -697,14 +697,14 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
switch (fields.subopcode) {
case 0: /* Add */
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 1: /* Move */
case 3: /* Move */
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 2: /* Compare */
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
}
break;
@@ -717,53 +717,53 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
case 0: /* Single Operand, Jumps and Special Format Instructions, 0x0F, [0x00, 0x00 - 0x07] */
switch (fields.c) {
case 0: /* J_S [r]*/
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
arcompact_jump (op, 0, 0, 0);
break;
case 1: /* J_S.D [r] */
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
arcompact_jump (op, 0, 0, 1);
break;
case 2: /* JL_S [r] */
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
arcompact_jump (op, 0, 0, 0);
break;
case 3: /* JL_S.D [r] */
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
arcompact_jump (op, 0, 0, 1);
break;
case 4:
case 5: /* Reserved - instruction error */
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case 6: /* SUB_S.NE [b] */
op->cond = R_ANAL_COND_NE;
op->type = R_ANAL_OP_TYPE_SUB;
op->cond = RZ_ANAL_COND_NE;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 7: /* Zero Operand Instructions, 0x0F, [0x00, 0x07, 0x00 - 0x07] */
switch (fields.b) {
case 0: /* nop_s */
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
op->size = 4;
break;
case 1:
case 2:
case 3: /* unimplemented and Reserved - instruction error */
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case 4: /* JEQ_S [blink] */
op->cond = R_ANAL_COND_EQ;
op->type = R_ANAL_OP_TYPE_CRET;
op->cond = RZ_ANAL_COND_EQ;
op->type = RZ_ANAL_OP_TYPE_CRET;
break;
case 5: /* JNE_S [blink] */
op->cond = R_ANAL_COND_NE;
op->type = R_ANAL_OP_TYPE_CRET;
op->cond = RZ_ANAL_COND_NE;
op->type = RZ_ANAL_OP_TYPE_CRET;
break;
case 7: /* J_S.D [blink] */
op->delay = 1;
/* fall through */
case 6: /* J_S [blink] */
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
}
break;
@@ -775,76 +775,76 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
case 9:
case 0xa:
case 0x17: /* Reserved - instruction error */
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case 2:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 4:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case 5:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case 6: /* Logical bitwise AND with invert */
/* dest = src1 AND NOT src2 */
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case 7:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case 0xb: /* Test */
/* no dst, b AND c */
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case 0xc:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case 0xd: /* Sign extend byte */
case 0xe: /* Sign extend word */
case 0xf: /* Zero extend byte */
case 0x10: /* Zero extend word */
case 0x13: /* Negate */
op->type = R_ANAL_OP_TYPE_CPL;
op->type = RZ_ANAL_OP_TYPE_CPL;
break;
case 0x11:
op->type = R_ANAL_OP_TYPE_ABS;
op->type = RZ_ANAL_OP_TYPE_ABS;
break;
case 0x12:
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
break;
case 0x14: /* Add with left shift by 1 */
case 0x15: /* Add with left shift by 2 */
case 0x16: /* Add with left shift by 3 */
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 0x18: /* Multiple arithmetic shift left */
op->type = R_ANAL_OP_TYPE_SAL;
op->type = RZ_ANAL_OP_TYPE_SAL;
break;
case 0x19: /* Multiple logical shift right */
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case 0x1a: /* Multiple arithmetic shift right */
op->type = R_ANAL_OP_TYPE_SAR;
op->type = RZ_ANAL_OP_TYPE_SAR;
break;
case 0x1b: /* Arithmetic shift left by one */
op->type = R_ANAL_OP_TYPE_SAL;
op->type = RZ_ANAL_OP_TYPE_SAL;
break;
case 0x1c: /* Arithmetic shift right by one */
op->type = R_ANAL_OP_TYPE_SAR;
op->type = RZ_ANAL_OP_TYPE_SAR;
break;
case 0x1d: /* Logical shift right by one */
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
break;
case 0x1e:
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
/* TODO: the description sounds more like a */
/* R_ANAL_OP_TYPE_SWI, but I don't know what */
/* RZ_ANAL_OP_TYPE_SWI, but I don't know what */
/* difference that would make to radare */
break;
case 0x1f:
op->type = R_ANAL_OP_TYPE_TRAP;
/* TODO: this should be R_ANAL_OP_TYPE_DEBUG, */
op->type = RZ_ANAL_OP_TYPE_TRAP;
/* TODO: this should be RZ_ANAL_OP_TYPE_DEBUG, */
/* but that type is commented out */
break;
}
@@ -854,36 +854,36 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
case 0x12: /* LDW_S c,[b,u6] */
case 0x13: /* LDW_S.X c,[b,u6] */
/* Load/Store with Offset, 0x10 - 0x16 */
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 0x14: /* ST_S c, [b, u7] */
case 0x15: /* STB_S c, [b, u5] */
case 0x16: /* STW_S c, [b, u6] */
/* Load/Store with Offset, 0x10 - 0x16 */
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case 0x17: /* Shift/Subtract/Bit Immediate, 0x17, [0x00 - 0x07] */
fields.subopcode = (words[0] & 0x00e00000) >> (16 + 5);
switch (fields.subopcode) {
case 0: /* Multiple arithmetic shift left */
op->type = R_ANAL_OP_TYPE_SAL;
op->type = RZ_ANAL_OP_TYPE_SAL;
break;
case 1: /* Multiple logical shift left */
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
break;
case 2: /* Multiple arithmetic shift right */
op->type = R_ANAL_OP_TYPE_SAR;
op->type = RZ_ANAL_OP_TYPE_SAR;
break;
case 3: /* Subtract */
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 4: /* Bit set */
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case 5: /* Bit clear */
case 6: /* Bit mask */
case 7: /* Bit test */
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
}
break;
@@ -892,26 +892,26 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
switch (fields.subopcode) {
case 0: /* Load long word sp-rel. */
case 1: /* Load unsigned byte sp-rel. */
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 2: /* Store long word sp-rel. */
case 3: /* Store unsigned byte sp-rel. */
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case 4: /* Add */
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 5: /* Add/Subtract SP Relative, 0x18, [0x05, 0x00-0x07] */
fields.b = (words[0] & 0x07000000) >> (16 + 8);
switch (fields.b) {
case 0: /* Add immediate to SP */
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 1: /* Subtract immediate from SP */
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
default:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
}
break;
@@ -920,10 +920,10 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
switch (fields.c) {
case 1: /* Pop register from stack */
case 0x11: /* Pop blink from stack */
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
break;
default:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
}
break;
@@ -932,10 +932,10 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
switch (fields.c) {
case 1: /* Push register to stack */
case 0x11: /* Push blink to stack */
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
break;
default:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
}
break;
@@ -947,37 +947,37 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
case 0: /* Load gp-relative (32-bit aligned) to r0 */
case 1: /* Load unsigned byte gp-relative (8-bit aligned) to r0 */
case 2: /* Load unsigned word gp-relative (16-bit aligned) to r0 */
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 3: /* Add gp-relative (32-bit aligned) to r0 */
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
}
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case 0x1a: /* Load PCL-Relative, 0x1A */
fields.c = (words[0] & 0x00ff0000) >> 14;
op->ptr = (addr & ~3) + fields.c;
op->refptr = 4;
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 0x1b: /* Move Immediate, 0x1B */
op->val = (words[0] & 0x00ff0000) >> 16;
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x1c: /* ADD/CMP Immediate, 0x1C, [0x00 - 0x01] */
fields.subopcode = (words[0] & 0x00800000) >> (16 + 7);
if (fields.subopcode == 0) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
} else {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
}
break;
case 0x1d: /* Branch on Compare Register with Zero, 0x1D, [0x00 - 0x01] */
/* fields.subopcode = (words[0] & 0x00800000) >> (16+7); */
fields.imm = SEX_S8 ((words[0] & 0x007f0000) >> (16 - 1));
/* fields.subopcode? reg NE: reg EQ; */
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
arcompact_branch (op, addr, fields.imm, 0);
break;
case 0x1e: /* Branch Conditionally, 0x1E, [0x00 - 0x03] */
@@ -985,18 +985,18 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
fields.imm = SEX_S10 ((words[0] & 0x01ff0000) >> (16 - 1));
switch (fields.subopcode) {
case 0: /* B_S */
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 1: /* BEQ_S */
op->cond = R_ANAL_COND_EQ;
op->type = R_ANAL_OP_TYPE_CJMP;
op->cond = RZ_ANAL_COND_EQ;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case 2: /* BNE_S */
op->cond = R_ANAL_COND_NE;
op->type = R_ANAL_OP_TYPE_CJMP;
op->cond = RZ_ANAL_COND_NE;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case 3: /* Bcc_S */
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
fields.imm = SEX_S7 ((words[0] & 0x003f0000) >> (16 - 1));
/* TODO: cond codes (looks like it is the BR table again?) */
break;
@@ -1005,7 +1005,7 @@ static int arcompact_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data,
break;
case 0x1f: /* Branch and Link Unconditionally, 0x1F */
fields.imm = SEX_S13 ((words[0] & 0x07ff0000) >> (16 - 2));
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
arcompact_branch (op, addr, fields.imm, 0);
break;
}
@@ -1028,36 +1028,36 @@ static int arc_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int le
case 0x04: /* Branch */
case 0x05: /* Branch with Link */
case 0x06: /* Loop */
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + 4 + ((rz_read_le32 (&data[0]) & 0x07ffff80) >> (7 - 2));
break;
case 0x07: /* Conditional Jump and Jump with Link */
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = 0;
break;
case 0x08:
case 0x09:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 0x0a:
case 0x0b:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 0x0c:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case 0x0d:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case 0x0f:
if ((b[0] == 0xff) && (b[1] == 0xff)) {
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
}
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case 0x13:
op->type = R_ANAL_OP_TYPE_ROR;
op->type = RZ_ANAL_OP_TYPE_ROR;
break;
default:
break;
@@ -1070,12 +1070,12 @@ static int archinfo(RzAnal *anal, int query) {
return -1;
}
switch (query) {
case R_ANAL_ARCHINFO_ALIGN:
case RZ_ANAL_ARCHINFO_ALIGN:
return 2;
case R_ANAL_ARCHINFO_MIN_OP_SIZE:
case RZ_ANAL_ARCHINFO_MIN_OP_SIZE:
/* all ops are at least 1 word long */
return 2;
case R_ANAL_ARCHINFO_MAX_OP_SIZE:
case RZ_ANAL_ARCHINFO_MAX_OP_SIZE:
return 8;
default:
return -1;
@@ -1148,10 +1148,10 @@ RzAnalPlugin rz_anal_plugin_arc = {
.set_reg_profile = set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_arc,
.version = R2_VERSION,
.version = RZ_VERSION,
};
#endif
+216 -216
View File
File diff suppressed because it is too large Load Diff
+64 -64
View File
@@ -54,61 +54,61 @@ static int op_thumb(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
/* CMP */
if (((ins & B4 (B1110, 0, 0, 0)) == B4 (B0010, 0, 0, 0))
&& (1 == (ins & B4 (1, B1000, 0, 0)) >> 11)) { // dp3
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
return op->size;
}
if ((ins & B4 (B1111, B1100, 0, 0)) == B4 (B0100, 0, 0, 0)) {
op_code = (ins & B4 (0, B0011, B1100, 0)) >> 6;
if (op_code == 8 || op_code == 10) { // dp5
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
return op->size;
}
}
if ((ins & B4 (B1111, B1100, 0, 0)) == B4 (B0100, B0100, 0, 0)) {
op_code = (ins & B4 (0, B0011, 0, 0)) >> 8; // dp8
if (op_code == 1) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
return op->size;
}
}
if (ins == 0xbf) {
// TODO: add support for more NOP instructions
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
} else if (((op_code = ((ins & B4 (B1111, B1000, 0, 0)) >> 11)) >= 12 &&
op_code <= 17)) {
if (op_code % 2) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
} else {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
}
} else if ((ins & B4 (B1111, 0, 0, 0)) == B4 (B0101, 0, 0, 0)) {
op_code = (ins & B4 (0, B1110, 0, 0)) >> 9;
if (op_code % 2) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
} else {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
}
} else if ((ins & B4 (B1111, 0, 0, 0)) == B4 (B1101, 0, 0, 0)) {
// BNE..
int delta = (ins & B4 (0, 0, B1111, B1111));
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + 4 + (delta << 1);
op->fail = addr + 4;
} else if ((ins & B4 (B1111, B1000, 0, 0)) == B4 (B1110, 0, 0, 0)) {
// B
int delta = (ins & B4 (0, 0, B1111, B1111));
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = addr + 4 + (delta << 1);
op->fail = addr + 4;
} else if ((ins & B4 (B1111, B1111, B1000, 0)) ==
B4 (B0100, B0111, B1000, 0)) {
// BLX
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
op->fail = addr + 4;
} else if ((ins & B4 (B1111, B1111, B1000, 0)) ==
B4 (B0100, B0111, 0, 0)) {
// BX
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
op->fail = addr + 4;
} else if ((ins & B4 (B1111, B1000, 0, 0)) == B4 (B1111, 0, 0, 0)) {
// BL The long branch with link, it's in 2 instructions:
@@ -121,13 +121,13 @@ static int op_thumb(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
}
int delta = high + ((nextins & B4 (0, B0111, B1111, B1111)) * 2);
op->jump = (int) (addr + 4 + (delta));
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->fail = addr + 4;
} else if ((ins & B4 (B1111, B1111, 0, 0)) == B4 (B1011, B1110, 0, 0)) {
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
op->val = (ut64) (ins >> 8);
} else if ((ins & B4 (B1111, B1111, 0, 0)) == B4 (B1101, B1111, 0, 0)) {
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
op->val = (ut64) (ins >> 8);
}
return op->size;
@@ -138,8 +138,8 @@ static int op_thumb(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
"hi", "ls", "ge", "lt", "gt", "le", "al", "nv",
#endif
static int iconds[] = {
R_ANAL_COND_EQ,
R_ANAL_COND_NE,
RZ_ANAL_COND_EQ,
RZ_ANAL_COND_NE,
0, // cs
0, // cc
0, // mi
@@ -149,12 +149,12 @@ static int iconds[] = {
0, // hi
0, // ls
R_ANAL_COND_GE,
R_ANAL_COND_LT,
R_ANAL_COND_GT,
R_ANAL_COND_LE,
R_ANAL_COND_AL,
R_ANAL_COND_NV,
RZ_ANAL_COND_GE,
RZ_ANAL_COND_LT,
RZ_ANAL_COND_GT,
RZ_ANAL_COND_LE,
RZ_ANAL_COND_AL,
RZ_ANAL_COND_NV,
};
static int op_cond(const ut8 *data) {
@@ -180,7 +180,7 @@ static int arm_op32(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
arm_set_input_buffer (arminsn, data);
arm_set_pc (arminsn, addr);
op->addr = addr;
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
if (anal->big_endian) {
b = data = ndata;
@@ -196,7 +196,7 @@ static int arm_op32(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
op->size = 4;
op->cond = op_cond (data);
if (b[2] == 0x8f && b[3] == 0xe2) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
#define ROR(x, y) ((int) ((x) >> (y)) | (((x) << (32 - (y)))))
op->ptr = addr + ROR (b[0], (b[1] & 0xf) << 1) + 8;
} else if (b[2] >= 0x9c && b[2] <= 0x9f) { // load instruction
@@ -212,22 +212,22 @@ static int arm_op32(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 6:
case 7:
case 8:
case 9: op->type = R_ANAL_OP_TYPE_LOAD; break;
case 9: op->type = RZ_ANAL_OP_TYPE_LOAD; break;
}
} else // 0x000037b8 00:0000 0 800000ef svc 0x00000080
if (b[2] == 0xa0 && b[3] == 0xe1) {
int n = (b[0] << 16) + b[1];
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
switch (n) {
case 0:
case 0x0110: case 0x0220: case 0x0330: case 0x0440:
case 0x0550: case 0x0660: case 0x0770: case 0x0880:
case 0x0990: case 0x0aa0: case 0x0bb0: case 0x0cc0:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
}
} else if (b[3] == 0xef) {
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
op->val = (b[0] | (b[1] << 8) | (b[2] << 2));
} else if ((b[3] & 0xf) == 5) { // [reg,0xa4]
#if 0
@@ -241,9 +241,9 @@ static int arm_op32(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
#endif
if ((b[1] & 0xf0) == 0xf0) {
// ldr pc, [pc, #1] ;
// op->type = R_ANAL_OP_TYPE_UJMP;
op->type = R_ANAL_OP_TYPE_RET; // FAKE FOR FUN
// op->stackop = R_ANAL_STACK_SET;
// op->type = RZ_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_RET; // FAKE FOR FUN
// op->stackop = RZ_ANAL_STACK_SET;
op->jump = 1234;
// op->ptr = 4+addr+b[0]; // sure? :)
// op->ptrptr = true;
@@ -252,33 +252,33 @@ static int arm_op32(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
// 0x0001B4D8, 1eff2fe1 bx lr
} else if (b[3] == 0xe2 && b[2] == 0x8d && b[1] == 0xd0) {
// ADD SP, SP, ...
op->type = R_ANAL_OP_TYPE_ADD;
op->stackop = R_ANAL_STACK_INC;
op->type = RZ_ANAL_OP_TYPE_ADD;
op->stackop = RZ_ANAL_STACK_INC;
op->val = -b[0];
} else if (b[3] == 0xe2 && b[2] == 0x4d && b[1] == 0xd0) {
// SUB SP, SP, ..
op->type = R_ANAL_OP_TYPE_SUB;
op->stackop = R_ANAL_STACK_INC;
op->type = RZ_ANAL_OP_TYPE_SUB;
op->stackop = RZ_ANAL_STACK_INC;
op->val = b[0];
} else if (b[3] == 0xe2 && b[2] == 0x4c && b[1] == 0xb0) {
// SUB SP, FP, ..
op->type = R_ANAL_OP_TYPE_SUB;
op->stackop = R_ANAL_STACK_INC;
op->type = RZ_ANAL_OP_TYPE_SUB;
op->stackop = RZ_ANAL_STACK_INC;
op->val = -b[0];
} else if (b[3] == 0xe2 && b[2] == 0x4b && b[1] == 0xd0) {
// SUB SP, IP, ..
op->type = R_ANAL_OP_TYPE_SUB;
op->stackop = R_ANAL_STACK_INC;
op->type = RZ_ANAL_OP_TYPE_SUB;
op->stackop = RZ_ANAL_STACK_INC;
op->val = -b[0];
} else if ((code[i] == 0x1eff2fe1) ||
(code[i] == 0xe12fff1e)) { // bx lr
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
} else if ((code[i] & ARM_DTX_LOAD)) { // IS_LOAD(code[i])) {
ut32 ptr = 0;
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
if (b[2] == 0x1b) {
/* XXX pretty incomplete */
op->stackop = R_ANAL_STACK_GET;
op->stackop = RZ_ANAL_STACK_GET;
op->ptr = b[0];
// var_add_access(addr, -b[0], 1, 0); // TODO: set/get (the last 0)
} else {
@@ -296,7 +296,7 @@ static int arm_op32(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
}
if (IS_LOAD (code[i])) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->refptr = 4;
}
if (((((code[i] & 0xff) >= 0x10 && (code[i] & 0xff) < 0x20)) &&
@@ -310,29 +310,29 @@ static int arm_op32(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
op->ptr = 0;
if ((((code[i] & 0xff) >= 0x10 && (code[i] & 0xff) < 0x20)) &&
((code[i] & 0xffffff00) == 0xe12fff00)) {
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
} else if (IS_BRANCHL (code[i])) {
if (IS_BRANCH (code[i])) {
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = branch_dst_addr;
op->fail = addr + 4;
} else {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
}
} else if (IS_BRANCH (code[i])) {
if (IS_CONDAL (code[i])) {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = branch_dst_addr;
op->fail = UT64_MAX;
} else {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = branch_dst_addr;
op->fail = addr + 4;
}
} else {
// unknown jump o return
// op->type = R_ANAL_OP_TYPE_UJMP;
// op->type = R_ANAL_OP_TYPE_NOP;
// op->type = RZ_ANAL_OP_TYPE_UJMP;
// op->type = RZ_ANAL_OP_TYPE_NOP;
}
}
// op->jump = arminsn->jmp;
@@ -361,39 +361,39 @@ static int arm_op64(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *d, int len
return haa;
}
op->size = 4;
op->type = R_ANAL_OP_TYPE_NULL;
op->type = RZ_ANAL_OP_TYPE_NULL;
if (d[0] == 0xc0 && d[3] == 0xd6) {
// defaults to x30 reg. but can be different
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
}
switch (d[3]) {
case 0x71:
case 0xeb:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case 0xb8:
case 0xb9:
case 0xf8:
case 0xa9: // ldp/stp
case 0xf9: // ldr/str
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 0x91: // mov
case 0x52: // mov
case 0x94: // bl A
case 0x97: // bl A
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = getaddr (addr, d);
op->fail = addr + 4;
break;
case 0x54: // beq A
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + (4 * ((d[0] >> 4) | (d[1] << 8) | (d[2] << 16)));
op->fail = addr + 4;
break;
case 0x17: // b A
case 0x14: // b A
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = getaddr (addr, d);
op->fail = addr + 4;
break;
@@ -444,16 +444,16 @@ static bool set_reg_profile(RzAnal *anal) {
}
static int archinfo(RzAnal *anal, int q) {
if (q == R_ANAL_ARCHINFO_ALIGN) {
if (q == RZ_ANAL_ARCHINFO_ALIGN) {
if (anal && anal->bits == 16) {
return 2;
}
return 4;
}
if (q == R_ANAL_ARCHINFO_MAX_OP_SIZE) {
if (q == RZ_ANAL_ARCHINFO_MAX_OP_SIZE) {
return 4;
}
if (q == R_ANAL_ARCHINFO_MIN_OP_SIZE) {
if (q == RZ_ANAL_ARCHINFO_MIN_OP_SIZE) {
if (anal && anal->bits == 16) {
return 2;
}
@@ -473,10 +473,10 @@ RzAnalPlugin rz_anal_plugin_arm_gnu = {
.set_reg_profile = set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_arm_gnu,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+20 -20
View File
@@ -13,20 +13,20 @@ static int hack_handle_dp_reg(ut32 insn, RzAnalOp *op) {
if (!S) {
if (opcode == 4) {
// irg
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
return op->size = 4;
} else if (opcode == 0) {
// subp
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
return op->size = 4;
} else if (opcode == 5) {
// gmi
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
return op->size = 4;
}
} else if (S && opcode == 0) {
// subps
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
return op->size = 4;
}
}
@@ -48,38 +48,38 @@ static int hack_handle_ldst(ut32 insn, RzAnalOp *op) {
switch (opc) {
case 0:
// stg
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
return op->size = 4;
case 1:
// stzg
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
return op->size = 4;
case 2:
// st2g
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
return op->size = 4;
case 3:
// stz2g
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
return op->size = 4;
}
} else if (op2 == 0) {
switch (opc) {
case 0:
// stzgm
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
return op->size = 4;
case 1:
// ldg
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
return op->size = 4;
case 2:
// stgm
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
return op->size = 4;
case 3:
// ldgm
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
return op->size = 4;
}
}
@@ -90,7 +90,7 @@ static int hack_handle_ldst(ut32 insn, RzAnalOp *op) {
const bool L = (insn >> 22) & 0x1;
if (opc == 1 && !V && !L) {
// stgp
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
return op->size = 4;
}
}
@@ -109,11 +109,11 @@ static int hack_handle_dp_imm(ut32 insn, RzAnalOp *op) {
if (sf && !S && !o2) {
if (op_ ) {
// subg
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
return op->size = 4;
}
// addg
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
return op->size = 4;
}
}
@@ -135,7 +135,7 @@ static int hack_handle_br_exc_sys(ut32 insn, RzAnalOp *op) {
case 2:
case 4:
case 6:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
return op->size = 4;
}
}
@@ -151,17 +151,17 @@ static inline int hackyArmAnal(RzAnal *a, RzAnalOp *op, const ut8 *buf, int len)
int insn_class = (*insn >> 25) & 0xf;
// xpaci // e#43c1da
if (!memcmp (buf + 1, "\x43\xc1\xda", 3)) {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
return op->size = 4;
}
// retaa
if (!memcmp (buf, "\xff\x0b\x5f\xd6", 4)) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
return op->size = 4;
}
// retab
if (!memcmp (buf, "\xff\x0f\x5f\xd6", 4)) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
return op->size = 4;
}
@@ -196,7 +196,7 @@ static inline int hackyArmAnal(RzAnal *a, RzAnalOp *op, const ut8 *buf, int len)
}
if (ret > 0) {
op->family = R_ANAL_OP_FAMILY_SECURITY;
op->family = RZ_ANAL_OP_FAMILY_SECURITY;
}
}
+22 -22
View File
@@ -59,8 +59,8 @@ static OPCODE_DESC* avr_op_analyze(RzAnal *anal, RzAnalOp *op, ut64 addr, const
#define CPU_PC_SIZE(cpu) ((((cpu)->pc) >> 3) + ((((cpu)->pc) & 0x07) ? 1 : 0))
#define INST_HANDLER(OPCODE_NAME) static void _inst__ ## OPCODE_NAME (RzAnal *anal, RzAnalOp *op, const ut8 *buf, int len, int *fail, CPU_MODEL *cpu)
#define INST_DECL(OP, M, SL, C, SZ, T) { #OP, (M), (SL), _inst__ ## OP, (C), (SZ), R_ANAL_OP_TYPE_ ## T }
#define INST_LAST { "unknown", 0, 0, (void *) 0, 2, 1, R_ANAL_OP_TYPE_UNK }
#define INST_DECL(OP, M, SL, C, SZ, T) { #OP, (M), (SL), _inst__ ## OP, (C), (SZ), RZ_ANAL_OP_TYPE_ ## T }
#define INST_LAST { "unknown", 0, 0, (void *) 0, 2, 1, RZ_ANAL_OP_TYPE_UNK }
#define INST_CALL(OPCODE_NAME) _inst__ ## OPCODE_NAME (anal, op, buf, len, fail, cpu)
#define INST_INVALID { *fail = 1; return; }
@@ -494,7 +494,7 @@ INST_HANDLER (cbi) { // CBI A, b
int b = buf[0] & 0x07;
RStrBuf *io_port;
op->family = R_ANAL_OP_FAMILY_IO;
op->family = RZ_ANAL_OP_FAMILY_IO;
op->type2 = 1;
op->val = a;
@@ -608,7 +608,7 @@ INST_HANDLER (dec) { // DEC Rd
INST_HANDLER (des) { // DES k
if (desctx.round < 16) { //DES
op->type = R_ANAL_OP_TYPE_CRYPTO;
op->type = RZ_ANAL_OP_TYPE_CRYPTO;
op->cycles = 1; //redo this
rz_strbuf_setf (&op->esil, "%d,des", desctx.round);
}
@@ -744,7 +744,7 @@ INST_HANDLER (in) { // IN Rd, A
RStrBuf *io_src = __generic_io_dest (a, 0, cpu);
op->type2 = 0;
op->val = a;
op->family = R_ANAL_OP_FAMILY_IO;
op->family = RZ_ANAL_OP_FAMILY_IO;
ESIL_A ("%s,r%d,=,", rz_strbuf_get (io_src), r);
rz_strbuf_free (io_src);
}
@@ -1092,7 +1092,7 @@ INST_HANDLER (out) { // OUT A, Rr
RStrBuf *io_dst = __generic_io_dest (a, 1, cpu);
op->type2 = 1;
op->val = a;
op->family = R_ANAL_OP_FAMILY_IO;
op->family = RZ_ANAL_OP_FAMILY_IO;
ESIL_A ("r%d,%s,", r, rz_strbuf_get (io_dst));
rz_strbuf_free (io_dst);
}
@@ -1160,7 +1160,7 @@ INST_HANDLER (ret) { // RET
INST_HANDLER (reti) { // RETI
//XXX: There are not privileged instructions in ATMEL/AVR
op->family = R_ANAL_OP_FAMILY_PRIV;
op->family = RZ_ANAL_OP_FAMILY_PRIV;
// first perform a standard 'ret'
INST_CALL (ret);
@@ -1271,7 +1271,7 @@ INST_HANDLER (sbi) { // SBI A, b
op->type2 = 1;
op->val = a;
op->family = R_ANAL_OP_FAMILY_IO;
op->family = RZ_ANAL_OP_FAMILY_IO;
// read port a and clear bit b
io_port = __generic_io_dest (a, 0, cpu);
@@ -1296,7 +1296,7 @@ INST_HANDLER (sbix) { // SBIC A, b
op->type2 = 0;
op->val = a;
op->family = R_ANAL_OP_FAMILY_IO;
op->family = RZ_ANAL_OP_FAMILY_IO;
// calculate next instruction size (call recursively avr_op_analyze)
// and free next_op's esil string (we dont need it now)
@@ -1630,7 +1630,7 @@ static OPCODE_DESC* avr_op_analyze(RzAnal *anal, RzAnalOp *op, ut64 addr, const
// eprintf ("opcode %s @%"PFMT64x" returned 0 cycles.\n", opcode_desc->name, op->addr);
opcode_desc->cycles = 2;
}
op->nopcode = (op->type == R_ANAL_OP_TYPE_UNK);
op->nopcode = (op->type == RZ_ANAL_OP_TYPE_UNK);
// remove trailing coma (COMETE LA COMA)
t = rz_strbuf_get (&op->esil);
@@ -1653,8 +1653,8 @@ static OPCODE_DESC* avr_op_analyze(RzAnal *anal, RzAnalOp *op, ut64 addr, const
INVALID_OP:
// An unknown or invalid option has appeared.
// -- Throw pokeball!
op->family = R_ANAL_OP_FAMILY_UNKNOWN;
op->type = R_ANAL_OP_TYPE_UNK;
op->family = RZ_ANAL_OP_FAMILY_UNKNOWN;
op->type = RZ_ANAL_OP_TYPE_UNK;
op->addr = addr;
op->nopcode = 1;
op->cycles = 1;
@@ -1893,10 +1893,10 @@ static int esil_avr_init(RzAnalEsil *esil) {
return false;
}
desctx.round = 0;
rz_anal_esil_set_op (esil, "des", avr_custom_des, 0, 0, R_ANAL_ESIL_OP_TYPE_CUSTOM); //better meta info plz
rz_anal_esil_set_op (esil, "SPM_PAGE_ERASE", avr_custom_spm_page_erase, 0, 0, R_ANAL_ESIL_OP_TYPE_CUSTOM);
rz_anal_esil_set_op (esil, "SPM_PAGE_FILL", avr_custom_spm_page_fill, 0, 0, R_ANAL_ESIL_OP_TYPE_CUSTOM);
rz_anal_esil_set_op (esil, "SPM_PAGE_WRITE", avr_custom_spm_page_write, 0, 0, R_ANAL_ESIL_OP_TYPE_CUSTOM);
rz_anal_esil_set_op (esil, "des", avr_custom_des, 0, 0, RZ_ANAL_ESIL_OP_TYPE_CUSTOM); //better meta info plz
rz_anal_esil_set_op (esil, "SPM_PAGE_ERASE", avr_custom_spm_page_erase, 0, 0, RZ_ANAL_ESIL_OP_TYPE_CUSTOM);
rz_anal_esil_set_op (esil, "SPM_PAGE_FILL", avr_custom_spm_page_fill, 0, 0, RZ_ANAL_ESIL_OP_TYPE_CUSTOM);
rz_anal_esil_set_op (esil, "SPM_PAGE_WRITE", avr_custom_spm_page_write, 0, 0, RZ_ANAL_ESIL_OP_TYPE_CUSTOM);
esil->cb.hook_reg_write = esil_avr_hook_reg_write;
return true;
@@ -2033,13 +2033,13 @@ RAMPX, RAMPY, RAMPZ, RAMPD and EIND:
}
static int archinfo(RzAnal *anal, int q) {
if (q == R_ANAL_ARCHINFO_ALIGN) {
if (q == RZ_ANAL_ARCHINFO_ALIGN) {
return 2;
}
if (q == R_ANAL_ARCHINFO_MAX_OP_SIZE) {
if (q == RZ_ANAL_ARCHINFO_MAX_OP_SIZE) {
return 4;
}
if (q == R_ANAL_ARCHINFO_MIN_OP_SIZE) {
if (q == RZ_ANAL_ARCHINFO_MIN_OP_SIZE) {
return 2;
}
return 2; // XXX
@@ -2107,10 +2107,10 @@ RzAnalPlugin rz_anal_plugin_avr = {
.anal_mask = anal_mask_avr,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_avr,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+14 -14
View File
@@ -35,7 +35,7 @@ static int bf_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len,
op->id = getid (buf[0]);
switch (buf[0]) {
case '[':
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->fail = addr+1;
buf = rz_mem_dup ((void *)buf, len);
if (!buf) {
@@ -62,7 +62,7 @@ static int bf_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len,
}
}
if (*p == 0x00 || *p == 0xff) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
goto beach;
}
if (i == len - 1 && anal->read_at) {
@@ -83,45 +83,45 @@ static int bf_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len,
beach:
free ((ut8 *)buf);
break;
case ']': op->type = R_ANAL_OP_TYPE_UJMP;
case ']': op->type = RZ_ANAL_OP_TYPE_UJMP;
// XXX This is wrong esil
rz_strbuf_set (&op->esil, "brk,--=,brk,[1],pc,=");
break;
case '>':
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
op->size = countChar (buf, len, '>');
rz_strbuf_setf (&op->esil, "%d,ptr,+=", op->size);
break;
case '<':
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
op->size = countChar (buf, len, '<');
rz_strbuf_setf (&op->esil, "%d,ptr,-=", op->size);
break;
case '+':
op->size = countChar (buf, len, '+');
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
rz_strbuf_setf (&op->esil, "%d,ptr,+=[1]", op->size);
break;
case '-':
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
op->size = countChar (buf, len, '-');
rz_strbuf_setf (&op->esil, "%d,ptr,-=[1]", op->size);
break;
case '.':
// print element in stack to screen
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
rz_strbuf_set (&op->esil, "ptr,[1],scr,=[1],scr,++=");
break;
case ',':
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
rz_strbuf_set (&op->esil, "kbd,[1],ptr,=[1],kbd,++=");
break;
case 0x00:
case 0xff:
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
break;
default:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
rz_strbuf_set (&op->esil, ",");
break;
}
@@ -156,10 +156,10 @@ RzAnalPlugin rz_anal_plugin_bf = {
.get_reg_profile = get_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_bf,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+39 -39
View File
@@ -15,92 +15,92 @@ static int chip8_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, in
uint8_t kk = opcode & 0xFF;
op->size = 2;
op->addr = addr;
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
switch (opcode & 0xF000) {
case 0x0000:
if (opcode == 0x00EE) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
}
break;
case 0x1000:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = nnn;
break;
case 0x2000:
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = nnn;
break;
case 0x3000:
op->type = R_ANAL_OP_TYPE_RJMP;
op->type = RZ_ANAL_OP_TYPE_RJMP;
op->jump = addr + op->size * 2;
op->fail = addr + op->size;
break;
case 0x4000:
op->type = R_ANAL_OP_TYPE_RJMP;
op->type = RZ_ANAL_OP_TYPE_RJMP;
op->jump = addr + op->size * 2;
op->fail = addr + op->size;
break;
case 0x5000:
op->type = R_ANAL_OP_TYPE_RJMP;
op->type = RZ_ANAL_OP_TYPE_RJMP;
op->jump = addr + op->size * 2;
op->fail = addr + op->size;
break;
case 0x6000:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x7000:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 0x8000: {
switch (nibble) {
case 0x0:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x1:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case 0x2:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case 0x3:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case 0x4:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 0x5:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 0x6:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case 0x7:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 0xE:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
break;
}
} break;
case 0x9000:
if (nibble == 0) {
op->type = R_ANAL_OP_TYPE_RJMP;
op->type = RZ_ANAL_OP_TYPE_RJMP;
op->jump = addr + op->size * 2;
op->fail = addr + op->size;
}
break;
case 0xA000:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0xB000:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
/* FIXME: this is wrong as op->jump depends on register V0 */
op->jump = nnn;
break;
case 0xE000:
if (kk == 0x9E || kk == 0xA1) {
rz_meta_set_string (anal, R_META_TYPE_COMMENT, addr, "KEYPAD");
op->type = R_ANAL_OP_TYPE_CJMP;
rz_meta_set_string (anal, RZ_META_TYPE_COMMENT, addr, "KEYPAD");
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + op->size * 2;
op->fail = addr + op->size;
}
@@ -108,41 +108,41 @@ static int chip8_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, in
case 0xF000: {
switch (kk) {
case 0x07:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x0A:
rz_meta_set_string (anal, R_META_TYPE_COMMENT, addr, "KEYPAD");
op->type = R_ANAL_OP_TYPE_MOV;
rz_meta_set_string (anal, RZ_META_TYPE_COMMENT, addr, "KEYPAD");
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x15:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x18:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x1E:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 0x29:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 0x30:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 0x33:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case 0x55:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case 0x65:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 0x75:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case 0x85:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
}
} break;
@@ -159,10 +159,10 @@ RzAnalPlugin rz_anal_plugin_chip8 = {
.op = &chip8_anop,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_chip8,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+26 -26
View File
@@ -28,57 +28,57 @@ static int cr16_op(RzAnal *anal, RzAnalOp *op, ut64 addr,
switch (cmd.type) {
case CR16_TYPE_MOV:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case CR16_TYPE_ADD:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case CR16_TYPE_MUL:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case CR16_TYPE_SUB:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case CR16_TYPE_CMP:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case CR16_TYPE_BE:
case CR16_TYPE_BNE:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case CR16_TYPE_AND:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case CR16_TYPE_OR:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case CR16_TYPE_SCOND:
break;
case CR16_TYPE_XOR:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case CR16_TYPE_SHIFT:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case CR16_TYPE_BIT:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case CR16_TYPE_SLPR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case CR16_TYPE_BCOND:
if (cmd.reladdr) {
op->jump = addr + cmd.reladdr;
op->fail = addr + 2;
}
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case CR16_TYPE_BR:
case CR16_TYPE_BAL:
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
break;
case CR16_TYPE_EXCP:
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
break;
case CR16_TYPE_JCOND:
case CR16_TYPE_JAL:
@@ -88,32 +88,32 @@ static int cr16_op(RzAnal *anal, RzAnalOp *op, ut64 addr,
op->jump = addr + cmd.reladdr;
op->fail = addr + 2;
}
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case CR16_TYPE_RETX:
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
case CR16_TYPE_PUSH:
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
break;
case CR16_TYPE_POP:
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
break;
case CR16_TYPE_LOAD:
case CR16_TYPE_DI:
case CR16_TYPE_EI:
case CR16_TYPE_STOR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case CR16_TYPE_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case CR16_TYPE_WAIT:
case CR16_TYPE_EWAIT:
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
break;
default:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
}
return ret;
@@ -128,10 +128,10 @@ RzAnalPlugin rz_anal_plugin_cr16 = {
.op = cr16_op,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_cr16,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+35 -35
View File
@@ -10,15 +10,15 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
switch (buf[0]) {
case 0x3f:
case 0x4f:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
opsize = 4;
break;
case 0x6f:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
opsize = 6;
break;
case 0x7f:
op->type = R_ANAL_OP_TYPE_LEA;
op->type = RZ_ANAL_OP_TYPE_LEA;
if (len > 5) {
op->ptr = buf[2];
op->ptr |= buf[3]<<8;
@@ -32,7 +32,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
}
break;
case 0xbf: // bsr
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
if (len > 5) {
st32 delta = buf[2];
delta |= buf[3]<<8;
@@ -47,9 +47,9 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
break;
case 0x00:
if (buf[1] == 0x00) {
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
} else {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
{
st8 delta = buf[0];
op->jump = addr + delta;
@@ -58,32 +58,32 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
break;
case 0xf0:
if (buf[1]==0xb9) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
}
break;
default:
switch (buf[1]) {
case 0x00:
op->type = R_ANAL_OP_TYPE_CJMP; // BCC
op->type = RZ_ANAL_OP_TYPE_CJMP; // BCC
break;
case 0xf3:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case 0x96: // move.d r, r
if (buf[0] >=0xc0) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
} else {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
}
break;
case 0xf2:
case 0x0b:
case 0x72:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case 0x05:
if (buf[0] == 0xb0) {
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
}
break;
case 0x01:
@@ -94,12 +94,12 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case 0x41:
case 0x61:
case 0x65:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 0x12:
case 0xf6:
case 0xe2:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 0x82: // moveq i, r
case 0xba: // move.d [r], r
@@ -123,10 +123,10 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case 0xaa:
case 0xa6:
case 0xb6:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0xe0:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
{
st8 delta = buf[0];
op->jump = addr + delta;
@@ -136,15 +136,15 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case 0x30:
case 0x20:
case 0x2d:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + buf[0];
op->fail = addr + 2; // delay slot here?
break;
case 0xbf:
op->type = R_ANAL_OP_TYPE_CALL; // bsr
op->type = RZ_ANAL_OP_TYPE_CALL; // bsr
break;
case 0xb9:
op->type = R_ANAL_OP_TYPE_UJMP; // jsr reg
op->type = RZ_ANAL_OP_TYPE_UJMP; // jsr reg
break;
}
}
@@ -158,17 +158,17 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case 0x61:
case 0x62:
case 0x63:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 0x88:
case 0x84:
case 0x81:
case 0x8c:
case 0xad:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 0x7f: // lapc <addr>, <reg>
op->type = R_ANAL_OP_TYPE_LEA;
op->type = RZ_ANAL_OP_TYPE_LEA;
break;
case 0xcf:
case 0xbe:
@@ -177,10 +177,10 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case 0x6a: // move.d reg, reg
case 0x7e:
case 0xfe:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x00:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
// jsr acr
break;
case 0xff:
@@ -190,7 +190,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case 0x1a:
case 0x9c:
case 0x6d: // bne
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
// jsr acr
break;
case 0xbf:
@@ -204,30 +204,30 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case 0xb7:
case 0xb8:
case 0xb9:
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
// jsr acr
break;
case 0x8f: // test.b [acr]
case 0xc0:
case 0xe1:
case 0xaa:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
default:
switch (*w) {
case 0xb0b9: //// jsr r0
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case 0xb005:
case 0x05b0:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case 0xf0b9:
case 0xb9f0:
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
default:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
}
}
@@ -285,10 +285,10 @@ RzAnalPlugin rz_anal_plugin_cris = {
.op = &analop,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_cris,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+114 -114
View File
@@ -47,7 +47,7 @@ static const char *getCondz(ut8 cond) {
static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int len, RzAnalOpMask mask) {
int sz = dalvik_opcodes[data[0]].len;
if (!op || sz >= len) {
if (op && (mask & R_ANAL_OP_MASK_DISASM)) {
if (op && (mask & RZ_ANAL_OP_MASK_DISASM)) {
op->mnemonic = strdup ("invalid");
}
return -1;
@@ -66,7 +66,7 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
}
switch (data[0]) {
case 0xca: // rem-float:
op->family = R_ANAL_OP_FAMILY_FPU;
op->family = RZ_ANAL_OP_FAMILY_FPU;
/* pass through */
case 0x1b: // const-string/jumbo
case 0x14: // const
@@ -76,17 +76,17 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x42: // const
case 0x12: // const/4
{
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
ut32 vB = (data[1] & 0x0f);
ut32 vA = (data[1] & 0xf0) >> 4;
ut32 vC = (len > 4)? rz_read_le32 (data + 2): 0x22;
// op->stackop = R_ANAL_STACK_SET;
// op->stackop = RZ_ANAL_STACK_SET;
// op->ptr = vC; // why
ut32 val = vC?vC:vA;
op->val = val;
// op->reg = vB;
op->nopcode = 2;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, "0x%"PFMT64x",v%d,=", val, vB);
}
}
@@ -98,15 +98,15 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
ut32 vB = (data[1] & 0x0f);
ut32 vA = (data[1] & 0xf0) >> 4;
if (vA == vB) {
op->type = R_ANAL_OP_TYPE_NOP;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_NOP;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, ",");
}
} else {
op->type = R_ANAL_OP_TYPE_MOV;
//op->stackop = R_ANAL_STACK_SET;
op->type = RZ_ANAL_OP_TYPE_MOV;
//op->stackop = RZ_ANAL_STACK_SET;
//op->ptr = -vA;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, "v%d,v%d,=", vA, vB);
}
}
@@ -119,11 +119,11 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x08: // move-object/from16
case 0x09: // move-object/16
case 0x13: // const/16
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
if (len > 2) {
int vA = (int) data[1];
ut32 vB = (data[3] << 8) | data[2];
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, "v%d,v%d,=", vA, vB);
}
op->val = vB;
@@ -132,36 +132,36 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x18: // const-wide
case 0x19: // const-wide
// 180001000101. const-wide v0:v1, 0x18201cd01010001
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x0a: // move-result
case 0x0d: // move-exception
case 0x0c: // move-result-object
case 0x0b: // move-result-wide
// TODO: add MOVRET OP TYPE ??
op->type = R_ANAL_OP_TYPE_MOV;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_MOV;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = data[1];
esilprintf (op, "sp,v%d,=[8],8,sp,+=,8", vA);
}
break;
case 0x1a: // const-string
op->type = R_ANAL_OP_TYPE_MOV;
op->datatype = R_ANAL_DATATYPE_STRING;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->datatype = RZ_ANAL_DATATYPE_STRING;
if (len > 2) {
ut32 vA = data[1];
ut32 vB = (data[3]<<8) | data[2];
ut64 offset = R_ANAL_GET_OFFSET (anal, 's', vB);
ut64 offset = RZ_ANAL_GET_OFFSET (anal, 's', vB);
op->ptr = offset;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
// op->refptr = 0;
esilprintf (op, "0x%"PFMT64x",v%d,=", offset, vA);
}
}
break;
case 0x1c: // const-class
op->type = R_ANAL_OP_TYPE_MOV;
op->datatype = R_ANAL_DATATYPE_CLASS;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->datatype = RZ_ANAL_DATATYPE_CLASS;
break;
case 0x89: // float-to-double
case 0x8a: // double-to-int
@@ -170,7 +170,7 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x8b: // double-to-long
case 0x88: // float-to-long
case 0x86: // long-to-double
op->family = R_ANAL_OP_FAMILY_FPU;
op->family = RZ_ANAL_OP_FAMILY_FPU;
/* pass through */
case 0x81: // int-to-long
case 0x82: // int-to-float
@@ -178,39 +178,39 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x83: // int-to-double
case 0x8d: // int-to-byte
case 0x8e: // int-to-char
op->type = R_ANAL_OP_TYPE_CAST;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_CAST;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = (data[1] & 0x0f);
ut32 vB = (data[1] & 0xf0) >> 4;
esilprintf (op, "v%d,0xff,&,v%d,=", vB, vA);
}
break;
case 0x8f: // int-to-short
op->type = R_ANAL_OP_TYPE_CAST;
// op->datatype = R_ANAL_DATATYPE_INT32 | R_ANAL_DATATYPE_INT16;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_CAST;
// op->datatype = RZ_ANAL_DATATYPE_INT32 | RZ_ANAL_DATATYPE_INT16;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = (data[1] & 0x0f);
ut32 vB = (data[1] & 0xf0) >> 4;
esilprintf (op, "v%d,0xffff,&,v%d,=", vB, vA);
}
break;
case 0x84: // long-to-int
op->type = R_ANAL_OP_TYPE_CAST;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_CAST;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = (data[1] & 0x0f);
ut32 vB = (data[1] & 0xf0) >> 4;
esilprintf (op, "v%d,0xffffffff,&,v%d,=", vB, vA);
}
break;
case 0x20: // instance-of
op->type = R_ANAL_OP_TYPE_CMP;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_CMP;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, "%d,instanceof,%d,-,!,v%d,=", vC, vB, vA);
}
break;
case 0x21: // array-length
op->type = R_ANAL_OP_TYPE_LENGTH;
op->datatype = R_ANAL_DATATYPE_ARRAY;
op->type = RZ_ANAL_OP_TYPE_LENGTH;
op->datatype = RZ_ANAL_DATATYPE_ARRAY;
break;
case 0x44: // aget
case 0x45: //aget-bool
@@ -242,11 +242,11 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xf3: //iget-bool
case 0xf8: //iget-bool
case 0xf2: //iget-quick
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 0x54: // iget-object
op->type = R_ANAL_OP_TYPE_LOAD;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_LOAD;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = (data[1] & 0x0f);
ut32 vB = (data[1] & 0xf0) >> 4;
ut32 vC = (data[2] & 0x0f);
@@ -254,9 +254,9 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
}
break;
case 0x63: // sget-boolean
op->datatype = R_ANAL_DATATYPE_BOOLEAN;
op->type = R_ANAL_OP_TYPE_LOAD;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->datatype = RZ_ANAL_DATATYPE_BOOLEAN;
op->type = RZ_ANAL_OP_TYPE_LOAD;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = (data[1] & 0x0f);
ut32 vB = (data[1] & 0xf0) >> 4;
ut32 vC = (data[2] & 0x0f);
@@ -266,11 +266,11 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
break;
case 0x62: // sget-object
{
op->datatype = R_ANAL_DATATYPE_OBJECT;
op->type = R_ANAL_OP_TYPE_LOAD;
op->datatype = RZ_ANAL_DATATYPE_OBJECT;
op->type = RZ_ANAL_OP_TYPE_LOAD;
ut32 vC = len > 3?(data[3] << 8) | data[2] : 0;
op->ptr = anal->binb.get_offset (anal->binb.bin, 'f', vC);
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = (data[1] & 0x0f);
esilprintf (op, "%d,v%d,=", op->ptr, vA);
}
@@ -305,32 +305,32 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x6c: // sput-wide
case 0xfe: // sput
{
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
ut32 vC = len > 3?(data[3] << 8) | data[2] : 0;
op->ptr = anal->binb.get_offset (anal->binb.bin, 'f', vC);
}
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = (data[1] & 0x0f);
esilprintf (op, "%d,v%d,=", op->ptr, vA);
}
break;
case 0xad: // mul-double
op->family = R_ANAL_OP_FAMILY_FPU;
op->type = R_ANAL_OP_TYPE_MUL;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->family = RZ_ANAL_OP_FAMILY_FPU;
op->type = RZ_ANAL_OP_TYPE_MUL;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, "v%d,v%d,*,v%d,=", vC, vB, vA);
}
break;
case 0x9d:
case 0xc8: // mul-float
op->family = R_ANAL_OP_FAMILY_FPU;
op->family = RZ_ANAL_OP_FAMILY_FPU;
/* fall through */
case 0xcd:
case 0xd2: // mul-int/lit16
case 0x92:
case 0xb2:
op->type = R_ANAL_OP_TYPE_MUL;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_MUL;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = (data[1] & 0x0f);
ut32 vB = (data[1] & 0xf0) >> 4;
ut32 vC = (data[2] << 8) | data[3];
@@ -340,7 +340,7 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
break;
case 0x7c: // not-int
case 0x7e: // not-long
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
break;
case 0xa4: // shr-long
case 0xba: // ushr-int/2addr
@@ -351,12 +351,12 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xc4: // shr-long/2addr
case 0xe1: // shr-int/lit8
case 0x99: // shr-int
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case 0xaa: // rem-float
case 0xcf: // rem-double
case 0xaf: // rem-double
op->family = R_ANAL_OP_FAMILY_FPU;
op->family = RZ_ANAL_OP_FAMILY_FPU;
/* pass through */
case 0xb4: // rem-int/2addr
case 0xdc: // rem-int/lit8
@@ -364,7 +364,7 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xbf: // rem-long/2addr
case 0x9f: // rem-long
case 0x94: // rem-int
op->type = R_ANAL_OP_TYPE_MOD; // mod = rem
op->type = RZ_ANAL_OP_TYPE_MOD; // mod = rem
break;
case 0xd7:
case 0xd9:
@@ -373,16 +373,16 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x95: // and-int
case 0x96: // or-int
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case 0xc2: // xor-long
case 0x97: // xor-int
case 0xdf: // xor-int/lit16
case 0xa2: // xor-long
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case 0xc9: // div-float
op->family = R_ANAL_OP_FAMILY_FPU;
op->family = RZ_ANAL_OP_FAMILY_FPU;
/* pass through */
case 0x93: // div-int
case 0xd3: // div-int/lit16
@@ -393,17 +393,17 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xae: // div-double
case 0xa9: // div-float
case 0xb3: // div-int/2addr
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
break;
case 0x0e: // return-void
case 0x0f: // return
case 0x10: // return-wide
case 0x11: // return-object
case 0xf1: // return-void-barrier
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->eob = true;
//TODO: handle return if(0x0e) {} else {}
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
if (data[0] == 0x0e) {// return-void
esilprintf (op, "sp,[8],ip,=,8,sp,+=");
} else {
@@ -414,18 +414,18 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
break;
case 0x28: // goto
op->jump = addr + ((char)data[1])*2;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->eob = true;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, "0x%"PFMT64x",ip,=", op->jump);
}
break;
case 0x29: // goto/16
if (len > 3) {
op->jump = addr + (short)(data[2]|data[3]<<8)*2;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->eob = true;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, "0x%"PFMT64x",ip,=", op->jump);
}
}
@@ -434,23 +434,23 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
if (len > 5) {
st64 dst = (st64)(data[2]|(data[3]<<8)|(data[4]<<16)|(data[5]<<24));
op->jump = addr + (dst * 2);
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->eob = true;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, "0x%"PFMT64x",ip,=", op->jump);
}
}
break;
case 0x2c:
case 0x2b:
op->type = R_ANAL_OP_TYPE_SWITCH;
op->type = RZ_ANAL_OP_TYPE_SWITCH;
break;
case 0x3e: // glitch 0 width instruction .. invalid instruction
case 0x43:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
op->size = 1;
op->eob = true;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, ",");
}
break;
@@ -461,7 +461,7 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x30: // cmlg-double
case 0x31: // cmp-long
case 0x1f: // check-cast
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case 0x32: // if-eq
case 0x33: // if-ne
@@ -469,13 +469,13 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x35: // if-ge
case 0x36: // if-gt
case 0x37: // if-le
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
//XXX fix this better the check is to avoid an oob
if (len > 2) {
op->jump = addr + (len>3?(short)(data[2]|data[3]<<8)*2 : 0);
op->fail = addr + sz;
op->eob = true;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = data[1];
ut32 vB = data[2];
const char *cond = getCond (data[0]);
@@ -489,13 +489,13 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x3b: // if-gez
case 0x3c: // if-gtz
case 0x3d: // if-lez
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
//XXX fix this better the check is to avoid an oob
if (len > 2) {
op->jump = addr + (len>3?(short)(data[2]|data[3]<<8)*2 : 0);
op->fail = addr + sz;
op->eob = true;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = data[1];
const char *cond = getCondz (data[0]);
esilprintf (op, "v%d,%s,?{,%"PFMT64d",ip,=}", vA, cond, op->jump);
@@ -503,24 +503,24 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
}
break;
case 0xec: // breakpoint
op->type = R_ANAL_OP_TYPE_TRAP;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_TRAP;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, "TRAP");
}
break;
case 0x1d: // monitor-enter
op->type = R_ANAL_OP_TYPE_PUSH;
op->stackop = R_ANAL_STACK_INC;
op->type = RZ_ANAL_OP_TYPE_PUSH;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = 1;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, ",");
}
break;
case 0x1e: // monitor-exit /// wrong type?
op->type = R_ANAL_OP_TYPE_POP;
op->stackop = R_ANAL_STACK_INC;
op->type = RZ_ANAL_OP_TYPE_POP;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -1;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, ",");
}
break;
@@ -541,13 +541,13 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
ut32 vB = len > 3?(data[3] << 8) | data[2] : 0;
ut64 dst = anal->binb.get_offset (anal->binb.bin, 'm', vB);
if (dst == 0) {
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
} else {
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = dst;
}
op->fail = addr + sz;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
// TODO: handle /range instructions
esilprintf (op, "8,sp,-=,0x%"PFMT64x",sp,=[8],0x%"PFMT64x",ip,=", op->fail, op->jump);
}
@@ -567,20 +567,20 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
// ut32 vB = len > 3?(data[3] << 8) | data[2] : 3;
//op->jump = anal->binb.get_offset (anal->binb.bin, 'm', vB);
op->fail = addr + sz;
// op->type = R_ANAL_OP_TYPE_CALL;
op->type = R_ANAL_OP_TYPE_UCALL;
// op->type = RZ_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
// TODO: handle /range instructions
// NOP esilprintf (op, "8,sp,-=,0x%"PFMT64x",sp,=[8],0x%"PFMT64x",ip,=", addr);
}
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
// TODO: handle /range instructions
esilprintf (op, "8,sp,-=,0x%"PFMT64x",sp,=[8],0x%"PFMT64x",ip,=", op->fail, op->jump);
}
break;
case 0x27: // throw
{
op->type = R_ANAL_OP_TYPE_TRAP;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_TRAP;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = data[1];
esilprintf (op, "v%d,TRAP", vA);
}
@@ -588,28 +588,28 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
break;
case 0xee: // execute-inline
case 0xef: // execute-inline/range
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
break;
case 0xed: // throw-verification-error
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
break;
case 0x22: // new-instance
op->type = R_ANAL_OP_TYPE_NEW;
op->type = RZ_ANAL_OP_TYPE_NEW;
if (len > 2) {
// resolve class name for vB
int vB = (data[3] << 8) | data[2];
ut64 off = R_ANAL_GET_OFFSET (anal, 't', vB);
ut64 off = RZ_ANAL_GET_OFFSET (anal, 't', vB);
op->ptr = off;
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
int vA = (int) data[1];
esilprintf (op, "%d,new,v%d,=", off, vA);
}
}
break;
case 0x23: // new-array
op->type = R_ANAL_OP_TYPE_NEW;
op->type = RZ_ANAL_OP_TYPE_NEW;
// 0x1c, 0x1f, 0x22
if (len > 2 && mask & R_ANAL_OP_MASK_ESIL) {
if (len > 2 && mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = (data[1] & 0x0f);
ut32 vB = (data[1] & 0xf0) >> 4;
ut32 vC = (int) data[2] | (data[3]<<8);
@@ -619,19 +619,19 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x24: // filled-new-array
case 0x25: // filled-new-array-range
case 0x26: // filled-new-array-data
op->type = R_ANAL_OP_TYPE_NEW;
op->type = RZ_ANAL_OP_TYPE_NEW;
// 0x1c, 0x1f, 0x22
if (len > 2) {
//int vA = (int) data[1];
int vB = (data[3] << 8) | data[2];
// resolve class name for vB
ut64 off = R_ANAL_GET_OFFSET (anal, 't', vB);
ut64 off = RZ_ANAL_GET_OFFSET (anal, 't', vB);
op->ptr = off;
}
break;
case 0x00: // nop
op->type = R_ANAL_OP_TYPE_NOP;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_NOP;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, ",");
}
break;
@@ -645,8 +645,8 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xcb: // add-double/2addr
case 0xd0: // add-int/lit16
case 0xd8: // add-int/lit8
op->type = R_ANAL_OP_TYPE_ADD;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_ADD;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vB = (data[1] & 0x0f);
ut32 vA = (data[1] & 0xf0) >> 4;
esilprintf (op, "v%d,v%d,+=", vB, vA);
@@ -654,7 +654,7 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
break;
case 0xa7: // sub-float
case 0xcc: // sub-double
op->family = R_ANAL_OP_FAMILY_FPU;
op->family = RZ_ANAL_OP_FAMILY_FPU;
/* fall through */
case 0xc7:
case 0xbc:
@@ -662,8 +662,8 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xb1: //sub-int/2addr
case 0xd1: //sub-int/2addr
case 0x9c: //sub-long
op->type = R_ANAL_OP_TYPE_SUB;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_SUB;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
esilprintf (op, "v%d,v%d,-,v%d,=", vC, vB, vA);
}
break;
@@ -671,20 +671,20 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x7d: // neg-long
case 0x7f: // neg-float
case 0x80: // neg-double
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
break;
case 0xa0: // and-long
case 0xc0: // and-long
case 0xdd: // and-long
case 0xd5: // and-long
case 0xb5: // and-int
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case 0xd6: // orint/lit16
case 0xc1: // or-long/2addr
case 0xa1: // or-long
op->type = R_ANAL_OP_TYPE_OR;
if (mask & R_ANAL_OP_MASK_ESIL) {
op->type = RZ_ANAL_OP_TYPE_OR;
if (mask & RZ_ANAL_OP_MASK_ESIL) {
ut32 vA = (data[1] & 0x0f);
ut32 vB = (data[1] & 0xf0) >> 4;
ut32 vC = (data[2] << 8) | data[3];
@@ -697,7 +697,7 @@ static int dalvik_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xa3: // shl-long
case 0x98: // shl-long
case 0xb8: // shl-int/2addr
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
break;
}
return sz;
@@ -765,10 +765,10 @@ RzAnalPlugin rz_anal_plugin_dalvik = {
.op = &dalvik_op,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_dalvik,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+26 -26
View File
@@ -15,9 +15,9 @@ static void ebc_anal_jmp8(RzAnalOp *op, ut64 addr, const ut8 *buf) {
op->fail = addr + 2;
if (TEST_BIT(buf[0], 7)) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
} else {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
}
}
@@ -28,12 +28,12 @@ static void ebc_anal_jmp(RzAnalOp *op, ut64 addr, const ut8 *buf) {
op->jump += addr + 6;
}
if (buf[1] & 0x7) {
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
} else {
if (TEST_BIT(buf[1], 7)) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
} else {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
}
}
}
@@ -51,9 +51,9 @@ static void ebc_anal_call(RzAnalOp *op, ut64 addr, const ut8 *buf) {
} else {
op->jump = addr_call;
}
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
} else {
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
}
}
@@ -97,10 +97,10 @@ static int ebc_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case EBC_MOVI:
case EBC_MOVIN:
case EBC_MOVREL:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case EBC_RET:
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
case EBC_CMPEQ:
case EBC_CMPLTE:
@@ -112,49 +112,49 @@ static int ebc_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case EBC_CMPIGTE:
case EBC_CMPIULTE:
case EBC_CMPIUGTE:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case EBC_SHR:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case EBC_SHL:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
break;
case EBC_OR:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case EBC_XOR:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case EBC_MUL:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case EBC_PUSH:
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
break;
case EBC_POP:
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
break;
case EBC_AND:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case EBC_ADD:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case EBC_SUB:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case EBC_NEG:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case EBC_CALL:
ebc_anal_call(op, addr, buf);
break;
case EBC_BREAK:
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
break;
default:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
}
@@ -170,10 +170,10 @@ RzAnalPlugin rz_anal_plugin_ebc = {
.op = &ebc_op,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_ebc,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+178 -178
View File
File diff suppressed because it is too large Load Diff
+31 -31
View File
@@ -49,15 +49,15 @@ static void h8300_anal_jmp(RzAnalOp *op, ut64 addr, const ut8 *buf) {
switch (buf[0]) {
case H8300_JMP_1:
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
break;
case H8300_JMP_2:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
rz_mem_swapendian ((ut8*)&ad, buf + 2, sizeof (ut16));
op->jump = ad;
break;
case H8300_JMP_3:
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
op->jump = buf[1];
break;
}
@@ -68,16 +68,16 @@ static void h8300_anal_jsr(RzAnalOp *op, ut64 addr, const ut8 *buf) {
switch (buf[0]) {
case H8300_JSR_1:
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
break;
case H8300_JSR_2:
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
rz_mem_swapendian ((ut8*)&ad, buf + 2, sizeof (ut16));
op->jump = ad;
op->fail = addr + 4;
break;
case H8300_JSR_3:
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
op->jump = buf[1];
break;
}
@@ -558,30 +558,30 @@ static int h8300_op(RzAnal *anal, RzAnalOp *op, ut64 addr,
case H8300_MOV_4BIT_2:
case H8300_MOV_4BIT_3:
case H8300_MOV_4BIT:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case H8300_CMP_4BIT:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case H8300_XOR_4BIT:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case H8300_AND_4BIT:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case H8300_ADD_4BIT:
case H8300_ADDX_4BIT:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case H8300_SUBX_4BIT:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
default:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
};
if (op->type != R_ANAL_OP_TYPE_UNK) {
if (op->type != RZ_ANAL_OP_TYPE_UNK) {
analop_esil(anal, op, addr, buf);
return ret;
}
@@ -598,47 +598,47 @@ static int h8300_op(RzAnal *anal, RzAnalOp *op, ut64 addr,
case H8300_MOV_1:
case H8300_MOV_2:
case H8300_EEPMOV:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case H8300_RTS:
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
case H8300_CMP_1:
case H8300_CMP_2:
case H8300_BTST_R2R8:
case H8300_BTST:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case H8300_SHL:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
break;
case H8300_SHR:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case H8300_XOR:
case H8300_XORC:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case H8300_MULXU:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case H8300_ANDC:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case H8300_ADDB_DIRECT:
case H8300_ADDW_DIRECT:
case H8300_ADDS:
case H8300_ADDX:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case H8300_SUB_1:
case H8300_SUBW:
case H8300_SUBS:
case H8300_SUBX:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case H8300_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case H8300_JSR_1:
case H8300_JSR_2:
@@ -666,15 +666,15 @@ static int h8300_op(RzAnal *anal, RzAnalOp *op, ut64 addr,
case H8300_BLT:
case H8300_BGT:
case H8300_BLE:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + 2 + (st8)(buf[1]);
op->fail = addr + 2;
break;
default:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
};
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
analop_esil(anal, op, addr, buf);
}
return ret;
@@ -732,10 +732,10 @@ RzAnalPlugin rz_anal_plugin_h8300 = {
.set_reg_profile = set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
struct rz_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_h8300,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+3 -3
View File
@@ -94,10 +94,10 @@ RzAnalPlugin rz_anal_plugin_hexagon = {
.set_reg_profile = set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_hexagon_v6,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+23 -23
View File
@@ -114,13 +114,13 @@ static int i4004_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int l
switch (high) {
case 0:
if (low) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
} else {
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
}
break;
case 1: //snprintf (basm, basz, "jcn %d 0x%02x", low, buf[1]); break;
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = (addr & (~0xFF)) + buf[1];
op->fail = addr + rlen;
break;
@@ -128,55 +128,55 @@ static int i4004_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int l
if (rlen == 1) {
snprintf (basm, basz, "scr r%d", (low & 0xe));
} else {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->val = buf[1];
snprintf (basm, basz, "fim r%d, 0x%02x", (low & 0xe), buf[1]);
}
break;
case 3:
if (low & 1) {
op->type = R_ANAL_OP_TYPE_RJMP;
op->type = RZ_ANAL_OP_TYPE_RJMP;
} else {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
snprintf (basm, basz, "fin r%d", (low & 0xe));
}
break;
case 4:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = (ut16) (low<<8) | buf[1];
break;
case 5: //snprintf (basm, basz, "jms 0x%03x", ((ut16)(low<<8) | buf[1])); break;
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = (ut16) (low<<8) | buf[1];
op->fail = addr + rlen;
break;
case 6: //snprintf (basm, basz, "inc r%d", low); break;
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 7: //snprintf (basm, basz, "isz r%d, 0x%02x", low, buf[1]);
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->fail = (addr & (~0xFF)) + buf[1];
op->jump = addr + rlen;
break;
case 8:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
//snprintf (basm, basz, "add r%d", low); break;
break;
case 9:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
//snprintf (basm, basz, "sub r%d", low); break;
break;
case 10: //snprintf (basm, basz, "ld r%d", low); break;
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 11: //snprintf (basm, basz, "xch r%d", low); break;
op->type = R_ANAL_OP_TYPE_XCHG;
op->type = RZ_ANAL_OP_TYPE_XCHG;
break;
case 12: //snprintf (basm, basz, "bbl %d", low); break;
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
case 13:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
//snprintf (basm, basz, "ldm %d", low); break;
break;
case 14:
@@ -187,16 +187,16 @@ static int i4004_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int l
strncpy (basm, i4004_f[low], basz);
basm[basz] = '\0';
if (!strcmp (basm, "dac")) {
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
}
break;
}
if (!strcmp (basm, "invalid")) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
} else if (!strcmp (basm, "ral")) {
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
} else if (!strcmp (basm, "rar")) {
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
}
return op->size = rlen;
}
@@ -212,10 +212,10 @@ RzAnalPlugin rz_anal_plugin_i4004 = {
.set_reg_profile = &set_reg_profile
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_i4004,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+24 -24
View File
@@ -15,10 +15,10 @@ static int i8080_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
char out[32];
int ilen = i8080_disasm (data, out, len);
op->addr = addr;
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
switch (data[0]) {
case 0x00:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case 0x03:
case 0x04:
@@ -32,7 +32,7 @@ static int i8080_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x33:
case 0x34:
case 0x3c:
op->type = R_ANAL_OP_TYPE_ADD; // INC
op->type = RZ_ANAL_OP_TYPE_ADD; // INC
break;
case 0x09:
case 0x19:
@@ -47,7 +47,7 @@ static int i8080_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x86:
case 0x87:
case 0xc6:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 0x90:
case 0x91:
@@ -58,7 +58,7 @@ static int i8080_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x96:
case 0x97:
case 0xd6:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 0xc0:
case 0xc8:
@@ -68,10 +68,10 @@ static int i8080_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xe8:
case 0xf0:
case 0xf8:
op->type = R_ANAL_OP_TYPE_CRET;
op->type = RZ_ANAL_OP_TYPE_CRET;
break;
case 0xc9:
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
case 0x05:
case 0x0b:
@@ -86,19 +86,19 @@ static int i8080_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x3b:
case 0x3d:
// XXXX: DEC
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 0xc5:
case 0xd5:
case 0xe5:
case 0xf5:
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
break;
case 0xc1:
case 0xd1:
case 0xe1:
case 0xf1:
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
break;
case 0x40:
case 0x49:
@@ -108,7 +108,7 @@ static int i8080_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x6d:
case 0x76:
case 0x7f:
op->type = R_ANAL_OP_TYPE_TRAP; // HALT
op->type = RZ_ANAL_OP_TYPE_TRAP; // HALT
break;
case 0x10:
case 0x18:
@@ -126,7 +126,7 @@ static int i8080_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xea:
case 0xf2:
case 0xfa:
op->type = R_ANAL_OP_TYPE_JMP; // jmpz
op->type = RZ_ANAL_OP_TYPE_JMP; // jmpz
break;
case 0xc4:
@@ -141,47 +141,47 @@ static int i8080_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xf4:
case 0xfc:
case 0xfd:
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
break;
case 0xc7: //rst 0
op->jump = 0x00;
op->fail = addr + ilen;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0xcf: //rst 8
op->jump = 0x08;
op->fail = addr + ilen;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0xd7: //rst 16
op->jump = 0x10;
op->fail = addr + ilen;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0xdf: //rst 24
op->jump = 0x18;
op->fail = addr + ilen;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0xe7: //rst 32
op->jump = 0x20;
op->fail = addr + ilen;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0xef: //rst 40
op->jump = 0x28;
op->fail = addr + ilen;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0xf7: //rst 48
op->jump = 0x30;
op->fail = addr + ilen;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0xff: //rst 56
op->jump = 0x38;
op->fail = addr + ilen;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break; // copypasta from gb and z80
}
return op->size = ilen;
@@ -196,10 +196,10 @@ RzAnalPlugin rz_anal_plugin_i8080 = {
.op = &i8080_op,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_i8080,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+86 -86
View File
@@ -64,7 +64,7 @@ static int java_switch_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data
// switch is too big can't read further
break;
}
int offset = (int)(ut32)(R_BIN_JAVA_UINT (data, pos));
int offset = (int)(ut32)(RZ_BIN_JAVA_UINT (data, pos));
rz_anal_switch_op_add_case (op->switch_op, addr + pos, cur_case + min_val, addr + offset);
}
} else {
@@ -77,139 +77,139 @@ static int java_switch_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data
static ut64 extract_bin_op(ut64 ranal2_op_type) {
ut64 bin_op_val = ranal2_op_type & (R_ANAL_JAVA_BIN_OP | 0x80000);
ut64 bin_op_val = ranal2_op_type & (RZ_ANAL_JAVA_BIN_OP | 0x80000);
switch (bin_op_val) {
case R_ANAL_JAVA_BINOP_XCHG:return R_ANAL_OP_TYPE_XCHG;
case R_ANAL_JAVA_BINOP_CMP: return R_ANAL_OP_TYPE_CMP;
case R_ANAL_JAVA_BINOP_ADD: return R_ANAL_OP_TYPE_ADD;
case R_ANAL_JAVA_BINOP_SUB: return R_ANAL_OP_TYPE_SUB;
case R_ANAL_JAVA_BINOP_MUL: return R_ANAL_OP_TYPE_MUL;
case R_ANAL_JAVA_BINOP_DIV: return R_ANAL_OP_TYPE_DIV;
case R_ANAL_JAVA_BINOP_SHR: return R_ANAL_OP_TYPE_SHR;
case R_ANAL_JAVA_BINOP_SHL: return R_ANAL_OP_TYPE_SHL;
case R_ANAL_JAVA_BINOP_SAL: return R_ANAL_OP_TYPE_SAL;
case R_ANAL_JAVA_BINOP_SAR: return R_ANAL_OP_TYPE_SAR;
case R_ANAL_JAVA_BINOP_OR : return R_ANAL_OP_TYPE_OR;
case R_ANAL_JAVA_BINOP_AND: return R_ANAL_OP_TYPE_AND;
case R_ANAL_JAVA_BINOP_XOR: return R_ANAL_OP_TYPE_XOR;
case R_ANAL_JAVA_BINOP_NOT: return R_ANAL_OP_TYPE_NOT;
case R_ANAL_JAVA_BINOP_MOD: return R_ANAL_OP_TYPE_MOD;
case R_ANAL_JAVA_BINOP_ROR: return R_ANAL_OP_TYPE_ROR;
case R_ANAL_JAVA_BINOP_ROL: return R_ANAL_OP_TYPE_ROL;
case RZ_ANAL_JAVA_BINOP_XCHG:return RZ_ANAL_OP_TYPE_XCHG;
case RZ_ANAL_JAVA_BINOP_CMP: return RZ_ANAL_OP_TYPE_CMP;
case RZ_ANAL_JAVA_BINOP_ADD: return RZ_ANAL_OP_TYPE_ADD;
case RZ_ANAL_JAVA_BINOP_SUB: return RZ_ANAL_OP_TYPE_SUB;
case RZ_ANAL_JAVA_BINOP_MUL: return RZ_ANAL_OP_TYPE_MUL;
case RZ_ANAL_JAVA_BINOP_DIV: return RZ_ANAL_OP_TYPE_DIV;
case RZ_ANAL_JAVA_BINOP_SHR: return RZ_ANAL_OP_TYPE_SHR;
case RZ_ANAL_JAVA_BINOP_SHL: return RZ_ANAL_OP_TYPE_SHL;
case RZ_ANAL_JAVA_BINOP_SAL: return RZ_ANAL_OP_TYPE_SAL;
case RZ_ANAL_JAVA_BINOP_SAR: return RZ_ANAL_OP_TYPE_SAR;
case RZ_ANAL_JAVA_BINOP_OR : return RZ_ANAL_OP_TYPE_OR;
case RZ_ANAL_JAVA_BINOP_AND: return RZ_ANAL_OP_TYPE_AND;
case RZ_ANAL_JAVA_BINOP_XOR: return RZ_ANAL_OP_TYPE_XOR;
case RZ_ANAL_JAVA_BINOP_NOT: return RZ_ANAL_OP_TYPE_NOT;
case RZ_ANAL_JAVA_BINOP_MOD: return RZ_ANAL_OP_TYPE_MOD;
case RZ_ANAL_JAVA_BINOP_ROR: return RZ_ANAL_OP_TYPE_ROR;
case RZ_ANAL_JAVA_BINOP_ROL: return RZ_ANAL_OP_TYPE_ROL;
default: break;
}
return R_ANAL_OP_TYPE_UNK;
return RZ_ANAL_OP_TYPE_UNK;
}
ut64 extract_unknown_op(ut64 ranal2_op_type) {
if ((ranal2_op_type & R_ANAL_JAVA_CODEOP_JMP) == R_ANAL_JAVA_CODEOP_JMP) {
return R_ANAL_OP_TYPE_UJMP;
if ((ranal2_op_type & RZ_ANAL_JAVA_CODEOP_JMP) == RZ_ANAL_JAVA_CODEOP_JMP) {
return RZ_ANAL_OP_TYPE_UJMP;
}
if ((ranal2_op_type & R_ANAL_JAVA_CODEOP_CALL) == R_ANAL_JAVA_CODEOP_CALL) {
return R_ANAL_OP_TYPE_UCALL;
if ((ranal2_op_type & RZ_ANAL_JAVA_CODEOP_CALL) == RZ_ANAL_JAVA_CODEOP_CALL) {
return RZ_ANAL_OP_TYPE_UCALL;
}
if ((ranal2_op_type & R_ANAL_JAVA_LDST_OP_PUSH) == R_ANAL_JAVA_LDST_OP_PUSH) {
return R_ANAL_OP_TYPE_UPUSH;
if ((ranal2_op_type & RZ_ANAL_JAVA_LDST_OP_PUSH) == RZ_ANAL_JAVA_LDST_OP_PUSH) {
return RZ_ANAL_OP_TYPE_UPUSH;
}
return R_ANAL_OP_TYPE_UNK;
return RZ_ANAL_OP_TYPE_UNK;
}
static ut64 extract_code_op(ut64 ranal2_op_type) {
ut64 conditional = R_ANAL_JAVA_COND_OP & ranal2_op_type ? R_ANAL_OP_TYPE_COND : 0;
ut64 code_op_val = ranal2_op_type & (R_ANAL_JAVA_CODE_OP | 0x1FF);
ut64 conditional = RZ_ANAL_JAVA_COND_OP & ranal2_op_type ? RZ_ANAL_OP_TYPE_COND : 0;
ut64 code_op_val = ranal2_op_type & (RZ_ANAL_JAVA_CODE_OP | 0x1FF);
switch (code_op_val) {
case R_ANAL_JAVA_CODEOP_CALL: return conditional | R_ANAL_OP_TYPE_CALL;
case R_ANAL_JAVA_CODEOP_JMP: return conditional | R_ANAL_OP_TYPE_JMP;
case R_ANAL_JAVA_CODEOP_RET: return conditional | R_ANAL_OP_TYPE_RET;
case R_ANAL_JAVA_CODEOP_LEAVE: return R_ANAL_OP_TYPE_LEAVE;
case R_ANAL_JAVA_CODEOP_SWI: return R_ANAL_OP_TYPE_SWI;
case R_ANAL_JAVA_CODEOP_TRAP: return R_ANAL_OP_TYPE_TRAP;
case R_ANAL_JAVA_CODEOP_SWITCH: return R_ANAL_OP_TYPE_SWITCH;
case RZ_ANAL_JAVA_CODEOP_CALL: return conditional | RZ_ANAL_OP_TYPE_CALL;
case RZ_ANAL_JAVA_CODEOP_JMP: return conditional | RZ_ANAL_OP_TYPE_JMP;
case RZ_ANAL_JAVA_CODEOP_RET: return conditional | RZ_ANAL_OP_TYPE_RET;
case RZ_ANAL_JAVA_CODEOP_LEAVE: return RZ_ANAL_OP_TYPE_LEAVE;
case RZ_ANAL_JAVA_CODEOP_SWI: return RZ_ANAL_OP_TYPE_SWI;
case RZ_ANAL_JAVA_CODEOP_TRAP: return RZ_ANAL_OP_TYPE_TRAP;
case RZ_ANAL_JAVA_CODEOP_SWITCH: return RZ_ANAL_OP_TYPE_SWITCH;
}
return R_ANAL_OP_TYPE_UNK;
return RZ_ANAL_OP_TYPE_UNK;
}
ut64 extract_load_store_op(ut64 ranal2_op_type) {
if ( (ranal2_op_type & R_ANAL_JAVA_LDST_OP_PUSH) == R_ANAL_JAVA_LDST_OP_PUSH) {
return R_ANAL_OP_TYPE_PUSH;
if ( (ranal2_op_type & RZ_ANAL_JAVA_LDST_OP_PUSH) == RZ_ANAL_JAVA_LDST_OP_PUSH) {
return RZ_ANAL_OP_TYPE_PUSH;
}
if ( (ranal2_op_type & R_ANAL_JAVA_LDST_OP_POP) == R_ANAL_JAVA_LDST_OP_POP) {
return R_ANAL_OP_TYPE_POP;
if ( (ranal2_op_type & RZ_ANAL_JAVA_LDST_OP_POP) == RZ_ANAL_JAVA_LDST_OP_POP) {
return RZ_ANAL_OP_TYPE_POP;
}
if ( (ranal2_op_type & R_ANAL_JAVA_LDST_OP_MOV) == R_ANAL_JAVA_LDST_OP_MOV) {
return R_ANAL_OP_TYPE_MOV;
if ( (ranal2_op_type & RZ_ANAL_JAVA_LDST_OP_MOV) == RZ_ANAL_JAVA_LDST_OP_MOV) {
return RZ_ANAL_OP_TYPE_MOV;
}
if ( (ranal2_op_type & R_ANAL_JAVA_LDST_OP_EFF_ADDR) == R_ANAL_JAVA_LDST_OP_EFF_ADDR) {
return R_ANAL_OP_TYPE_LEA;
if ( (ranal2_op_type & RZ_ANAL_JAVA_LDST_OP_EFF_ADDR) == RZ_ANAL_JAVA_LDST_OP_EFF_ADDR) {
return RZ_ANAL_OP_TYPE_LEA;
}
return R_ANAL_OP_TYPE_UNK;
return RZ_ANAL_OP_TYPE_UNK;
}
static ut64 map_java_op_to_anal_op_type (ut64 t) {
ut64 t2 = extract_bin_op(t);
if (t2 != R_ANAL_OP_TYPE_UNK) {
if (t2 != RZ_ANAL_OP_TYPE_UNK) {
return t2;
}
switch (t) {
case R_ANAL_JAVA_NULL_OP: return R_ANAL_OP_TYPE_NULL;
case R_ANAL_JAVA_NOP: return R_ANAL_OP_TYPE_NOP;
case R_ANAL_JAVA_BINOP_ADD: return R_ANAL_OP_TYPE_ADD;
case R_ANAL_JAVA_BINOP_AND: return R_ANAL_OP_TYPE_AND;
case R_ANAL_JAVA_BINOP_MUL: return R_ANAL_OP_TYPE_MUL;
case R_ANAL_JAVA_BINOP_XOR: return R_ANAL_OP_TYPE_XOR;
case R_ANAL_JAVA_BINOP_XCHG: return R_ANAL_OP_TYPE_MOV;
case R_ANAL_JAVA_OBJOP_NEW: return R_ANAL_OP_TYPE_UCALL;
case R_ANAL_JAVA_OBJOP_SIZE: return R_ANAL_OP_TYPE_UCALL;
case R_ANAL_JAVA_ILL_OP: return R_ANAL_OP_TYPE_ILL;
case RZ_ANAL_JAVA_NULL_OP: return RZ_ANAL_OP_TYPE_NULL;
case RZ_ANAL_JAVA_NOP: return RZ_ANAL_OP_TYPE_NOP;
case RZ_ANAL_JAVA_BINOP_ADD: return RZ_ANAL_OP_TYPE_ADD;
case RZ_ANAL_JAVA_BINOP_AND: return RZ_ANAL_OP_TYPE_AND;
case RZ_ANAL_JAVA_BINOP_MUL: return RZ_ANAL_OP_TYPE_MUL;
case RZ_ANAL_JAVA_BINOP_XOR: return RZ_ANAL_OP_TYPE_XOR;
case RZ_ANAL_JAVA_BINOP_XCHG: return RZ_ANAL_OP_TYPE_MOV;
case RZ_ANAL_JAVA_OBJOP_NEW: return RZ_ANAL_OP_TYPE_UCALL;
case RZ_ANAL_JAVA_OBJOP_SIZE: return RZ_ANAL_OP_TYPE_UCALL;
case RZ_ANAL_JAVA_ILL_OP: return RZ_ANAL_OP_TYPE_ILL;
default:
if (t & R_ANAL_JAVA_UNK_OP) {
if (t & RZ_ANAL_JAVA_UNK_OP) {
return extract_unknown_op (t);
}
if (t & R_ANAL_JAVA_CODE_OP) {
if (t & RZ_ANAL_JAVA_CODE_OP) {
return extract_code_op (t);
}
if (t & R_ANAL_JAVA_REP_OP) {
ut64 ret = map_java_op_to_anal_op_type (t & ~R_ANAL_JAVA_REP_OP);
return R_ANAL_OP_TYPE_REP | ret;
if (t & RZ_ANAL_JAVA_REP_OP) {
ut64 ret = map_java_op_to_anal_op_type (t & ~RZ_ANAL_JAVA_REP_OP);
return RZ_ANAL_OP_TYPE_REP | ret;
}
if (t & (R_ANAL_JAVA_LOAD_OP | R_ANAL_JAVA_STORE_OP)) {
if (t & (RZ_ANAL_JAVA_LOAD_OP | RZ_ANAL_JAVA_STORE_OP)) {
return extract_load_store_op(t);
}
if (t & R_ANAL_JAVA_BIN_OP) {
if (t & RZ_ANAL_JAVA_BIN_OP) {
return extract_bin_op (t);
}
break;
}
if (R_ANAL_JAVA_OBJOP_CAST & t) {
return R_ANAL_OP_TYPE_MOV;
if (RZ_ANAL_JAVA_OBJOP_CAST & t) {
return RZ_ANAL_OP_TYPE_MOV;
}
return R_ANAL_OP_TYPE_UNK;
return RZ_ANAL_OP_TYPE_UNK;
}
static int rz_anal_java_is_op_type_eop(ut64 x) {
ut8 result = (x & R_ANAL_JAVA_CODE_OP) ? 1 : 0;
ut8 result = (x & RZ_ANAL_JAVA_CODE_OP) ? 1 : 0;
return result &&
( (x & R_ANAL_JAVA_CODEOP_LEAVE) == R_ANAL_JAVA_CODEOP_LEAVE ||
(x & R_ANAL_JAVA_CODEOP_RET) == R_ANAL_JAVA_CODEOP_RET ||
(x & R_ANAL_JAVA_CODEOP_JMP) == R_ANAL_JAVA_CODEOP_JMP ||
(x & R_ANAL_JAVA_CODEOP_SWITCH) == R_ANAL_JAVA_CODEOP_SWITCH);
( (x & RZ_ANAL_JAVA_CODEOP_LEAVE) == RZ_ANAL_JAVA_CODEOP_LEAVE ||
(x & RZ_ANAL_JAVA_CODEOP_RET) == RZ_ANAL_JAVA_CODEOP_RET ||
(x & RZ_ANAL_JAVA_CODEOP_JMP) == RZ_ANAL_JAVA_CODEOP_JMP ||
(x & RZ_ANAL_JAVA_CODEOP_SWITCH) == RZ_ANAL_JAVA_CODEOP_SWITCH);
}
static int java_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int len, RzAnalOpMask mask) {
/* get opcode size */
if (len < 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
return 1;
}
//ut8 op_byte = data[0];
ut8 op_byte = data[0];
int sz = JAVA_OPS[op_byte].size;
if (!op) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
return sz;
}
IFDBG {
@@ -238,7 +238,7 @@ static int java_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int l
op->addr = addr;
op->size = 4;
op->type2 = 0;
op->type = R_ANAL_OP_TYPE_CASE
op->type = RZ_ANAL_OP_TYPE_CASE
op->eob = 0;
return op->sizes;
}
@@ -257,24 +257,24 @@ static int java_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int l
// incomplete analysis here
return 0;
}
if (op->type == R_ANAL_OP_TYPE_POP) {
op->stackop = R_ANAL_STACK_INC;
if (op->type == RZ_ANAL_OP_TYPE_POP) {
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = 8;
}
op->direction = R_ANAL_OP_DIR_EXEC;
if (op->type == R_ANAL_OP_TYPE_PUSH) {
op->stackop = R_ANAL_STACK_INC;
op->direction = RZ_ANAL_OP_DIR_EXEC;
if (op->type == RZ_ANAL_OP_TYPE_PUSH) {
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -8;
}
if (op->type == R_ANAL_OP_TYPE_CJMP) {
if (op->type == RZ_ANAL_OP_TYPE_CJMP) {
op->jump = addr + (short)(USHORT (data, 1));
op->fail = addr + sz;
IFDBG eprintf ("%s jmpto 0x%04"PFMT64x" failto 0x%04"PFMT64x".\n",
JAVA_OPS[op_byte].name, op->jump, op->fail);
} else if (op->type == R_ANAL_OP_TYPE_JMP) {
} else if (op->type == RZ_ANAL_OP_TYPE_JMP) {
op->jump = addr + (short)(USHORT (data, 1));
IFDBG eprintf ("%s jmpto 0x%04"PFMT64x".\n", JAVA_OPS[op_byte].name, op->jump);
} else if ( (op->type & R_ANAL_OP_TYPE_CALL) == R_ANAL_OP_TYPE_CALL ) {
} else if ( (op->type & RZ_ANAL_OP_TYPE_CALL) == RZ_ANAL_OP_TYPE_CALL ) {
op->jump = (int)(short)(USHORT (data, 1));
op->fail = addr + sz;
//IFDBG eprintf ("%s callto 0x%04x failto 0x%04x.\n", JAVA_OPS[op_byte].name, op->jump, op->fail);
@@ -345,10 +345,10 @@ RzAnalPlugin rz_anal_plugin_java = {
0
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_java,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+24 -24
View File
@@ -84,13 +84,13 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
}
n = cs_disasm (handle, (ut8*)buf, len, addr, 1, &insn);
if (n < 1 || insn->size < 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
op->size = 2;
opsize = -1;
goto beach;
}
if (!memcmp (buf, "\xff\xff", R_MIN (len, 2))) {
op->type = R_ANAL_OP_TYPE_ILL;
if (!memcmp (buf, "\xff\xff", RZ_MIN (len, 2))) {
op->type = RZ_ANAL_OP_TYPE_ILL;
op->size = 2;
opsize = -1;
goto beach;
@@ -99,7 +99,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
opsize = op->size = insn->size;
switch (insn->id) {
case M680X_INS_INVLD:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case M680X_INS_ABA: ///< M6800/1/2/3
case M680X_INS_ABX:
@@ -118,7 +118,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M680X_INS_ADDF:
case M680X_INS_ADDR:
case M680X_INS_ADDW:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case M680X_INS_AIM:
case M680X_INS_AIS:
@@ -156,7 +156,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M680X_INS_BITMD:
break;
case M680X_INS_BRA:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = addr + op->size + REL(0).offset;
op->fail = UT64_MAX;
break;
@@ -183,7 +183,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M680X_INS_BSR:
case M680X_INS_BVC:
case M680X_INS_BVS:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + op->size + REL(0).offset;
op->fail = addr + op->size;
break;
@@ -217,7 +217,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M680X_INS_CMPW:
case M680X_INS_CMPX:
case M680X_INS_CMPY:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case M680X_INS_COM:
case M680X_INS_COMA:
@@ -264,14 +264,14 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
break;
case M680X_INS_EMUL:
case M680X_INS_EMULS:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case M680X_INS_EOR:
case M680X_INS_EORA:
case M680X_INS_EORB:
case M680X_INS_EORD:
case M680X_INS_EORR:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case M680X_INS_ETBL:
case M680X_INS_EXG:
@@ -281,7 +281,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
break;
case M680X_INS_IDIV:
case M680X_INS_IDIVS:
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
break;
case M680X_INS_ILLGL:
break;
@@ -293,17 +293,17 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M680X_INS_INCF:
case M680X_INS_INCW:
case M680X_INS_INCX:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case M680X_INS_INS: ///< M6800/1/2/3
case M680X_INS_INX: ///< M6800/1/2/3
case M680X_INS_INY:
break;
case M680X_INS_JMP:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case M680X_INS_JSR:
op->type = R_ANAL_OP_TYPE_RJMP;
op->type = RZ_ANAL_OP_TYPE_RJMP;
break;
case M680X_INS_LBCC: ///< or LBHS
case M680X_INS_LBCS: ///< or LBLO
@@ -362,21 +362,21 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M680X_INS_MOV:
case M680X_INS_MOVB:
case M680X_INS_MOVW:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case M680X_INS_MUL:
case M680X_INS_MULD:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case M680X_INS_NEG:
case M680X_INS_NEGA:
case M680X_INS_NEGB:
case M680X_INS_NEGD:
case M680X_INS_NEGX:
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
break;
case M680X_INS_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case M680X_INS_NSA:
case M680X_INS_OIM:
@@ -463,12 +463,12 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M680X_INS_SUBF:
case M680X_INS_SUBR:
case M680X_INS_SUBW:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case M680X_INS_SWI:
case M680X_INS_SWI2:
case M680X_INS_SWI3:
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
break;
case M680X_INS_SYNC:
case M680X_INS_TAB: ///< M6800/1/2/3
@@ -492,7 +492,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M680X_INS_TSTF:
case M680X_INS_TSTW:
case M680X_INS_TSTX:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case M680X_INS_TSX: ///< M6800/1/2/3
case M680X_INS_TSY:
@@ -548,10 +548,10 @@ RzAnalPlugin rz_anal_plugin_m680x_cs = {
};
#endif
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_m680x_cs,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+52 -52
View File
@@ -130,8 +130,8 @@ static int parse_reg_name(RzRegItem *reg, csh handle, cs_insn *insn, int reg_num
static void op_fillval(RzAnalOp *op, csh handle, cs_insn *insn) {
static RzRegItem reg;
switch (op->type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_MOV:
switch (op->type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_MOV:
ZERO_FILL (reg);
if (OPERAND(1).type == M68K_OP_MEM) {
op->src[0] = rz_anal_value_new ();
@@ -145,7 +145,7 @@ static void op_fillval(RzAnalOp *op, csh handle, cs_insn *insn) {
op->dst->delta = OPERAND(1).mem.disp;
}
break;
case R_ANAL_OP_TYPE_LEA:
case RZ_ANAL_OP_TYPE_LEA:
ZERO_FILL (reg);
if (OPERAND(1).type == M68K_OP_MEM) {
op->dst = rz_anal_value_new ();
@@ -205,13 +205,13 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
}
n = cs_disasm (handle, (ut8*)buf, len, addr, 1, &insn);
if (n < 1 || insn->size < 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
op->size = 2;
opsize = -1;
goto beach;
}
if (!memcmp (buf, "\xff\xff", R_MIN (len, 2))) {
op->type = R_ANAL_OP_TYPE_ILL;
if (!memcmp (buf, "\xff\xff", RZ_MIN (len, 2))) {
op->type = RZ_ANAL_OP_TYPE_ILL;
op->size = 2;
opsize = -1;
goto beach;
@@ -220,29 +220,29 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
m68k = &detail->m68k;
op->id = insn->id;
opsize = op->size = insn->size;
if (mask & R_ANAL_OP_MASK_OPEX) {
if (mask & RZ_ANAL_OP_MASK_OPEX) {
opex (&op->opex, handle, insn);
}
switch (insn->id) {
case M68K_INS_INVALID:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case M68K_INS_ADD:
case M68K_INS_ADDA:
case M68K_INS_ADDI:
case M68K_INS_ADDQ:
case M68K_INS_ADDX:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case M68K_INS_AND:
case M68K_INS_ANDI:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case M68K_INS_ASL:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
break;
case M68K_INS_ASR:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case M68K_INS_ABCD:
break;
@@ -262,13 +262,13 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M68K_INS_BLT:
case M68K_INS_BGT:
case M68K_INS_BLE:
handle_branch_instruction (op, addr, m68k, R_ANAL_OP_TYPE_CJMP, 0);
handle_branch_instruction (op, addr, m68k, RZ_ANAL_OP_TYPE_CJMP, 0);
break;
case M68K_INS_BRA:
handle_branch_instruction (op, addr, m68k, R_ANAL_OP_TYPE_JMP, 0);
handle_branch_instruction (op, addr, m68k, RZ_ANAL_OP_TYPE_JMP, 0);
break;
case M68K_INS_BSR:
handle_branch_instruction (op, addr, m68k, R_ANAL_OP_TYPE_CALL, 0);
handle_branch_instruction (op, addr, m68k, RZ_ANAL_OP_TYPE_CALL, 0);
break;
case M68K_INS_BCHG:
case M68K_INS_BCLR:
@@ -296,12 +296,12 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M68K_INS_CMPI:
case M68K_INS_CMPM:
case M68K_INS_CMP2:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case M68K_INS_CINVL:
case M68K_INS_CINVP:
case M68K_INS_CINVA:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case M68K_INS_CPUSHL:
case M68K_INS_CPUSHP:
@@ -324,20 +324,20 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M68K_INS_DBGT:
case M68K_INS_DBLE:
case M68K_INS_DBRA:
handle_branch_instruction (op, addr, m68k, R_ANAL_OP_TYPE_CJMP, 1);
handle_branch_instruction (op, addr, m68k, RZ_ANAL_OP_TYPE_CJMP, 1);
break;
case M68K_INS_DIVS:
case M68K_INS_DIVSL:
case M68K_INS_DIVU:
case M68K_INS_DIVUL:
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
break;
case M68K_INS_EOR:
case M68K_INS_EORI:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case M68K_INS_EXG:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case M68K_INS_EXT:
case M68K_INS_EXTB:
@@ -529,38 +529,38 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M68K_INS_FTRAPST:
case M68K_INS_FTST:
case M68K_INS_FTWOTOX:
op->type = R_ANAL_OP_TYPE_UNK;
op->family = R_ANAL_OP_FAMILY_FPU;
op->type = RZ_ANAL_OP_TYPE_UNK;
op->family = RZ_ANAL_OP_FAMILY_FPU;
break;
case M68K_INS_HALT:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case M68K_INS_ILLEGAL:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case M68K_INS_JMP:
handle_jump_instruction (op, addr, m68k, R_ANAL_OP_TYPE_JMP);
handle_jump_instruction (op, addr, m68k, RZ_ANAL_OP_TYPE_JMP);
break;
case M68K_INS_JSR:
handle_jump_instruction (op, addr, m68k, R_ANAL_OP_TYPE_CALL);
handle_jump_instruction (op, addr, m68k, RZ_ANAL_OP_TYPE_CALL);
break;
case M68K_INS_LPSTOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case M68K_INS_LSL:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
break;
case M68K_INS_LINK:
op->type = R_ANAL_OP_TYPE_PUSH;
op->stackop = R_ANAL_STACK_INC;
op->type = RZ_ANAL_OP_TYPE_PUSH;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -(st16)IMM(1);
break;
case M68K_INS_LSR:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case M68K_INS_PEA:
case M68K_INS_LEA:
op->type = R_ANAL_OP_TYPE_LEA;
op->type = RZ_ANAL_OP_TYPE_LEA;
break;
case M68K_INS_MOVE:
case M68K_INS_MOVEA:
@@ -570,25 +570,25 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M68K_INS_MOVEQ:
case M68K_INS_MOVES:
case M68K_INS_MOVE16:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case M68K_INS_MULS:
case M68K_INS_MULU:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case M68K_INS_NBCD:
case M68K_INS_NEG:
case M68K_INS_NEGX:
break;
case M68K_INS_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case M68K_INS_NOT:
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
break;
case M68K_INS_OR:
case M68K_INS_ORI:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case M68K_INS_PACK:
case M68K_INS_PFLUSH:
@@ -609,10 +609,10 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M68K_INS_RESET:
break;
case M68K_INS_ROL:
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
break;
case M68K_INS_ROR:
op->type = R_ANAL_OP_TYPE_ROR;
op->type = RZ_ANAL_OP_TYPE_ROR;
break;
case M68K_INS_ROXL:
case M68K_INS_ROXR:
@@ -622,7 +622,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M68K_INS_RTM:
case M68K_INS_RTR:
case M68K_INS_RTS:
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
case M68K_INS_SBCD:
case M68K_INS_ST:
@@ -650,10 +650,10 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M68K_INS_SUBI:
case M68K_INS_SUBQ:
case M68K_INS_SUBX:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case M68K_INS_SWAP:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case M68K_INS_TAS:
break;
@@ -677,22 +677,22 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case M68K_INS_TRAPLT:
case M68K_INS_TRAPGT:
case M68K_INS_TRAPLE:
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
break;
case M68K_INS_TST:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case M68K_INS_UNPK: // unpack BCD
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case M68K_INS_UNLK:
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
// reset stackframe
op->stackop = R_ANAL_STACK_SET;
op->stackop = RZ_ANAL_STACK_SET;
op->stackptr = 0;
break;
}
if (mask & R_ANAL_OP_MASK_VAL) {
if (mask & RZ_ANAL_OP_MASK_VAL) {
op_fillval (op, handle, insn);
}
beach:
@@ -780,10 +780,10 @@ RzAnalPlugin rz_anal_plugin_m68k_cs = {
};
#endif
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_m68k_cs,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+12 -12
View File
@@ -8,28 +8,28 @@ static int mal_anal(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
if (len) {
switch ((data[0] + addr) % 94) {
case 4:
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
break;
case 5:
case 23:
op->type = R_ANAL_OP_TYPE_IO;
op->type = RZ_ANAL_OP_TYPE_IO;
break;
case 39:
op->type = R_ANAL_OP_TYPE_ROR;
op->type2 = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_ROR;
op->type2 = RZ_ANAL_OP_TYPE_LOAD;
break;
case 40:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 62:
op->type = R_ANAL_OP_TYPE_XOR;
op->type2 = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_XOR;
op->type2 = RZ_ANAL_OP_TYPE_LOAD;
break;
case 81:
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
break;
default:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
}
return op->size = 1;
}
@@ -45,10 +45,10 @@ RzAnalPlugin rz_anal_plugin_malbolge = {
.op = &mal_anal,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_malbolge,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+9 -9
View File
@@ -18,21 +18,21 @@ static int mcore_anal(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int
if ((instr = mcore_next (&handle))) {
op->type = instr->type;
switch (instr->type) {
case R_ANAL_OP_TYPE_CALL:
case R_ANAL_OP_TYPE_CJMP:
case RZ_ANAL_OP_TYPE_CALL:
case RZ_ANAL_OP_TYPE_CJMP:
op->fail = addr + 2;
op->jump = addr + instr->args[0].value + 1;
break;
case R_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_JMP:
op->jump = addr + instr->args[0].value + 1;
break;
case R_ANAL_OP_TYPE_ICALL:
case RZ_ANAL_OP_TYPE_ICALL:
// the loading address depends on the word
// that this pointer points to.
// op->jump = addr + ((instr->args[i].value << 2) & 0xfffffffc);
break;
case R_ANAL_OP_TYPE_RET:
case R_ANAL_OP_TYPE_ILL:
case RZ_ANAL_OP_TYPE_RET:
case RZ_ANAL_OP_TYPE_ILL:
op->eob = true;
break;
default:
@@ -124,10 +124,10 @@ RzAnalPlugin rz_anal_plugin_mcore = {
.set_reg_profile = &set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_mcore,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+69 -69
View File
@@ -34,20 +34,20 @@ static ut64 t9_pre = UT64_MAX;
#define SET_SRC_DST_3_REGS(op) \
CREATE_SRC_DST_3 (op);\
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), R_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), R_REG_TYPE_GPR);\
(op)->src[1]->reg = rz_reg_get (anal->reg, REG (2), R_REG_TYPE_GPR);
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), RZ_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), RZ_REG_TYPE_GPR);\
(op)->src[1]->reg = rz_reg_get (anal->reg, REG (2), RZ_REG_TYPE_GPR);
#define SET_SRC_DST_3_IMM(op) \
CREATE_SRC_DST_3 (op);\
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), R_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), R_REG_TYPE_GPR);\
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), RZ_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), RZ_REG_TYPE_GPR);\
(op)->src[1]->imm = IMM (2);
#define SET_SRC_DST_2_REGS(op) \
CREATE_SRC_DST_2 (op);\
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), R_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), R_REG_TYPE_GPR);
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), RZ_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), RZ_REG_TYPE_GPR);
#define SET_SRC_DST_3_REG_OR_IMM(op) \
if (OPERAND(2).type == MIPS_OP_IMM) {\
@@ -625,8 +625,8 @@ static int parse_reg_name(RzRegItem *reg, csh handle, cs_insn *insn, int reg_num
static void op_fillval(RzAnal *anal, RzAnalOp *op, csh *handle, cs_insn *insn) {
static RzRegItem reg;
switch (op->type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_LOAD:
switch (op->type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_LOAD:
if (OPERAND(1).type == MIPS_OP_MEM) {
ZERO_FILL (reg);
op->src[0] = rz_anal_value_new ();
@@ -635,7 +635,7 @@ static void op_fillval(RzAnal *anal, RzAnalOp *op, csh *handle, cs_insn *insn) {
op->src[0]->delta = OPERAND(1).mem.disp;
}
break;
case R_ANAL_OP_TYPE_STORE:
case RZ_ANAL_OP_TYPE_STORE:
if (OPERAND(1).type == MIPS_OP_MEM) {
ZERO_FILL (reg);
op->dst = rz_anal_value_new ();
@@ -644,20 +644,20 @@ static void op_fillval(RzAnal *anal, RzAnalOp *op, csh *handle, cs_insn *insn) {
op->dst->delta = OPERAND(1).mem.disp;
}
break;
case R_ANAL_OP_TYPE_SHL:
case R_ANAL_OP_TYPE_SHR:
case R_ANAL_OP_TYPE_SAR:
case R_ANAL_OP_TYPE_XOR:
case R_ANAL_OP_TYPE_SUB:
case R_ANAL_OP_TYPE_AND:
case R_ANAL_OP_TYPE_ADD:
case R_ANAL_OP_TYPE_OR:
case RZ_ANAL_OP_TYPE_SHL:
case RZ_ANAL_OP_TYPE_SHR:
case RZ_ANAL_OP_TYPE_SAR:
case RZ_ANAL_OP_TYPE_XOR:
case RZ_ANAL_OP_TYPE_SUB:
case RZ_ANAL_OP_TYPE_AND:
case RZ_ANAL_OP_TYPE_ADD:
case RZ_ANAL_OP_TYPE_OR:
SET_SRC_DST_3_REG_OR_IMM (op);
break;
case R_ANAL_OP_TYPE_MOV:
case RZ_ANAL_OP_TYPE_MOV:
SET_SRC_DST_3_REG_OR_IMM (op);
break;
case R_ANAL_OP_TYPE_DIV: // UDIV
case RZ_ANAL_OP_TYPE_DIV: // UDIV
#if 0
capstone bug
------------
@@ -700,21 +700,21 @@ capstone bug
}
static void set_opdir(RzAnalOp *op) {
switch (op->type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_LOAD:
op->direction = R_ANAL_OP_DIR_READ;
switch (op->type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_LOAD:
op->direction = RZ_ANAL_OP_DIR_READ;
break;
case R_ANAL_OP_TYPE_STORE:
op->direction = R_ANAL_OP_DIR_WRITE;
case RZ_ANAL_OP_TYPE_STORE:
op->direction = RZ_ANAL_OP_DIR_WRITE;
break;
case R_ANAL_OP_TYPE_LEA:
op->direction = R_ANAL_OP_DIR_REF;
case RZ_ANAL_OP_TYPE_LEA:
op->direction = RZ_ANAL_OP_DIR_REF;
break;
case R_ANAL_OP_TYPE_CALL:
case R_ANAL_OP_TYPE_JMP:
case R_ANAL_OP_TYPE_UJMP:
case R_ANAL_OP_TYPE_UCALL:
op->direction = R_ANAL_OP_DIR_EXEC;
case RZ_ANAL_OP_TYPE_CALL:
case RZ_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_UJMP:
case RZ_ANAL_OP_TYPE_UCALL:
op->direction = RZ_ANAL_OP_DIR_EXEC;
break;
default:
break;
@@ -764,12 +764,12 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
}
n = cs_disasm (hndl, (ut8*)buf, len, addr, 1, &insn);
if (n < 1 || insn->size < 1) {
if (mask & R_ANAL_OP_MASK_DISASM) {
if (mask & RZ_ANAL_OP_MASK_DISASM) {
op->mnemonic = strdup ("invalid");
}
goto beach;
}
if (mask & R_ANAL_OP_MASK_DISASM) {
if (mask & RZ_ANAL_OP_MASK_DISASM) {
op->mnemonic = rz_str_newf ("%s%s%s",
insn->mnemonic,
insn->op_str[0]?" ":"",
@@ -780,7 +780,7 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
op->refptr = 0;
switch (insn->id) {
case MIPS_INS_INVALID:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case MIPS_INS_LB:
case MIPS_INS_LBU:
@@ -803,7 +803,7 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_LDL:
case MIPS_INS_LDR:
case MIPS_INS_LDXC1:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
if (!op->refptr) {
op->refptr = 8;
}
@@ -838,24 +838,24 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_SWL:
case MIPS_INS_SWR:
case MIPS_INS_SWXC1:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case MIPS_INS_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case MIPS_INS_SYSCALL:
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
break;
case MIPS_INS_BREAK:
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
break;
case MIPS_INS_JALR:
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
op->delay = 1;
if (REGID(0) == MIPS_REG_25) {
op->jump = t9_pre;
t9_pre = UT64_MAX;
op->type = R_ANAL_OP_TYPE_RCALL;
op->type = RZ_ANAL_OP_TYPE_RCALL;
}
break;
case MIPS_INS_JAL:
@@ -874,7 +874,7 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_BGTZALC:
case MIPS_INS_JIALC:
case MIPS_INS_JIC:
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = IMM(0);
switch (insn->id) {
@@ -897,10 +897,10 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_LI:
case MIPS_INS_LUI:
SET_VAL (op, 1);
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case MIPS_INS_MOVE:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case MIPS_INS_ADD:
case MIPS_INS_ADDI:
@@ -911,12 +911,12 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_DADDIU:
SET_VAL (op, 2);
op->sign = (insn->id == MIPS_INS_ADDI || insn->id == MIPS_INS_ADD);
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
if (REGID(0) == MIPS_REG_T9) {
t9_pre += IMM(2);
}
if (REGID(0) == MIPS_REG_SP) {
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -IMM(2);
}
break;
@@ -934,7 +934,7 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_SUBUH_R:
SET_VAL (op,2);
op->sign = insn->id == MIPS_INS_SUB;
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case MIPS_INS_MULV:
case MIPS_INS_MULT:
@@ -943,28 +943,28 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_MUL:
case MIPS_INS_DMULT:
case MIPS_INS_DMULTU:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case MIPS_INS_XOR:
case MIPS_INS_XORI:
SET_VAL (op,2);
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case MIPS_INS_AND:
case MIPS_INS_ANDI:
SET_VAL (op,2);
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
if (REGID(0) == MIPS_REG_SP) {
op->stackop = R_ANAL_STACK_ALIGN;
op->stackop = RZ_ANAL_STACK_ALIGN;
}
break;
case MIPS_INS_NOT:
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
break;
case MIPS_INS_OR:
case MIPS_INS_ORI:
SET_VAL (op,2);
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case MIPS_INS_DIV:
case MIPS_INS_DIVU:
@@ -973,13 +973,13 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_FDIV:
case MIPS_INS_DIV_S:
case MIPS_INS_DIV_U:
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
break;
case MIPS_INS_CMPGDU:
case MIPS_INS_CMPGU:
case MIPS_INS_CMPU:
case MIPS_INS_CMPI:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case MIPS_INS_J:
case MIPS_INS_B:
@@ -1008,9 +1008,9 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_BLTZC:
case MIPS_INS_BGTZC:
if (insn->id == MIPS_INS_J || insn->id == MIPS_INS_B ) {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
} else {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
}
if (OPERAND(0).type == MIPS_OP_IMM) {
@@ -1039,11 +1039,11 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
break;
case MIPS_INS_JR:
case MIPS_INS_JRC:
op->type = R_ANAL_OP_TYPE_RJMP;
op->type = RZ_ANAL_OP_TYPE_RJMP;
op->delay = 1;
// register is $ra, so jmp is a return
if (insn->detail->mips.operands[0].reg == MIPS_REG_RA) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
t9_pre = UT64_MAX;
}
if (REGID(0) == MIPS_REG_25) {
@@ -1065,32 +1065,32 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_SHRA:
case MIPS_INS_SHRA_R:
case MIPS_INS_SRA:
op->type = R_ANAL_OP_TYPE_SAR;
op->type = RZ_ANAL_OP_TYPE_SAR;
SET_VAL (op,2);
break;
case MIPS_INS_SHRL:
case MIPS_INS_SRLV:
case MIPS_INS_SRL:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
SET_VAL (op,2);
break;
case MIPS_INS_SLLV:
case MIPS_INS_SLL:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
SET_VAL (op,2);
break;
}
beach:
set_opdir (op);
if (insn && mask & R_ANAL_OP_MASK_OPEX) {
if (insn && mask & RZ_ANAL_OP_MASK_OPEX) {
opex (&op->opex, hndl, insn);
}
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
if (analop_esil (anal, op, addr, buf, len, &hndl, insn) != 0) {
rz_strbuf_fini (&op->esil);
}
}
if (mask & R_ANAL_OP_MASK_VAL) {
if (mask & RZ_ANAL_OP_MASK_VAL) {
op_fillval (anal, op, &hndl, insn);
}
cs_free (insn, n);
@@ -1227,10 +1227,10 @@ RzAnalPlugin rz_anal_plugin_mips_cs = {
.op = &analop,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_mips_cs,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+26 -26
View File
@@ -31,7 +31,7 @@ static int mips_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
return oplen;
}
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
op->size = oplen;
op->addr = addr;
@@ -40,7 +40,7 @@ static int mips_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
// eprintf ("MIPS: %02x %02x %02x %02x (after endian: big=%d)\n", buf[0], buf[1], buf[2], buf[3], anal->big_endian);
if (opcode == 0) {
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
return oplen;
}
@@ -91,22 +91,22 @@ static int mips_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
//eprintf ("%llx jr\n", addr);
// TODO: check return value or gtfo
if (((buf[0]&3)<<3) + (buf[1]>>5) == 31) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
} else {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
}
op->delay = 1;
break;
case 9: // jalr
//eprintf ("%llx jalr\n", addr);
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
op->delay = 1;
break;
case 12: // syscall
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
break;
case 13: // break
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
break;
case 16: // mfhi
case 18: // mflo
@@ -119,24 +119,24 @@ static int mips_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
case 26: // div
case 27: // divu
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
break;
case 32: // add
case 33: // addu
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 34: // sub
case 35: // subu
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case 36: // and
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case 37: // or
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case 38: // xor
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case 39: // nor
case 42: // slt
@@ -180,13 +180,13 @@ static int mips_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
ut64 page_hack = addr & 0xf0000000;
switch (optype) {
case 2: // j
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = page_hack + address;
op->delay = 1;
rz_strbuf_setf (&op->esil, "0x%08x,pc,=", address);
break;
case 3: // jal
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = page_hack + address;
op->fail = addr+8;
op->delay = 1;
@@ -255,7 +255,7 @@ static int mips_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
case 6: // blez
case 7: // bgtz
// XXX: use imm here
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr+(imm<<2)+4;
op->fail = addr+8;
op->delay = 1;
@@ -278,16 +278,16 @@ static int mips_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
// flags directly, as suggested here: https://github.com/rizinorg/rizin/issues/949#issuecomment-43654922
case 15: // lui
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, mips_reg_decode(rt), R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, mips_reg_decode(rt), RZ_REG_TYPE_GPR);
// TODO: currently there is no way for the macro to get access to this register
op->val = imm;
break;
case 9: // addiu
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, mips_reg_decode(rt), R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, mips_reg_decode(rt), RZ_REG_TYPE_GPR);
// TODO: currently there is no way for the macro to get access to this register
op->src[0] = rz_anal_value_new ();
op->src[0]->reg = rz_reg_get (anal->reg, mips_reg_decode(rs), R_REG_TYPE_GPR);
op->src[0]->reg = rz_reg_get (anal->reg, mips_reg_decode(rs), RZ_REG_TYPE_GPR);
op->val = imm; // Beware: this one is signed... use `?vi $v`
break;
case 8: // addi
@@ -308,7 +308,7 @@ static int mips_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
case 57: // swc1
break;
case 29: // jalx
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = addr + 4*((buf[3] | buf[2]<<8 | buf[1]<<16));
op->fail = addr + 8;
op->delay = 1;
@@ -320,16 +320,16 @@ static int mips_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
#if 0
switch (optype) {
case 'R': // register only
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case 'I': // immediate
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 'J': // memory address jumps
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
break;
case 'C': // coprocessor
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
}
#endif
@@ -540,9 +540,9 @@ RzAnalPlugin rz_anal_plugin_mips_gnu = {
.set_reg_profile = mips_set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_mips_gnu
};
#endif
+17 -17
View File
@@ -15,8 +15,8 @@ static int msp430_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int
//op->id = ???;
op->size = -1;
op->nopcode = 1;
op->type = R_ANAL_OP_TYPE_UNK;
op->family = R_ANAL_OP_FAMILY_CPU;
op->type = RZ_ANAL_OP_TYPE_UNK;
op->family = RZ_ANAL_OP_FAMILY_CPU;
ret = op->size = msp430_decode_command (buf, len, &cmd);
@@ -31,16 +31,16 @@ static int msp430_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int
switch (cmd.opcode) {
case MSP430_RRA:
case MSP430_RRC:
op->type = R_ANAL_OP_TYPE_ROR; break;
op->type = RZ_ANAL_OP_TYPE_ROR; break;
case MSP430_PUSH:
op->type = R_ANAL_OP_TYPE_PUSH; break;
op->type = RZ_ANAL_OP_TYPE_PUSH; break;
case MSP430_CALL:
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->fail = addr + op->size;
op->jump = rz_read_at_le16 (buf, 2);
break;
case MSP430_RETI:
op->type = R_ANAL_OP_TYPE_RET; break;
op->type = RZ_ANAL_OP_TYPE_RET; break;
}
break;
case MSP430_TWOOP:
@@ -49,36 +49,36 @@ static int msp430_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int
case MSP430_BIC:
case MSP430_BIS:
case MSP430_MOV:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
if ((cmd.instr)[0] == 'b' && (cmd.instr)[1] == 'r') {
// Emulated branch instruction, moves source operand to PC register.
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
}
break;
case MSP430_DADD:
case MSP430_ADDC:
case MSP430_ADD: op->type = R_ANAL_OP_TYPE_ADD; break;
case MSP430_ADD: op->type = RZ_ANAL_OP_TYPE_ADD; break;
case MSP430_SUBC:
case MSP430_SUB: op->type = R_ANAL_OP_TYPE_SUB; break;
case MSP430_CMP: op->type = R_ANAL_OP_TYPE_CMP; break;
case MSP430_XOR: op->type = R_ANAL_OP_TYPE_XOR; break;
case MSP430_AND: op->type = R_ANAL_OP_TYPE_AND; break;
case MSP430_SUB: op->type = RZ_ANAL_OP_TYPE_SUB; break;
case MSP430_CMP: op->type = RZ_ANAL_OP_TYPE_CMP; break;
case MSP430_XOR: op->type = RZ_ANAL_OP_TYPE_XOR; break;
case MSP430_AND: op->type = RZ_ANAL_OP_TYPE_AND; break;
}
break;
case MSP430_JUMP:
if (cmd.jmp_cond == MSP430_JMP) {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
} else {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
}
op->jump = addr + cmd.jmp_addr;
op->fail = addr + 2;
break;
case MSP430_INV:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
default:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
}
return ret;
+16 -16
View File
@@ -14,39 +14,39 @@ static int nios2_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len
if ((b[0]&0xff) == 0x3a) {
// XXX
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
} else
if ((b[0]&0xf) == 0xa) {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
} else
if ((b[0]&0xf) == 4) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
} else
if ((b[0]&0xf) == 5) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
} else
if ((b[0]&0xf) == 6) {
// blt, r19, r5, 0x8023480
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
// TODO: address
} else
if ((b[0]&0xf) == 7) {
// blt, r19, r5, 0x8023480
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
// TODO: address
} else {
switch (b[0]) {
case 0x3a:
if (b[1] >= 0xa0 && b[1] <= 0xaf && b[3] == 0x3d) {
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
} else if ((b[1] >= 0xe0 && b[1] <= 0xe7) && b[2] == 0x3e && !b[3]) {
// nextpc ra
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
}
break;
case 0x01:
// jmpi
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0x00:
case 0x20:
@@ -54,7 +54,7 @@ static int nios2_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len
case 0x80:
case 0xc0:
//
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
break;
case 0x26:
// beq
@@ -64,7 +64,7 @@ static int nios2_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len
case 0x87:
case 0xc7:
// ldb
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 0x0d:
case 0x2d:
@@ -72,14 +72,14 @@ static int nios2_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len
case 0x8d:
case 0xcd:
// sth && sthio
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 0x06:
case 0x46:
case 0x86:
case 0xc6:
// br
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
break;
}
}
@@ -96,10 +96,10 @@ RzAnalPlugin rz_anal_plugin_nios2 = {
.op = &nios2_op,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_nios2,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+3 -3
View File
@@ -23,10 +23,10 @@ RzAnalPlugin rz_anal_plugin_null = {
.set_reg_profile = &null_set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_null,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+6 -6
View File
@@ -70,7 +70,7 @@ static int insn_to_op(RzAnal *a, RzAnalOp *op, ut64 addr, insn_t *descr, insn_ex
break;
case 0x03: /* l.bnf */
o.n = get_operand_value(insn, type_descr, INSN_OPER_N);
op->cond = R_ANAL_COND_NE;
op->cond = RZ_ANAL_COND_NE;
op->jump = n_oper_to_addr(o.n, get_operand_mask(type_descr, INSN_OPER_N),
addr);
op->fail = addr + 8;
@@ -78,7 +78,7 @@ static int insn_to_op(RzAnal *a, RzAnalOp *op, ut64 addr, insn_t *descr, insn_ex
break;
case 0x04: /* l.bf */
o.n = get_operand_value(insn, type_descr, INSN_OPER_N);
op->cond = R_ANAL_COND_EQ;
op->cond = RZ_ANAL_COND_EQ;
op->jump = n_oper_to_addr(o.n, get_operand_mask(type_descr, INSN_OPER_N),
addr);
op->fail = addr + 8;
@@ -140,7 +140,7 @@ static int insn_to_op(RzAnal *a, RzAnalOp *op, ut64 addr, insn_t *descr, insn_ex
}
/* temporary solution to prevent using wrong register values */
if ((op->type & R_ANAL_OP_TYPE_JMP) == R_ANAL_OP_TYPE_JMP) {
if ((op->type & RZ_ANAL_OP_TYPE_JMP) == RZ_ANAL_OP_TYPE_JMP) {
/* FIXME: handle delay slot after branches */
cpu_enable = 0;
}
@@ -196,10 +196,10 @@ RzAnalPlugin rz_anal_plugin_or1k = {
.op = &or1k_op,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_or1k,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+93 -93
View File
@@ -74,19 +74,19 @@ typedef struct _pic_midrange_op_anal_info {
INST_HANDLER (NOP) {}
INST_HANDLER (RETFIE) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
}
INST_HANDLER (OPTION) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
}
INST_HANDLER (TRIS) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
}
INST_HANDLER (RETURN) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
e ("0x1f,stkptr,==,$z,?{,BREAK,},");
e ("_stack,stkptr,2,*,+,[2],2,*,pc,=,");
e ("0x01,stkptr,-=,");
@@ -95,7 +95,7 @@ INST_HANDLER (RETURN) {
INST_HANDLER (CALL) {
ut64 pclath;
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
rz_anal_esil_reg_read (anal->esil, "pclath", &pclath, NULL);
op->jump = 2 * (((pclath & 0x78) << 8) + args->k);
ef ("8,pclath,0x78,&,<<,0x%x,+,2,*,pc,=,", args->k);
@@ -107,7 +107,7 @@ INST_HANDLER (CALL) {
INST_HANDLER (GOTO) {
ut64 pclath;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
rz_anal_esil_reg_read (anal->esil, "pclath", &pclath, NULL);
op->jump = 2 * (((pclath & 0x78) << 8) + args->k);
ef ("8,pclath,0x78,&,<<,0x%x,+,2,*,pc,=,", args->k);
@@ -129,7 +129,7 @@ INST_HANDLER (BSF) {
INST_HANDLER (BTFSC) {
ut8 mask = (1 << args->b);
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + 4;
op->fail = addr + 2;
ef (PIC_MIDRANGE_ESIL_BSR_ADDR ",[1],0x%x,&,!,?{,0x%x,pc,=,},",
@@ -138,7 +138,7 @@ INST_HANDLER (BTFSC) {
INST_HANDLER (BTFSS) {
ut8 mask = (1 << args->b);
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + 4;
op->fail = addr + 2;
ef (PIC_MIDRANGE_ESIL_BSR_ADDR ",[1],0x%x,&,?{,0x%x,pc,=,},", args->f,
@@ -147,7 +147,7 @@ INST_HANDLER (BTFSS) {
INST_HANDLER (BRA) {
st16 branch = args->k;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
branch |= ((branch & 0x100) ? 0xfe00 : 0);
op->jump = addr + 2 * (branch + 1);
ef ("%s0x%x,1,+,2,*,pc,+=,", branch < 0 ? "-" : "",
@@ -156,7 +156,7 @@ INST_HANDLER (BRA) {
INST_HANDLER (BRW) {
ut64 wreg;
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
rz_anal_esil_reg_read (anal->esil, "wreg", &wreg, NULL);
op->jump = addr + 2 * (wreg + 1);
e ("wreg,1,+,2,*,pc,+=,");
@@ -172,7 +172,7 @@ INST_HANDLER (CLR) {
}
INST_HANDLER (SUBWF) {
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
if (args->d) {
ef (PIC_MIDRANGE_ESIL_FWF_OP (-), args->f);
} else {
@@ -182,7 +182,7 @@ INST_HANDLER (SUBWF) {
}
INST_HANDLER (DECFSZ) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + 4;
op->fail = addr + 2;
if (args->d) {
@@ -196,7 +196,7 @@ INST_HANDLER (DECFSZ) {
}
INST_HANDLER (INCFSZ) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + 4;
op->fail = addr + 2;
if (args->d) {
@@ -210,7 +210,7 @@ INST_HANDLER (INCFSZ) {
}
INST_HANDLER (INCF) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
if (args->d) {
ef ("0x01," PIC_MIDRANGE_ESIL_BSR_ADDR ",+=[1],", args->f);
} else {
@@ -221,7 +221,7 @@ INST_HANDLER (INCF) {
}
INST_HANDLER (DECF) {
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
if (args->d) {
ef ("0x01," PIC_MIDRANGE_ESIL_BSR_ADDR ",-=[1],", args->f);
} else {
@@ -232,7 +232,7 @@ INST_HANDLER (DECF) {
}
INST_HANDLER (IORWF) {
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
if (args->d) {
ef (PIC_MIDRANGE_ESIL_FWF_OP (|), args->f);
} else {
@@ -241,7 +241,7 @@ INST_HANDLER (IORWF) {
}
INST_HANDLER (ANDWF) {
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
if (args->d) {
ef (PIC_MIDRANGE_ESIL_FWF_OP (&), args->f);
} else {
@@ -250,7 +250,7 @@ INST_HANDLER (ANDWF) {
}
INST_HANDLER (XORWF) {
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
if (args->d) {
ef (PIC_MIDRANGE_ESIL_FWF_OP (^), args->f);
} else {
@@ -259,7 +259,7 @@ INST_HANDLER (XORWF) {
}
INST_HANDLER (ADDWF) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
if (args->d) {
ef (PIC_MIDRANGE_ESIL_FWF_OP (+), args->f);
} else {
@@ -268,37 +268,37 @@ INST_HANDLER (ADDWF) {
}
INST_HANDLER (SUBLW) {
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
ef (PIC_MIDRANGE_ESIL_LW_OP (-), args->k);
}
INST_HANDLER (ADDLW) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
ef (PIC_MIDRANGE_ESIL_LW_OP (+), args->k);
}
INST_HANDLER (IORLW) {
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
ef (PIC_MIDRANGE_ESIL_LW_OP (|), args->k);
}
INST_HANDLER (ANDLW) {
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
ef (PIC_MIDRANGE_ESIL_LW_OP (&), args->k);
}
INST_HANDLER (XORLW) {
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
ef (PIC_MIDRANGE_ESIL_LW_OP (^), args->k);
}
INST_HANDLER (MOVLW) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
ef ("0x%x,wreg,=,", args->k);
}
INST_HANDLER (RETLW) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
ef ("0x%x,wreg,=,", args->k);
e ("0x1f,stkptr,==,$z,?{,BREAK,},");
e ("_stack,stkptr,2,*,+,[2],2,*,pc,=,");
@@ -307,17 +307,17 @@ INST_HANDLER (RETLW) {
}
INST_HANDLER (MOVLP) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
ef ("0x%x,pclath,=,", args->f);
}
INST_HANDLER (MOVLB) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
ef ("0x%x,bsr,=,", args->k);
}
INST_HANDLER (CALLW) {
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
e ("8,pclath,<<,0x%x,+,wreg,2,*,pc,=,");
e ("0x1f,stkptr,==,$z,?{,0xff,stkptr,=,},");
e ("0x0f,stkptr,==,$z,?{,0xff,stkptr,=,},");
@@ -326,12 +326,12 @@ INST_HANDLER (CALLW) {
}
INST_HANDLER (MOVWF) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
ef ("wreg," PIC_MIDRANGE_ESIL_BSR_ADDR ",=[1],", args->f);
}
INST_HANDLER (MOVF) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
if (args->d) {
ef (PIC_MIDRANGE_ESIL_BSR_ADDR
",[1]," PIC_MIDRANGE_ESIL_BSR_ADDR ",=[1],",
@@ -350,7 +350,7 @@ INST_HANDLER (SWAPF) {
}
INST_HANDLER (LSLF) {
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
ef ("7," PIC_MIDRANGE_ESIL_BSR_ADDR ",[1],>>,c,=,", args->f);
if (args->d) {
ef ("1," PIC_MIDRANGE_ESIL_BSR_ADDR ",<<=[1],", args->f);
@@ -362,7 +362,7 @@ INST_HANDLER (LSLF) {
}
INST_HANDLER (LSRF) {
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
ef ("1," PIC_MIDRANGE_ESIL_BSR_ADDR ",[1],&,c,=,", args->f);
if (args->d) {
ef ("1," PIC_MIDRANGE_ESIL_BSR_ADDR ",>>=[1],", args->f);
@@ -374,7 +374,7 @@ INST_HANDLER (LSRF) {
}
INST_HANDLER (ASRF) {
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
ef ("1," PIC_MIDRANGE_ESIL_BSR_ADDR ",[1],&,c,=,", args->f);
ef ("1," PIC_MIDRANGE_ESIL_BSR_ADDR ",[1],>>,", args->f);
ef ("0x80," PIC_MIDRANGE_ESIL_BSR_ADDR ",[1],&,", args->f);
@@ -387,7 +387,7 @@ INST_HANDLER (ASRF) {
}
INST_HANDLER (RRF) {
op->type = R_ANAL_OP_TYPE_ROR;
op->type = RZ_ANAL_OP_TYPE_ROR;
ef ("1," PIC_MIDRANGE_ESIL_BSR_ADDR ",[1],&,", args->f);
if (args->d) {
ef ("1," PIC_MIDRANGE_ESIL_BSR_ADDR ",>>=[1],"
@@ -402,7 +402,7 @@ INST_HANDLER (RRF) {
}
INST_HANDLER (RLF) {
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
ef ("7," PIC_MIDRANGE_ESIL_BSR_ADDR ",[1],>>,", args->f);
if (args->d) {
ef ("1," PIC_MIDRANGE_ESIL_BSR_ADDR ",<<=[1],"
@@ -426,14 +426,14 @@ INST_HANDLER (COMF) {
}
INST_HANDLER (RESET) {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = 0;
e ("0x0,pc,=,");
e ("0x1f,stkptr,=,");
}
INST_HANDLER (ADDFSR) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
if (args->n == 0) {
ef ("0x%x,fsr0l,+=,", args->k);
e ("7,$c,?{,0x01,fsr0h,+=,},");
@@ -454,7 +454,7 @@ INST_HANDLER (SLEEP) {
}
INST_HANDLER (SUBWFB) {
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
e ("c,!=,");
if (args->d) {
ef (PIC_MIDRANGE_ESIL_FWF_OP_C (-), args->f);
@@ -465,7 +465,7 @@ INST_HANDLER (SUBWFB) {
}
INST_HANDLER (ADDWFC) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
if (args->d) {
ef (PIC_MIDRANGE_ESIL_FWF_OP_C (+), args->f);
} else {
@@ -640,7 +640,7 @@ static RzIODesc *cpu_memory_map (RzIOBind *iob, RzIODesc *desc, ut32 addr,
if (desc && iob->fd_get_name (iob->io, desc->fd)) {
iob->fd_remap (iob->io, desc->fd, addr);
} else {
desc = iob->open_at (iob->io, mstr, R_PERM_RW, 0, addr);
desc = iob->open_at (iob->io, mstr, RZ_PERM_RW, 0, addr);
}
free (mstr);
return desc;
@@ -648,7 +648,7 @@ static RzIODesc *cpu_memory_map (RzIOBind *iob, RzIODesc *desc, ut32 addr,
static bool pic_midrange_reg_write (RzReg *reg, const char *regname, ut32 num) {
if (reg) {
RzRegItem *item = rz_reg_get (reg, regname, R_REG_TYPE_GPR);
RzRegItem *item = rz_reg_get (reg, regname, RZ_REG_TYPE_GPR);
if (item) {
rz_reg_set_value (reg, item, num);
return true;
@@ -690,7 +690,7 @@ static int anal_pic_midrange_op (RzAnal *anal, RzAnalOp *op, ut64 addr,
anal_pic_midrange_malloc (anal, false);
if (!buf || len < 2) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
return op->size;
}
@@ -699,7 +699,7 @@ static int anal_pic_midrange_op (RzAnal *anal, RzAnalOp *op, ut64 addr,
// Default op params
op->size = 2;
op->cycles = 1;
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
PicMidrangeOpcode opcode = pic_midrange_get_opcode (instr);
PicMidrangeOpArgsVal args_val;
@@ -719,7 +719,7 @@ static int anal_pic_midrange_op (RzAnal *anal, RzAnalOp *op, ut64 addr,
}
static void pic18_cond_branch (RzAnalOp *op, ut64 addr, const ut8 *buf, char *flag) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + 2 + 2 * (*(ut16 *)buf & 0xff);
op->fail = addr + op->size;
op->cycles = 2;
@@ -736,7 +736,7 @@ static int anal_pic_pic18_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b
op->size = 2;
ut16 b = *(ut16 *)buf;
ut32 dword_instr = 0;
memcpy (&dword_instr, buf, R_MIN (sizeof (dword_instr), len));
memcpy (&dword_instr, buf, RZ_MIN (sizeof (dword_instr), len));
switch (b >> 9) {
case 0x76: //call
if (len < 4) {
@@ -746,15 +746,15 @@ static int anal_pic_pic18_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b
goto beach;
}
op->size = 4;
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
return op->size;
};
switch (b >> 11) { //NEX_T
case 0x1b: //rcall
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
return op->size;
case 0x1a: //bra
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->cycles = 2;
op->jump = addr + 2 + 2 * (*(ut16 *)buf & 0x7ff);
rz_strbuf_setf (&op->esil, "0x%x,pc,=", op->jump);
@@ -762,7 +762,7 @@ static int anal_pic_pic18_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b
}
switch (b >> 12) { //NOP,movff,BAF_T
case 0xf: //nop
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
op->cycles = 1;
rz_strbuf_setf (&op->esil, ",");
return op->size;
@@ -774,16 +774,16 @@ static int anal_pic_pic18_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b
goto beach;
}
op->size = 4;
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
return op->size;
case 0xb: //btfsc
case 0xa: //btfss
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
return op->size;
case 0x9: //bcf
case 0x8: //bsf
case 0x7: //btg
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
return op->size;
};
@@ -823,46 +823,46 @@ static int anal_pic_pic18_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b
op->cycles = 2;
op->jump = ((dword_instr & 0xff) | ((dword_instr & 0xfff0000) >> 8)) * 2;
rz_strbuf_setf (&op->esil, "0x%x,pc,=", op->jump);
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
return op->size;
case 0xf: //addlw
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
op->cycles = 1;
//TODO add support for dc flag
rz_strbuf_setf (&op->esil, "0x%x,wreg,+=,$z,z,:=,7,$s,n,:=,7,$c,c,:=,7,$o,ov,:=,", *(ut16 *)buf & 0xff);
return op->size;
case 0xe: //movlw
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->cycles = 1;
rz_strbuf_setf (&op->esil, "0x%x,wreg,=,");
return op->size;
case 0xd: //mullw
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
op->cycles = 1;
rz_strbuf_setf (&op->esil, "0x%x,wreg,*,prod,=", *(ut16 *)buf & 0xff);
return op->size;
case 0xc: //retlw
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->cycles = 2;
rz_strbuf_setf (&op->esil, "0x%x,wreg,=,tos,pc,=,", *(ut16 *)buf & 0xff);
return op->size;
case 0xb: //andlw
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
op->cycles = 1;
rz_strbuf_setf (&op->esil, "0x%x,wreg,&=,$z,z,:=,7,$s,n,:=,", *(ut16 *)buf & 0xff);
return op->size;
case 0xa: //xorlw
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
op->cycles = 1;
rz_strbuf_setf (&op->esil, "0x%x,wreg,^=,$z,z,:=,7,$s,n,:=,", *(ut16 *)buf & 0xff);
return op->size;
case 0x9: //iorlw
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
op->cycles = 1;
rz_strbuf_setf (&op->esil, "0x%x,wreg,^=,$z,z,:=,7,$s,n,:=,", *(ut16 *)buf & 0xff);
return op->size;
case 0x8: //sublw
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
op->cycles = 1;
//TODO add support for dc flag
rz_strbuf_setf (&op->esil, "wreg,0x%x,-,wreg,=,$z,z,:=,7,$s,n,:=,7,$c,c,:=,7,$o,ov,:=,", *(ut16 *)buf & 0xff);
@@ -878,7 +878,7 @@ static int anal_pic_pic18_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b
goto beach;
}
op->size = 4;
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
return op->size;
};
switch (b >> 10) { //DAF_T
@@ -888,69 +888,69 @@ static int anal_pic_pic18_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b
case 0x13: //dcfsnz
case 0xb: //decfsz
case 0x1: //decf
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
return op->size;
case 0x14: //movf
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
return op->size;
case 0x12: //infsnz
case 0xf: //incfsz
case 0xa: //incf
case 0x8: //addwfc
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
return op->size;
case 0x9: //addwf
op->cycles = 1;
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
return op->size;
case 0x11: //rlncf
case 0xd: //rlcf
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
return op->size;
case 0x10: //rrncf
case 0xc: //rrcf
op->type = R_ANAL_OP_TYPE_ROR;
op->type = RZ_ANAL_OP_TYPE_ROR;
return op->size;
case 0xe: //swapf
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
return op->size;
case 0x7: //comf
op->type = R_ANAL_OP_TYPE_CPL;
op->type = RZ_ANAL_OP_TYPE_CPL;
return op->size;
case 0x6: //xorwf
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
return op->size;
case 0x5: //andwf
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
return op->size;
case 0x4: //iorwf
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
return op->size;
};
switch (b >> 9) { //AF_T
case 0x37: //movwf
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
return op->size;
case 0x36: //negf
case 0x35: //clrf
case 0x34: //setf
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
return op->size;
case 0x33: //tstfsz
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
return op->size;
case 0x32: //cpfsgt
case 0x31: //cpfseq
case 0x30: //cpfslt
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
return op->size;
case 0x1: //mulwf
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
return op->size;
};
switch (b >> 4) {
case 0x10: //movlb
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->cycles = 1;
rz_strbuf_setf (&op->esil, "0x%x,bsr,=,", *(ut16 *)buf & 0xf);
return op->size;
@@ -960,48 +960,48 @@ static int anal_pic_pic18_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b
case 0x7: //daw
case 0x4: //clwdt
case 0x3: //sleep
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
return op->size;
case 0x13: //return
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->cycles = 2;
rz_strbuf_setf (&op->esil, "tos,pc,=,");
return op->size;
case 0x12: //return
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->cycles = 2;
rz_strbuf_setf (&op->esil, "tos,pc,=");
return op->size;
case 0x11: //retfie
case 0x10: //retfie
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
return op->size;
case 0xf: //tblwt
case 0xe: //tblwt
case 0xd: //tblwt
case 0xc: //tblwt
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
return op->size;
case 0xb: //tblrd
case 0xa: //tblrd
case 0x9: //tblrd
case 0x8: //tblrd
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
return op->size;
case 0x6: //pop
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
return op->size;
case 0x5: //push
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
return op->size;
case 0x0: //nop
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
op->cycles = 1;
rz_strbuf_setf (&op->esil, ",");
return op->size;
};
beach:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
return op->size;
}
@@ -1190,10 +1190,10 @@ RzAnalPlugin rz_anal_plugin_pic = {
.esil = true
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_pic,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+148 -148
View File
@@ -419,72 +419,72 @@ static int analop_vle(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
//op->id = instr->type;
switch (op->type) {
case R_ANAL_OP_TYPE_ILL:
case RZ_ANAL_OP_TYPE_ILL:
break;
case R_ANAL_OP_TYPE_ADD:
case RZ_ANAL_OP_TYPE_ADD:
break;
case R_ANAL_OP_TYPE_AND:
case RZ_ANAL_OP_TYPE_AND:
break;
case R_ANAL_OP_TYPE_CALL:
case RZ_ANAL_OP_TYPE_CALL:
op->jump = addr + instr->fields[instr->n - 1].value;
op->fail = addr + op->size;
break;
case R_ANAL_OP_TYPE_CCALL:
case RZ_ANAL_OP_TYPE_CCALL:
op->eob = true;
op->jump = addr + instr->fields[instr->n - 1].value;
op->fail = addr + op->size;
break;
case R_ANAL_OP_TYPE_CJMP:
op->cond = instr->cond; //R_ANAL_COND_NE;
case RZ_ANAL_OP_TYPE_CJMP:
op->cond = instr->cond; //RZ_ANAL_COND_NE;
op->eob = true;
op->jump = addr + instr->fields[instr->n - 1].value;
op->fail = addr + op->size;
break;
case R_ANAL_OP_TYPE_CMP:
case RZ_ANAL_OP_TYPE_CMP:
break;
case R_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_JMP:
op->jump = addr + instr->fields[instr->n - 1].value;
break;
case R_ANAL_OP_TYPE_LOAD:
case RZ_ANAL_OP_TYPE_LOAD:
break;
case R_ANAL_OP_TYPE_MOV:
case RZ_ANAL_OP_TYPE_MOV:
break;
case R_ANAL_OP_TYPE_MUL:
case RZ_ANAL_OP_TYPE_MUL:
break;
case R_ANAL_OP_TYPE_NOT:
case RZ_ANAL_OP_TYPE_NOT:
break;
case R_ANAL_OP_TYPE_OR:
case RZ_ANAL_OP_TYPE_OR:
break;
case R_ANAL_OP_TYPE_ROR:
case RZ_ANAL_OP_TYPE_ROR:
break;
case R_ANAL_OP_TYPE_ROL:
case RZ_ANAL_OP_TYPE_ROL:
break;
case R_ANAL_OP_TYPE_RCALL:
case RZ_ANAL_OP_TYPE_RCALL:
op->eob = true;
break;
case R_ANAL_OP_TYPE_RET:
case RZ_ANAL_OP_TYPE_RET:
op->eob = true;
break;
case R_ANAL_OP_TYPE_RJMP:
case RZ_ANAL_OP_TYPE_RJMP:
break;
case R_ANAL_OP_TYPE_SHL:
case RZ_ANAL_OP_TYPE_SHL:
break;
case R_ANAL_OP_TYPE_SHR:
case RZ_ANAL_OP_TYPE_SHR:
break;
case R_ANAL_OP_TYPE_STORE:
case RZ_ANAL_OP_TYPE_STORE:
break;
case R_ANAL_OP_TYPE_SUB:
case RZ_ANAL_OP_TYPE_SUB:
break;
case R_ANAL_OP_TYPE_SWI:
case RZ_ANAL_OP_TYPE_SWI:
break;
case R_ANAL_OP_TYPE_SYNC:
case RZ_ANAL_OP_TYPE_SYNC:
break;
case R_ANAL_OP_TYPE_TRAP:
case RZ_ANAL_OP_TYPE_TRAP:
break;
case R_ANAL_OP_TYPE_XOR:
case RZ_ANAL_OP_TYPE_XOR:
break;
default:
//eprintf ("Missing an R_ANAL_OP_TYPE (%"PFMT64u")\n", op->type);
//eprintf ("Missing an RZ_ANAL_OP_TYPE (%"PFMT64u")\n", op->type);
break;
}
vle_free (instr);
@@ -545,33 +545,33 @@ static void set_src_dst(RzAnalValue *val, csh *handle, cs_insn *insn, int x) {
static void op_fillval(RzAnalOp *op, csh handle, cs_insn *insn) {
create_src_dst (op);
switch (op->type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_MOV:
case R_ANAL_OP_TYPE_CMP:
case R_ANAL_OP_TYPE_ADD:
case R_ANAL_OP_TYPE_SUB:
case R_ANAL_OP_TYPE_MUL:
case R_ANAL_OP_TYPE_DIV:
case R_ANAL_OP_TYPE_SHR:
case R_ANAL_OP_TYPE_SHL:
case R_ANAL_OP_TYPE_SAL:
case R_ANAL_OP_TYPE_SAR:
case R_ANAL_OP_TYPE_OR:
case R_ANAL_OP_TYPE_AND:
case R_ANAL_OP_TYPE_XOR:
case R_ANAL_OP_TYPE_NOR:
case R_ANAL_OP_TYPE_NOT:
case R_ANAL_OP_TYPE_LOAD:
case R_ANAL_OP_TYPE_LEA:
case R_ANAL_OP_TYPE_ROR:
case R_ANAL_OP_TYPE_ROL:
case R_ANAL_OP_TYPE_CAST:
switch (op->type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_MOV:
case RZ_ANAL_OP_TYPE_CMP:
case RZ_ANAL_OP_TYPE_ADD:
case RZ_ANAL_OP_TYPE_SUB:
case RZ_ANAL_OP_TYPE_MUL:
case RZ_ANAL_OP_TYPE_DIV:
case RZ_ANAL_OP_TYPE_SHR:
case RZ_ANAL_OP_TYPE_SHL:
case RZ_ANAL_OP_TYPE_SAL:
case RZ_ANAL_OP_TYPE_SAR:
case RZ_ANAL_OP_TYPE_OR:
case RZ_ANAL_OP_TYPE_AND:
case RZ_ANAL_OP_TYPE_XOR:
case RZ_ANAL_OP_TYPE_NOR:
case RZ_ANAL_OP_TYPE_NOT:
case RZ_ANAL_OP_TYPE_LOAD:
case RZ_ANAL_OP_TYPE_LEA:
case RZ_ANAL_OP_TYPE_ROR:
case RZ_ANAL_OP_TYPE_ROL:
case RZ_ANAL_OP_TYPE_CAST:
set_src_dst (op->src[2], &handle, insn, 3);
set_src_dst (op->src[1], &handle, insn, 2);
set_src_dst (op->src[0], &handle, insn, 1);
set_src_dst (op->dst, &handle, insn, 0);
break;
case R_ANAL_OP_TYPE_STORE:
case RZ_ANAL_OP_TYPE_STORE:
set_src_dst (op->dst, &handle, insn, 1);
set_src_dst (op->src[0], &handle, insn, 0);
break;
@@ -616,9 +616,9 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
// capstone-next
n = cs_disasm (handle, (const ut8*)buf, len, addr, 1, &insn);
if (n < 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
} else {
if (mask & R_ANAL_OP_MASK_OPEX) {
if (mask & RZ_ANAL_OP_MASK_OPEX) {
opex (&op->opex, handle, insn);
}
struct Getarg gop = {
@@ -644,7 +644,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case PPC_INS_CMP:
case PPC_INS_CMPI:
#endif
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
op->sign = true;
if (ARG (2)[0] == '\0') {
esilprintf (op, "%s,%s,-,0xff,&,cr0,=", ARG (1), ARG (0));
@@ -653,37 +653,37 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
}
break;
case PPC_INS_MFLR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "lr,%s,=", ARG (0));
break;
case PPC_INS_MTLR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "%s,lr,=", ARG (0));
break;
case PPC_INS_MR:
case PPC_INS_LI:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "%s,%s,=", ARG (1), ARG (0));
break;
case PPC_INS_LIS:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "%s0000,%s,=", ARG (1), ARG (0));
break;
case PPC_INS_CLRLWI:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
esilprintf (op, "%s,%s,&,%s,=", ARG (1), cmask32 (ARG (2), "0x1F"), ARG (0));
break;
case PPC_INS_RLWINM:
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
esilprintf (op, "%s,%s,<<<,%s,&,%s,=", ARG (2), ARG (1), cmask32 (ARG (3), ARG (4)), ARG (0));
break;
case PPC_INS_SC:
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
esilprintf (op, "0,$");
break;
case PPC_INS_EXTSB:
op->sign = true;
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
if (a->bits == 64) {
esilprintf (op, "%s,0x80,&,?{,0xFFFFFFFFFFFFFF00,%s,|,%s,=,}", ARG (1), ARG (1), ARG (0));
} else {
@@ -714,55 +714,55 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case PPC_INS_SLBMTE:
case PPC_INS_EIEIO:
case PPC_INS_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
esilprintf (op, ",");
break;
case PPC_INS_STW:
case PPC_INS_STWUX:
case PPC_INS_STWX:
case PPC_INS_STWCX:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
esilprintf (op, "%s,%s", ARG (0), ARG2 (1, "=[4]"));
break;
case PPC_INS_STWU:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op1 = ARG (1);
op1[strlen (op1) - 1] = 0;
esilprintf (op, "%s,%s,=[4],%s=", ARG (0), op1, op1);
if (strstr (op1, "r1")) {
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -atoi (op1);
}
break;
case PPC_INS_STWBRX:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case PPC_INS_STB:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
esilprintf (op, "%s,%s", ARG (0), ARG2 (1, "=[1]"));
break;
case PPC_INS_STBU:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op1 = ARG (1);
op1[strlen (op1) - 1] = 0;
esilprintf (op, "%s,%s,=[1],%s=", ARG (0), op1, op1);
break;
case PPC_INS_STH:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
esilprintf (op, "%s,%s", ARG (0), ARG2 (1, "=[2]"));
break;
case PPC_INS_STHU:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op1 = ARG (1);
op1[strlen (op1) - 1] = 0;
esilprintf (op, "%s,%s,=[2],%s=", ARG (0), op1, op1);
break;
case PPC_INS_STD:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
esilprintf (op, "%s,%s", ARG (0), ARG2 (1, "=[8]"));
break;
case PPC_INS_STDU:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op1 = ARG (1);
op1[strlen (op1) - 1] = 0;
esilprintf (op, "%s,%s,=[8],%s=", ARG (0), op1, op1);
@@ -773,13 +773,13 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
#endif
case PPC_INS_LBZU:
case PPC_INS_LBZUX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op1 = ARG (1);
op1[strlen (op1) - 1] = 0;
esilprintf (op, "%s,[1],%s,=,%s=", op1, ARG (0), op1);
break;
case PPC_INS_LBZX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
esilprintf (op, "%s,%s,=", ARG2 (1, "[1]"), ARG (0));
break;
case PPC_INS_LD:
@@ -789,17 +789,17 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
#endif
case PPC_INS_LDU:
case PPC_INS_LDUX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op1 = ARG (1);
op1[strlen (op1) - 1] = 0;
esilprintf (op, "%s,[8],%s,=,%s=", op1, ARG (0), op1);
break;
case PPC_INS_LDX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
esilprintf (op, "%s,%s,=", ARG2 (1, "[8]"), ARG (0));
break;
case PPC_INS_LDBRX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case PPC_INS_LFD:
case PPC_INS_LFDU:
@@ -811,7 +811,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case PPC_INS_LFSU:
case PPC_INS_LFSUX:
case PPC_INS_LFSX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
esilprintf (op, "%s,%s,=", ARG2 (1, "[4]"), ARG (0));
break;
case PPC_INS_LHA:
@@ -820,13 +820,13 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case PPC_INS_LHAX:
case PPC_INS_LHZ:
case PPC_INS_LHZU:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op1 = ARG (1);
op1[strlen (op1) - 1] = 0;
esilprintf (op, "%s,[2],%s,=,%s=", op1, ARG (0), op1);
break;
case PPC_INS_LHBRX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case PPC_INS_LWA:
case PPC_INS_LWARX:
@@ -837,34 +837,34 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case PPC_INS_LWZCIX:
#endif
case PPC_INS_LWZX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
esilprintf (op, "%s,%s,=", ARG2 (1, "[4]"), ARG (0));
break;
case PPC_INS_LWZU:
case PPC_INS_LWZUX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op1 = ARG (1);
op1[strlen(op1) - 1] = 0;
esilprintf (op, "%s,[4],%s,=,%s=", op1, ARG (0), op1);
break;
case PPC_INS_LWBRX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case PPC_INS_SLW:
case PPC_INS_SLWI:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
esilprintf (op, "%s,%s,<<,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_SRW:
case PPC_INS_SRWI:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
esilprintf (op, "%s,%s,>>,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_MULLI:
op->sign = true;
case PPC_INS_MULLW:
case PPC_INS_MULLD:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
esilprintf (op, "%s,%s,*,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_SUB:
@@ -872,13 +872,13 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case PPC_INS_SUBF:
case PPC_INS_SUBFIC:
case PPC_INS_SUBFZE:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
esilprintf (op, "%s,%s,-,%s,=", ARG (1), ARG (2), ARG (0));
break;
case PPC_INS_ADD:
case PPC_INS_ADDI:
op->sign = true;
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
esilprintf (op, "%s,%s,+,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_CRCLR:
@@ -888,36 +888,36 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case PPC_INS_CRNOR:
case PPC_INS_CRNOT:
// reset conditional bits
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case PPC_INS_ADDC:
case PPC_INS_ADDIC:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
esilprintf (op, "%s,%s,+,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_ADDE:
case PPC_INS_ADDIS:
case PPC_INS_ADDME:
case PPC_INS_ADDZE:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
esilprintf (op, "%s,%s,+,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_MTSPR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "%s,%s,=", ARG (1), PPCSPR (0));
break;
case PPC_INS_BCTR: // switch table here
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
esilprintf (op, "ctr,pc,=");
break;
case PPC_INS_BCTRL: // switch table here
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
esilprintf (op, "pc,lr,=,ctr,pc,=");
break;
case PPC_INS_B:
case PPC_INS_BC:
case PPC_INS_BA:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = ARG (1)[0] == '\0' ? IMM (0) : IMM (1);
op->fail = addr + op->size;
switch (insn->detail->ppc.bc) {
@@ -964,7 +964,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
}
break;
case PPC_BC_INVALID:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
esilprintf (op, "%s,pc,=", ARG (0));
case PPC_BC_UN: // unordered
case PPC_BC_NU: // not unordered
@@ -978,91 +978,91 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case PPC_INS_BF:
switch (insn->detail->ppc.operands[0].type) {
case PPC_OP_CRX:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->fail = addr + op->size;
break;
case PPC_OP_REG:
if (op->type == R_ANAL_OP_TYPE_CJMP) {
op->type = R_ANAL_OP_TYPE_UCJMP;
if (op->type == RZ_ANAL_OP_TYPE_CJMP) {
op->type = RZ_ANAL_OP_TYPE_UCJMP;
} else {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
}
op->jump = IMM (1);
op->fail = addr + op->size;
//op->type = R_ANAL_OP_TYPE_UJMP;
//op->type = RZ_ANAL_OP_TYPE_UJMP;
default:
break;
}
break;
case PPC_INS_BDNZ:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = IMM (0);
op->fail = addr + op->size;
esilprintf (op, "1,ctr,-=,$z,!,?{,%s,pc,=,}", ARG (0));
break;
case PPC_INS_BDNZA:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = IMM (0);
op->fail = addr + op->size;
break;
case PPC_INS_BDNZL:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = IMM (0);
op->fail = addr + op->size;
break;
case PPC_INS_BDNZLA:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = IMM (0);
op->fail = addr + op->size;
break;
case PPC_INS_BDNZLR:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->fail = addr + op->size;
esilprintf (op, "1,ctr,-=,$z,!,?{,lr,pc,=,},");
break;
case PPC_INS_BDNZLRL:
op->fail = addr + op->size;
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case PPC_INS_BDZ:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = IMM (0);
op->fail = addr + op->size;
esilprintf (op, "1,ctr,-=,$z,?{,%s,pc,=,}", ARG (0));
break;
case PPC_INS_BDZA:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = IMM (0);
op->fail = addr + op->size;
break;
case PPC_INS_BDZL:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = IMM (0);
op->fail = addr + op->size;
break;
case PPC_INS_BDZLA:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = IMM (0);
op->fail = addr + op->size;
break;
case PPC_INS_BDZLR:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->fail = addr + op->size;
esilprintf (op, "1,ctr,-=,$z,?{,lr,pc,=,}");
break;
case PPC_INS_BDZLRL:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->fail = addr + op->size;
break;
case PPC_INS_BLR:
case PPC_INS_BLRL:
case PPC_INS_BCLR:
case PPC_INS_BCLRL:
op->type = R_ANAL_OP_TYPE_CRET; //I'm a condret
op->type = RZ_ANAL_OP_TYPE_CRET; //I'm a condret
op->fail = addr + op->size;
switch (insn->detail->ppc.bc) {
case PPC_BC_INVALID:
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
esilprintf (op, "lr,pc,=");
break;
case PPC_BC_LT:
@@ -1116,136 +1116,136 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
}
break;
case PPC_INS_NOR:
op->type = R_ANAL_OP_TYPE_NOR;
op->type = RZ_ANAL_OP_TYPE_NOR;
esilprintf (op, "%s,%s,|,!,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_XOR:
case PPC_INS_XORI:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
esilprintf (op, "%s,%s,^,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_XORIS:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
esilprintf (op, "16,%s,<<,%s,^,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_DIVD:
case PPC_INS_DIVW:
op->sign = true;
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
esilprintf (op, "%s,%s,/,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_DIVDU:
case PPC_INS_DIVWU:
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
esilprintf (op, "%s,%s,/,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_BL:
case PPC_INS_BLA:
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = IMM (0);
op->fail = addr + op->size;
esilprintf (op, "pc,lr,=,%s,pc,=", ARG (0));
break;
case PPC_INS_TRAP:
op->sign = true;
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
break;
case PPC_INS_AND:
case PPC_INS_NAND:
case PPC_INS_ANDI:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
esilprintf (op, "%s,%s,&,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_ANDIS:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
esilprintf (op, "16,%s,<<,%s,&,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_OR:
case PPC_INS_ORI:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
esilprintf (op, "%s,%s,|,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_ORIS:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
esilprintf (op, "16,%s,<<,%s,|,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_MFPVR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "pvr,%s,=", ARG (0));
break;
case PPC_INS_MFSPR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "%s,%s,=", PPCSPR (1), ARG (0));
break;
case PPC_INS_MFCTR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "ctr,%s,=", ARG (0));
break;
case PPC_INS_MFDCCR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "dccr,%s,=", ARG (0));
break;
case PPC_INS_MFICCR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "iccr,%s,=", ARG (0));
break;
case PPC_INS_MFDEAR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "dear,%s,=", ARG (0));
break;
case PPC_INS_MFMSR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "msr,%s,=", ARG (0));
break;
case PPC_INS_MTCTR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "%s,ctr,=", ARG (0));
break;
case PPC_INS_MTDCCR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "%s,dccr,=", ARG (0));
break;
case PPC_INS_MTICCR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "%s,iccr,=", ARG (0));
break;
case PPC_INS_MTDEAR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "%s,dear,=", ARG (0));
break;
case PPC_INS_MTMSR:
case PPC_INS_MTMSRD:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
esilprintf (op, "%s,msr,=", ARG (0));
break;
// Data Cache Block Zero
case PPC_INS_DCBZ:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
esilprintf (op, "%s,%s", ARG (0), ARG2 (1, ",=[128]"));
break;
case PPC_INS_CLRLDI:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
esilprintf (op, "%s,%s,&,%s,=", ARG (1), cmask64 (ARG (2), "0x3F"), ARG (0));
break;
case PPC_INS_ROTLDI:
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
esilprintf (op, "%s,%s,<<<,%s,=", ARG (2), ARG (1), ARG (0));
break;
case PPC_INS_RLDCL:
case PPC_INS_RLDICL:
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
esilprintf (op, "%s,%s,<<<,%s,&,%s,=", ARG (2), ARG (1), cmask64 (ARG (3), "0x3F"), ARG (0));
break;
case PPC_INS_RLDCR:
case PPC_INS_RLDICR:
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
esilprintf (op, "%s,%s,<<<,%s,&,%s,=", ARG (2), ARG (1), cmask64 (0, ARG (3)), ARG (0));
break;
}
if (mask & R_ANAL_OP_MASK_VAL) {
if (mask & RZ_ANAL_OP_MASK_VAL) {
op_fillval (op, handle, insn);
}
if (!(mask & R_ANAL_OP_MASK_ESIL)) {
if (!(mask & RZ_ANAL_OP_MASK_ESIL)) {
rz_strbuf_fini (&op->esil);
}
cs_free (insn, n);
@@ -1281,10 +1281,10 @@ RzAnalPlugin rz_anal_plugin_ppc_cs = {
.set_reg_profile = &set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_ppc_cs,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+10 -10
View File
@@ -24,9 +24,9 @@ static int ppc_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *bytes, int l
//eprintf("OPCODE IS %08x : %02x (opcode=%d) baddr = %d\n", addr, bytes[0], opcode, baddr);
switch (opcode) {
// case 0: // bl op->type = R_ANAL_OP_TYPE_NOP; break;
// case 0: // bl op->type = RZ_ANAL_OP_TYPE_NOP; break;
case 11: // cmpi
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case 9: // pure branch
if (bytes[0] == 0x4e) {
@@ -40,19 +40,19 @@ static int ppc_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *bytes, int l
op->eob = 1;
break;
case 6: // bc // conditional jump
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = (aa)?(baddr):(addr+baddr+4);
op->eob = 1;
break;
#if 0
case 7: // sc/svc
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
break;
#endif
#if 0
case 15: // bl
// OK
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = (aa)?(baddr):(addr+baddr);
op->fail = addr+4;
op->eob = 1;
@@ -60,13 +60,13 @@ static int ppc_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *bytes, int l
#endif
case 8: // bne i tal
// OK
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = (aa)?(baddr):(addr+baddr+4);
op->fail = addr+4;
op->eob = 1;
break;
case 19: // bclr/bcr/bcctr/bcc
op->type = R_ANAL_OP_TYPE_RET; // jump to LR
op->type = RZ_ANAL_OP_TYPE_RET; // jump to LR
if (lk) {
op->jump = 0xFFFFFFFF; // LR ?!?
op->fail = addr+4;
@@ -151,11 +151,11 @@ RzAnalPlugin rz_anal_plugin_ppc_gnu = {
.set_reg_profile = &set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_ppc_gnu,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+13 -13
View File
@@ -31,31 +31,31 @@ static int propeller_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, i
case PROP_TJZ:
case PROP_CMPS:
case PROP_CMPSUB:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case PROP_ADD:
case PROP_ADDX:
case PROP_ADDABS:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case PROP_OR:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case PROP_RCL:
case PROP_ROL:
case PROP_SHL:
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
break;
case PROP_RCR:
case PROP_ROR:
case PROP_SHR:
op->type = R_ANAL_OP_TYPE_ROR;
op->type = RZ_ANAL_OP_TYPE_ROR;
break;
case PROP_NEG:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case PROP_XOR:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case PROP_ABS:
case PROP_MINS:
@@ -72,27 +72,27 @@ static int propeller_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, i
case PROP_WAITVID:
case PROP_MUXC:
if (cmd.opcode == PROP_MOV && cmd.dst == 0x44 && cmd.src == 0x3c) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
} else {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
}
break;
case PROP_SUB:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case PROP_JMP:
case PROP_DJNZ:
if (cmd.immed == 0) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = 0x20 + cmd.src;
op->fail = addr + 2;
} else {
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
op->fail = addr + 2;
}
break;
default:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
}
+13 -13
View File
@@ -15,9 +15,9 @@ static int archinfo(RzAnal *anal, int query) {
}
switch (query) {
case R_ANAL_ARCHINFO_MIN_OP_SIZE:
case RZ_ANAL_ARCHINFO_MIN_OP_SIZE:
return (anal->bits == 16)? 1: 2;
case R_ANAL_ARCHINFO_MAX_OP_SIZE:
case RZ_ANAL_ARCHINFO_MAX_OP_SIZE:
return (anal->bits == 16)? 3: 2;
default:
return -1;
@@ -47,7 +47,7 @@ static int pyc_op(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *data, int len,
RzListIter *iter = NULL;
pyc_code_object *func = NULL, *t = NULL;
rz_list_foreach (cobjs, iter, t) {
if (R_BETWEEN (t->start_offset, addr, t->end_offset - 1)) { // addr in [start_offset, end_offset)
if (RZ_BETWEEN (t->start_offset, addr, t->end_offset - 1)) { // addr in [start_offset, end_offset)
func = t;
break;
}
@@ -61,7 +61,7 @@ static int pyc_op(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *data, int len,
ut8 op_code = data[0];
op->addr = addr;
op->sign = true;
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
op->id = op_code;
if (!ops || !pyc_opcodes_equal (ops, a->cpu)) {
@@ -72,7 +72,7 @@ static int pyc_op(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *data, int len,
bool is_python36 = a->bits == 8;
pyc_opcode_object *op_obj = &ops->opcodes[op_code];
if (!op_obj->op_name) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
op->size = 1;
goto anal_end;
}
@@ -92,29 +92,29 @@ static int pyc_op(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *data, int len,
}
if (op_obj->type & HASJABS) {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = func_base + oparg;
if (op_obj->type & HASCONDITION) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->fail = addr + ((is_python36)? 2: 3);
}
goto anal_end;
}
if (op_obj->type & HASJREL) {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = addr + oparg + ((is_python36)? 2: 3);
op->fail = addr + ((is_python36)? 2: 3);
if (op_obj->type & HASCONDITION) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
//op->fail = addr + ((is_python36)? 2: 3);
}
//goto anal_end;
}
if (op_obj->type & HASCOMPARE) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
goto anal_end;
}
@@ -146,10 +146,10 @@ RzAnalPlugin rz_anal_plugin_pyc = {
.fini = &finish,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_pyc,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+37 -37
View File
@@ -299,26 +299,26 @@ static int riscv_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
int xlen = anal->bits;
op->size = 4;
op->addr = addr;
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
if (len >= sizeof (ut64)) {
word = rz_read_ble64 (data, anal->big_endian);
} else if (len >= sizeof (ut32)) {
word = rz_read_ble16 (data, anal->big_endian);
} else {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
return -1;
}
struct riscv_opcode *o = get_opcode (word);
if (word == UT64_MAX) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
return -1;
}
if (!o || !o->name) {
return op->size;
}
if (mask & R_ANAL_OP_MASK_DISASM) {
if (mask & RZ_ANAL_OP_MASK_DISASM) {
op->mnemonic = strdup (o->name);
}
@@ -355,7 +355,7 @@ static int riscv_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
else if (!strncmp (name, "addi16sp", 8)) {
esilprintf (op, "%s,sp,+,%s,=", ARG (1), ARG (0));
if (!strcmp (ARG (0), riscv_gpr_names[X_SP])) {
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = rz_num_math (NULL, ARG (1));
}
} else if (!strncmp (name, "addw", 4)) {
@@ -367,7 +367,7 @@ static int riscv_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
esilprintf (op, "%s,%s,+,%s,=", ARG (2), ARG (1), ARG (0));
if (name[3] == 'i' && !strcmp (ARG (0), riscv_gpr_names[X_SP]) &&
!strcmp (ARG (1), riscv_gpr_names[X_SP])) {
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = -(signed)rz_num_math (NULL, ARG (2));
}
} else if (!strncmp (name, "subw", 4)) {
@@ -379,7 +379,7 @@ static int riscv_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
esilprintf (op, "%s,%s,-,%s,=", ARG (2), ARG (1), ARG (0));
if (name[3] == 'i' && !strcmp (ARG (0), riscv_gpr_names[X_SP]) &&
!strcmp (ARG (1), riscv_gpr_names[X_SP])) {
op->stackop = R_ANAL_STACK_INC;
op->stackop = RZ_ANAL_STACK_INC;
op->stackptr = rz_num_math (NULL, ARG (2));
}
} else if (!strncmp (name, "mulw", 4)) {
@@ -544,76 +544,76 @@ static int riscv_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
if (is_any ("jal")) {
// decide whether it's jump or call
int rd = (word >> OP_SH_RD) & OP_MASK_RD;
op->type = (rd == 0) ? R_ANAL_OP_TYPE_JMP: R_ANAL_OP_TYPE_CALL;
op->type = (rd == 0) ? RZ_ANAL_OP_TYPE_JMP: RZ_ANAL_OP_TYPE_CALL;
op->jump = EXTRACT_UJTYPE_IMM (word) + addr;
op->fail = addr + op->size;
} else if (is_any ("c.jal")) {
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = EXTRACT_RVC_IMM (word) + addr;
op->fail = addr + op->size;
} else if (is_any ("jr")) {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
} else if (is_any ("c.j", "jump")) {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = EXTRACT_RVC_J_IMM (word) + addr;
} else if (is_any ("jalr")) {
// decide whether it's ret or call
int rd = (word >> OP_SH_RD) & OP_MASK_RD;
op->type = (rd == 0) ? R_ANAL_OP_TYPE_RET: R_ANAL_OP_TYPE_UCALL;
op->type = (rd == 0) ? RZ_ANAL_OP_TYPE_RET: RZ_ANAL_OP_TYPE_UCALL;
} else if (is_any ("c.jalr")) {
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
} else if (is_any ("c.jr")) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
} else if (is_any ("beqz", "beq", "blez", "bgez", "ble",
"bleu", "bge", "bgeu", "bltz", "bgtz", "blt", "bltu",
"bgt", "bgtu", "bnez", "bne")) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = EXTRACT_SBTYPE_IMM (word) + addr;
op->fail = addr + op->size;
} else if (is_any ("c.beqz", "c.bnez")) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = EXTRACT_RVC_B_IMM (word) + addr;
op->fail = addr + op->size;
// math
} else if (is_any ("addi", "addw", "addiw", "add", "auipc", "c.addi",
"c.addw", "c.add", "c.addi4spn", "c.addi16sp")) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
} else if (is_any ("c.mv")) {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
} else if (is_any ("subi", "subw", "sub", "c.sub")) {
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
} else if (is_any ("xori", "xor", "c.xor")) {
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
} else if (is_any ("andi", "and", "c.andi")) {
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
} else if (is_any ("ori", "or", "c.or")) {
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
} else if (is_any ("not")) {
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
} else if (is_any ("c.nop")) {
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
} else if (is_any ("mul", "mulh", "mulhu", "mulhsu", "mulw")) {
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
} else if (is_any ("div", "divu", "divw", "divuw")) {
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
} else if (is_any ("slli", "c.slli")) {
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
} else if (is_any ("srl", "c.srli")) {
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
} else if (is_any ("sra", "srai", "c.srai")) {
op->type = R_ANAL_OP_TYPE_SAR;
op->type = RZ_ANAL_OP_TYPE_SAR;
// memory
} else if (is_any ("sd", "sb", "sh", "sw", "c.sd", "c.sw",
"c.swsp")) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
} else if (is_any ("ld", "lw", "lwu", "lui", "li",
"lb", "lbu", "lh", "lhu", "la", "lla", "c.ld",
"c.lw", "c.lwsp", "c.li", "c.lui")) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
}
if (mask & R_ANAL_OP_MASK_VAL && args.num) {
if (mask & RZ_ANAL_OP_MASK_VAL && args.num) {
int i, j = 1;
op->dst = R_NEW0 (RzAnalValue);
op->dst = RZ_NEW0 (RzAnalValue);
char *argf = strdup (o->args);
char *comma = strtok (argf, ",");
if (comma && strchr (comma, '(')) {
@@ -626,7 +626,7 @@ static int riscv_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
op->dst->reg = rz_reg_get (anal->reg, args.arg[0], -1);
}
for (i = 0; j < args.num; i++, j++) {
op->src[i] = R_NEW0 (RzAnalValue);
op->src[i] = RZ_NEW0 (RzAnalValue);
comma = strtok (NULL, ",");
if (comma && strchr (comma, '(')) {
op->src[i]->delta = (st64)rz_num_get (NULL, args.arg[j]);
@@ -829,10 +829,10 @@ RzAnalPlugin rz_anal_plugin_riscv = {
.get_reg_profile = &get_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_riscv,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+51 -51
View File
@@ -36,20 +36,20 @@
#define SET_SRC_DST_3_REGS(op) \
CREATE_SRC_DST_3 (op);\
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), R_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), R_REG_TYPE_GPR);\
(op)->src[1]->reg = rz_reg_get (anal->reg, REG (2), R_REG_TYPE_GPR);
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), RZ_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), RZ_REG_TYPE_GPR);\
(op)->src[1]->reg = rz_reg_get (anal->reg, REG (2), RZ_REG_TYPE_GPR);
#define SET_SRC_DST_3_IMM(op) \
CREATE_SRC_DST_3 (op);\
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), R_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), R_REG_TYPE_GPR);\
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), RZ_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), RZ_REG_TYPE_GPR);\
(op)->src[1]->imm = IMM (2);
#define SET_SRC_DST_2_REGS(op) \
CREATE_SRC_DST_2 (op);\
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), R_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), R_REG_TYPE_GPR);
(op)->dst->reg = rz_reg_get (anal->reg, REG (0), RZ_REG_TYPE_GPR);\
(op)->src[0]->reg = rz_reg_get (anal->reg, REG (1), RZ_REG_TYPE_GPR);
#define SET_SRC_DST_3_REG_OR_IMM(op) \
if (OPERAND(2).type == RISCV_OP_IMM) {\
@@ -220,8 +220,8 @@ static int parse_reg_name(RzRegItem *reg, csh handle, cs_insn *insn, int reg_num
static void op_fillval(RzAnal *anal, RzAnalOp *op, csh *handle, cs_insn *insn) {
static RzRegItem reg;
switch (op->type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_LOAD:
switch (op->type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_LOAD:
if (OPERAND(1).type == RISCV_OP_MEM) {
ZERO_FILL (reg);
op->src[0] = rz_anal_value_new ();
@@ -230,7 +230,7 @@ static void op_fillval(RzAnal *anal, RzAnalOp *op, csh *handle, cs_insn *insn) {
op->src[0]->delta = OPERAND(1).mem.disp;
}
break;
case R_ANAL_OP_TYPE_STORE:
case RZ_ANAL_OP_TYPE_STORE:
if (OPERAND(1).type == RISCV_OP_MEM) {
ZERO_FILL (reg);
op->dst = rz_anal_value_new ();
@@ -239,20 +239,20 @@ static void op_fillval(RzAnal *anal, RzAnalOp *op, csh *handle, cs_insn *insn) {
op->dst->delta = OPERAND(1).mem.disp;
}
break;
case R_ANAL_OP_TYPE_SHL:
case R_ANAL_OP_TYPE_SHR:
case R_ANAL_OP_TYPE_SAR:
case R_ANAL_OP_TYPE_XOR:
case R_ANAL_OP_TYPE_SUB:
case R_ANAL_OP_TYPE_AND:
case R_ANAL_OP_TYPE_ADD:
case R_ANAL_OP_TYPE_OR:
case RZ_ANAL_OP_TYPE_SHL:
case RZ_ANAL_OP_TYPE_SHR:
case RZ_ANAL_OP_TYPE_SAR:
case RZ_ANAL_OP_TYPE_XOR:
case RZ_ANAL_OP_TYPE_SUB:
case RZ_ANAL_OP_TYPE_AND:
case RZ_ANAL_OP_TYPE_ADD:
case RZ_ANAL_OP_TYPE_OR:
SET_SRC_DST_3_REG_OR_IMM (op);
break;
case R_ANAL_OP_TYPE_MOV:
case RZ_ANAL_OP_TYPE_MOV:
SET_SRC_DST_3_REG_OR_IMM (op);
break;
case R_ANAL_OP_TYPE_DIV: // UDIV
case RZ_ANAL_OP_TYPE_DIV: // UDIV
#if 0
capstone bug
------------
@@ -295,21 +295,21 @@ capstone bug
}
static void set_opdir(RzAnalOp *op) {
switch (op->type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_LOAD:
op->direction = R_ANAL_OP_DIR_READ;
switch (op->type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_LOAD:
op->direction = RZ_ANAL_OP_DIR_READ;
break;
case R_ANAL_OP_TYPE_STORE:
op->direction = R_ANAL_OP_DIR_WRITE;
case RZ_ANAL_OP_TYPE_STORE:
op->direction = RZ_ANAL_OP_DIR_WRITE;
break;
case R_ANAL_OP_TYPE_LEA:
op->direction = R_ANAL_OP_DIR_REF;
case RZ_ANAL_OP_TYPE_LEA:
op->direction = RZ_ANAL_OP_DIR_REF;
break;
case R_ANAL_OP_TYPE_CALL:
case R_ANAL_OP_TYPE_JMP:
case R_ANAL_OP_TYPE_UJMP:
case R_ANAL_OP_TYPE_UCALL:
op->direction = R_ANAL_OP_DIR_EXEC;
case RZ_ANAL_OP_TYPE_CALL:
case RZ_ANAL_OP_TYPE_JMP:
case RZ_ANAL_OP_TYPE_UJMP:
case RZ_ANAL_OP_TYPE_UCALL:
op->direction = RZ_ANAL_OP_DIR_EXEC;
break;
default:
break;
@@ -350,42 +350,42 @@ static int analop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int len
opsize = op->size = insn->size;
switch (insn->id) {
case RISCV_INS_C_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case RISCV_INS_INVALID:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case RISCV_INS_C_JALR:
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
break;
case RISCV_INS_C_JR:
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
break;
case RISCV_INS_C_MV:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case RISCV_INS_JAL:
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = IMM(0);
op->fail = op->addr + op->size;
break;
case RISCV_INS_MRET:
case RISCV_INS_SRET:
case RISCV_INS_URET:
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
}
beach:
set_opdir (op);
if (insn && mask & R_ANAL_OP_MASK_OPEX) {
if (insn && mask & RZ_ANAL_OP_MASK_OPEX) {
opex (&op->opex, hndl, insn);
}
if (mask & R_ANAL_OP_MASK_ESIL) {
if (mask & RZ_ANAL_OP_MASK_ESIL) {
if (analop_esil (anal, op, addr, buf, len, &hndl, insn) != 0) {
rz_strbuf_fini (&op->esil);
}
}
if (mask & R_ANAL_OP_MASK_VAL) {
if (mask & RZ_ANAL_OP_MASK_VAL) {
op_fillval (anal, op, &hndl, insn);
}
cs_free (insn, n);
@@ -572,11 +572,11 @@ static char *get_reg_profile(RzAnal *anal) {
static int archinfo(RzAnal *anal, int q) {
switch (q) {
case R_ANAL_ARCHINFO_ALIGN:
case RZ_ANAL_ARCHINFO_ALIGN:
return 4;
case R_ANAL_ARCHINFO_MAX_OP_SIZE:
case RZ_ANAL_ARCHINFO_MAX_OP_SIZE:
return 4;
case R_ANAL_ARCHINFO_MIN_OP_SIZE:
case RZ_ANAL_ARCHINFO_MIN_OP_SIZE:
if (anal->bits == 64) {
return 4;
}
@@ -597,20 +597,20 @@ RzAnalPlugin rz_anal_plugin_riscv_cs = {
.op = &analop,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_riscv_cs,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
#else
RzAnalPlugin rz_anal_plugin_riscv_cs = {0};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.version = R2_VERSION
.type = RZ_LIB_TYPE_ANAL,
.version = RZ_VERSION
};
#endif
#endif
+134 -134
View File
@@ -29,7 +29,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
return 4;
}
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
op->size = 4;
op->addr = addr;
rz_strbuf_set (&op->esil, "TODO");
@@ -45,7 +45,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
switch (rz_instr.operands[i].type) {
case RSP_OPND_GP_REG:
snprintf (parsed_operands[i].esil, sizeof (parsed_operands[i].esil), "%s", rsp_gp_reg_soft_names[rz_instr.operands[i].u]);
parsed_operands[i].value->reg = rz_reg_get (anal->reg, rsp_gp_reg_soft_names[rz_instr.operands[i].u], R_REG_TYPE_GPR);
parsed_operands[i].value->reg = rz_reg_get (anal->reg, rsp_gp_reg_soft_names[rz_instr.operands[i].u], RZ_REG_TYPE_GPR);
break;
case RSP_OPND_ZIMM:
case RSP_OPND_SHIFT_AMOUNT:
@@ -59,7 +59,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
case RSP_OPND_BASE_OFFSET:
snprintf (parsed_operands[i].esil, sizeof (parsed_operands[i].esil),
"%"PFMT64d",%s,+", rz_instr.operands[i].s, rsp_gp_reg_soft_names[rz_instr.operands[i].u]);
parsed_operands[i].value->reg = rz_reg_get (anal->reg, rsp_gp_reg_soft_names[rz_instr.operands[i].u], R_REG_TYPE_GPR);
parsed_operands[i].value->reg = rz_reg_get (anal->reg, rsp_gp_reg_soft_names[rz_instr.operands[i].u], RZ_REG_TYPE_GPR);
parsed_operands[i].value->imm = rz_instr.operands[i].s;
break;
case RSP_OPND_OFFSET:
@@ -74,7 +74,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
break;
case RSP_OPND_C0_REG:
snprintf (parsed_operands[i].esil, sizeof (parsed_operands[i].esil), "%s", rsp_c0_reg_names[rz_instr.operands[i].u]);
parsed_operands[i].value->reg = rz_reg_get (anal->reg, rsp_c0_reg_names[rz_instr.operands[i].u], R_REG_TYPE_GPR);
parsed_operands[i].value->reg = rz_reg_get (anal->reg, rsp_c0_reg_names[rz_instr.operands[i].u], RZ_REG_TYPE_GPR);
break;
case RSP_OPND_C2_CREG:
case RSP_OPND_C2_ACCU:
@@ -89,18 +89,18 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
switch (rz_instr.opcode) {
case RSP_OP_INVALID:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case RSP_OP_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
rz_strbuf_set (&op->esil, ",");
break;
case RSP_OP_BREAK:
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
// TODO
break;
case RSP_OP_LUI:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
rz_strbuf_setf (&op->esil, "%s,%s,=", parsed_operands[1].esil, parsed_operands[0].esil);
@@ -109,7 +109,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
case RSP_OP_ADDU:
case RSP_OP_ADDI:
case RSP_OP_ADDIU:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[1] = parsed_operands[2].value;
@@ -117,7 +117,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
break;
case RSP_OP_SUB:
case RSP_OP_SUBU:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[1] = parsed_operands[2].value;
@@ -125,7 +125,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
break;
case RSP_OP_AND:
case RSP_OP_ANDI:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[1] = parsed_operands[2].value;
@@ -133,7 +133,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
break;
case RSP_OP_OR:
case RSP_OP_ORI:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[1] = parsed_operands[2].value;
@@ -141,14 +141,14 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
break;
case RSP_OP_XOR:
case RSP_OP_XORI:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[1] = parsed_operands[2].value;
rz_strbuf_setf (&op->esil, "%s,%s,^,%s,=", parsed_operands[2].esil, parsed_operands[1].esil, parsed_operands[0].esil);
break;
case RSP_OP_NOR:
op->type = R_ANAL_OP_TYPE_NOR;
op->type = RZ_ANAL_OP_TYPE_NOR;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[1] = parsed_operands[2].value;
@@ -156,7 +156,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
break;
case RSP_OP_SLL:
case RSP_OP_SLLV:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[1] = parsed_operands[2].value;
@@ -164,7 +164,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
break;
case RSP_OP_SRL:
case RSP_OP_SRLV:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[1] = parsed_operands[2].value;
@@ -172,7 +172,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
break;
case RSP_OP_SRA:
case RSP_OP_SRAV:
op->type = R_ANAL_OP_TYPE_SAR;
op->type = RZ_ANAL_OP_TYPE_SAR;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[1] = parsed_operands[2].value;
@@ -182,118 +182,118 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
case RSP_OP_SLTU:
case RSP_OP_SLTI:
case RSP_OP_SLTIU:
op->type = R_ANAL_OP_TYPE_CMOV;
op->cond = R_ANAL_COND_LT;
op->type = RZ_ANAL_OP_TYPE_CMOV;
op->cond = RZ_ANAL_COND_LT;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[1] = parsed_operands[2].value;
rz_strbuf_setf (&op->esil, "%s,%s,<,$z,?{,1,%s,=,}{,0,%s,=,}", parsed_operands[2].esil, parsed_operands[1].esil, parsed_operands[0].esil, parsed_operands[0].esil);
break;
case RSP_OP_J:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
rz_strbuf_setf (&op->esil, "%s,PC,=", parsed_operands[0].esil);
break;
case RSP_OP_JAL:
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
rz_strbuf_setf (&op->esil, "%s,PC,=,0x%08x,RA,=", parsed_operands[0].esil, op->fail);
break;
case RSP_OP_JR:
/* if register is RA, this is a return */
op->type = (rz_instr.operands[0].u == 29)
? R_ANAL_OP_TYPE_RET
: R_ANAL_OP_TYPE_UJMP;
? RZ_ANAL_OP_TYPE_RET
: RZ_ANAL_OP_TYPE_UJMP;
op->delay = 1;
op->eob = 1;
op->fail = rsp_mem_addr (addr + 8, RSP_IMEM_OFFSET);
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
rz_strbuf_setf (&op->esil, "%s,PC,=", parsed_operands[0].esil);
break;
case RSP_OP_BEQ:
op->type = R_ANAL_OP_TYPE_CJMP;
op->cond = R_ANAL_COND_EQ;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->cond = RZ_ANAL_COND_EQ;
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
op->src[1] = parsed_operands[1].value;
rz_strbuf_setf (&op->esil, "%s,%s,==,$z,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil, parsed_operands[2].esil);
break;
case RSP_OP_BNE:
op->type = R_ANAL_OP_TYPE_CJMP;
op->cond = R_ANAL_COND_NE;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->cond = RZ_ANAL_COND_NE;
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
op->src[1] = parsed_operands[1].value;
rz_strbuf_setf (&op->esil, "%s,%s,==,$z,!,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil, parsed_operands[2].esil);
break;
case RSP_OP_BLEZ:
op->type = R_ANAL_OP_TYPE_CJMP;
op->cond = R_ANAL_COND_LE;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->cond = RZ_ANAL_COND_LE;
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
op->src[1] = parsed_operands[1].value;
rz_strbuf_setf (&op->esil, "%s,!,%s,0x80000000,&,!,!,|,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[0].esil, parsed_operands[1].esil);
// rz_strbuf_setf (&op->esil, "0,%s,<=,$z,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil);
break;
case RSP_OP_BGTZ:
op->type = R_ANAL_OP_TYPE_CJMP;
op->cond = R_ANAL_COND_GT;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->cond = RZ_ANAL_COND_GT;
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
op->src[1] = parsed_operands[1].value;
rz_strbuf_setf (&op->esil, "%s,0x80000000,&,!,%s,!,!,&,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[0].esil, parsed_operands[1].esil);
// rz_strbuf_setf (&op->esil, "0,%s,>,$z,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil);
break;
case RSP_OP_BLTZ:
op->type = R_ANAL_OP_TYPE_CJMP;
op->cond = R_ANAL_COND_LT;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->cond = RZ_ANAL_COND_LT;
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
op->src[1] = parsed_operands[1].value;
rz_strbuf_setf (&op->esil, "%s,0x80000000,&,!,!,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil);
// rz_strbuf_setf (&op->esil, "0,%s,<,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil);
break;
case RSP_OP_BGEZ:
op->type = R_ANAL_OP_TYPE_CJMP;
op->cond = R_ANAL_COND_GE;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->cond = RZ_ANAL_COND_GE;
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
op->src[1] = parsed_operands[1].value;
rz_strbuf_setf (&op->esil, "%s,0x80000000,&,!,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil);
// rz_strbuf_setf (&op->esil, "0,%s,>=,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil);
break;
case RSP_OP_BLTZAL:
op->type = R_ANAL_OP_TYPE_CCALL;
op->cond = R_ANAL_COND_LT;
op->type = RZ_ANAL_OP_TYPE_CCALL;
op->cond = RZ_ANAL_COND_LT;
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
op->src[1] = parsed_operands[1].value;
// TODO
break;
case RSP_OP_BGEZAL:
op->type = R_ANAL_OP_TYPE_CCALL;
op->cond = R_ANAL_COND_GE;
op->type = RZ_ANAL_OP_TYPE_CCALL;
op->cond = RZ_ANAL_COND_GE;
op->dst = rz_anal_value_new ();
op->dst->reg = rz_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
op->dst->reg = rz_reg_get (anal->reg, "PC", RZ_REG_TYPE_GPR);
op->src[0] = parsed_operands[0].value;
op->src[1] = parsed_operands[1].value;
// TODO
break;
case RSP_OP_LB:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[0]->memref = op->refptr = 1;
@@ -301,7 +301,7 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
rz_strbuf_setf (&op->esil, "%s,[1],%s,=", parsed_operands[1].esil, parsed_operands[0].esil);
break;
case RSP_OP_LH:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[0]->memref = op->refptr = 2;
@@ -309,267 +309,267 @@ static int rsp_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *b, int len,
rz_strbuf_setf (&op->esil, "%s,[2],%s,=", parsed_operands[1].esil, parsed_operands[0].esil);
break;
case RSP_OP_LW:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[0]->memref = op->refptr = 4;
rz_strbuf_setf (&op->esil, "%s,[4],%s,=", parsed_operands[1].esil, parsed_operands[0].esil);
break;
case RSP_OP_LBU:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[0]->memref = op->refptr = 1;
rz_strbuf_setf (&op->esil, "%s,[1],%s,=", parsed_operands[1].esil, parsed_operands[0].esil);
break;
case RSP_OP_LHU:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
op->src[0]->memref = op->refptr = 2;
rz_strbuf_setf (&op->esil, "%s,[2],%s,=", parsed_operands[1].esil, parsed_operands[0].esil);
break;
case RSP_OP_SB:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = parsed_operands[0].value;
op->dst = parsed_operands[1].value;
op->dst->memref = op->refptr = 1;
rz_strbuf_setf (&op->esil, "%s,%s,=[1]", parsed_operands[0].esil, parsed_operands[1].esil);
break;
case RSP_OP_SH:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = parsed_operands[0].value;
op->dst = parsed_operands[1].value;
op->dst->memref = op->refptr = 2;
rz_strbuf_setf (&op->esil, "%s,%s,=[2]", parsed_operands[0].esil, parsed_operands[1].esil);
break;
case RSP_OP_SW:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = parsed_operands[0].value;
op->dst = parsed_operands[1].value;
op->dst->memref = op->refptr = 4;
rz_strbuf_setf (&op->esil, "%s,%s,=[4]", parsed_operands[0].esil, parsed_operands[1].esil);
break;
case RSP_OP_MFC0:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->dst = parsed_operands[0].value;
op->src[0] = parsed_operands[1].value;
rz_strbuf_setf (&op->esil, "%s,%s,=", parsed_operands[1].esil, parsed_operands[0].esil);
break;
case RSP_OP_MTC0:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->src[0] = parsed_operands[0].value;
op->dst = parsed_operands[1].value;
rz_strbuf_setf (&op->esil, "%s,%s,=", parsed_operands[0].esil, parsed_operands[1].esil);
break;
case RSP_OP_MFC2:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->dst = parsed_operands[0].value;
//op->src[0] = parsed_operands[1].value;
break;
case RSP_OP_MTC2:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->src[0] = parsed_operands[0].value;
//op->dst = parsed_operands[1].value;
break;
case RSP_OP_CFC2:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case RSP_OP_CTC2:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case RSP_OP_VMULF:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMULU:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMUDL:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMUDM:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMUDN:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMUDH:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMACF:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMACU:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMADL:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMADM:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMADN:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VMADH:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case RSP_OP_VADD:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case RSP_OP_VSUB:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case RSP_OP_VABS:
op->type = R_ANAL_OP_TYPE_ABS;
op->type = RZ_ANAL_OP_TYPE_ABS;
break;
case RSP_OP_VADDC:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case RSP_OP_VSUBC:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case RSP_OP_VSAR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case RSP_OP_VLT:
op->type = R_ANAL_OP_TYPE_CMP;
op->cond = R_ANAL_COND_LT;
op->type = RZ_ANAL_OP_TYPE_CMP;
op->cond = RZ_ANAL_COND_LT;
break;
case RSP_OP_VEQ:
op->type = R_ANAL_OP_TYPE_CMP;
op->cond = R_ANAL_COND_EQ;
op->type = RZ_ANAL_OP_TYPE_CMP;
op->cond = RZ_ANAL_COND_EQ;
break;
case RSP_OP_VNE:
op->type = R_ANAL_OP_TYPE_CMP;
op->cond = R_ANAL_COND_NE;
op->type = RZ_ANAL_OP_TYPE_CMP;
op->cond = RZ_ANAL_COND_NE;
break;
case RSP_OP_VGE:
op->type = R_ANAL_OP_TYPE_CMP;
op->cond = R_ANAL_COND_GE;
op->type = RZ_ANAL_OP_TYPE_CMP;
op->cond = RZ_ANAL_COND_GE;
break;
case RSP_OP_VCL:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case RSP_OP_VCH:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case RSP_OP_VCR:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case RSP_OP_VMRG:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case RSP_OP_VAND:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case RSP_OP_VNAND:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case RSP_OP_VOR:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case RSP_OP_VNOR:
op->type = R_ANAL_OP_TYPE_NOR;
op->type = RZ_ANAL_OP_TYPE_NOR;
break;
case RSP_OP_VXOR:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case RSP_OP_VNXOR:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
case RSP_OP_VRCP:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case RSP_OP_VRCPL:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case RSP_OP_VRCPH:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case RSP_OP_VMOV:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case RSP_OP_VRSQ:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case RSP_OP_VRSQL:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case RSP_OP_VRSQH:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case RSP_OP_VNOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case RSP_OP_LBV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_LSV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_LLV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_LDV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_LQV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_LRV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_LPV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_LUV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_LHV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_LFV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_LTV:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case RSP_OP_SBV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_SSV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_SLV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_SDV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_SQV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_SRV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_SPV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_SUV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_SHV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_SFV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_SWV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case RSP_OP_STV:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
default: break;
}
@@ -698,10 +698,10 @@ RzAnalPlugin rz_anal_plugin_rsp = {
.get_reg_profile = &get_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_rsp,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+145 -145
View File
@@ -207,7 +207,7 @@ static char *regs[]={"r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","r10","r1
static RzAnalValue *anal_fill_ai_rg(RzAnal *anal, int idx) {
RzAnalValue *ret = rz_anal_value_new ();
ret->reg = rz_reg_get (anal->reg, regs[idx], R_REG_TYPE_GPR);
ret->reg = rz_reg_get (anal->reg, regs[idx], RZ_REG_TYPE_GPR);
return ret;
}
@@ -235,7 +235,7 @@ static RzAnalValue *anal_fill_reg_ref(RzAnal *anal, int reg, st64 size) {
/* @(R0,Rx) references for all sizes */
static RzAnalValue *anal_fill_r0_reg_ref(RzAnal *anal, int reg, st64 size) {
RzAnalValue *ret = anal_fill_ai_rg (anal, 0);
ret->regdelta = rz_reg_get (anal->reg, regs[reg], R_REG_TYPE_GPR);
ret->regdelta = rz_reg_get (anal->reg, regs[reg], RZ_REG_TYPE_GPR);
ret->memref = size;
return ret;
}
@@ -257,7 +257,7 @@ static RzAnalValue *anal_pcrel_disp_mov(RzAnal* anal, RzAnalOp* op, ut8 disp, in
//= PC+4+R<reg>
static RzAnalValue *anal_regrel_jump(RzAnal* anal, RzAnalOp* op, ut8 reg) {
RzAnalValue *ret = rz_anal_value_new ();
ret->reg = rz_reg_get (anal->reg, regs[reg], R_REG_TYPE_GPR);
ret->reg = rz_reg_get (anal->reg, regs[reg], RZ_REG_TYPE_GPR);
ret->base = op->addr + 4;
return ret;
}
@@ -266,99 +266,99 @@ static RzAnalValue *anal_regrel_jump(RzAnal* anal, RzAnalOp* op, ut8 reg) {
static int first_nibble_is_0(RzAnal* anal, RzAnalOp* op, ut16 code) { //STOP
if (IS_BSRF (code)) {
/* Call 'far' subroutine Rn+PC+4 */
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
op->delay = 1;
op->dst = anal_regrel_jump (anal, op, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "1,SETD,pc,2,+,pr,=,r%d,2,+,pc,+=", GET_TARGET_REG (code));
} else if (IS_BRAF (code)) {
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
op->dst = anal_regrel_jump (anal, op, GET_TARGET_REG (code));
op->eob = true;
op->delay = 1;
rz_strbuf_setf (&op->esil, "1,SETD,r%d,2,+,pc,+=", GET_TARGET_REG (code));
} else if (IS_RTS (code)) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->delay = 1;
op->eob = true;
rz_strbuf_setf (&op->esil, "pr,pc,=");
} else if (IS_RTE (code)) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->delay = 1;
op->eob = true;
//rz_strbuf_setf (&op->esil, "1,SETD,r15,[4],4,+,pc,=,r15,4,+,[4],0xFFF0FFF,&,sr,=,8,r15,+=");
//not sure if should be added 4 to pc
rz_strbuf_setf (&op->esil, "1,SETD,r15,[4],pc,=,r15,4,+,[4],0xFFF0FFF,&,sr,=,8,r15,+=");
} else if (IS_MOVB_REG_TO_R0REL (code)) { //0000nnnnmmmm0100 mov.b <REG_M>,@(R0,<REG_N>)
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_r0_reg_ref (anal, GET_TARGET_REG (code), BYTE_SIZE);
rz_strbuf_setf (&op->esil, "r%d,0xFF,&,r0,r%d,+,=[1]", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_MOVW_REG_TO_R0REL (code)) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_r0_reg_ref (anal, GET_TARGET_REG (code), WORD_SIZE);
rz_strbuf_setf (&op->esil, "r%d,0xFFFF,&,r0,r%d,+,=[2]", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_MOVL_REG_TO_R0REL (code)) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_r0_reg_ref(anal, GET_TARGET_REG (code), LONG_SIZE);
rz_strbuf_setf (&op->esil, "r%d,r0,r%d,+,=[4]", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_MOVB_R0REL_TO_REG (code)) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->src[0] = anal_fill_r0_reg_ref (anal, GET_SOURCE_REG (code), BYTE_SIZE);
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r0,r%d,+,[1],r%d,=,0x000000FF,r%d,&=,r%d,0x80,&,?{,0xFFFFFF00,r%d,|=,}", GET_SOURCE_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
} else if (IS_MOVW_R0REL_TO_REG (code)) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->src[0] = anal_fill_r0_reg_ref (anal, GET_SOURCE_REG (code), WORD_SIZE);
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r0,r%d,+,[2],r%d,=,0x0000FFFF,r%d,&=,r%d,0x8000,&,?{,0xFFFF0000,r%d,|=,}", GET_SOURCE_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
} else if (IS_MOVL_R0REL_TO_REG (code)) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->src[0] = anal_fill_r0_reg_ref (anal, GET_SOURCE_REG (code), LONG_SIZE);
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r0,r%d,+,[4],r%d,=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_NOP (code)) {
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
rz_strbuf_setf (&op->esil, " ");
} else if (IS_CLRT (code)) {
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=");
} else if (IS_SETT (code)) {
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
rz_strbuf_setf (&op->esil, "0x1,sr,|=");
} else if (IS_CLRMAC (code)) {
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
rz_strbuf_setf (&op->esil, "0,mach,=,0,macl,=");
} else if (IS_DIV0U (code)) {
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
rz_strbuf_setf (&op->esil, "0xFFFFFCFE,sr,&=");
} else if (IS_MOVT (code)) {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "0x1,sr,&,r%d,=", GET_TARGET_REG (code));
} else if (IS_MULL (code)) { //multiply long
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
op->src[0] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
rz_strbuf_setf (&op->esil, "r%d,r%d,*,macl,=", GET_TARGET_REG (code), GET_SOURCE_REG (code));
} else if (IS_SLEEP (code)) {
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
rz_strbuf_setf (&op->esil, "sleep_called,TRAP", GET_TARGET_REG (code));
} else if (IS_STSMACH (code)) { //0000nnnn0000101_ sts MAC*,<REG_N>
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "mach,r%d,=", GET_TARGET_REG (code));
} else if (IS_STSMACL (code)) { //0000nnnn0000101_ sts MAC*,<REG_N>
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "macl,r%d,=", GET_TARGET_REG (code));
} else if (IS_STSLMACL (code)) {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "macl,r%d,=", GET_TARGET_REG (code));
} else if (IS_STCSR1 (code)) { //0000nnnn00010010 stc {sr,gbr,vbr,ssr},<REG_N>
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
//todo: plug in src
switch(GET_SOURCE_REG (code)) {
@@ -377,7 +377,7 @@ static int first_nibble_is_0(RzAnal* anal, RzAnalOp* op, ut16 code) { //STOP
}
} else if (IS_STSPR (code)) { //0000nnnn00101010 sts PR,<REG_N>
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "pr,r%d,=", GET_TARGET_REG (code));
} else if (IS_MACL (code)) {
@@ -406,14 +406,14 @@ static int first_nibble_is_0(RzAnal* anal, RzAnalOp* op, ut16 code) { //STOP
, GET_TARGET_REG (code), GET_SOURCE_REG (code),
GET_TARGET_REG (code), GET_SOURCE_REG (code),
GET_TARGET_REG (code), GET_SOURCE_REG (code));
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
}
return op->size;
}
//nibble=1; 0001nnnnmmmmi4*4 mov.l <REG_M>,@(<disp>,<REG_N>)
static int movl_reg_rdisp(RzAnal* anal, RzAnalOp* op, ut16 code) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_reg_disp_mem (anal, GET_TARGET_REG (code), code & 0x0F, LONG_SIZE);
rz_strbuf_setf (&op->esil, "r%d,r%d,0x%x,+,=[4]", GET_SOURCE_REG (code), GET_TARGET_REG (code), (code & 0xF) << 2);
@@ -422,68 +422,68 @@ static int movl_reg_rdisp(RzAnal* anal, RzAnalOp* op, ut16 code) {
static int first_nibble_is_2(RzAnal* anal, RzAnalOp* op, ut16 code) {
if (IS_MOVB_REG_TO_REGREF (code)) { // 0010nnnnmmmm0000 mov.b <REG_M>,@<REG_N>
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_reg_ref (anal, GET_TARGET_REG (code), BYTE_SIZE);
rz_strbuf_setf (&op->esil, "r%d,r%d,=[1]", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_MOVW_REG_TO_REGREF (code)) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_reg_ref (anal, GET_TARGET_REG (code), WORD_SIZE);
rz_strbuf_setf (&op->esil, "r%d,r%d,=[2]", GET_SOURCE_REG (code) & 0xFF, GET_TARGET_REG (code));
} else if (IS_MOVL_REG_TO_REGREF (code)) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_reg_ref (anal, GET_TARGET_REG (code), LONG_SIZE);
rz_strbuf_setf (&op->esil, "r%d,r%d,=[4]", GET_SOURCE_REG (code) & 0xFF, GET_TARGET_REG (code));
} else if (IS_AND_REGS (code)) {
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,r%d,&=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_XOR_REGS (code)) {
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,r%d,^=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_OR_REGS (code)) {
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,r%d,|=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_PUSHB (code)) {
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
rz_strbuf_setf (&op->esil, "1,r%d,-=,r%d,r%d,=[1]", GET_TARGET_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_PUSHW (code)) {
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
rz_strbuf_setf (&op->esil, "2,r%d,-=,r%d,r%d,=[2]", GET_TARGET_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_PUSHL (code)) {
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
rz_strbuf_setf (&op->esil, "4,r%d,-=,r%d,r%d,=[4]", GET_TARGET_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_TSTRR (code)) {
op->type = R_ANAL_OP_TYPE_ACMP;
op->type = RZ_ANAL_OP_TYPE_ACMP;
rz_strbuf_setf (&op->esil, "1,sr,|=,r%d,r%d,&,?{,0xFFFFFFFE,sr,&=,}", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_CMPSTR (code)) { //0010nnnnmmmm1100 cmp/str <REG_M>,<REG_N>
op->type = R_ANAL_OP_TYPE_ACMP; //maybe not?
op->type = RZ_ANAL_OP_TYPE_ACMP; //maybe not?
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,24,r%d,r%d,^,>>,0xFF,&,!,?{,1,sr,|=,},16,r%d,r%d,^,>>,0xFF,&,!,?{,1,sr,|=,},8,r%d,r%d,^,>>,0xFF,&,!,?{,1,sr,|=,},r%d,r%d,^,0xFF,&,!,?{,1,sr,|=,}", GET_SOURCE_REG (code), GET_TARGET_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_XTRCT (code)) { //0010nnnnmmmm1101 xtrct <REG_M>,<REG_N>
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "16,r%d,0xFFFF,&,<<,16,r%d,0xFFFF0000,&,>>,|,r%d,=", GET_SOURCE_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
} else if (IS_DIV0S (code)) {
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
rz_strbuf_setf (&op->esil, "0xFFFFFCFE,sr,&=,r%d,0x80000000,&,?{,0x200,sr,|=,},r%d,0x80000000,&,?{,0x100,sr,|=,},sr,1,sr,<<,^,0x200,&,?{,1,sr,|=,}", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_MULUW (code)) {
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
op->src[0] = anal_fill_ai_rg(anal, GET_SOURCE_REG (code));
op->src[1] = anal_fill_ai_rg(anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,0xFFFF,&,r%d,0xFFFF,&,*,macl,=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_MULSW (code)) { //0010nnnnmmmm111_ mul{s,u}.w <REG_M>,<REG_N>
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
op->src[0] = anal_fill_ai_rg(anal, GET_SOURCE_REG (code));
op->src[1] = anal_fill_ai_rg(anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, S16_EXT("r%d") "," S16_EXT("r%d") ",*,macl,=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
@@ -496,62 +496,62 @@ static int first_nibble_is_2(RzAnal* anal, RzAnalOp* op, ut16 code) {
static int first_nibble_is_3(RzAnal* anal, RzAnalOp* op, ut16 code) {
//TODO Handle carry/overflow , CMP/xx?
if (IS_ADD (code)) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,r%d,+=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_ADDC (code)) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "sr,0x1,&,0xFFFFFFFE,sr,&=,r%d,+=,31,$c,sr,|,sr,:=,r%d,r%d,+=,31,$c,sr,|,sr,:=", GET_TARGET_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_ADDV (code)) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,r%d,+=,31,$o,sr,|=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_SUB (code)) {
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,r%d,-=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_SUBC (code)) {
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "sr,1,&," CLR_T ",r%d,-=,31,$b,sr,|,sr,:=,r%d,r%d,-=,31,$b,sr,|,sr,:=", GET_TARGET_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_SUBV (code)) {
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, CLR_T ",r%d,r%d,-=,31,$o,sr,|,sr,:=", GET_SOURCE_REG(code), GET_TARGET_REG (code));
} else if (IS_CMPEQ (code)) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
op->src[0] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&,r%d,r%d,^,!,|,sr,=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_CMPGE (code)) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
op->src[0] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,r%d,>=,?{,0x1,sr,|=,}", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_CMPGT (code)) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
op->src[0] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,r%d,>,?{,0x1,sr,|=,}", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_CMPHI (code)) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
op->src[0] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,0x100000000,+,r%d,0x100000000,+,>,?{,0x1,sr,|=,}", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_CMPHS (code)) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
op->src[0] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,0x100000000,+,r%d,0x100000000,+,>=,?{,0x1,sr,|=,}", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_DIV1 (code)) {
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
op->src[0] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
rz_strbuf_setf (&op->esil,
@@ -579,12 +579,12 @@ static int first_nibble_is_3(RzAnal* anal, RzAnalOp* op, ut16 code) {
GET_SOURCE_REG(code), GET_TARGET_REG (code),
GET_TARGET_REG (code));
} else if (IS_DMULU (code)) {
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "32,r%d,r%d,*,DUP,0xFFFFFFFF,&,macl,=,>>,mach,=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_DMULS (code)) {
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->src[1] = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "32,r%d,r%d,0x80000000,&,?{,0xFFFFFFFF00000000,+,},r%d,r%d,0x80000000,&,?{,0xFFFFFFFF00000000,+,},*,DUP,0xFFFFFFFF,&,macl,=,>>,mach,=", GET_SOURCE_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
@@ -597,140 +597,140 @@ static int first_nibble_is_3(RzAnal* anal, RzAnalOp* op, ut16 code) {
static int first_nibble_is_4(RzAnal* anal, RzAnalOp* op, ut16 code) {
switch(code & 0xF0FF) { //TODO: change to common } else if construction
case 0x4020: //shal
op->type = R_ANAL_OP_TYPE_SAL;
op->type = RZ_ANAL_OP_TYPE_SAL;
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,0x80000000,&,?{,0x1,sr,|=,},1,r%d,<<=", GET_TARGET_REG (code), GET_TARGET_REG (code));
break;
case 0x4021: //shar
op->type = R_ANAL_OP_TYPE_SAR;
op->type = RZ_ANAL_OP_TYPE_SAR;
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,0x1,&,?{,0x1,sr,|=,},0,r%d,0x80000000,&,?{,0x80000000,+,},1,r%d,>>=,r%d,|=", GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
break;
case 0x4000: //shll
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,0x80000000,&,?{,0x1,sr,|=,},1,r%d,<<=", GET_TARGET_REG (code), GET_TARGET_REG (code));
break;
case 0x4008: //shll2
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
rz_strbuf_setf (&op->esil, "2,r%d,<<=", GET_TARGET_REG (code));
break;
case 0x4018: //shll8
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
rz_strbuf_setf (&op->esil, "8,r%d,<<=", GET_TARGET_REG (code));
break;
case 0x4028: //shll16
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
rz_strbuf_setf (&op->esil, "16,r%d,<<=", GET_TARGET_REG (code));
break;
case 0x4001: //shlr
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,0x1,&,?{,0x1,sr,|=,},1,r%d,>>=", GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case 0x4009: //shlr2
rz_strbuf_setf (&op->esil, "2,r%d,>>=", GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case 0x4019: //shlr8
rz_strbuf_setf (&op->esil, "8,r%d,>>=", GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
case 0x4029: //shlr16
rz_strbuf_setf (&op->esil, "16,r%d,>>=", GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
default:
break;
}
if (IS_JSR (code)) {
// op->type = R_ANAL_OP_TYPE_UCALL; //call to reg
op->type = R_ANAL_OP_TYPE_RCALL; //call to reg
// op->type = RZ_ANAL_OP_TYPE_UCALL; //call to reg
op->type = RZ_ANAL_OP_TYPE_RCALL; //call to reg
op->delay = 1;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "1,SETD,pc,2,+,pr,=,r%d,pc,=", GET_TARGET_REG (code));
} else if (IS_JMP (code)) {
op->type = R_ANAL_OP_TYPE_UJMP; //jmp to reg
op->type = RZ_ANAL_OP_TYPE_UJMP; //jmp to reg
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->delay = 1;
op->eob = true;
rz_strbuf_setf (&op->esil, "1,SETD,r%d,pc,=", GET_TARGET_REG (code));
} else if (IS_CMPPL (code)) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,0,r%d,>,?{,0x1,sr,|=,}", GET_TARGET_REG (code));
} else if (IS_CMPPZ (code)) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,0,r%d,>=,?{,0x1,sr,|=,}", GET_TARGET_REG (code));
} else if (IS_LDCLSR (code)) {
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
rz_strbuf_setf (&op->esil, "r%d,[4],0x0FFF0FFF,&,sr,=,4,r%d,+=", GET_TARGET_REG (code), GET_TARGET_REG (code));
} else if (IS_LDCLSRGBR (code)) {
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
rz_strbuf_setf (&op->esil, "r%d,[4],gbr,=,4,r%d,+=", GET_TARGET_REG (code), GET_TARGET_REG (code));
} else if (IS_LDCLSRVBR (code)) {
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
rz_strbuf_setf (&op->esil, "r%d,[4],vbr,=,4,r%d,+=", GET_TARGET_REG (code), GET_TARGET_REG (code));
//todo ssr?
} else if (IS_LDSLMACH (code)) {
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
rz_strbuf_setf (&op->esil, "r%d,[4],mach,=,4,r%d,+=", GET_TARGET_REG (code), GET_TARGET_REG (code));
} else if (IS_LDSLMACL (code)) {
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
rz_strbuf_setf (&op->esil, "r%d,[4],macl,=,4,r%d,+=", GET_TARGET_REG (code), GET_TARGET_REG (code));
} else if (IS_LDSLPR (code)) {
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
rz_strbuf_setf (&op->esil, "r%d,[4],pr,=,4,r%d,+=", GET_TARGET_REG (code), GET_TARGET_REG (code));
} else if (IS_LDCSR (code)) {
rz_strbuf_setf (&op->esil, "r%d,0x0FFF0FFF,&,sr,=", GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
} else if (IS_LDCGBR (code)) {
rz_strbuf_setf (&op->esil, "r%d,gbr,=", GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
} else if (IS_LDCVBR (code)) {
rz_strbuf_setf (&op->esil, "r%d,vbr,=", GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
} else if (IS_LDSMACH (code)) {
rz_strbuf_setf (&op->esil, "r%d,mach,=", GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
} else if (IS_LDSMACL (code)) {
rz_strbuf_setf (&op->esil, "r%d,macl,=", GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
} else if (IS_LDSPR (code)) {
rz_strbuf_setf (&op->esil, "r%d,pr,=", GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
} else if (IS_ROTR (code)) {
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,0x1,&,sr,|=,0x1,r%d,>>>,r%d,=", GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = (code & 1)? R_ANAL_OP_TYPE_ROR:R_ANAL_OP_TYPE_ROL;
op->type = (code & 1)? RZ_ANAL_OP_TYPE_ROR:RZ_ANAL_OP_TYPE_ROL;
} else if (IS_ROTL (code)) {
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,0x1,r%d,<<<,r%d,=,r%d,0x1,&,sr,|=", GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = (code & 1)? R_ANAL_OP_TYPE_ROR:R_ANAL_OP_TYPE_ROL;
op->type = (code & 1)? RZ_ANAL_OP_TYPE_ROR:RZ_ANAL_OP_TYPE_ROL;
} else if (IS_ROTCR (code)) {
rz_strbuf_setf (&op->esil, "0,sr,0x1,&,?{,0x80000000,},0xFFFFFFFE,sr,&=,r%d,1,&,sr,|=,1,r%d,>>=,r%d,|=", GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = (code & 1)? R_ANAL_OP_TYPE_ROR:R_ANAL_OP_TYPE_ROL;
op->type = (code & 1)? RZ_ANAL_OP_TYPE_ROR:RZ_ANAL_OP_TYPE_ROL;
} else if (IS_ROTCL (code)) {
rz_strbuf_setf (&op->esil, "sr,0x1,&,0xFFFFFFFE,sr,&=,r%d,0x80000000,&,?{,1,sr,|=,},1,r%d,<<=,r%d,|=", GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = (code & 1)? R_ANAL_OP_TYPE_ROR:R_ANAL_OP_TYPE_ROL;
op->type = (code & 1)? RZ_ANAL_OP_TYPE_ROR:RZ_ANAL_OP_TYPE_ROL;
} else if (IS_STCLSR (code)) {
rz_strbuf_setf (&op->esil, "4,r%d,-=,sr,r%d,=[4]", GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
} else if (IS_STCLGBR (code)) {
rz_strbuf_setf (&op->esil, "4,r%d,-=,gbr,r%d,=[4]", GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
} else if (IS_STCLVBR (code)) {
rz_strbuf_setf (&op->esil, "4,r%d,-=,vbr,r%d,=[4]", GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
} else if (IS_STSLMACL (code)) {
rz_strbuf_setf (&op->esil, "4,r%d,-=,macl,r%d,=[4]", GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
} else if (IS_STSLMACH (code)) {
rz_strbuf_setf (&op->esil, "4,r%d,-=,mach,r%d,=[4]", GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
} else if (IS_STSLPR (code)) {
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
rz_strbuf_setf (&op->esil, "4,r%d,-=,pr,r%d,=[4]", GET_TARGET_REG (code), GET_TARGET_REG (code));
} else if (IS_TASB (code)) {
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r%d,[1],!,?{,0x80,r%d,=[1],1,sr,|=,}", GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
} else if (IS_DT (code)) {
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,1,r%d,-=,$z,sr,|,sr,:=", GET_TARGET_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
} else if (IS_MACW(code)){
rz_strbuf_setf (&op->esil,
"0x2,sr,&,!,?{," //if S==0
@@ -764,14 +764,14 @@ static int first_nibble_is_4(RzAnal* anal, RzAnalOp* op, ut16 code) {
GET_TARGET_REG (code), GET_SOURCE_REG (code),
GET_TARGET_REG (code), GET_SOURCE_REG (code),
GET_TARGET_REG (code), GET_SOURCE_REG (code));
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
}
return op->size;
}
//nibble=5; 0101nnnnmmmmi4*4 mov.l @(<disp>,<REG_M>),<REG_N>
static int movl_rdisp_reg(RzAnal* anal, RzAnalOp* op, ut16 code) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[0] = anal_fill_reg_disp_mem (anal, GET_SOURCE_REG (code), code & 0x0F, LONG_SIZE);
rz_strbuf_setf (&op->esil, "r%d,0x%x,+,[4],r%d,=", GET_SOURCE_REG (code), (code&0xF) * 4, GET_TARGET_REG (code));
@@ -781,28 +781,28 @@ static int movl_rdisp_reg(RzAnal* anal, RzAnalOp* op, ut16 code) {
static int first_nibble_is_6(RzAnal* anal, RzAnalOp* op, ut16 code) {
if (IS_MOV_REGS (code)) {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,r%d,=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_MOVB_REGREF_TO_REG (code)) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->src[0] = anal_fill_reg_ref (anal, GET_SOURCE_REG (code), BYTE_SIZE);
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "0x000000FF,r%d,&=,r%d,[1],DUP,0x80,&,?{,0xFFFFFF00,|=,},r%d,=", GET_TARGET_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_MOVW_REGREF_TO_REG (code)) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->src[0] = anal_fill_reg_ref (anal, GET_SOURCE_REG (code), WORD_SIZE);
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "0x0000FFFF,r%d,&=,r%d,[2],DUP,0x8000,&,?{,0xFFFF0000,|=,},r%d,=", GET_TARGET_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_MOVL_REGREF_TO_REG (code)) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->src[0] = anal_fill_reg_ref (anal, GET_SOURCE_REG (code), LONG_SIZE);
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,[4],r%d,=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
} else if (IS_EXT (code)) {
//ext{s,u}.{b,w} instructs. todo : more detail ?
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
switch(code & 0xF) {
@@ -823,41 +823,41 @@ static int first_nibble_is_6(RzAnal* anal, RzAnalOp* op, ut16 code) {
break;
}
} else if (IS_MOVB_POP (code)) {
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,[1],DUP,0x80,&,?{,0xFFFFFF00,|,},r%d,=,1,r%d,+=", GET_SOURCE_REG (code), GET_TARGET_REG (code), GET_SOURCE_REG (code));
} else if (IS_MOVW_POP (code)) {
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,[2],DUP,0x8000,&,?{,0xFFFF0000,|,},r%d,=,2,r%d,+=", GET_SOURCE_REG (code), GET_TARGET_REG (code), GET_SOURCE_REG (code));
} else if (IS_MOVL_POP (code)) {
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "r%d,[4],r%d,=,4,r%d,+=", GET_SOURCE_REG (code), GET_TARGET_REG (code), GET_SOURCE_REG (code));
} else if (IS_NEG (code)) {
//todo: neg and negc details
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
rz_strbuf_setf (&op->esil, "r%d,0,-,r%d,=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
} else if (IS_NEGC (code)) {
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
rz_strbuf_setf (&op->esil, "1,sr,&,0xFFFFFFFE,sr,&=,r%d,+,0,-,31,$b,sr,|,sr,=,r%d,=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
} else if (IS_NOT (code)) {
//todo : details?
rz_strbuf_setf (&op->esil, "0xFFFFFFFF,r%d,^,r%d,=", GET_SOURCE_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
} else if (IS_SWAPB (code)) {
rz_strbuf_setf (&op->esil, "r%d,0xFFFF0000,&,8,r%d,0xFF,&,<<,|,8,r%d,0xFF00,&,>>,|,r%d,=", GET_SOURCE_REG (code), GET_SOURCE_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
//todo : details
} else if (IS_SWAPW (code)) {
rz_strbuf_setf (&op->esil, "16,r%d,0xFFFF,&,<<,16,r%d,0xFFFF0000,&,>>,|,r%d,=", GET_SOURCE_REG (code), GET_SOURCE_REG (code), GET_TARGET_REG (code));
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
}
return op->size;
}
@@ -865,7 +865,7 @@ static int first_nibble_is_6(RzAnal* anal, RzAnalOp* op, ut16 code) {
//nibble=7; 0111nnnni8*1.... add #<imm>,<REG_N>
static int add_imm(RzAnal* anal, RzAnalOp* op, ut16 code) {
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
op->src[0] = anal_fill_im (anal, (st8)(code & 0xFF)); //Casting to (st8) forces sign-extension.
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
rz_strbuf_setf (&op->esil, "0x%x,DUP,0x80,&,?{,0xFFFFFF00,|,},r%d,+=", code & 0xFF, GET_TARGET_REG (code));
@@ -874,7 +874,7 @@ static int add_imm(RzAnal* anal, RzAnalOp* op, ut16 code) {
static int first_nibble_is_8(RzAnal* anal, RzAnalOp* op, ut16 code) {
if (IS_BT_OR_BF (code)) {
op->type = R_ANAL_OP_TYPE_CJMP; //Jump if true or jump if false insns
op->type = RZ_ANAL_OP_TYPE_CJMP; //Jump if true or jump if false insns
op->jump = disarm_8bit_offset (op->addr, GET_BTF_OFFSET (code));
op->fail = op->addr + 2 ;
op->eob = true;
@@ -891,28 +891,28 @@ static int first_nibble_is_8(RzAnal* anal, RzAnalOp* op, ut16 code) {
}
} else if (IS_MOVB_REGDISP_R0 (code)) {
// 10000100mmmmi4*1 mov.b @(<disp>,<REG_M>),R0
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = anal_fill_ai_rg (anal, 0);
op->src[0] = anal_fill_reg_disp_mem (anal, GET_SOURCE_REG (code), code & 0x0F, BYTE_SIZE);
rz_strbuf_setf (&op->esil, "r%d,0x%x,+,[1],DUP,0x80,&,?{,0xFFFFFF00,|,},r0,=", GET_SOURCE_REG (code), code & 0xF);
} else if (IS_MOVW_REGDISP_R0 (code)) {
// 10000101mmmmi4*2 mov.w @(<disp>,<REG_M>),R0
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = anal_fill_ai_rg (anal, 0);
op->src[0] = anal_fill_reg_disp_mem (anal, GET_SOURCE_REG (code), code & 0x0F, WORD_SIZE);
rz_strbuf_setf (&op->esil, "r%d,0x%x,+,[2],DUP,0x8000,&,?{,0xFFFF0000,|,},r0,=", GET_SOURCE_REG (code), (code & 0xF) * 2);
} else if (IS_CMPIMM (code)) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,0x%x,DUP,0x80,&,?{,0xFFFFFF00,|,},r0,==,$z,sr,|,sr,:=", code & 0xFF);
} else if (IS_MOVB_R0_REGDISP (code)) {
/* 10000000mmmmi4*1 mov.b R0,@(<disp>,<REG_M>)*/
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, 0);
op->dst = anal_fill_reg_disp_mem (anal, GET_SOURCE_REG (code), code & 0x0F, BYTE_SIZE);
rz_strbuf_setf (&op->esil, "r0,0xFF,&,0x%x,r%d,+,=[1]", code & 0xF, GET_SOURCE_REG (code));
} else if (IS_MOVW_R0_REGDISP (code)) {
// 10000001mmmmi4*2 mov.w R0,@(<disp>,<REG_M>))
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, 0);
op->dst = anal_fill_reg_disp_mem (anal, GET_SOURCE_REG (code), code & 0x0F, WORD_SIZE);
rz_strbuf_setf (&op->esil, "r0,0xFFFF,&,0x%x,r%d,+,=[2]", (code & 0xF) * 2, GET_SOURCE_REG (code));
@@ -922,7 +922,7 @@ static int first_nibble_is_8(RzAnal* anal, RzAnalOp* op, ut16 code) {
//nibble=9; 1001nnnni8p2.... mov.w @(<disp>,PC),<REG_N>
static int movw_pcdisp_reg(RzAnal* anal, RzAnalOp* op, ut16 code) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[0] = rz_anal_value_new ();
op->src[0]->base = (code & 0xFF) * 2+op->addr + 4;
@@ -934,7 +934,7 @@ static int movw_pcdisp_reg(RzAnal* anal, RzAnalOp* op, ut16 code) {
//nibble=A; 1010i12......... bra <bdisp12>
static int bra(RzAnal* anal, RzAnalOp* op, ut16 code) {
/* Unconditional branch, relative to PC */
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->delay = 1;
op->jump = disarm_12bit_offset (op, GET_BRA_OFFSET (code));
op->eob = true;
@@ -945,7 +945,7 @@ static int bra(RzAnal* anal, RzAnalOp* op, ut16 code) {
//nibble=B; 1011i12......... bsr <bdisp12>
static int bsr(RzAnal* anal, RzAnalOp* op, ut16 code) {
/* Subroutine call, relative to PC */
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = disarm_12bit_offset (op, GET_BRA_OFFSET (code));
op->delay = 1;
rz_strbuf_setf (&op->esil, "1,SETD,pc,2,+,pr,=,0x%x,pc,=", op->jump);
@@ -954,12 +954,12 @@ static int bsr(RzAnal* anal, RzAnalOp* op, ut16 code) {
static int first_nibble_is_c(RzAnal* anal, RzAnalOp* op, ut16 code) {
if (IS_TRAP (code)) {
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
op->val = (ut8)(code & 0xFF);
rz_strbuf_setf (&op->esil, "4,r15,-=,sr,r15,=[4],4,r15,-=,2,pc,-,r15,=[4],2,0x%x,<<,4,+,vbr,+,pc,=", code & 0xFF);
} else if (IS_MOVA_PCREL_R0 (code)) {
// 11000111i8p4.... mova @(<disp>,PC),R0
op->type = R_ANAL_OP_TYPE_LEA;
op->type = RZ_ANAL_OP_TYPE_LEA;
op->src[0] = anal_pcrel_disp_mov (anal, op, code & 0xFF, LONG_SIZE); //this is wrong !
op->dst = anal_fill_ai_rg (anal, 0); //Always R0
rz_strbuf_setf (&op->esil, "0x%x,pc,+,r0,=", (code & 0xFF) * 4);
@@ -970,19 +970,19 @@ static int first_nibble_is_c(RzAnal* anal, RzAnalOp* op, ut16 code) {
switch(code & 0xFF00) {
case 0xC800: //tst
//TODO : get correct op->dst ! (T flag)
op->type = R_ANAL_OP_TYPE_ACMP;
op->type = RZ_ANAL_OP_TYPE_ACMP;
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r0,0x%x,&,!,?{,1,sr,|=,}", code & 0xFF);
break;
case 0xC900: //and
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
rz_strbuf_setf (&op->esil, "0x%x,r0,&=", code & 0xFF);
break;
case 0xCA00: //xor
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
rz_strbuf_setf (&op->esil, "0x%x,r0,^=", code & 0xFF);
break;
case 0xCB00: //or
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
rz_strbuf_setf (&op->esil, "0x%x,r0,|=", code & 0xFF);
break;
}
@@ -991,45 +991,45 @@ static int first_nibble_is_c(RzAnal* anal, RzAnalOp* op, ut16 code) {
switch(code & 0xFF00) {
case 0xCC00: //tst
//TODO : get correct op->dst ! (T flag)
op->type = R_ANAL_OP_TYPE_ACMP;
op->type = RZ_ANAL_OP_TYPE_ACMP;
rz_strbuf_setf (&op->esil, "0xFFFFFFFE,sr,&=,r0,gbr,+,[1],0x%x,&,!,?{,1,sr,|=,}", code & 0xFF);
break;
case 0xCD00: //and
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
rz_strbuf_setf (&op->esil, "r0,gbr,+,[1],0x%x,&,r0,gbr,+,=[1]", code & 0xFF);
break;
case 0xCE00: //xor
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
rz_strbuf_setf (&op->esil, "r0,gbr,+,[1],0x%x,^,r0,gbr,+,=[1]", code & 0xFF);
break;
case 0xCF00: //or
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
rz_strbuf_setf (&op->esil, "r0,gbr,+,[1],0x%x,|,r0,gbr,+,=[1]", code & 0xFF);
break;
}
//TODO : implement @(R0,gbr) dest and src[1]
} else if (IS_MOVB_R0_GBRREF (code)) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, 0);
rz_strbuf_setf (&op->esil, "r0,gbr,0x%x,+,=[1]", code & 0xFF);
} else if (IS_MOVW_R0_GBRREF (code)) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, 0);
rz_strbuf_setf (&op->esil, "r0,gbr,0x%x,+,=[2]", (code & 0xFF) * 2);
} else if (IS_MOVL_R0_GBRREF (code)) {
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, 0);
rz_strbuf_setf (&op->esil, "r0,gbr,0x%x,+,=[4]", (code & 0xFF) * 4);
} else if (IS_MOVB_GBRREF_R0 (code)) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = anal_fill_ai_rg (anal, 0);
rz_strbuf_setf (&op->esil, "gbr,0x%x,+,[1],DUP,0x80,&,?{,0xFFFFFF00,|,},r0,=", (code & 0xFF));
} else if (IS_MOVW_GBRREF_R0 (code)) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = anal_fill_ai_rg (anal, 0);
rz_strbuf_setf (&op->esil, "gbr,0x%x,+,[2],DUP,0x8000,&,?{,0xFFFF0000,|,},r0,=", (code & 0xFF)*2);
} else if (IS_MOVL_GBRREF_R0 (code)) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->dst = anal_fill_ai_rg (anal, 0);
rz_strbuf_setf (&op->esil, "gbr,0x%x,+,[4],r0,=", (code & 0xFF) * 4);
}
@@ -1039,7 +1039,7 @@ static int first_nibble_is_c(RzAnal* anal, RzAnalOp* op, ut16 code) {
//nibble=d; 1101nnnni8 : mov.l @(<disp>,PC), Rn
static int movl_pcdisp_reg(RzAnal* anal, RzAnalOp* op, ut16 code) {
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
op->src[0] = anal_pcrel_disp_mov (anal, op, code & 0xFF, LONG_SIZE);
//TODO: check it
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
@@ -1050,7 +1050,7 @@ static int movl_pcdisp_reg(RzAnal* anal, RzAnalOp* op, ut16 code) {
//nibble=e; 1110nnnni8*1.... mov #<imm>,<REG_N>
static int mov_imm_reg(RzAnal* anal, RzAnalOp* op, ut16 code) {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[0] = anal_fill_im (anal, (st8)(code & 0xFF));
rz_strbuf_setf (&op->esil, "0x%x,r%d,=,r%d,0x80,&,?{,0xFFFFFF00,r%d,|=,}", code & 0xFF, GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
@@ -1060,7 +1060,7 @@ static int mov_imm_reg(RzAnal* anal, RzAnalOp* op, ut16 code) {
//nibble=f;
static int fpu_insn(RzAnal* anal, RzAnalOp* op, ut16 code) {
//Not interested on FPU stuff for now
op->family = R_ANAL_OP_FAMILY_FPU;
op->family = RZ_ANAL_OP_FAMILY_FPU;
return op->size;
}
@@ -1095,7 +1095,7 @@ static int sh_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int len
return 0;
}
op->addr = addr;
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
op->size = 2;
@@ -1147,7 +1147,7 @@ static bool sh_set_reg_profile(RzAnal* anal) {
static int archinfo(RzAnal *anal, int q) {
#if 0
if (q == R_ANAL_ARCHINFO_ALIGN) {
if (q == RZ_ANAL_ARCHINFO_ALIGN) {
return 4;
}
#endif
@@ -1167,11 +1167,11 @@ RzAnalPlugin rz_anal_plugin_sh = {
.esil = true
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_sh,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+37 -37
View File
@@ -17,17 +17,17 @@ static int snes_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
}
op->nopcode = 1;
op->addr = addr;
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
switch (data[0]) {
case 0xea: // nop
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case 0xfb: // xce
op->type = R_ANAL_OP_TYPE_XCHG;
op->type = RZ_ANAL_OP_TYPE_XCHG;
break;
case 0x00: // brk
case 0x02: // cop
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
break;
case 0x1b: // tcs
case 0x3b: // tsc
@@ -41,7 +41,7 @@ static int snes_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xaa: // tax
case 0xba: // tsx
case 0xbb: // tyx
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case 0x48: // pha
case 0x8b: // phb
@@ -50,7 +50,7 @@ static int snes_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x08: // php
case 0xda: // phx
case 0x5a: // phy
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
break;
case 0x68: // pla
case 0xab: // plb
@@ -58,7 +58,7 @@ static int snes_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x28: // plp
case 0xfa: // plx
case 0x7a: // ply
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
break;
// adc
case 0x61: case 0x63: case 0x65: case 0x67: case 0x69: case 0x6d:
@@ -68,17 +68,17 @@ static int snes_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x1a: case 0xe6: case 0xee: case 0xf6: case 0xfe:
case 0xe8: // inx
case 0xc8: // iny
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
// and
case 0x23: case 0x25: case 0x27: case 0x29: case 0x2d: case 0x2f:
case 0x31: case 0x32: case 0x33: case 0x35: case 0x37: case 0x39:
case 0x3d: case 0x3f:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
// bit
case 0x24: case 0x2c: case 0x34: case 0x3c: case 0x89:
op->type = R_ANAL_OP_TYPE_ACMP;
op->type = RZ_ANAL_OP_TYPE_ACMP;
break;
// cmp
case 0xc1: case 0xc3: case 0xc5: case 0xc7: case 0xc9: case 0xcd:
@@ -88,35 +88,35 @@ static int snes_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xe0: case 0xe4: case 0xec:
// cpy
case 0xc0: case 0xc4: case 0xcc:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
// ora
case 0x01: case 0x03: case 0x05: case 0x07: case 0x09: case 0x0d:
case 0x0f: case 0x11: case 0x12: case 0x13: case 0x15: case 0x17:
case 0x19: case 0x1d: case 0x1f:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
// eor
case 0x41: case 0x43: case 0x45: case 0x47: case 0x49: case 0x4d:
case 0x4f: case 0x51: case 0x52: case 0x53: case 0x55: case 0x57:
case 0x59: case 0x5d: case 0x5f:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
break;
// asl
case 0x06: case 0x0a: case 0x0e: case 0x16: case 0x1e:
op->type = R_ANAL_OP_TYPE_SAL;
op->type = RZ_ANAL_OP_TYPE_SAL;
break;
// lsr
case 0x46: case 0x4a: case 0x4e: case 0x56: case 0x5e:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
break;
// rol
case 0x26: case 0x2a: case 0x2e: case 0x36: case 0x3e:
op->type = R_ANAL_OP_TYPE_ROL;
op->type = RZ_ANAL_OP_TYPE_ROL;
break;
// ror
case 0x66: case 0x6a: case 0x6e: case 0x76: case 0x7e:
op->type = R_ANAL_OP_TYPE_ROR;
op->type = RZ_ANAL_OP_TYPE_ROR;
break;
// sbc
case 0xe1: case 0xe3: case 0xe5: case 0xe7: case 0xe9: case 0xed:
@@ -126,7 +126,7 @@ static int snes_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x3a: case 0xc6: case 0xce: case 0xd6: case 0xde:
case 0xca: // dex
case 0x88: // dey
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
// sta
case 0x81: case 0x83: case 0x85: case 0x87: case 0x8d: case 0x8f:
@@ -138,7 +138,7 @@ static int snes_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0x84: case 0x8c: case 0x94:
// stz
case 0x64: case 0x74: case 0x9c: case 0x9e:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
// lda
case 0xa1: case 0xa3: case 0xa5: case 0xa7: case 0xa9: case 0xad:
@@ -148,33 +148,33 @@ static int snes_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case 0xa2: case 0xa6: case 0xae: case 0xb6: case 0xbe:
// ldy
case 0xa0: case 0xa4: case 0xac: case 0xb4: case 0xbc:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case 0x4c: // jmp addr
op->eob = true;
op->jump = (addr & 0xFF0000) | ut8p_bw (data + 1);
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0x5c: // jmp long
op->eob = true;
op->jump = data[1] | data[2] << 8 | data[3] << 16;
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0x80: // bra
op->eob = true;
op->jump = addr + 2 + (st8)data[1];
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0x82: // brl
op->eob = true;
op->jump = addr + 3 + (st16)ut8p_bw (data + 1);
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case 0x6c: // jmp (addr)
case 0x7c: // jmp (addr,X)
case 0xdc: // jmp [addr]
op->eob = true;
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
break;
case 0x10: // bpl
case 0x30: // bmi
@@ -185,38 +185,38 @@ static int snes_anop(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
op->eob = true;
op->jump = addr + 2 + (st8)data[1];
op->fail = addr + 2;
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case 0xd0: // bne
op->eob = true;
op->cond = R_ANAL_COND_NE;
op->cond = RZ_ANAL_COND_NE;
op->jump = addr + 2 + (st8)data[1];
op->fail = addr + 2;
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case 0xf0: // beq
op->eob = true;
op->cond = R_ANAL_COND_EQ;
op->cond = RZ_ANAL_COND_EQ;
op->jump = addr + 2 + (st8)data[1];
op->fail = addr + 2;
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case 0x20: // jsr addr
op->jump = (addr & 0xFF0000) | ut8p_bw (data+1);
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
break;
case 0x22: // jsr long
op->jump = data[1] | data[2] << 8 | data[3] << 16;
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
break;
case 0xfc: // jsr (addr,X)
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
break;
case 0x40: // rti
case 0x60: // rts
case 0x6b: // rtl
op->eob = true;
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
break;
case 0xc2: // rep
if (((st8)data[1]) & 0x10) {
@@ -263,10 +263,10 @@ RzAnalPlugin rz_anal_plugin_snes = {
.op = &snes_anop,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_snes,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+27 -27
View File
@@ -72,8 +72,8 @@ static int parse_reg_name(RzRegItem *reg, csh handle, cs_insn *insn, int reg_num
static void op_fillval(RzAnalOp *op, csh handle, cs_insn *insn) {
static RzRegItem reg;
switch (op->type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_LOAD:
switch (op->type & RZ_ANAL_OP_TYPE_MASK) {
case RZ_ANAL_OP_TYPE_LOAD:
if (INSOP(0).type == SPARC_OP_MEM) {
ZERO_FILL (reg);
op->src[0] = rz_anal_value_new ();
@@ -82,7 +82,7 @@ static void op_fillval(RzAnalOp *op, csh handle, cs_insn *insn) {
op->src[0]->delta = INSOP(0).mem.disp;
}
break;
case R_ANAL_OP_TYPE_STORE:
case RZ_ANAL_OP_TYPE_STORE:
if (INSOP(1).type == SPARC_OP_MEM) {
ZERO_FILL (reg);
op->dst = rz_anal_value_new ();
@@ -123,28 +123,28 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
// capstone-next
n = cs_disasm (handle, (const ut8*)buf, len, addr, 1, &insn);
if (n < 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
} else {
if (mask & R_ANAL_OP_MASK_OPEX) {
if (mask & RZ_ANAL_OP_MASK_OPEX) {
opex (&op->opex, handle, insn);
}
op->size = insn->size;
op->id = insn->id;
switch (insn->id) {
case SPARC_INS_INVALID:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case SPARC_INS_MOV:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case SPARC_INS_RETT:
case SPARC_INS_RET:
case SPARC_INS_RETL:
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->delay = 1;
break;
case SPARC_INS_UNIMP:
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
break;
case SPARC_INS_CALL:
switch (INSOP(0).type) {
@@ -152,25 +152,25 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
// TODO
break;
case SPARC_OP_REG:
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
op->delay = 1;
break;
default:
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->delay = 1;
op->jump = INSOP(0).imm;
break;
}
break;
case SPARC_INS_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case SPARC_INS_CMP:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case SPARC_INS_JMP:
case SPARC_INS_JMPL:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->delay = 1;
op->jump = INSOP(0).imm;
break;
@@ -183,7 +183,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case SPARC_INS_LDUB:
case SPARC_INS_LDUH:
case SPARC_INS_LDX:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case SPARC_INS_STBAR:
case SPARC_INS_STB:
@@ -192,13 +192,13 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case SPARC_INS_STH:
case SPARC_INS_STQ:
case SPARC_INS_STX:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case SPARC_INS_ORCC:
case SPARC_INS_ORNCC:
case SPARC_INS_ORN:
case SPARC_INS_OR:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case SPARC_INS_B:
case SPARC_INS_BMASK:
@@ -211,7 +211,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case SPARC_INS_FB:
switch (INSOP(0).type) {
case SPARC_OP_REG:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->delay = 1;
if (INSCC != SPARC_CC_ICC_N) { // never
op->jump = INSOP (1).imm;
@@ -221,7 +221,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
}
break;
case SPARC_OP_IMM:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->delay = 1;
if (INSCC != SPARC_CC_ICC_N) { // never
op->jump = INSOP (0).imm;
@@ -250,7 +250,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case SPARC_INS_SUB:
case SPARC_INS_TSUBCCTV:
case SPARC_INS_TSUBCC:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case SPARC_INS_ADDCC:
case SPARC_INS_ADDX:
@@ -274,7 +274,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case SPARC_INS_FPADD64:
case SPARC_INS_TADDCCTV:
case SPARC_INS_TADDCC:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
case SPARC_INS_FDMULQ:
case SPARC_INS_FMUL8SUX16:
@@ -296,7 +296,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case SPARC_INS_UMUL:
case SPARC_INS_XMULX:
case SPARC_INS_XMULXHI:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
break;
case SPARC_INS_FDIVD:
case SPARC_INS_FDIVQ:
@@ -307,10 +307,10 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case SPARC_INS_UDIVCC:
case SPARC_INS_UDIVX:
case SPARC_INS_UDIV:
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
break;
}
if (mask & R_ANAL_OP_MASK_VAL) {
if (mask & RZ_ANAL_OP_MASK_VAL) {
op_fillval (op, handle, insn);
}
cs_free (insn, n);
@@ -392,10 +392,10 @@ RzAnalPlugin rz_anal_plugin_sparc_cs = {
.set_reg_profile = &set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_sparc_cs,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+50 -50
View File
@@ -85,48 +85,48 @@ enum {
FCC_ULE = 0xe,
};
/* Define some additional conditions that are nor mappable to
the existing R_ANAL_COND* ones and need to be handled in a
the existing RZ_ANAL_COND* ones and need to be handled in a
special way. */
enum {
R_ANAL_COND_ALWAYS = -1,
R_ANAL_COND_NEVER = -2,
R_ANAL_COND_UNKNOWN = -3,
RZ_ANAL_COND_ALWAYS = -1,
RZ_ANAL_COND_NEVER = -2,
RZ_ANAL_COND_UNKNOWN = -3,
};
static int icc_to_r_cond(const int cond) {
/* we treat signed and unsigned the same here */
switch(cond) {
case ICC_A: return R_ANAL_COND_ALWAYS;
case ICC_CC: return R_ANAL_COND_GE;
case ICC_CS: return R_ANAL_COND_LT;
case ICC_E: return R_ANAL_COND_EQ;
case ICC_G: return R_ANAL_COND_GT;
case ICC_GE: return R_ANAL_COND_GE;
case ICC_GU: return R_ANAL_COND_GT;
case ICC_L: return R_ANAL_COND_LT;
case ICC_LE: return R_ANAL_COND_LE;
case ICC_LEU: return R_ANAL_COND_LE;
case ICC_N: return R_ANAL_COND_NEVER;
case ICC_NE: return R_ANAL_COND_NE;
case ICC_A: return RZ_ANAL_COND_ALWAYS;
case ICC_CC: return RZ_ANAL_COND_GE;
case ICC_CS: return RZ_ANAL_COND_LT;
case ICC_E: return RZ_ANAL_COND_EQ;
case ICC_G: return RZ_ANAL_COND_GT;
case ICC_GE: return RZ_ANAL_COND_GE;
case ICC_GU: return RZ_ANAL_COND_GT;
case ICC_L: return RZ_ANAL_COND_LT;
case ICC_LE: return RZ_ANAL_COND_LE;
case ICC_LEU: return RZ_ANAL_COND_LE;
case ICC_N: return RZ_ANAL_COND_NEVER;
case ICC_NE: return RZ_ANAL_COND_NE;
case ICC_NEG:
case ICC_POS:
case ICC_VC:
case ICC_VS:
default: return R_ANAL_COND_UNKNOWN;
default: return RZ_ANAL_COND_UNKNOWN;
}
}
static int fcc_to_r_cond(const int cond) {
switch (cond) {
case FCC_A: return R_ANAL_COND_ALWAYS;
case FCC_E: return R_ANAL_COND_EQ;
case FCC_G: return R_ANAL_COND_GT;
case FCC_GE: return R_ANAL_COND_GE;
case FCC_L: return R_ANAL_COND_LT;
case FCC_LE: return R_ANAL_COND_LE;
case FCC_LG: return R_ANAL_COND_NE;
case FCC_N: return R_ANAL_COND_NEVER;
case FCC_NE: return R_ANAL_COND_NE;
case FCC_A: return RZ_ANAL_COND_ALWAYS;
case FCC_E: return RZ_ANAL_COND_EQ;
case FCC_G: return RZ_ANAL_COND_GT;
case FCC_GE: return RZ_ANAL_COND_GE;
case FCC_L: return RZ_ANAL_COND_LT;
case FCC_LE: return RZ_ANAL_COND_LE;
case FCC_LG: return RZ_ANAL_COND_NE;
case FCC_N: return RZ_ANAL_COND_NEVER;
case FCC_NE: return RZ_ANAL_COND_NE;
case FCC_O:
case FCC_U:
case FCC_UE:
@@ -135,7 +135,7 @@ static int fcc_to_r_cond(const int cond) {
case FCC_UL:
case FCC_ULE:
default:
return R_ANAL_COND_UNKNOWN;
return RZ_ANAL_COND_UNKNOWN;
}
}
@@ -282,21 +282,21 @@ static RzAnalValue * value_fill_addr_pc_disp(const ut64 addr, const st64 disp) {
static RzAnalValue * value_fill_addr_reg_regdelta(RzAnal const * const anal, const int ireg, const int iregdelta) {
RzAnalValue *val = rz_anal_value_new();
val->reg = rz_reg_get(anal->reg, gpr_regs[ireg], R_REG_TYPE_GPR);
val->reg = rz_reg_get(anal->reg, gpr_regs[iregdelta], R_REG_TYPE_GPR);
val->reg = rz_reg_get(anal->reg, gpr_regs[ireg], RZ_REG_TYPE_GPR);
val->reg = rz_reg_get(anal->reg, gpr_regs[iregdelta], RZ_REG_TYPE_GPR);
return val;
}
static RzAnalValue * value_fill_addr_reg_disp(RzAnal const * const anal, const int ireg, const st64 disp) {
RzAnalValue *val = rz_anal_value_new();
val->reg = rz_reg_get(anal->reg, gpr_regs[ireg], R_REG_TYPE_GPR);
val->reg = rz_reg_get(anal->reg, gpr_regs[ireg], RZ_REG_TYPE_GPR);
val->delta = disp;
return val;
}
static void anal_call(RzAnalOp *op, const ut32 insn, const ut64 addr) {
const st64 disp = (get_immed_sgnext(insn, 29) * 4);
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->dst = value_fill_addr_pc_disp(addr, disp);
op->jump = addr + disp;
op->fail = addr + 4;
@@ -309,18 +309,18 @@ static void anal_jmpl(RzAnal const * const anal, RzAnalOp *op, const ut32 insn,
}
if (X_RD(insn) == GPR_O7) {
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
op->fail = addr + 4;
} else if (X_RD(insn) == GPR_G0
&& X_LDST_I(insn) == 1
&& (X_RS1(insn) == GPR_I7 || X_RS1(insn) == GPR_O7)
&& disp == 8) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
op->eob = true;
return;
}
else {
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
op->eob = true;
}
@@ -342,16 +342,16 @@ static void anal_branch(RzAnalOp *op, const ut32 insn, const ut64 addr) {
} else if(X_OP2(insn) == OP2_FBfcc || X_OP2(insn) == OP2_FBPfcc) {
rz_cond = fcc_to_r_cond (X_COND(insn));
} else if(X_OP2(insn) == OP2_BPr) {
rz_cond = R_ANAL_COND_UNKNOWN;
rz_cond = RZ_ANAL_COND_UNKNOWN;
}
if (rz_cond == R_ANAL_COND_ALWAYS) {
op->type = R_ANAL_OP_TYPE_JMP;
} else if (rz_cond == R_ANAL_COND_NEVER) {
op->type = R_ANAL_OP_TYPE_NOP;
if (rz_cond == RZ_ANAL_COND_ALWAYS) {
op->type = RZ_ANAL_OP_TYPE_JMP;
} else if (rz_cond == RZ_ANAL_COND_NEVER) {
op->type = RZ_ANAL_OP_TYPE_NOP;
return;
} else {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->fail = addr + 4;
}
@@ -373,7 +373,7 @@ static int sparc_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
int sz = 4;
ut32 insn;
op->family = R_ANAL_OP_FAMILY_CPU;
op->family = RZ_ANAL_OP_FAMILY_CPU;
op->addr = addr;
op->size = sz;
@@ -390,7 +390,7 @@ static int sparc_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
switch(X_OP2(insn)) {
case OP2_ILLTRAP:
case OP2_INV:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
sz = 0; /* make rz_core_anal_bb stop */
break;
case OP2_BPcc:
@@ -411,24 +411,24 @@ static int sparc_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case OP32_INV3:
case OP32_INV4:
case OP32_INV5:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
sz = 0; /* make rz_core_anal_bb stop */
break;
case OP32_CONDINV1:
if(X_RD(insn) == 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
sz = 0; /* make rz_core_anal_bb stop */
}
break;
case OP32_CONDINV2:
if(X_RS1(insn) == 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
sz = 0; /* make rz_core_anal_bb stop */
}
break;
case OP32_CONDINV3:
if(X_RS1(insn) != 0) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
sz = 0; /* make rz_core_anal_bb stop */
}
break;
@@ -455,7 +455,7 @@ static int sparc_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *data, int
case OP33_INV14:
case OP33_INV15:
case OP33_INV16:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
sz = 0; /* make rz_core_anal_bb stop */
break;
}
@@ -616,10 +616,10 @@ RzAnalPlugin rz_anal_plugin_sparc_gnu = {
.set_reg_profile = set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_sparc_gnu,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+13 -13
View File
@@ -60,19 +60,19 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
// capstone-next
int n = cs_disasm (handle, (const ut8*)buf, len, addr, 1, &insn);
if (n < 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
} else {
if (mask & R_ANAL_OP_MASK_OPEX) {
if (mask & RZ_ANAL_OP_MASK_OPEX) {
opex (&op->opex, handle, insn);
}
op->size = insn->size;
switch (insn->id) {
case SYSZ_INS_BRCL:
case SYSZ_INS_BRASL:
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
break;
case SYSZ_INS_BR:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
break;
case SYSZ_INS_BRC:
case SYSZ_INS_BER:
@@ -93,7 +93,7 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case SYSZ_INS_BRAS:
case SYSZ_INS_BRCT:
case SYSZ_INS_BRCTG:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
break;
case SYSZ_INS_JE:
case SYSZ_INS_JGE:
@@ -124,12 +124,12 @@ static int analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf, int len, R
case SYSZ_INS_JO:
case SYSZ_INS_JGO:
case SYSZ_INS_JG:
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = INSOP(0).imm;
op->fail = addr+op->size;
break;
case SYSZ_INS_J:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = INSOP(0).imm;
op->fail = UT64_MAX;
break;
@@ -182,11 +182,11 @@ static bool set_reg_profile(RzAnal *anal) {
static int archinfo(RzAnal *anal, int q) {
switch (q) {
case R_ANAL_ARCHINFO_ALIGN:
case RZ_ANAL_ARCHINFO_ALIGN:
return 2;
case R_ANAL_ARCHINFO_MAX_OP_SIZE:
case RZ_ANAL_ARCHINFO_MAX_OP_SIZE:
return 4;
case R_ANAL_ARCHINFO_MIN_OP_SIZE:
case RZ_ANAL_ARCHINFO_MIN_OP_SIZE:
return 2;
}
return 2;
@@ -204,10 +204,10 @@ RzAnalPlugin rz_anal_plugin_sysz = {
.set_reg_profile = &set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_sysz,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+22 -22
View File
@@ -32,49 +32,49 @@ int tms320_c55x_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
op->delay = 0;
op->size = tms320_dasm(&engine, buf, len);
op->type = R_ANAL_OP_TYPE_NULL;
op->type = RZ_ANAL_OP_TYPE_NULL;
str = strstr(str, "||") ? str + 3 : str;
if (match(str, "B ")) {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
if (match (str, "B AC")) {
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
}
} else if (match(str, "BCC ") || match(str, "BCCU ")) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
} else if (match(str, "CALL ")) {
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
if (match (str, "CALL AC")) {
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
}
} else if (match(str, "CALLCC ")) {
op->type = R_ANAL_OP_TYPE_CCALL;
op->type = RZ_ANAL_OP_TYPE_CCALL;
} else if (match(str, "RET")) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
if (match (str, "RETCC")) {
op->type = R_ANAL_OP_TYPE_CRET;
op->type = RZ_ANAL_OP_TYPE_CRET;
}
} else if (match(str, "MOV ")) {
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
} else if (match(str, "PSHBOTH ")) {
op->type = R_ANAL_OP_TYPE_UPUSH;
op->type = RZ_ANAL_OP_TYPE_UPUSH;
} else if (match(str, "PSH ")) {
op->type = R_ANAL_OP_TYPE_PUSH;
op->type = RZ_ANAL_OP_TYPE_PUSH;
} else if (match(str, "POPBOTH ") || match(str, "POP ")) {
op->type = R_ANAL_OP_TYPE_POP;
op->type = RZ_ANAL_OP_TYPE_POP;
} else if (match(str, "CMP ")) {
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
} else if (match(str, "CMPAND ")) {
op->type = R_ANAL_OP_TYPE_ACMP;
op->type = RZ_ANAL_OP_TYPE_ACMP;
} else if (match(str, "NOP")) {
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
} else if (match(str, "INTR ")) {
op->type = R_ANAL_OP_TYPE_SWI;
op->type = RZ_ANAL_OP_TYPE_SWI;
} else if (match(str, "TRAP ")) {
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
} else if (match(str, "INVALID")) {
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
}
return op->size;
@@ -119,10 +119,10 @@ RzAnalPlugin rz_anal_plugin_tms320 = {
.op = &tms320_op,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_tms320,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+13 -13
View File
@@ -26,53 +26,53 @@ int tms320_c55x_plus_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, i
if (ins_len == 1) {
if (*ins == 0x20) {
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
} else if (*ins == 0x21) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
}
} else if (ins_len >= 4 && buf[0] == 0xD8) {
// BCC conditional absolute jump
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3];
} else if (ins_len >= 2 && buf[0] == 0x6A) {
// BCC conditional relative jump
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + ((st8)buf[1]) + ins_len;
} else if (ins_len >= 3 && buf[0] == 0x9A) {
// BCC conditional relative jump
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len;
} else if (ins_len >= 4 && buf[0] == 0x9C) {
// B unconditional absolute jump
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3];
} else if (ins_len >= 3 && buf[0] == 0x68) {
// B unconditional relative jump
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len;
} else if (ins_len == 2 && buf[0] == 0x02) {
// CALL unconditional absolute call with acumulator register ACx
op->type = R_ANAL_OP_TYPE_UCALL;
op->type = RZ_ANAL_OP_TYPE_UCALL;
op->fail = addr + ins_len;
} else if (ins_len >= 3 && buf[0] == 0x69) {
// CALL unconditional relative call
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len;
} else if (ins_len >= 3 && buf[0] == 0x9D) {
// CALL unconditional absolute call
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3];
} else if (ins_len >= 3 && buf[0] == 0x9B) {
// CALLCC conditional relative call
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len;
} else if (ins_len >= 4 && buf[0] == 0xD9) {
// CALLCC conditional absolute call
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3];
} else {
op->type = R_ANAL_OP_TYPE_UNK;
op->type = RZ_ANAL_OP_TYPE_UNK;
}
return op->size;
}
+19 -19
View File
@@ -80,35 +80,35 @@ static int tms320c64x_analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf,
// capstone-next
n = cs_disasm (handle, (const ut8*)buf, len, addr, 1, &insn);
if (n < 1) {
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
} else {
if (mask & R_ANAL_OP_MASK_OPEX) {
if (mask & RZ_ANAL_OP_MASK_OPEX) {
opex (&op->opex, handle, insn);
}
op->size = insn->size;
op->id = insn->id;
switch (insn->id) {
case TMS320C64X_INS_INVALID:
op->type = R_ANAL_OP_TYPE_ILL;
op->type = RZ_ANAL_OP_TYPE_ILL;
break;
case TMS320C64X_INS_AND:
case TMS320C64X_INS_ANDN:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
break;
case TMS320C64X_INS_NOT:
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
break;
case TMS320C64X_INS_NEG:
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
break;
case TMS320C64X_INS_SWAP2:
case TMS320C64X_INS_SWAP4:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case TMS320C64X_INS_BNOP:
case TMS320C64X_INS_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
case TMS320C64X_INS_CMPEQ:
case TMS320C64X_INS_CMPEQ2:
@@ -118,10 +118,10 @@ static int tms320c64x_analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf,
case TMS320C64X_INS_CMPGTU4:
case TMS320C64X_INS_CMPLT:
case TMS320C64X_INS_CMPLTU:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
break;
case TMS320C64X_INS_B:
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
// higher 32bits of the 64bit address is lost, lets clone
op->jump = INSOP(0).imm + (addr & 0xFFFFFFFF00000000);
break;
@@ -134,7 +134,7 @@ static int tms320c64x_analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf,
case TMS320C64X_INS_LDNW:
case TMS320C64X_INS_LDW:
case TMS320C64X_INS_LMBD:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
break;
case TMS320C64X_INS_STB:
case TMS320C64X_INS_STDW:
@@ -142,10 +142,10 @@ static int tms320c64x_analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf,
case TMS320C64X_INS_STNDW:
case TMS320C64X_INS_STNW:
case TMS320C64X_INS_STW:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
break;
case TMS320C64X_INS_OR:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
break;
case TMS320C64X_INS_SSUB:
case TMS320C64X_INS_SUB:
@@ -157,7 +157,7 @@ static int tms320c64x_analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf,
case TMS320C64X_INS_SUBAW:
case TMS320C64X_INS_SUBC:
case TMS320C64X_INS_SUBU:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
break;
case TMS320C64X_INS_ADD:
case TMS320C64X_INS_ADD2:
@@ -173,7 +173,7 @@ static int tms320c64x_analop(RzAnal *a, RzAnalOp *op, ut64 addr, const ut8 *buf,
case TMS320C64X_INS_SADD2:
case TMS320C64X_INS_SADDU4:
case TMS320C64X_INS_SADDUS2:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
break;
}
cs_free (insn, n);
@@ -208,11 +208,11 @@ RzAnalPlugin rz_anal_plugin_tms320c64x = {
};
#endif
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_tms320c64x,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
*/
+3 -3
View File
@@ -79,10 +79,10 @@ RzAnalPlugin rz_anal_plugin_tricore = {
.set_reg_profile = set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_tricore,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif
+45 -45
View File
@@ -75,33 +75,33 @@ static int v810_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
switch (opcode) {
case V810_MOV:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
rz_strbuf_appendf (&op->esil, "r%u,r%u,=",
REG1(word1), REG2(word1));
break;
case V810_MOV_IMM5:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
rz_strbuf_appendf (&op->esil, "%d,r%u,=",
(st8)SEXT5(IMM5(word1)), REG2(word1));
break;
case V810_MOVHI:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
rz_strbuf_appendf (&op->esil, "16,%hu,<<,r%u,+,r%u,=",
word2, REG1(word1), REG2(word1));
break;
case V810_MOVEA:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
rz_strbuf_appendf (&op->esil, "%hd,r%u,+,r%u,=",
word2, REG1(word1), REG2(word1));
break;
case V810_LDSR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case V810_STSR:
op->type = R_ANAL_OP_TYPE_MOV;
op->type = RZ_ANAL_OP_TYPE_MOV;
break;
case V810_NOT:
op->type = R_ANAL_OP_TYPE_NOT;
op->type = RZ_ANAL_OP_TYPE_NOT;
rz_strbuf_appendf (&op->esil, "r%u,0xffffffff,^,r%u,=",
REG1(word1), REG2(word1));
update_flags (op, V810_FLAG_S | V810_FLAG_Z);
@@ -109,7 +109,7 @@ static int v810_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
break;
case V810_DIV:
case V810_DIVU:
op->type = R_ANAL_OP_TYPE_DIV;
op->type = RZ_ANAL_OP_TYPE_DIV;
rz_strbuf_appendf (&op->esil, "r%u,r%u,/=,r%u,r%u,%,r30,=",
REG1(word1), REG2(word1),
REG1(word1), REG2(word1));
@@ -117,22 +117,22 @@ static int v810_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
break;
case V810_JMP:
if (REG1 (word1) == 31) {
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
} else {
op->type = R_ANAL_OP_TYPE_UJMP;
op->type = RZ_ANAL_OP_TYPE_UJMP;
}
rz_strbuf_appendf (&op->esil, "r%u,pc,=",
REG1(word1));
break;
case V810_OR:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
rz_strbuf_appendf (&op->esil, "r%u,r%u,|=",
REG1(word1), REG2(word1));
update_flags (op, V810_FLAG_S | V810_FLAG_Z);
clear_flags (op, V810_FLAG_OV);
break;
case V810_ORI:
op->type = R_ANAL_OP_TYPE_OR;
op->type = RZ_ANAL_OP_TYPE_OR;
rz_strbuf_appendf (&op->esil, "%hu,r%u,|,r%u,=",
word2, REG1(word1), REG2(word1));
update_flags (op, V810_FLAG_S | V810_FLAG_Z);
@@ -140,92 +140,92 @@ static int v810_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
break;
case V810_MUL:
case V810_MULU:
op->type = R_ANAL_OP_TYPE_MUL;
op->type = RZ_ANAL_OP_TYPE_MUL;
rz_strbuf_appendf (&op->esil, "r%u,r%u,*=,32,r%u,r%u,*,>>,r30,=",
REG1(word1), REG2(word1),
REG1(word1), REG2(word1));
update_flags (op, V810_FLAG_OV | V810_FLAG_S | V810_FLAG_Z);
break;
case V810_XOR:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
rz_strbuf_appendf (&op->esil, "r%u,r%u,^=",
REG1(word1), REG2(word1));
update_flags (op, V810_FLAG_S | V810_FLAG_Z);
clear_flags (op, V810_FLAG_OV);
break;
case V810_XORI:
op->type = R_ANAL_OP_TYPE_XOR;
op->type = RZ_ANAL_OP_TYPE_XOR;
rz_strbuf_appendf (&op->esil, "%hu,r%u,^,r%u,=",
word2, REG1(word1), REG2(word1));
update_flags (op, V810_FLAG_S | V810_FLAG_Z);
clear_flags (op, V810_FLAG_OV);
break;
case V810_AND:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
rz_strbuf_appendf (&op->esil, "r%u,r%u,&=",
REG1(word1), REG2(word1));
update_flags (op, V810_FLAG_S | V810_FLAG_Z);
clear_flags (op, V810_FLAG_OV);
break;
case V810_ANDI:
op->type = R_ANAL_OP_TYPE_AND;
op->type = RZ_ANAL_OP_TYPE_AND;
rz_strbuf_appendf (&op->esil, "%hu,r%u,&,r%u,=",
word2, REG1(word1), REG2(word1));
update_flags (op, V810_FLAG_Z);
clear_flags (op, V810_FLAG_OV | V810_FLAG_S);
break;
case V810_CMP:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
rz_strbuf_appendf (&op->esil, "r%u,r%u,==",
REG1(word1), REG2(word1));
update_flags (op, -1);
break;
case V810_CMP_IMM5:
op->type = R_ANAL_OP_TYPE_CMP;
op->type = RZ_ANAL_OP_TYPE_CMP;
rz_strbuf_appendf (&op->esil, "%d,r%u,==",
(st8)SEXT5(IMM5(word1)), REG2(word1));
update_flags (op, -1);
break;
case V810_SUB:
op->type = R_ANAL_OP_TYPE_SUB;
op->type = RZ_ANAL_OP_TYPE_SUB;
rz_strbuf_appendf (&op->esil, "r%u,r%u,-=",
REG1(word1), REG2(word1));
update_flags (op, -1);
break;
case V810_ADD:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
rz_strbuf_appendf (&op->esil, "r%u,r%u,+=",
REG1(word1), REG2(word1));
update_flags (op, -1);
break;
case V810_ADDI:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
rz_strbuf_appendf (&op->esil, "%hd,r%u,+,r%u,=",
word2, REG1(word1), REG2(word1));
update_flags (op, -1);
break;
case V810_ADD_IMM5:
op->type = R_ANAL_OP_TYPE_ADD;
op->type = RZ_ANAL_OP_TYPE_ADD;
rz_strbuf_appendf (&op->esil, "%d,r%u,+=",
(st8)SEXT5(IMM5(word1)), REG2(word1));
update_flags(op, -1);
break;
case V810_SHR:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
rz_strbuf_appendf (&op->esil, "r%u,r%u,>>=",
REG1(word1), REG2(word1));
update_flags (op, V810_FLAG_CY | V810_FLAG_S | V810_FLAG_Z);
clear_flags (op, V810_FLAG_OV);
break;
case V810_SHR_IMM5:
op->type = R_ANAL_OP_TYPE_SHR;
op->type = RZ_ANAL_OP_TYPE_SHR;
rz_strbuf_appendf (&op->esil, "%u,r%u,>>=",
(ut8)IMM5(word1), REG2(word1));
update_flags (op, V810_FLAG_CY | V810_FLAG_S | V810_FLAG_Z);
clear_flags (op, V810_FLAG_OV);
break;
case V810_SAR:
op->type = R_ANAL_OP_TYPE_SAR;
op->type = RZ_ANAL_OP_TYPE_SAR;
reg1 = REG1(word1);
reg2 = REG2(word1);
rz_strbuf_appendf (&op->esil, "31,r%u,>>,?{,r%u,32,-,r%u,1,<<,--,<<,}{,0,},r%u,r%u,>>,|,r%u,=",
@@ -234,7 +234,7 @@ static int v810_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
clear_flags (op, V810_FLAG_OV);
break;
case V810_SAR_IMM5:
op->type = R_ANAL_OP_TYPE_SAR;
op->type = RZ_ANAL_OP_TYPE_SAR;
imm5 = IMM5(word1);
reg2 = REG2(word1);
rz_strbuf_appendf (&op->esil, "31,r%u,>>,?{,%u,32,-,%u,1,<<,--,<<,}{,0,},%u,r%u,>>,|,r%u,=",
@@ -243,49 +243,49 @@ static int v810_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
clear_flags (op, V810_FLAG_OV);
break;
case V810_SHL:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
rz_strbuf_appendf (&op->esil, "r%u,r%u,<<=",
REG1(word1), REG2(word1));
update_flags (op, V810_FLAG_CY | V810_FLAG_S | V810_FLAG_Z);
clear_flags (op, V810_FLAG_OV);
break;
case V810_SHL_IMM5:
op->type = R_ANAL_OP_TYPE_SHL;
op->type = RZ_ANAL_OP_TYPE_SHL;
rz_strbuf_appendf (&op->esil, "%u,r%u,<<=",
(ut8)IMM5(word1), REG2(word1));
update_flags (op, V810_FLAG_CY | V810_FLAG_S | V810_FLAG_Z);
clear_flags (op, V810_FLAG_OV);
break;
case V810_LDB:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
rz_strbuf_appendf (&op->esil, "r%u,%hd,+,[1],r%u,=",
REG1(word1), word2, REG2(word1));
rz_strbuf_appendf (&op->esil, ",DUP,0x80,&,?{,0xffffff00,|,}");
break;
case V810_LDH:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
rz_strbuf_appendf (&op->esil, "r%u,%hd,+,0xfffffffe,&,[2],r%u,=",
REG1(word1), word2, REG2(word1));
rz_strbuf_appendf (&op->esil, ",DUP,0x8000,&,?{,0xffffff00,|,}");
break;
case V810_LDW:
op->type = R_ANAL_OP_TYPE_LOAD;
op->type = RZ_ANAL_OP_TYPE_LOAD;
rz_strbuf_appendf (&op->esil, "r%u,%hd,+,0xfffffffc,&,[4],r%u,=",
REG1(word1), word2, REG2(word1));
rz_strbuf_appendf (&op->esil, ",DUP,0x80000000,&,?{,0xffffff00,|,}");
break;
case V810_STB:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
rz_strbuf_appendf (&op->esil, "r%u,r%u,%hd,+,=[1]",
REG2(word1), REG1(word1), word2);
break;
case V810_STH:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
rz_strbuf_appendf (&op->esil, "r%u,r%u,%hd,+,0xfffffffe,&,=[2]",
REG2(word1), REG1(word1), word2);
break;
case V810_STW:
op->type = R_ANAL_OP_TYPE_STORE;
op->type = RZ_ANAL_OP_TYPE_STORE;
rz_strbuf_appendf (&op->esil, "r%u,r%u,%hd,+,=[4]",
REG2(word1), REG1(word1), word2);
break;
@@ -295,14 +295,14 @@ static int v810_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
case V810_OUTB:
case V810_OUTH:
case V810_OUTW:
op->type = R_ANAL_OP_TYPE_IO;
op->type = RZ_ANAL_OP_TYPE_IO;
break;
case V810_TRAP:
op->type = R_ANAL_OP_TYPE_TRAP;
op->type = RZ_ANAL_OP_TYPE_TRAP;
rz_strbuf_appendf (&op->esil, "%u,TRAP", IMM5(word1));
break;
case V810_RETI:
op->type = R_ANAL_OP_TYPE_RET;
op->type = RZ_ANAL_OP_TYPE_RET;
//rz_strbuf_appendf (&op->esil, "np,?{,fepc,fepsw,}{,eipc,eipsw,},psw,=,pc,=");
break;
case V810_JAL:
@@ -312,10 +312,10 @@ static int v810_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
op->fail = addr + 4;
if (opcode == V810_JAL) {
op->type = R_ANAL_OP_TYPE_CALL;
op->type = RZ_ANAL_OP_TYPE_CALL;
rz_strbuf_appendf (&op->esil, "$$,4,+,r31,=,", jumpdisp);
} else {
op->type = R_ANAL_OP_TYPE_JMP;
op->type = RZ_ANAL_OP_TYPE_JMP;
}
rz_strbuf_appendf (&op->esil, "$$,%d,+,pc,=", jumpdisp);
@@ -323,14 +323,14 @@ static int v810_op(RzAnal *anal, RzAnalOp *op, ut64 addr, const ut8 *buf, int le
case V810_BCOND:
cond = COND(word1);
if (cond == V810_COND_NOP) {
op->type = R_ANAL_OP_TYPE_NOP;
op->type = RZ_ANAL_OP_TYPE_NOP;
break;
}
jumpdisp = DISP9(word1);
op->jump = addr + jumpdisp;
op->fail = addr + 2;
op->type = R_ANAL_OP_TYPE_CJMP;
op->type = RZ_ANAL_OP_TYPE_CJMP;
switch (cond) {
case V810_COND_V:
@@ -453,10 +453,10 @@ RzAnalPlugin rz_anal_plugin_v810 = {
.set_reg_profile = set_reg_profile,
};
#ifndef R2_PLUGIN_INCORE
#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.type = RZ_LIB_TYPE_ANAL,
.data = &rz_anal_plugin_v810,
.version = R2_VERSION
.version = RZ_VERSION
};
#endif

Some files were not shown because too many files have changed in this diff Show More