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, thenllvm-mcsends its output to standard output β but only if the input is coming from standard input too. - if
-ois set to"-", the output also goes to standard output. periodt. - and if you don't specify
-oat all and your input file is something other than"-", thenllvm-mcmakes up an output filename for you: it takes the input filename, removes any existing.sextension, and adds a.osuffix. cute, right?
the rest of the options are below, bestie. π
π End-user Options π
--helpβ shows you all the available options. (and--help-hiddenshows 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-versionto 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 otherllvm-mcflags. for example, it can transcode assembly between different dialects β like on Intel, where you can use-output-asm-variant=1to translate from AT&T to Intel assembly syntax. you can also pair it with--show-encodingto 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 assemblyobjβ the tool outputs an object filenullβ 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=helpfor details).--mcpu=<cpu-name>β target a specific cpu type (-mcpu=helpfor details).--triple=<string>β target triple to assemble for, see-versionfor 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β emitR_X86_64_GOTPCRELXinstead ofR_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=0prints in AT&T syntax, and--output-asm-variant=1prints 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. π«Ά
π Copyright π
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
- fedora 44: llvm 22.1.8-4.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 44: llvm 22.1.8-4.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms