LLVM-MC(1)

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

okay so. this is a page from the LLVM manual set, and it's literally the glow-up era of assembly tooling. welcome to the playground, babe πŸŽ€


✨ NAME ✨

llvm-mc β€” LLVM Machine Code Playground πŸ‘‘


🌸 SYNOPSIS 🌸

llvm-mc [options] [filename]

πŸ¦‹ DESCRIPTION πŸ¦‹

So llvm-mc takes assembly code for an architecture you pick, and it makes an object file or an executable out of it. That's the whole vibe. 🫢

It's basically a little toolkit for machine code β€” encoding instructions, showing you the internal representations, disassembling strings into bytes, all of that. It's giving "backstage pass to the assembler." πŸ’…

And here's the cute part: which architecture it targets for the output assembly is figured out automatically from your input file. Unless you use the --arch option to override the default, in which case you're the main character and you decide. ✨


πŸ”₯ OPTIONS πŸ”₯

First, the output tea β˜• β€” because this part matters:

  • If you leave out the -o option, llvm-mc sends its output to standard output when the input is from standard input.
  • If -o is set to "-", the output also goes to standard output. periodt.
  • If there's no -o option and you gave an input file that isn't "-", then llvm-mc builds the output filename like this: take the input filename, strip any existing .s extension, and slap a .o on the end. iconic behavior fr fr. 🧚

And all the other llvm-mc options are down below, bestie. ⬇️

🌈 End-user Options 🌈

  • --help β€” shows you all the available options. Add --help-hidden if you want more. πŸ™ˆ
  • -o <filename> β€” use <filename> as the output filename. scroll up to the summary if you want the deets. πŸ’–
  • --arch=<string> β€” the target arch you're assembling for. run -version to see which targets are actually available. πŸ‘‘
  • --as-lex β€” applies the assembler's "lexer" to chop your input into tokens and print each one out. this one's for developing and testing an assembler implementation, iykyk. πŸ”€
  • --assemble β€” assemble the assembly file (this is the default!), and print the result out as assembly. super useful for designing and testing instruction parsers, and it's lowkey a great tool when you pair it with other llvm-mc flags. for example, it's handy for transcoding 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 combine it with --show-encoding to understand how instructions are encoded. ate. πŸ’…
  • --disassemble β€” parses a series of hex bytes and prints the result out as assembly syntax. hex in, assembly out, slay. πŸ¦‹
  • --mdis β€” marked up disassembly of a string of hex bytes. fancy. ✨
  • --cdis β€” colored disassembly of a string of hex bytes. it's giving rainbow 🌈
  • --filetype=[asm,null,obj] β€” sets the output filetype. asm makes the tool output text assembly. obj makes the tool output an object file. null means no output gets created at all, which is great for timing purposes. the default value is asm. πŸ“„
  • -g β€” generate DWARF debugging info for assembly source files. πŸ›
  • --hex β€” takes raw hexadecimal bytes as input for disassembly. whitespace gets ignored, no stress. πŸ’œ
  • --large-code-model β€” creates CFI directives that assume the code might be more than 2 GB. big code, big energy. πŸ’€
  • --main-file-name=<string> β€” specify the name we should consider the input file. 🏷️
  • --masm-hexfloats β€” enables 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> β€” the target triple to assemble for. run -version to see the available targets. ⭐
  • --split-dwarf-file=<filename> β€” DWO output filename. πŸ—‚οΈ
  • --show-inst-operands β€” shows instruction operands as they're parsed. πŸ‘€
  • --show-inst β€” shows the internal instruction representation. πŸ”
  • --show-encoding β€” shows instruction encodings. πŸ”’
  • --save-temp-labels β€” don't discard temporary labels. keep them, they're precious. πŸ₯Ί
  • --relax-relocations β€” emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL. glow-up for your relocations. ✨
  • --print-imm-hex β€” prefers hex format for immediate values. πŸ”‘
  • --preserve-comments β€” preserves comments in the outputted assembly. your thoughts stay valid, bestie. πŸ’¬
  • --output-asm-variant=<uint> β€” the 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. pick your fighter. βš”οΈ
  • --compress-debug-sections=[none|zlib|zstd] β€” choose DWARF debug sections compression. zip zip. 🀐

πŸ’€ EXIT STATUS πŸ’€

If llvm-mc succeeds, it exits with 0. πŸŽ‰

Otherwise, if an error happens, it exits with a non-zero value. 😭


🫢 AUTHOR 🫢

Maintained by the LLVM Team (https://llvm.org/). they're the blueprint, honestly. πŸ‘‘


2003-2026, LLVM Project


and that's the whole page, bestie β€” no cap, every flag accounted for. πŸ’–βœ¨

cute little sign-off for the footer tea: this page is from the LLVM source, dated 2026-07-22, sitting in the LLVM-MC(1) slot of the manual. mwah πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from