1 llvm-mc - LLVM Machine Code Playground
2 ======================================
9 :program:`llvm-mc` [*options*] [*filename*]
14 The :program:`llvm-mc` command takes assembly code for a specified architecture
15 as input and generates an object file or executable.
17 :program:`llvm-mc` provides a set of tools for working with machine code,
18 such as encoding instructions and displaying internal representations,
19 disassembling strings to bytes, etc.
21 The choice of architecture for the output assembly code is automatically
22 determined from the input file, unless the :option:`--arch` option is used to
28 If the :option:`-o` option is omitted, then :program:`llvm-mc` will send its
29 output to standard output if the input is from standard input. If the
30 :option:`-o` option specifies "``-``", then the output will also be sent to
33 If no :option:`-o` option is specified and an input file other than "``-``" is
34 specified, then :program:`llvm-mc` creates the output filename by taking the
35 input filename, removing any existing ``.s`` extension, and adding a ``.o``
38 Other :program:`llvm-mc` options are described below.
45 Display available options (--help-hidden for more).
47 .. option:: -o <filename>
49 Use ``<filename>`` as the output filename. See the summary above for more
52 .. option:: --arch=<string>
54 Target arch to assemble for, see -version for available targets.
58 Apply the assemblers "lexer" to break the input into tokens and print each of
59 them out. This is intended to help develop and test an assembler
62 .. option:: --assemble
64 Assemble assembly file (default), and print the result to assembly. This is
65 useful to design and test instruction parsers, and can be a useful tool when
66 combined with other llvm-mc flags. For example, this option may be useful to
67 transcode assembly from different dialects, e.g. on Intel where you can use
68 -output-asm-variant=1 to translate from AT&T to Intel assembly syntax. It can
69 also be combined with --show-encoding to understand how instructions are
72 .. option:: --disassemble
74 Parse a series of hex bytes, and print the result out as assembly syntax.
78 Marked up disassembly of string of hex bytes.
82 Colored disassembly of string of hex bytes.
84 .. option:: --filetype=[asm,null,obj]
86 Sets the output filetype. Setting this flag to `asm` will make the tool output
87 text assembly. Setting this flag to `obj` will make the tool output an object
88 file. Setting it to `null` causes no output to be created and can be used for
89 timing purposes. The default value is `asm`.
93 Generate DWARF debugging info for assembly source files.
95 .. option:: --large-code-model
97 Create CFI directives that assume the code might be more than 2 GB.
99 .. option:: --main-file-name=<string>
101 Specify the name we should consider the input file.
104 .. option:: --masm-hexfloats
106 Enable MASM-style hex float initializers (3F800000r).
109 .. option:: -mattr=a1,+a2,-a3,...
110 Target specific attributes (-mattr=help for details).
112 .. option:: --mcpu=<cpu-name>
114 Target a specific cpu type (-mcpu=help for details).
116 .. option:: --triple=<string>
118 Target triple to assemble for, see -version for available targets.
120 .. option:: --split-dwarf-file=<filename>
124 .. option:: --show-inst-operands
126 Show instructions operands as parsed.
128 .. option:: --show-inst
130 Show internal instruction representation.
132 .. option:: --show-encoding
134 Show instruction encodings.
136 .. option:: --save-temp-labels
138 Don't discard temporary labels.
140 .. option:: --relax-relocations
142 Emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL.
144 .. option:: --print-imm-hex
146 Prefer hex format for immediate values.
148 .. option:: --preserve-comments
150 Preserve Comments in outputted assembly.
152 .. option:: --output-asm-variant=<uint>
154 Syntax variant to use for output printing. For example, on x86 targets
155 --output-asm-variant=0 prints in AT&T syntax, and --output-asm-variant=1
156 prints in Intel/MASM syntax.
158 .. option:: --compress-debug-sections=[none|zlib|zstd]
160 Choose DWARF debug sections compression.
166 If :program:`llvm-mc` succeeds, it will exit with 0. Otherwise, if an error
167 occurs, it will exit with a non-zero value.