LLVM-MC(1)

πŸ’– LLVM-MC(1) β€” the LLVM Machine Code Playground πŸ’–

okay bestie, welcome to the LLVM manual, section 1, and this one is genuinely iconic. it's called llvm-mc, it's the machine code playground, and yes we're gonna read the whole thing together. grab a snack. πŸ“


✨ NAME ✨

llvm-mc β€” the LLVM Machine Code Playground 🎠


🌈 SYNOPSIS 🌈

llvm-mc [options] [filename]

that's it. that's the whole vibe. options and maybe a file. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so the way that llvm-mc works is: you hand it assembly code for whatever architecture you picked, and it hands you back an object file or an executable. slay.

it's basically a whole little toolkit for messing with machine code β€” encoding instructions, showing you the internal representations, disassembling strings into bytes, all of it. no cap.

and here's the cute part: which architecture it assembles for gets figured out automatically from the input file. you don't have to do anything. unless you want to override it, in which case you use --arch and you're the main character now. πŸ‘‘


πŸ‘‘ OPTIONS πŸ‘‘

okay so first, some output rules before we get into the actual flags, because these matter and i need you to pay attention:

  • if you omit -o, then llvm-mc sends its output to standard output β€” but only if the input is coming from standard input too.
  • if -o is set to "-", the output also goes to standard output. periodt.
  • and if you don't specify -o at all and your input file is something other than "-", then llvm-mc makes up an output filename for you: it takes the input filename, removes any existing .s extension, and adds a .o suffix. cute, right?

the rest of the options are below, bestie. πŸ’œ

πŸŽ€ End-user Options πŸŽ€

  • --help β€” shows you all the available options. (and --help-hidden shows you even more, if you're nosy like me πŸ™ˆ)
  • -o <filename> β€” use <filename> as the output filename. see the summary above for the details, i'm not retyping all that.
  • --arch=<string> β€” the target arch to assemble for. run -version to see which targets you actually have available.
  • --as-lex β€” runs the assembler's "lexer" on your input, breaking it into tokens and printing every single one out. this exists to help people develop and test assembler implementations. it's giving microscope energy πŸ”¬
  • --assemble β€” assemble the assembly file (this is the default), and print the result back out as assembly. super useful for designing and testing instruction parsers, and it's a great tool when you combine it with other llvm-mc flags. for example, it can transcode assembly between different dialects β€” like on Intel, where you can use -output-asm-variant=1 to translate from AT&T to Intel assembly syntax. you can also pair it with --show-encoding to understand how instructions are encoded. combo moves πŸ’…
  • --disassemble β€” parse a series of hex bytes and print the result out as assembly syntax.
  • --mdis β€” marked up disassembly of a string of hex bytes.
  • --cdis β€” colored disassembly of a string of hex bytes. 🌈
  • --filetype=[asm,null,obj] β€” sets the output filetype.
    • asm β†’ the tool outputs text assembly
    • obj β†’ the tool outputs an object file
    • null β†’ no output gets created at all, which is handy for timing purposes
    • the default value is asm.
  • -g β€” generate DWARF debugging info for assembly source files.
  • --hex β€” take raw hexadecimal bytes as input for disassembly. whitespace is ignored. 🧚
  • --large-code-model β€” create CFI directives that assume the code might be more than 2 GB. big girl code. πŸ’€
  • --main-file-name=<string> β€” specify the name we should consider the input file.
  • --masm-hexfloats β€” enable MASM-style hex float initializers (3F800000r).
  • -mattr=a1,+a2,-a3,... β€” target specific attributes (-mattr=help for details).
  • --mcpu=<cpu-name> β€” target a specific cpu type (-mcpu=help for details).
  • --triple=<string> β€” target triple to assemble for, see -version for available targets.
  • --split-dwarf-file=<filename> β€” DWO output filename.
  • --show-inst-operands β€” show instruction operands as parsed.
  • --show-inst β€” show the internal instruction representation.
  • --show-encoding β€” show instruction encodings.
  • --save-temp-labels β€” don't discard temporary labels.
  • --relax-relocations β€” emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL.
  • --print-imm-hex β€” prefer hex format for immediate values.
  • --preserve-comments β€” preserve comments in the outputted assembly.
  • --output-asm-variant=<uint> β€” syntax variant to use for output printing. for example, on x86 targets --output-asm-variant=0 prints in AT&T syntax, and --output-asm-variant=1 prints in Intel/MASM syntax.
  • --compress-debug-sections=[none|zlib|zstd] β€” choose DWARF debug sections compression.

⭐ EXIT STATUS ⭐

if llvm-mc succeeds, it exits with 0. if something goes wrong, it exits with a non-zero value. no in-between, she's decisive. πŸ’…


🌸 Author 🌸

maintained by the LLVM Team (https://llvm.org/). shoutout to the whole squad. 🫢


2003-2026, LLVM Project


and that's the whole page bestie!! this was LLVM-MC(1) from the LLVM manual, page 22, dated 2026-07-16. you ate that. go assemble something iconic. βœ¨πŸ‘‘πŸ’…

πŸ“¦ where this page comes from