LLVM-MC(1)

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

okay so. hi. you're looking at the manual for llvm-mc from the LLVM fam, and honestly? she's a whole vibe. let's get into it. πŸ¦‹


✨ NAME ✨

llvm-mc β€” literally the LLVM Machine Code Playground. that's it. that's the name. iconic. πŸ‘‘


🌸 SYNOPSIS 🌸

llvm-mc [options] [filename]

πŸŽ€ DESCRIPTION πŸŽ€

so what does she even do. llvm-mc takes assembly code for a specified architecture as input and generates an object file or executable. periodt. πŸ’…

she's basically a lil toolbox for working with machine code β€” encoding instructions, showing you the internal representations of stuff, disassembling strings into bytes, all of it. she's giving swiss army knife, she's giving main character energy. ✨

and the architecture for the output assembly code? she figures that out automatically from the input file. no cap. the only time she doesn't is when you use the --arch option to override the default. then you're the boss. 🫢


πŸ”₯ OPTIONS πŸ”₯

first, the housekeeping on output, because this part is actually important:

  • if you skip the -o option, llvm-mc sends its output to standard output when the input is coming from standard input. makes sense, right?
  • if -o is set to "-", the output also goes to standard output. same energy.
  • if there's no -o and the input file is something other than "-", then llvm-mc makes the output filename for you: it takes the input filename, removes any existing .s extension, and adds a .o suffix. so like thing.s β†’ thing.o. cute, efficient, no notes. πŸ’–

the rest of the options are below. strap in.

🧚 End-user Options 🧚

  • --help β€” display the available options. (there's also --help-hidden for more, if you're nosy. and honestly? be nosy. πŸ™ˆ)
  • -o <filename> β€” use <filename> as the output filename. see the summary above for the deets.
  • --arch=<string> β€” the target arch to assemble for. check -version for the available targets, bestie.
  • --as-lex β€” apply the assembler's "lexer" to break the input into tokens and print each one out. this is here to help develop and test an assembler implementation. it's giving "peek behind the curtain". ✨
  • --assemble β€” assemble the assembly file (this is the default), and print the result to assembly. this is useful for designing and testing instruction parsers, and it's a genuinely useful tool when you combine it with other llvm-mc flags. for example, this option may be useful to transcode assembly from 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. reverse uno card. πŸ’€
  • --mdis β€” marked up disassembly of a string of hex bytes.
  • --cdis β€” colored disassembly of a string of hex bytes. 🌈 (the aesthetic option, obviously.)
  • --filetype=[asm,null,obj] β€” sets the output filetype. set it to asm and the tool outputs text assembly. set it to obj and the tool outputs an object file. set it to null and no output is created at all β€” which you can use for timing purposes. the default value is asm.
  • -g β€” generate DWARF debugging info for assembly source files. debug girlies rise. πŸ›
  • --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 code. big energy. πŸ’ͺ
  • --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 internal instruction representation.
  • --show-encoding β€” show instruction encodings.
  • --save-temp-labels β€” don't discard temporary labels. keep them. they're valid. πŸ₯Ί
  • --relax-relocations β€” emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL.
  • --print-imm-hex β€” prefer hex format for immediate values. hex girlies, this one's for you. πŸ“
  • --preserve-comments β€” preserve comments in outputted assembly. (yes, your little ; hi notes. they live on. 🫢)
  • --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.
  • --compress-debug-sections=[none|zlib|zstd] β€” choose DWARF debug sections compression. squish. πŸ—œοΈ

πŸ’… EXIT STATUS πŸ’…

if llvm-mc succeeds, she exits with 0. otherwise, if an error occurs, she exits with a non-zero value. simple as. ✨


🌟 AUTHOR 🌟

maintained by the LLVM Team (https://llvm.org/). the whole squad. πŸ‘‘


2003-2025, LLVM Project


ok and that's the whole page!! no cap, you read all of it, I'm so proud of you bestie πŸ₯ΉπŸ’–

LLVM Β· version 20 Β· dated 2025-09-03 Β· mwah, go assemble something iconic πŸ’…βœ¨

πŸ“¦ where this page comes from