Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capstone v6 update (without Mips) #4662

Merged
merged 27 commits into from
Oct 24, 2024
Merged

Conversation

Rot127
Copy link
Member

@Rot127 Rot127 commented Oct 6, 2024

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

Bumps Capstone version to newest Capstone next (beyond first v6-Alpha1).

Changes:

  • Fixes leaks
  • Fixes build and change to AArch64 and SystemZ compatibility headers.
  • Marks M68k test as broken (see commit message).
  • Fix AArch64 and SystemZ tests
  • Handle op.size == 0 for x86 IL ops

Test plan

All green

Closing issues

...

test/db/formats/elf/m68k Show resolved Hide resolved
doc/PACKAGERS.md Outdated Show resolved Hide resolved
@XVilka XVilka mentioned this pull request Oct 6, 2024
5 tasks
.github/workflows/ci.yml Outdated Show resolved Hide resolved
test/db/analysis/vars Outdated Show resolved Hide resolved
@Rot127
Copy link
Member Author

Rot127 commented Oct 21, 2024

Fix for build issue: capstone-engine/capstone#2522

@XVilka
Copy link
Member

XVilka commented Oct 23, 2024

@Rot127 please update the Capstone commit and rebase one more time

@Rot127 Rot127 force-pushed the cs6-aarch64-fixups branch from 495c008 to 5fdf04c Compare October 23, 2024 15:21
@Rot127 Rot127 marked this pull request as ready for review October 24, 2024 11:14
Rot127 added 21 commits October 24, 2024 11:22
This test is broken. The reason is that Rizin can't distinguish
CPU models. Each M68k model has a different address mask (32-24 bits).
It defaults to one which has only 24bits.
Hence, the subi.l instruction decodes to
'subi.l 0x15b119, d0' instead of 'subi.l 0x8015b119, d0'
Should be fixable with RzArch (if anyone is still intereses).
See: rizinorg#4334
This reverts commit 8b55655.
With capstone-engine/capstone#2504 two false positives and a new function is discovered.
This is an attempt to fix a reported false positive warning of GCC 12
which is not reported by GCC 14.
@Rot127 Rot127 force-pushed the cs6-aarch64-fixups branch from 5fdf04c to 470ef0a Compare October 24, 2024 11:22
@XVilka XVilka merged commit f82993a into rizinorg:dev Oct 24, 2024
44 of 45 checks passed
@XVilka
Copy link
Member

XVilka commented Oct 24, 2024

@Rot127 please fix the build with older Capstone versions too:

gcc -Ilibrz/arch/librz_arch.so.0.8.0.p -I. -I.. -Ilibrz -I../librz -Ilibrz/include -I../librz/include -I../librz/arch/isa -I../librz/arch/isa_gnu -Ilibrz/arch -I../librz/arch -Ilibrz/util/sdb/src -I../librz/util/sdb/src -I../librz/bin/format -I../librz/type/parser -Isubprojects/rzspp -I../subprojects/rzspp -I/usr/include/capstone -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O3 -Wimplicit-fallthrough=3 -DRZ_PLUGIN_INCORE=1 -DUSE_SYS_CAPSTONE -DSUPPORTS_PCRE2_JIT -D_GNU_SOURCE --std=gnu99 -Werror=sizeof-pointer-memaccess -fvisibility=hidden -Wno-cpp -fPIC -MD -MQ librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_esil32.c.o -MF librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_esil32.c.o.d -o librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_esil32.c.o -c ../librz/arch/isa/arm/arm_esil32.c
In file included from ../librz/arch/isa/arm/arm_esil32.c:10:
../librz/arch/isa/arm/arm_cs.h:24:67: error: unknown type name ‘ARM64CC_CondCode’
   24 | RZ_IPI const char *rz_arm64_cs_esil_prefix_cond(RzAnalysisOp *op, ARM64CC_CondCode cond_type);
      |                                                                   ^~~~~~~~~~~~~~~~
