-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Building python bindings on next
doesn't seem to use correct dylib
#2279
Comments
next
doesn't use updated dylibnext
doesn't seem to use correct dylib
Watch out for having capstone installed multiple times. Once system-wide and once for the user. The user install might still use the system libraries. Check which path was used to load the library by the import capstone
print('python code:', capstone.__path__)
print(capstone.debug())
print('c library path:', capstone._path) |
@rchtsang Could you check if it is due to multiple Capstone installations? |
Sorry, yes I just checked. Running from a conda environment: $ cd bindings/python
$ make install3
$ pip list
DEPRECATION: Loading egg at /opt/homebrew/Caskroom/miniforge/base/envs/capstone/lib/python3.11/site-packages/capstone-5.0.0.post1-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. Discussion can be found at https://github.com/pypa/pip/issues/12330
Package Version
---------- -----------
capstone 5.0.0.post1
capstone 5.0.0.post1
capstone 5.0.0.post1
pip 24.0
setuptools 69.1.0
wheel 0.42.0 then checking the installation as follows: >>> import capstone
>>> print(capstone.__path__)
['/Users/rtsang/Documents/Research/projects/embedded-emu/capstone/bindings/python/capstone']
>>> print(capstone.debug())
python-standard-aarch64-alpha-arm-bpf-evm-m680x-m68k-mips-mos65xx-ppc-riscv-sh-sparc-sysz-tms320c64x-tricore-wasm-xcore-x86-c5.0-b5.0
>>> print(capstone._path)
/Users/rtsang/Documents/Research/projects/embedded-emu/capstone/bindings/python/capstone/lib The capstone library path is pointing to From what I can tell, this path should be right, but diff-ing the dylib file from the built version does show that it is different: $ diff capstone/lib/libcapstone.dylib ../../libcapstone.5.dylib
Binary files capstone/lib/libcapstone.dylib and ../../libcapstone.5.dylib differ Though admittedly, there could be any number of reasons for this since idk if the binary changes when copied. So I don't think I have a multiple install problem. I do have capstone also installed via brew, but that is the latest version and does not have the problem I was seeing with #1935 as I am still getting when I install to virtual environment using I did manage to manually specify the correct dylib for >>> from capstone import *
>>> from capstone.arm_const import *
>>> cs = Cs(CS_ARCH_ARM, CS_MODE_THUMB)
>>> insn = next(cs.disasm(b"\xff\xf7\xad\xff", 0))
>>> insn
<CsInsn 0x0 [fff7adff]: bl 0xffffff5e> However, when it is not specified, the default dylib being built or used by |
Did you installed the |
when I installed to the conda environment it was with |
Ok, huh, odd. I just tried Also, this may need it's own issue, but when it's installed to pip, it shows up 3 times on $ sudo make install3
$ pip list
DEPRECATION: Loading egg at /opt/homebrew/Caskroom/miniforge/base/envs/capstone/lib/python3.11/site-packages/capstone-5.0.0.post1-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. Discussion can be found at https://github.com/pypa/pip/issues/12330
Package Version
---------- -----------
capstone 5.0.0.post1
capstone 5.0.0.post1
capstone 5.0.0.post1
pip 24.0
setuptools 69.1.0
wheel 0.42.0 |
Yeah, the build instructions need some love as well. But there are a few things which need some care, when it comes to the Python bindings. Is this issue solved with this? |
See #1935 for original issue, whose underlying issue was resolved in #1949.
On Mac M1 Pro, macOS Sonoma 14.2.1.
Python 3.11,
next
branch @215eae8
The original issue was that dissassembling Thumb branch/call immediate instructions did not calculate the correct immediate value.
For instance, in the following example:
The correct result (as can be verified with
cstool
) is0xffffff5e
:Since
cstool
works, it would seem that there is an issue with building the python bindings, though I haven't managed to locate it.Seems like it might be related to and/or solved by #2223, though I was using 3.11 to avoid the issues mentioned there.
Building python bindings following these steps:
Which puts
capstone 5.0.0.post1
in my pip environment (which should ostensibly not matter, because the original issue should've been fixed with v5).The text was updated successfully, but these errors were encountered: