2025-03-14 21:59:59 -06:00
|
|
|
# llvm-mc
|
|
|
|
|
|
|
|
|
|
> LLVM Machine Code Playground. It provides a set of tools for working with LLVM machine code.
|
|
|
|
|
> Part of LLVM.
|
|
|
|
|
> More information: <https://llvm.org/docs/CommandGuide/llvm-mc.html>.
|
|
|
|
|
|
|
|
|
|
- Assemble assembly code file into object file with machine code:
|
|
|
|
|
|
|
|
|
|
`llvm-mc --filetype=obj -o {{path/to/output.o}} {{path/to/input.s}}`
|
|
|
|
|
|
|
|
|
|
- Disassemble object file with machine code into assembly code file:
|
|
|
|
|
|
|
|
|
|
`llvm-mc --disassemble -o {{path/to/output.s}} {{path/to/input.o}}`
|
|
|
|
|
|
|
|
|
|
- Compile LLVM bit code file into assembly code:
|
|
|
|
|
|
|
|
|
|
`llvm-mc -o {{path/to/output.s}} {{path/to/input.bc}}`
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
- Assemble assembly code from `stdin` and show encoding to `stdout`:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
`echo "{{addl %eax, %ebx}}" | llvm-mc -show-encoding -show-inst`
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
- Disassemble machine code from `stdin` for specified triple:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
`echo "{{0xCD 0x21}}" | llvm-mc --disassemble -triple={{target_name}}`
|