LLVM-MC(1)

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

okay so bestie, welcome to llvm-mc, literally the LLVM Machine Code Playground β€” the manual name is LLVM-MC(1) and it's from the LLVM crew, and it's about to become your new obsession ✨


🌸 NAME 🌸

llvm-mc β€” the LLVM Machine Code Playground, no cap πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

llvm-mc [options] [filename]

✨ DESCRIPTION ✨

So the llvm-mc command takes input as the assembly code for a specified architecture and generates an object file or executable as an output for a specified architecture. Slay. πŸ’…

It also provides a powerful set of tools for working with the machine code β€” like encoding of their instruction and their internal representation, disassembling string to bytes, etc. It's giving Swiss Army knife but make it machine code, fr fr. πŸ”₯

The choice of architecture for the output assembly code is automatically determined from the input file, unless the --arch option is used to override the default. Main character energy, honestly. πŸ‘‘


πŸŽ€ OPTIONS πŸŽ€

If the -o option is omitted, then llvm-mc will send its output to standard output if the input is from standard input. And if the -o option specifies -, then the output will also be sent to standard output. iykyk 🫢

If no -o option is specified and an input file other than - is specified, then llvm-mc creates the output filename by taking the input filename, removing any existing .s extension, and adding a .o suffix. Cute and efficient, we love to see it. 🌸

Other llvm-mc options are described below, bestie β€” buckle up:

πŸ’œ End-user Options πŸ’œ

  • --help β€” Display available options (--help-hidden for more). Your go-to when you're like "wait what does anything do" 😭
  • -o <filename> β€” Use <filename> as the output filename. See the summary above for more details. Simple, iconic, done. πŸ’…
  • --arch=<string> β€” Target arch to assemble for, see -version for available targets. Pick your fighter πŸ₯Š
  • --as-lex β€” Apply the assemblers "lexer" to break the input into tokens and print each of them out. This is intended to help develop and test an assembler implementation. It's literally the vibe check for your tokens. πŸ”
  • --assemble β€” Assemble assembly file (default), and print the result to assembly. This is useful to design and test instruction parsers, and can be a useful tool when combined with other llvm-mc flags. For example, this option may be useful to transcode assembly from different dialects, e.g. on Intel where you can use -output-asm-variant=1 to translate from AT&T to Intel assembly syntax. It can also be combined with --show-encoding to understand how instructions are encoded. This option ate and left no crumbs. πŸ”₯
  • --disassemble β€” Parse a series of hex bytes, and print the result out as assembly syntax. Hex bytes to assembly? It's giving magic trick, ngl. ✨
  • --mdis β€” Marked up disassembly of string of hex bytes. A little extra flair on your disassembly, we love a glow-up. πŸ’–
  • --filetype=[asm,null,obj] β€” Sets the output filetype. Setting this flag to asm will make the tool output text assembly. Setting this flag to obj will make the tool output an object file. Setting it to null causes no output to be created and can be used for timing purposes. The default value is asm. Choose your output era. 🌈
  • -g β€” Generate DWARF debugging info for assembly source files. For when you need to know what's really going on, fr fr πŸ•΅οΈ
  • --large-code-model β€” Create CFI directives that assume the code might be more than 2 GB. Big code, big energy, no cap. πŸ’€
  • --main-file-name=<string> β€” Specify the name we should consider the input file. Just naming things, nbd. 🏷️
  • --masm-hexfloats β€” Enable MASM-style hex float initializers (3F800000r). Hex floats but make it MASM, we stay cultured. 🧚
  • -mattr=a1,+a2,-a3,... β€” Target specific attributes (-mattr=help for details). Turn features on and off like a light switch, periodt. πŸ’‘
  • --mcpu=<cpu-name> β€” Target a specific cpu type (-mcpu=help for details). It's giving "I know exactly which CPU I want" energy. πŸ‘‘
  • --triple=<string> β€” Target triple to assemble for, see -version for available targets. The triple threat of assembly, literally. 🎯
  • --split-dwarf-file=<filename> β€” DWO output filename. DWO is short and mysterious and we respect that. πŸ¦‹
  • --show-inst-operands β€” Show instructions operands as parsed. Peek behind the curtain, bestie. πŸ‘€
  • --show-inst β€” Show internal instruction representation. The instruction's inner monologue, basically. πŸ’­
  • --show-encoding β€” Show instruction encodings. See exactly how the instructions are encoded, no mystery, no gatekeeping. πŸ”
  • --save-temp-labels β€” Don't discard temporary labels. Keep the temp labels, they might be main characters too. πŸŽ€
  • --relax-relocations β€” Emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL. Two relocations walk into a bar and one is way more relaxed. 😌
  • --print-imm-hex β€” Prefer hex format for immediate values. Hex girlies rise. πŸ”’
  • --preserve-comments β€” Preserve Comments in outputted assembly. Your comments are safe with us, we would never. 🫢
  • --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. Pick your syntax flavor. 🌢️
  • --compress-debug-sections=[none|zlib|zstd] β€” Choose DWARF debug sections compression. Zip it, zstd it, or leave it alone β€” your call, bestie. πŸ—œοΈ

πŸ’€ EXIT STATUS πŸ’€

If llvm-mc succeeds, it will exit with 0. Otherwise, if an error occurs, it will exit with a non-zero value. So if you see 0, you ate. If you see non-zero, something is not giving what it's supposed to give. 😭


🫢 AUTHOR 🫢

Maintained by the LLVM Team (https://llvm.org/). They're the parents of this whole playground, we love them for it. πŸ’–


2003-2023, LLVM Project β€” iconic longevity, no cap. πŸ‘‘


bestie if you're still here, you're literally a machine code scholar now. go assemble something iconic. πŸ¦‹βœ¨

~~ with love from the LLVM Project, version 17, dated 2023-12-01 β€” mwah πŸ’‹ ~~

πŸ“¦ where this page comes from