[1481/2211] Compiling C object librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_esil64.c.o
FAILED: librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_esil64.c.o 
gcc -Ilibrz/arch/librz_arch.so.0.8.0.p -I. -I.. -Ilibrz -I../librz -Ilibrz/include -I../librz/include -I../librz/arch/isa -I../librz/arch/isa_gnu -Ilibrz/arch -I../librz/arch -Ilibrz/util/sdb/src -I../librz/util/sdb/src -I../librz/bin/format -I../librz/type/parser -Isubprojects/rzspp -I../subprojects/rzspp -I/usr/include/capstone -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O3 -Wimplicit-fallthrough=3 -DRZ_PLUGIN_INCORE=1 -DUSE_SYS_CAPSTONE -DSUPPORTS_PCRE2_JIT -D_GNU_SOURCE --std=gnu99 -Werror=sizeof-pointer-memaccess -fvisibility=hidden -Wno-cpp -fPIC -MD -MQ librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_esil64.c.o -MF librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_esil64.c.o.d -o librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_esil64.c.o -c ../librz/arch/isa/arm/arm_esil64.c
In file included from ../librz/arch/isa/arm/arm_esil64.c:11:
../librz/arch/isa/arm/arm_cs.h:24:67: error: unknown type name ‘ARM64CC_CondCode’
   24 | RZ_IPI const char *rz_arm64_cs_esil_prefix_cond(RzAnalysisOp *op, ARM64CC_CondCode cond_type);
      |                                                                   ^~~~~~~~~~~~~~~~
../librz/arch/isa/arm/arm_esil64.c:18:67: error: unknown type name ‘ARM64CC_CondCode’
   18 | RZ_IPI const char *rz_arm64_cs_esil_prefix_cond(RzAnalysisOp *op, ARM64CC_CondCode cond_type) {
      |                                                                   ^~~~~~~~~~~~~~~~
../librz/arch/isa/arm/arm_esil64.c:132:28: error: unknown type name ‘aarch64_extender’; did you mean ‘arm64_extender’?
  132 | static int decode_sign_ext(aarch64_extender extender) {
      |                            ^~~~~~~~~~~~~~~~
      |                            arm64_extender
../librz/arch/isa/arm/arm_esil64.c:156:36: error: unknown type name ‘aarch64_shifter’; did you mean ‘arm64_shifter’?
  156 | static const char *decode_shift_64(aarch64_shifter shift) {
      |                                    ^~~~~~~~~~~~~~~
      |                                    arm64_shifter
../librz/arch/isa/arm/arm_esil64.c: In function ‘shifted_reg64_append’:
../librz/arch/isa/arm/arm_esil64.c:154:18: error: implicit declaration of function ‘decode_sign_ext’ [-Werror=implicit-function-declaration]
  154 | #define EXT64(x) decode_sign_ext(insn->detail->arm64.operands[x].ext)
      |                  ^~~~~~~~~~~~~~~
../librz/arch/isa/arm/arm_esil64.c:207:23: note: in expansion of macro ‘EXT64’
  207 |         int signext = EXT64(n);
      |                       ^~~~~
../librz/arch/isa/arm/arm_esil64.c:180:27: error: implicit declaration of function ‘decode_shift_64’ [-Werror=implicit-function-declaration]
  180 | #define DECODE_SHIFT64(x) decode_shift_64(insn->detail->arm64.operands[x].shift.type)
      |                           ^~~~~~~~~~~~~~~
../librz/arch/isa/arm/arm_esil64.c:219:100: note: in expansion of macro ��DECODE_SHIFT64’
  219 |                                 rz_strbuf_appendf(sb, "%d,%d,%s,~,%s", LSHIFT2_64(n), signext, rn, DECODE_SHIFT64(n));
      |                                                                                                    ^~~~~~~~~~~~~~
../librz/arch/isa/arm/arm_esil64.c:219:68: error: format ‘%s’ expects argument of type ‘char *’, but argument 6 has type ‘int’ [-Werror=format=]
  219 |                                 rz_strbuf_appendf(sb, "%d,%d,%s,~,%s", LSHIFT2_64(n), signext, rn, DECODE_SHIFT64(n));
      |                                                                   ~^
      |                                                                    |
      |                                                                    char *
      |                                                                   %d
../librz/arch/isa/arm/arm_esil64.c:221:63: error: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘int’ [-Werror=format=]
  221 |                                 rz_strbuf_appendf(sb, "%d,%s,%s", LSHIFT2_64(n), rn, DECODE_SHIFT64(n));
      |                                                              ~^
      |                                                               |
      |                                                               char *
      |                                                              %d
../librz/arch/isa/arm/arm_esil64.c:231:68: error: format ‘%s’ expects argument of type ‘char *’, but argument 6 has type ‘int’ [-Werror=format=]
  231 |                                 rz_strbuf_appendf(sb, "%d,%d,%s,~,%s,1,%d,%s,~,<<<,1,&,?{,%" PFMT64u ",}{,0,},|",
      |                                                                   ~^
      |                                                                    |
      |                                                                    char *
      |                                                                   %d
../librz/arch/isa/arm/arm_esil64.c:234:63: error: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘int’ [-Werror=format=]
  234 |                                 rz_strbuf_appendf(sb, "%d,%s,%s,1,%s,<<<,1,&,?{,%" PFMT64u ",}{,0,},|",
      |                                                              ~^
      |                                                               |
      |                                                               char *
      |                                                              %d
../librz/arch/isa/arm/arm_esil64.c: In function ‘rz_arm_cs_analysis_op_64_esil’:
../librz/arch/isa/arm/arm_esil64.c:404:19: error: implicit declaration of function ‘rz_arm64_cs_esil_prefix_cond’; did you mean ‘rz_arm32_cs_esil_prefix_cond’? [-Werror=implicit-function-declaration]
  404 |         postfix = rz_arm64_cs_esil_prefix_cond(op, insn->detail->arm64.cc);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   rz_arm32_cs_esil_prefix_cond
../librz/arch/isa/arm/arm_esil64.c:404:17: error: assignment to ‘const char *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
  404 |         postfix = rz_arm64_cs_esil_prefix_cond(op, insn->detail->arm64.cc);
      |                 ^
../librz/arch/isa/arm/arm_esil64.c:714:70: error: format ‘%s’ expects argument of type ‘char *’, but argument 6 has type ‘int’ [-Werror=format=]
  714 |                                         rz_strbuf_appendf(&op->esil, "%s,%d,%" PFMT64d ",%s,+",
      |                                                                      ^~~~~~~~~
../librz/arch/isa/arm/arm_esil64.c:714:91: note: format string is defined here
  714 |                                         rz_strbuf_appendf(&op->esil, "%s,%d,%" PFMT64d ",%s,+",
      |                                                                                          ~^
      |                                                                                           |
      |                                                                                           char *
      |                                                                                          %d
../librz/arch/isa/arm/arm_esil64.c:815:70: error: format ‘%s’ expects argument of type ‘char *’, but argument 7 has type ‘int’ [-Werror=format=]
  815 |                                         rz_strbuf_appendf(&op->esil, "%d,%s,%d,%" PFMT64d ",%s",
      |                                                                      ^~~~~~~~~~~~
../librz/arch/isa/arm/arm_esil64.c:815:94: note: format string is defined here
  815 |                                         rz_strbuf_appendf(&op->esil, "%d,%s,%d,%" PFMT64d ",%s",
      |                                                                                             ~^
      |                                                                                              |
      |                                                                                              char *
      |                                                                                             %d
../librz/arch/isa/arm/arm_esil64.c:991:70: error: format ‘%s’ expects argument of type ‘char *’, but argument 7 has type ‘int’ [-Werror=format=]
  991 |                                         rz_strbuf_appendf(&op->esil, "%s,%s,%d,%" PFMT64d ",%s,+",
      |                                                                      ^~~~~~~~~~~~
../librz/arch/isa/arm/arm_esil64.c:991:94: note: format string is defined here
  991 |                                         rz_strbuf_appendf(&op->esil, "%s,%s,%d,%" PFMT64d ",%s,+",
      |                                                                                             ~^
      |                                                                                              |
      |                                                                                              char *
      |                                                                                             %d
cc1: all warnings being treated as errors
[1482/2211] Compiling C object librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il64.c.o
FAILED: librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il64.c.o 
gcc -Ilibrz/arch/librz_arch.so.0.8.0.p -I. -I.. -Ilibrz -I../librz -Ilibrz/include -I../librz/include -I../librz/arch/isa -I../librz/arch/isa_gnu -Ilibrz/arch -I../librz/arch -Ilibrz/util/sdb/src -I../librz/util/sdb/src -I../librz/bin/format -I../librz/type/parser -Isubprojects/rzspp -I../subprojects/rzspp -I/usr/include/capstone -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O3 -Wimplicit-fallthrough=3 -DRZ_PLUGIN_INCORE=1 -DUSE_SYS_CAPSTONE -DSUPPORTS_PCRE2_JIT -D_GNU_SOURCE --std=gnu99 -Werror=sizeof-pointer-memaccess -fvisibility=hidden -Wno-cpp -fPIC -MD -MQ librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il64.c.o -MF librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il64.c.o.d -o librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il64.c.o -c ../librz/arch/isa/arm/arm_il64.c
In file included from ../librz/arch/isa/arm/arm_il64.c:11:
../librz/arch/isa/arm/arm_cs.h:24:67: error: unknown type name ‘ARM64CC_CondCode’
   24 | RZ_IPI const char *rz_arm64_cs_esil_prefix_cond(RzAnalysisOp *op, ARM64CC_CondCode cond_type);
      |                                                                   ^~~~~~~~~~~~~~~~
../librz/arch/isa/arm/arm_il64.c:42:25: error: unknown type name ‘ARM64CC_CondCode’
   42 | static RzILOpBool *cond(ARM64CC_CondCode c) {
      |                         ^~~~~~~~~~~~~~~~
../librz/arch/isa/arm/arm_il64.c: In function ‘branch’:
../librz/arch/isa/arm/arm_il64.c:637:25: error: implicit declaration of function ‘cond’ [-Werror=implicit-function-declaration]
  637 |         RzILOpBool *c = cond(insn->detail->arm64.cc);
      |                         ^~~~
../librz/arch/isa/arm/arm_il64.c:637:25: error: initialization of ‘RzILOpBool *’ {aka ‘struct rz_il_op_pure_t *’} from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
../librz/arch/isa/arm/arm_il64.c: In function ‘cmp’:
../librz/arch/isa/arm/arm_il64.c:890:25: error: initialization of ‘RzILOpBool *’ {aka ‘struct rz_il_op_pure_t *’} from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
  890 |         RzILOpBool *c = cond(insn->detail->arm64.cc);
      |                         ^~~~
../librz/arch/isa/arm/arm_il64.c: In function ‘csinc’:
../librz/arch/isa/arm/arm_il64.c:924:25: error: initialization of ‘RzILOpBool *’ {aka ‘struct rz_il_op_pure_t *’} from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
  924 |         RzILOpBool *c = cond(insn->detail->arm64.cc);
      |                         ^~~~
../librz/arch/isa/arm/arm_il64.c: In function ‘cset’:
../librz/arch/isa/arm/arm_il64.c:1004:11: error: assignment to ‘RzILOpBool *’ {aka ‘struct rz_il_op_pure_t *’} from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
 1004 |         c = cond(insn->detail->arm64.cc);
      |           ^
cc1: all warnings being treated as errors
gcc -Ilibrz/arch/librz_arch.so.0.8.0.p -I. -I.. -Ilibrz -I../librz -Ilibrz/include -I../librz/include -I../librz/arch/isa -I../librz/arch/isa_gnu -Ilibrz/arch -I../librz/arch -Ilibrz/util/sdb/src -I../librz/util/sdb/src -I../librz/bin/format -I../librz/type/parser -Isubprojects/rzspp -I../subprojects/rzspp -I/usr/include/capstone -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O3 -Wimplicit-fallthrough=3 -DRZ_PLUGIN_INCORE=1 -DUSE_SYS_CAPSTONE -DSUPPORTS_PCRE2_JIT -D_GNU_SOURCE --std=gnu99 -Werror=sizeof-pointer-memaccess -fvisibility=hidden -Wno-cpp -fPIC -MD -MQ librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il32.c.o -MF librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il32.c.o.d -o librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il32.c.o -c ../librz/arch/isa/arm/arm_il32.c
In file included from ../librz/arch/isa/arm/arm_il32.c:12:
../librz/arch/isa/arm/arm_cs.h:24:67: error: unknown type name ‘ARM64CC_CondCode’
   24 | RZ_IPI const char *rz_arm64_cs_esil_prefix_cond(RzAnalysisOp *op, ARM64CC_CondCode cond_type);
      |                                                                   ^~~~~~~~~~~~~~~~
[1485/2211] Compiling C object librz/arch/librz_arch.so.0.8.0.p/isa_8051_8051_ass.c.o
ninja: build stopped: subcommand failed.
Error: Process completed with exit code 1.

@XVilka
Copy link
Member

XVilka commented Oct 25, 2024

@Rot127 see also

cc -Ilibrz/arch/librz_arch.so.0.8.0.p -I. -I.. -Ilibrz -I../librz -Ilibrz/include -I../librz/include -I../librz/arch/isa -I../librz/arch/isa_gnu -Ilibrz/arch -I../librz/arch -Ilibrz/util/sdb/src -I../librz/util/sdb/src -I../librz/bin/format -I../librz/type/parser -I../subprojects/capstone-next/include -I../subprojects/capstone-next/include/capstone -Isubprojects/rzspp -I../subprojects/rzspp -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O3 --std=gnu99 -Werror=sizeof-pointer-memaccess -Wimplicit-fallthrough=3 -fvisibility=hidden -DRZ_PLUGIN_INCORE=1 -DSUPPORTS_PCRE2_JIT -D_GNU_SOURCE -Wno-cpp -fPIC -MD -MQ librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il32.c.o -MF librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il32.c.o.d -o librz/arch/librz_arch.so.0.8.0.p/isa_arm_arm_il32.c.o -c ../librz/arch/isa/arm/arm_il32.c
../librz/arch/isa/arm/arm_il32.c:8:32: error: unknown option after ‘#pragma GCC diagnostic’ kind [-Werror=pragmas]
    8 | #pragma GCC diagnostic ignored "-Wenum-conversion"
      |                                ^~~~~~~~~~~~~~~~~~~
In file included from ../librz/arch/isa/arm/arm_il32.c:12:
../librz/arch/isa/arm/arm_cs.h:9:32: error: unknown option after ‘#pragma GCC diagnostic’ kind [-Werror=pragmas]
    9 | #pragma GCC diagnostic ignored "-Wenum-conversion"
      |                                ^~~~~~~~~~~~~~~~~~~
In file included from ../librz/arch/isa/arm/arm_il32.c:13:
../librz/arch/isa/arm/arm_accessors32.h:11:32: error: unknown option after ‘#pragma GCC diagnostic’ kind [-Werror=pragmas]
   11 | #pragma GCC diagnostic ignored "-Wenum-conversion"
      |                                ^~~~~~~~~~~~~~~~~~~

@Rot127
Copy link
Member Author

Rot127 commented Oct 25, 2024

Damn, I thought the whole time I am on the v5/v4 building branch.
Anyways, here is the patch: capstone-engine/capstone#2525

@Rot127 Rot127 deleted the cs6-aarch64-fixups branch October 26, 2024 11:31
@amibranch amibranch mentioned this pull request Oct 27, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants