Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/CITest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- uses: actions/checkout@v3

- name: prepare
shell: 'script -q -e -c "bash {0}"'
shell: 'script -q -e -c "bash -e {0}"'
run: |
export LD_LIBRARY_PATH=`pwd`/tests/:$LD_LIBRARY_PATH
wget https://github.com/groundx/capstonefuzz/raw/master/corpus/corpus-libFuzzer-capstone_fuzz_disasmnext-latest.zip
Expand All @@ -64,7 +64,7 @@ jobs:

- name: make
if: startsWith(matrix.config.build-system, 'make')
shell: 'script -q -e -c "bash {0}"'
shell: 'script -q -e -c "bash -e {0}"'
run: |
./make.sh;
make check;
Expand All @@ -73,7 +73,7 @@ jobs:

- name: cmake
if: startsWith(matrix.config.build-system, 'cmake')
shell: 'script -q -e -c "bash {0}"'
shell: 'script -q -e -c "bash -e {0}"'
run: |
mkdir build && cd build;
cmake -DCAPSTONE_INSTALL=1 -DBUILD_SHARED_LIBS=1 ..;
Expand All @@ -82,9 +82,10 @@ jobs:
# sudo make install;

- name: cstest
shell: 'script -q -e -c "bash {0}"'
shell: 'script -q -e -c "bash -e {0}"'
run: |
cd suite/cstest && ./build_cstest.sh;
export LD_LIBRARY_PATH="${PWD}/../..:${LD_LIBRARY_PATH:-}";
python cstest_report.py -D -t build/cstest -d ../MC;
python cstest_report.py -D -t build/cstest -f issues.cs; cd ..;

Expand Down
252 changes: 252 additions & 0 deletions .github/workflows/CrossBuilds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
name: Cross Build Tests
on:
push:
paths-ignore:
- ".gitignore"
- "docs/**"
- "ChangeLog"
- "CREDITS.TXT"
- "COMPILE.TXT"
- "COMPILE_CMAKE.TXT"
- "COMPILE_MSVC.TXT"
- "HACK.TXT"
- "LICENSE.TXT"
- "LICENSE_LLVM.TXT"
- "README.md"
- "RELEASE_NOTES"
- "SPONSORS.TXT"
pull_request:

# Stop previous runs on the same branch on new push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CI: true

jobs:
Linux:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.name }}
strategy:
fail-fast: false
matrix:
config:
- {
name: 'QEMU Linux s390x',
os: ubuntu-24.04,
system: 'Linux',
processor: 's390x',
cc: 's390x-linux-gnu-gcc',
cxx: 's390x-linux-gnu-g++',
sysroot: '/usr/s390x-linux-gnu',
qemu: 'qemu-s390x-static',
build_type: 'Debug',
packages: 'gcc-s390x-linux-gnu g++-s390x-linux-gnu binutils-s390x-linux-gnu libc6-dev-s390x-cross qemu-user-static',
build_tests: 'ON',
diet_build: 'OFF',
toolchain_file: 'toolchain.cmake',
}
- {
name: 'QEMU Linux MIPS 32 BE',
os: ubuntu-24.04,
system: 'Linux',
processor: 'mips',
cc: 'mips-linux-gnu-gcc',
cxx: 'mips-linux-gnu-g++',
sysroot: '/usr/mips-linux-gnu',
qemu: 'qemu-mips-static',
build_type: 'Debug',
packages: 'gcc-mips-linux-gnu g++-mips-linux-gnu binutils-mips-linux-gnu libc6-dev-mips-cross qemu-user-static',
build_tests: 'ON',
diet_build: 'OFF',
toolchain_file: 'toolchain.cmake',
}
- {
name: 'QEMU Linux Mips64el',
os: ubuntu-24.04,
system: 'Linux',
processor: 'mips64el',
cc: 'mips64el-linux-gnuabi64-gcc',
cxx: 'mips64el-linux-gnuabi64-g++',
sysroot: '/usr/mips64el-linux-gnuabi64',
qemu: 'qemu-mips64el-static',
build_type: 'Debug',
packages: 'gcc-mips64el-linux-gnuabi64 g++-mips64el-linux-gnuabi64 binutils-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross qemu-user-static',
build_tests: 'ON',
diet_build: 'OFF',
toolchain_file: 'toolchain.cmake',
}
- {
name: 'QEMU Linux PPC64',
os: ubuntu-24.04,
system: 'Linux',
processor: 'ppc64',
cc: 'powerpc64-linux-gnu-gcc',
cxx: 'powerpc64-linux-gnu-g++',
sysroot: '/usr/powerpc64-linux-gnu',
qemu: 'qemu-ppc64-static',
build_type: 'Debug',
packages: 'gcc-powerpc64-linux-gnu g++-powerpc64-linux-gnu binutils-powerpc64-linux-gnu libc6-dev-ppc64-cross qemu-user-static',
build_tests: 'ON',
diet_build: 'OFF',
toolchain_file: 'toolchain.cmake',
}
- {
name: 'QEMU Linux ARM',
os: ubuntu-24.04,
system: 'Linux',
processor: 'arm',
cc: 'arm-linux-gnueabihf-gcc',
cxx: 'arm-linux-gnueabihf-g++',
sysroot: '/usr/arm-linux-gnueabihf',
qemu: 'qemu-arm-static',
build_type: 'Debug',
packages: 'gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-cross qemu-user-static',
build_tests: 'ON',
diet_build: 'OFF',
toolchain_file: 'toolchain.cmake',
}
- {
name: '[BUILD ONLY] Windows i686 mingw',
os: ubuntu-24.04,
system: 'Windows',
processor: 'i686',
cc: 'i686-w64-mingw32-gcc',
cxx: 'i686-w64-mingw32-g++',
rc: 'i686-w64-mingw32-windres',
find_root: '/usr/i686-w64-mingw32',
build_type: 'Debug',
skip_tests: true,
packages: 'gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools',
build_tests: 'OFF',
diet_build: 'OFF',
toolchain_file: 'toolchain.cmake',
}
- {
name: '[BUILD ONLY] Android 35 (arm64_v8a) NDK 29',
os: ubuntu-24.04,
system: 'Android',
processor: 'aarch64',
build_option: '-DANDROID_PLATFORM=android-35 -DANDROID_ABI=arm64-v8a',
build_type: 'Debug',
# QEMU alone can't emulate the binaries, because the NDK doesn't
# provide dynamic linker.
skip_tests: true,
packages: 'qemu-user-static unzip wget',
ndk_version: 'r29',
build_tests: 'OFF',
diet_build: 'OFF',
toolchain_file: 'ndk/build/cmake/android.toolchain.cmake',
}

steps:
- uses: actions/checkout@v6

- name: Install cross build dependencies
if: ${{ matrix.config.packages != '' }}
env:
packages: ${{ matrix.config.packages }}
run: |
sudo apt-get update
sudo apt-get install -y ${packages}

- name: Setup Android NDK
if: contains(matrix.config.name, 'Android')
env:
ndk_version: ${{ matrix.config.ndk_version }}
run: |
wget -q https://dl.google.com/android/repository/android-ndk-${ndk_version}-linux.zip
unzip -q android-ndk-${ndk_version}-linux.zip
mv android-ndk-${ndk_version} ndk
cat ndk/source.properties

- name: Build cmocka
if: ${{ matrix.config.skip_tests != true }}
env:
system: ${{ matrix.config.system }}
processor: ${{ matrix.config.processor }}
cc: ${{ matrix.config.cc }}
cxx: ${{ matrix.config.cxx }}
sysroot: ${{ matrix.config.sysroot }}
qemu: ${{ matrix.config.qemu }}
build_type: ${{ matrix.config.build_type }}
toolchain_file: ${{ matrix.config.toolchain_file }}
run: |
git clone --depth 1 https://git.cryptomilk.org/projects/cmocka.git suite/cstest/cmocka
cmake -S suite/cstest/cmocka \
-B build/cmocka \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_TOOLCHAIN_FILE="${PWD}/${toolchain_file}" \
-DCMAKE_INSTALL_PREFIX="${PWD}/build/cmocka-install" \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=OFF \
-DWITH_STATIC_LIB=ON \
-DWITH_EXAMPLES=OFF \
-DUNIT_TESTING=OFF
cmake --build build/cmocka --config ${build_type} --parallel
cmake --install build/cmocka --config ${build_type}

- name: cmake (cross build)
env:
system: ${{ matrix.config.system }}
processor: ${{ matrix.config.processor }}
cc: ${{ matrix.config.cc }}
cxx: ${{ matrix.config.cxx }}
rc: ${{ matrix.config.rc }}
find_root: ${{ matrix.config.find_root }}
sysroot: ${{ matrix.config.sysroot }}
qemu: ${{ matrix.config.qemu }}
build_option: ${{ matrix.config.build_option }}
build_type: ${{ matrix.config.build_type }}
build_tests: ${{ matrix.config.build_tests }}
diet_build: ${{ matrix.config.diet_build }}
toolchain_file: ${{ matrix.config.toolchain_file }}
run: |
cmake -DCMAKE_BUILD_TYPE=${build_type} \
-DBUILD_STATIC_LIBS=ON \
-DBUILD_SHARED_LIBS=OFF \
-DCAPSTONE_BUILD_TESTS=${build_tests} \
-DCAPSTONE_BUILD_CSTOOL=ON \
-DCAPSTONE_BUILD_CSTEST=OFF \
-S . \
-DCAPSTONE_BUILD_DIET=${diet_build} \
-DCMAKE_TOOLCHAIN_FILE=${toolchain_file} \
${build_option} \
-B build
cmake --build build --config ${build_type} --parallel

- name: C tests
if: ${{ matrix.config.skip_tests != true }}
run: |
ctest --test-dir build --output-on-failure -R '^capstone_'
Comment thread
Rot127 marked this conversation as resolved.

- name: cstest
if: ${{ matrix.config.skip_tests != true }}
shell: 'script -q -e -c "bash -e {0}"'
env:
cc: ${{ matrix.config.cc }}
qemu: ${{ matrix.config.qemu }}
sysroot: ${{ matrix.config.sysroot }}
run: |
cmocka_lib="$(find build/cmocka build/cmocka-install -type f \( -name 'libcmocka*.a' -o -name 'libcmocka*.so' \) | sort | head -n 1)"
test -n "${cmocka_lib}"
${cc} suite/cstest/src/*.c \
-Iinclude \
-Isuite/cstest/include \
-Ibuild/cmocka-install/include \
-o build/cstest \
build/libcapstone.a \
"${cmocka_lib}" \
-pthread
cat > build/run-cstest <<'EOF'
#!/bin/sh
export LD_LIBRARY_PATH="${CMOCKA_PREFIX}/lib:${CMOCKA_PREFIX}/lib64:${LD_LIBRARY_PATH}"
exec "${qemu}" -L "${sysroot}" "${cstest_bin}" "$@"
EOF
chmod +x build/run-cstest
export CMOCKA_PREFIX="${PWD}/build/cmocka-install"
export cstest_bin="${PWD}/build/cstest"
python suite/cstest/cstest_report.py -D -t build/run-cstest -d suite/MC
python suite/cstest/cstest_report.py -D -t build/run-cstest -f suite/cstest/issues.cs
5 changes: 3 additions & 2 deletions arch/AArch64/AArch64InstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,8 +1224,9 @@ static void printVRegOperand(MCInst *MI, unsigned OpNum, SStream *O)
static void printSysCROperand(MCInst *MI, unsigned OpNum, SStream *O)
{
MCOperand *Op = MCInst_getOperand(MI, OpNum);
unsigned Val = (unsigned)MCOperand_getImm(Op);
//assert(Op.isImm() && "System instruction C[nm] operands must be immediates!");
SStream_concat(O, "c%u", MCOperand_getImm(Op));
SStream_concat(O, "c%u", Val);

if (MI->csh->detail) {
#ifndef CAPSTONE_DIET
Expand All @@ -1236,7 +1237,7 @@ static void printSysCROperand(MCInst *MI, unsigned OpNum, SStream *O)
MI->ac_idx++;
#endif
MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_CIMM;
MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = MCOperand_getImm(Op);
MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].imm = Val;
MI->flat_insn->detail->arm64.op_count++;
}
}
Expand Down
8 changes: 4 additions & 4 deletions arch/M68K/M68KInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ static void printAddressingMode(SStream* O, unsigned int pc, const cs_m68k* inst
case M68K_AM_REGI_ADDR_PRE_DEC: SStream_concat(O, "-(a%d)", (op->reg - M68K_REG_A0)); break;
case M68K_AM_REGI_ADDR_DISP: SStream_concat(O, "%s$%x(a%d)", op->mem.disp < 0 ? "-" : "", abs(op->mem.disp), (op->mem.base_reg - M68K_REG_A0)); break;
case M68K_AM_PCI_DISP: SStream_concat(O, "$%x(pc)", pc + 2 + op->mem.disp); break;
case M68K_AM_ABSOLUTE_DATA_SHORT: SStream_concat(O, "$%x.w", op->imm); break;
case M68K_AM_ABSOLUTE_DATA_LONG: SStream_concat(O, "$%x.l", op->imm); break;
case M68K_AM_ABSOLUTE_DATA_SHORT: SStream_concat(O, "$%x.w", (unsigned int)op->imm); break;
case M68K_AM_ABSOLUTE_DATA_LONG: SStream_concat(O, "$%x.l", (unsigned int)op->imm); break;
case M68K_AM_IMMEDIATE:
if (inst->op_size.type == M68K_SIZE_TYPE_FPU) {
#if defined(_KERNEL_MODE)
Expand All @@ -172,7 +172,7 @@ static void printAddressingMode(SStream* O, unsigned int pc, const cs_m68k* inst
break;
#endif
}
SStream_concat(O, "#$%x", op->imm);
SStream_concat(O, "#$%x", (unsigned int)op->imm);
break;
case M68K_AM_PCI_INDEX_8_BIT_DISP:
SStream_concat(O, "$%x(pc,%s%s.%c)", pc + 2 + op->mem.disp, s_spacing, getRegName(op->mem.index_reg), op->mem.index_size ? 'l' : 'w');
Expand Down Expand Up @@ -287,7 +287,7 @@ void M68K_printInst(MCInst* MI, SStream* O, void* PrinterInfo)

if (MI->Opcode == M68K_INS_INVALID) {
if (ext->op_count)
SStream_concat(O, "dc.w $%x", ext->operands[0].imm);
SStream_concat(O, "dc.w $%x", (unsigned int)ext->operands[0].imm);
else
SStream_concat(O, "dc.w $<unknown>");
return;
Expand Down
10 changes: 5 additions & 5 deletions arch/MOS65XX/MOS65XXDisassembler.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void MOS65XX_printInst(MCInst *MI, struct SStream *O, void *PrinterInfo)
value = 3 + (signed short)value;

SStream_concat(O, " %s%04x", prefix,
(MI->address + value) & 0xffff);
(unsigned int)((MI->address + value) & 0xffff));
break;

case MOS65XX_AM_ABS_IND:
Expand Down Expand Up @@ -375,16 +375,16 @@ void MOS65XX_printInst(MCInst *MI, struct SStream *O, void *PrinterInfo)

case MOS65XX_AM_BLOCK:
SStream_concat(O, " %s%02x, %s%02x",
prefix, MI->Operands[0].ImmVal,
prefix, MI->Operands[1].ImmVal);
prefix, (unsigned int)MI->Operands[0].ImmVal,
prefix, (unsigned int)MI->Operands[1].ImmVal);
break;

case MOS65XX_AM_ZP_REL:
value = 3 + (signed char)MI->Operands[1].ImmVal;
/* BBR0, zp, rel and BBS0, zp, rel */
SStream_concat(O, " %s%02x, %s%04x",
prefix, MI->Operands[0].ImmVal,
prefix, (MI->address + value) & 0xffff);
prefix, (unsigned int)MI->Operands[0].ImmVal,
prefix, (unsigned int)((MI->address + value) & 0xffff));
break;

}
Expand Down
Loading
Loading