llvm-mc - Man Page

LLVM Machine Code Playground

Synopsis

llvm-mc [options] [filename]

Description

The llvm-mc command takes assembly code for a specified architecture as input and generates an object file or executable.

llvm-mc provides a set of tools for working with machine code, such as encoding instructions and displaying internal representations, disassembling strings to bytes, etc.

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.

Options

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

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.

Other llvm-mc options are described below.

End-user Options

--help

Display available options (--help-hidden for more).

-o <filename>

Use <filename> as the output filename. See the summary above for more details.

--arch=<string>

Target arch to assemble for, see -version for available targets.

--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.

--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.

--disassemble

Parse a series of hex bytes, and print the result out as assembly syntax.

--mdis

Marked up disassembly of string of hex bytes.

--cdis

Colored disassembly of string of hex bytes.

--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.

-g

Generate DWARF debugging info for assembly source files.

--large-code-model

Create CFI directives that assume the code might be more than 2 GB.

--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 instructions operands as parsed.

--show-inst

Show internal instruction representation.

--show-encoding

Show instruction encodings.

--save-temp-labels

Don't discard temporary labels.

--relax-relocations

Emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL.

--print-imm-hex

Prefer hex format for immediate values.

--preserve-comments

Preserve Comments in outputted assembly.

--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.

--compress-debug-sections=[none|zlib|zstd]

Choose DWARF debug sections compression.

Exit Status

If llvm-mc succeeds, it will exit with 0.  Otherwise, if an error occurs, it will exit with a non-zero value.

Author

Maintained by the LLVM Team (https://llvm.org/).

Info

2024-05-17 19 LLVM