Add CI job to verify builds with system-wide capstone ##build

This commit is contained in:
pancake 2022-01-26 09:49:36 +01:00 committed by GitHub
parent 098733d015
commit 54b1fcd23c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 14 deletions

View File

@ -78,10 +78,26 @@ jobs:
sudo apt install gperf
- name: Installing with symlinks
run: |
export CFLAGS="-O2 -Werror -Wno-unused-result -Wno-stringop-truncation"
export CFLAGS="-O0 -Werror -Wno-unused-result -Wno-stringop-truncation"
sys/install.sh
- name: Running tests
run: r2r test/db/cmd
build-syscapstone:
name: linux-sys-capstone
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Installing capstone
run: |
git clone --branch next --single-branch --depth=1 https://github.com/capstone-engine/capstone
cd capstone && ( git log | head ) && sh make.sh && sudo make install
- name: Installing r2 with sys-capstone
run: |
export CFLAGS="-O0 -Werror -Wno-unused-result -Wno-stringop-truncation"
sys/install.sh
- name: Checking if capstone was cloned
run: if [ -d shlr/capstone ]; then echo "Capstone wasnt supposed to be cloned"; return 1; fi
build-resymlink:
name: linux-acr-resymlink
runs-on: ubuntu-20.04
@ -90,7 +106,7 @@ jobs:
uses: actions/checkout@v2
- name: Installing with symlinks
run: |
export CFLAGS="-O2 -Werror -Wno-unused-result -Wno-stringop-truncation"
export CFLAGS="-O0 -Werror -Wno-unused-result -Wno-stringop-truncation"
sys/install.sh
- name: Uninstalling
run: sudo make uninstall
@ -160,7 +176,7 @@ jobs:
git config --global pull.rebase false
git clone --depth 1 . "spa ces"
cd "spa ces"
export CFLAGS="-O2 -Werror -Wno-unused-result -Wno-stringop-truncation"
export CFLAGS="-O0 -Werror -Wno-unused-result -Wno-stringop-truncation"
meson --prefix="/tmp/r 2" build
ninja -C build
ninja -C build install

View File

@ -115,11 +115,11 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
static int obits = 32;
bool disp_hash = a->immdisp;
cs_insn* insn = NULL;
cs_mode mode = 0;
int ret, n = 0;
bool found = false;
ut64 itcond;
cs_mode mode = 0;
mode |= (a->bits == 16)? CS_MODE_THUMB: CS_MODE_ARM;
mode |= (a->big_endian)? CS_MODE_BIG_ENDIAN: CS_MODE_LITTLE_ENDIAN;
if (mode != omode || a->bits != obits) {
@ -133,10 +133,8 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
if (strstr (a->cpu, "cortex")) {
mode |= CS_MODE_MCLASS;
}
if (a->bits != 64) {
if (strstr (a->cpu, "v8")) {
mode |= CS_MODE_V8;
}
if (a->bits != 64 && strstr (a->cpu, "v8")) {
mode |= CS_MODE_V8;
}
}
if (a->features && a->bits != 64) {
@ -227,7 +225,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
const bool is_thumb = (a->bits == 16);
int opsize;
ut32 opcode;
ut32 opcode = UT32_MAX;
if (a->bits == 64) {
if (!arm64ass (buf, a->pc, &opcode)) {
return -1;

View File

@ -39,7 +39,7 @@ ifeq ($(USE_CS4),1)
CS_TIP=a7cac8352f7397aa73bb2e2dcc1b6cdb2e1b8461
CS_BRA=v4
else
CS_TIP=f049e65f596bf8b1cbf5f2371067e34715ef1764
CS_TIP=6656bcb63ab4e87dc6079bd6b6b12cc8dd9b2ad8
CS_BRA=next
endif
ifeq ($(CS_COMMIT_ARCHIVE),1)

View File

@ -70,6 +70,9 @@ get_capstone() {
if [ -d capstone ]; then
return
fi
if [ -f capstone ]; then
rm -f capstone
fi
git_clone || fatal_msg 'Clone failed'
cd capstone || fatal_msg 'Failed to chdir'
parse_capstone_tip

View File

@ -20,7 +20,7 @@ if not capstone_dep.found() or not get_option('use_sys_capstone')
patches_files = []
# NOTE: when you update CS_TIP or CS_BRA, also update them in shlr/Makefile
if capstone_version == 'v5'
CS_TIP = 'f049e65f596bf8b1cbf5f2371067e34715ef1764'
CS_TIP = '6656bcb63ab4e87dc6079bd6b6b12cc8dd9b2ad8'
CS_BRA = 'next'
patches_files = [
'fix-x86-16.patch',

View File

@ -118,13 +118,30 @@ else
fi
fi
NEED_CAPSTONE=1
pkg-config --cflags capstone 2>&1 > /dev/null
if [ $? = 0 ]; then
export CFGARG="--with-syscapstone"
pkg-config --atleast-version=5.0.0 capstone 2>/dev/null
if [ $? = 0 ]; then
pkg-config --variable=archs capstone 2> /dev/null | grep -q riscv
if [ $? = 0 ]; then
export CFGARG="--with-syscapstone"
NEED_CAPSTONE=0
echo "Note: Using system-wide-capstone"
else
echo "Warning: Your system-wide capstone dont have enough archs"
fi
else
echo "Warning: Your system-wide capstone is too old for me"
fi
else
echo "Warning: Cannot find system wide capstone"
fi
if [ ! -d shlr/capstone ]; then
./preconfigure
if [ "$NEED_CAPSTONE" = 1 ]; then
if [ ! -d shlr/capstone ]; then
./preconfigure
fi
fi
if [ "${M32}" = 1 ]; then