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
321 stars 16 forks source link

ARM bl instruction with supplied label fails to assemble #63

Closed adrianherrera closed 4 months ago

adrianherrera commented 4 months 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 4 months 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 months ago

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