Is there a python binding, or any other script binding, that has access to individual instructions?

There is llvmlite llvmlite — llvmlite 0.40.0dev0-9-g395022f-dirty documentation , but it doesn't seem to support reading individual instructions, based on these docs.

I was thinking to make a simple code analysis tool to, for example, find all system calls that have unchecked return codes, but I can't find a binding for any scripting language. And I am averse to writing this in C++.

Thanks,

Yuri

Hi Yuri,

When you say code analysis, do you mean checking from source code itself, the intermediate representation, the assembly instructions or the binary?

Brenda

I was going to check C/C++ source code by the means of compiling it into .ll format and looking at the instruction level.

Yuri

Hi,

I was thinking to make a simple code analysis tool to, for example, find all system calls that have unchecked return codes, but I can't find a binding for any scripting language. And I am averse to writing this in C++.

One possible choice would be llvmcpy -- Python bindings used by the rev.ng (https://rev.ng/) project:
GitHub - revng/llvmcpy: Python bindings for LLVM auto-generated from the LLVM-C API

Here's an example showing syscalls invocations tracing:

Best,
Matt

This works, thank you!

I've created the FreeBSD port for llvmcpy.

Thanks!

Yuri

There is llvmlite llvmlite — llvmlite 0.40.0dev0-9-g395022f-dirty documentation , but it doesn't seem to support reading individual instructions, based on these docs.

I was thinking to make a simple code analysis tool to, for example, find all system calls that have unchecked return codes, but I can't find a binding for any scripting language. And I am averse to writing this in C++.

Thanks,

Yuri