emproof-com / nyxstone

Nyxstone: assembly / disassembly library based on LLVM, implemented in C++ with Rust and Python bindings, maintained by emproof.com
https://www.emproof.com
MIT License
231 stars 6 forks source link

ARM bl instruction with supplied label fails to assemble #63

Closed adrianherrera closed 5 days ago

adrianherrera commented 5 days ago

Branch and link to a provided label fails to assemble.

E.g.,:

from nyxstone import Nyxstone

ns = Nyxstone("arm")
ns.assemble("bl .label", labels={".label": 0x1000})

Produces the error:

ValueError: Error during assembly: error: Could not resolve relocation/label (reported by Nyxstone)
bl .label
^

Note that ns.assemble("b .label", labels={".label": 0x1000}) works.

stuxnot commented 5 days ago

Thank you for reporting this. LLVM seems to emit a relocation for bl but not for b, but only if the triple/architecture is specified as a shorthand. If you use thumbv8, aarch64, or armv8m.main-none-eabi as the triple, Nyxstone is able to assemble the bl. We will update the README and docs to make selecting triples easier.

adrianherrera commented 4 days ago

Oooooh, okay! Thanks for the quick response + updates!