Refactor auto-sync updater
This refactors the auto-sync updater scripts, adds multiple tests and some other smaller things:
- Converts the updater in a proper Python package.
- Renaming was done to fit this new package structure.
- Format code with usort and black and enforce it with the CI.
- Add license information to auto-sync scripts.
- Update tree-sitter-cpp to v20.0.5
- Fix py-tree-sitter version to `< 0.22.0` due to https://github.com/tree-sitter/tree-sitter-cpp/issues/250
- Allow file/dir creation of non existing paths.
- Add CI tests for Patch, inc gen, translation and diff persistence testing.
- Implement editing of diffs with an editor.
- Fix: Add Namespace id also to anonymous enumeration members.
There is a compiler bug in latest MSVC, which at the time of writing is
19.36.32535: given `switch (x)`, where `x` is 64 bits wide, the compiler
generates code that computes an incorrect jump table index. E.g. if
`x` is zero, it ends up reading the table entry at index -1.
To support building a static Capstone with many supported architectures
and only paying for the ones needed in each consumer. In this way they
won't have to build multiple copies of Capstone to minimize footprint.
Disassembling single floating points with immediate values currently
gives wrong results on big endian hosts (like s390x), e.g.:
./cstool/cstool m68k40 'f2 3c 44 22 40 49 0e 56'
0 f2 3c 44 22 40 49 0e 56 fadd.s #0.000000, fp0
While it should be (like on x86):
./cstool/cstool m68k40 'f2 3c 44 22 40 49 0e 56'
0 f2 3c 44 22 40 49 0e 56 fadd.s #3.141500, fp0
The problem is that these single float values are supposed to be stored
in the 32-bit "simm" field of struct cs_m68k_op (see e.g. the printing
of M68K_FPU_SIZE_SINGLE in printAddressingMode() in M68KInstPrinter.c),
but currently the immediate is only written to the 64-bit "imm" field
of the union in cs_m68k_op. This works on little endian systems, since
the least significant bytes overlap in the union there. For example,
let's assume that the value 0x01020304 gets written to "imm":
04 03 02 01 00 00 00 00 uint64_t imm
xx xx xx xx xx xx xx xx double dimm;
xx xx xx xx .. .. .. .. float simm;
But on big endian hosts, the important bytes do not overlap, so "simm"
is always zero there:
00 00 00 00 01 02 03 04 uint64_t imm
xx xx xx xx xx xx xx xx double dimm;
xx xx xx xx .. .. .. .. float simm;
To fix the problem, let's always set "simm" explicitly, this works on
both, big endian and little endian hosts.
Thanks to Michal Schulz for his initial analysis of the problem
(in #1710) and to Travis Finkenauer for providing an easy example
to reproduce the issue (in #1931).
Closes: https://github.com/capstone-engine/capstone/issues/1710