]> granicus.if.org Git - yasm/blob - yasm.1
Add missing objfmt_x64 to CMakeLists.txt.
[yasm] / yasm.1
1 '\" t
2 .\"     Title: yasm
3 .\"    Author: Peter Johnson <peter@tortall.net>
4 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
5 .\"      Date: April 2007
6 .\"    Manual: The Yasm Modular Assembler
7 .\"    Source: Yasm
8 .\"  Language: English
9 .\"
10 .TH "YASM" "1" "April 2007" "Yasm" "The Yasm Modular Assembler"
11 .\" -----------------------------------------------------------------
12 .\" * set default formatting
13 .\" -----------------------------------------------------------------
14 .\" disable hyphenation
15 .nh
16 .\" disable justification (adjust text to left margin only)
17 .ad l
18 .\" -----------------------------------------------------------------
19 .\" * MAIN CONTENT STARTS HERE *
20 .\" -----------------------------------------------------------------
21 .SH "NAME"
22 yasm \- The Yasm Modular Assembler
23 .SH "SYNOPSIS"
24 .HP \w'\fByasm\fR\ 'u
25 \fByasm\fR [\fB\-f\ \fR\fB\fIformat\fR\fR] [\fB\-o\ \fR\fB\fIoutfile\fR\fR] [\fB\fIother\ options\fR\fR...] {\fIinfile\fR}
26 .HP \w'\fByasm\fR\ 'u
27 \fByasm\fR \fB\-h\fR
28 .SH "DESCRIPTION"
29 .PP
30 The Yasm Modular Assembler is a portable, retargetable assembler written under the
31 \(lqnew\(rq
32 (2 or 3 clause) BSD license\&. Yasm currently supports the x86 and AMD64 instruction sets, accepts NASM and GAS assembler syntaxes, outputs binary, ELF32, ELF64, COFF, Win32, and Win64 object formats, and generates source debugging information in STABS, DWARF 2, and CodeView 8 formats\&.
33 .PP
34 YASM consists of the
35 \fByasm\fR
36 command, libyasm, the core backend library, and a large number of modules\&. Currently, libyasm and the loadable modules are statically built into the
37 \fByasm\fR
38 executable\&.
39 .PP
40 The
41 \fByasm\fR
42 command assembles the file infile and directs output to the file
43 \fIoutfile\fR
44 if specified\&. If
45 \fIoutfile\fR
46 is not specified,
47 \fByasm\fR
48 will derive a default output file name from the name of its input file, usually by appending
49 \&.o
50 or
51 \&.obj, or by removing all extensions for a raw binary file\&. Failing that, the output file name will be
52 yasm\&.out\&.
53 .PP
54 If called with an
55 \fIinfile\fR
56 of
57 \(lq\-\(rq,
58 \fByasm\fR
59 assembles the standard input and directs output to the file
60 \fIoutfile\fR, or
61 yasm\&.out
62 if no
63 \fIoutfile\fR
64 is specified\&.
65 .SH "OPTIONS"
66 .PP
67 Many options may be given in one of two forms: either a dash followed by a single letter, or two dashes followed by a long option name\&. Options are listed in alphabetical order\&.
68 .SS "General Options"
69 .PP
70 \fB\-a \fR\fB\fIarch\fR\fR or \fB\-\-arch=\fR\fB\fIarch\fR\fR: Select target architecture
71 .RS 4
72 Selects the target architecture\&. The default architecture is
73 \(lqx86\(rq, which supports both the IA\-32 and derivatives and AMD64 instruction sets\&. To print a list of available architectures to standard output, use
74 \(lqhelp\(rq
75 as
76 \fIarch\fR\&. See
77 \fByasm_arch\fR(7)
78 for a list of supported architectures\&.
79 .RE
80 .PP
81 \fB\-f \fR\fB\fIformat\fR\fR or \fB\-\-oformat=\fR\fB\fIformat\fR\fR: Select object format
82 .RS 4
83 Selects the output object format\&. The default object format is
84 \(lqbin\(rq, which is a flat format binary with no relocation\&. To print a list of available object formats to standard output, use
85 \(lqhelp\(rq
86 as
87 \fIformat\fR\&. See
88 \fByasm_objfmts\fR(7)
89 for a list of supported object formats\&.
90 .RE
91 .PP
92 \fB\-g \fR\fB\fIdebug\fR\fR or \fB\-\-dformat=\fR\fB\fIdebug\fR\fR: Select debugging format
93 .RS 4
94 Selects the debugging format for debug information\&. Debugging information can be used by a debugger to associate executable code back to the source file or get data structure and type information\&. Available debug formats vary between different object formats;
95 \fByasm\fR
96 will error when an invalid combination is selected\&. The default object format is selected by the object format\&. To print a list of available debugging formats to standard output, use
97 \(lqhelp\(rq
98 as
99 \fIdebug\fR\&. See
100 \fByasm_dbgfmts\fR(7)
101 for a list of supported debugging formats\&.
102 .RE
103 .PP
104 \fB\-L \fR\fB\fIlist\fR\fR or \fB\-\-lformat=\fR\fB\fIlist\fR\fR: Select list file format
105 .RS 4
106 Selects the format/style of the output list file\&. List files typically intermix the original source with the machine code generated by the assembler\&. The default list format is
107 \(lqnasm\(rq, which mimics the NASM list file format\&. To print a list of available list file formats to standard output, use
108 \(lqhelp\(rq
109 as
110 \fIlist\fR\&.
111 .RE
112 .PP
113 \fB\-l \fR\fB\fIlistfile\fR\fR or \fB\-\-list=\fR\fB\fIlistfile\fR\fR: Specify list filename
114 .RS 4
115 Specifies the name of the output list file\&. If this option is not used, no list file is generated\&.
116 .RE
117 .PP
118 \fB\-m \fR\fB\fImachine\fR\fR or \fB\-\-machine=\fR\fB\fImachine\fR\fR: Select target machine architecture
119 .RS 4
120 Selects the target machine architecture\&. Essentially a subtype of the selected architecture, the machine type selects between major subsets of an architecture\&. For example, for the
121 \(lqx86\(rq
122 architecture, the two available machines are
123 \(lqx86\(rq, which is used for the IA\-32 and derivative 32\-bit instruction set, and
124 \(lqamd64\(rq, which is used for the 64\-bit instruction set\&. This differentiation is required to generate the proper object file for relocatable object formats such as COFF and ELF\&. To print a list of available machines for a given architecture to standard output, use
125 \(lqhelp\(rq
126 as
127 \fImachine\fR
128 and the given architecture using
129 \fB\-a \fR\fB\fIarch\fR\fR\&. See
130 \fByasm_arch\fR(7)
131 for more details\&.
132 .RE
133 .PP
134 \fB\-o \fR\fB\fIfilename\fR\fR or \fB\-\-objfile=\fR\fB\fIfilename\fR\fR: Specify object filename
135 .RS 4
136 Specifies the name of the output file, overriding any default name generated by Yasm\&.
137 .RE
138 .PP
139 \fB\-p \fR\fB\fIparser\fR\fR or \fB\-\-parser=\fR\fB\fIparser\fR\fR: Select parser
140 .RS 4
141 Selects the parser (the assembler syntax)\&. The default parser is
142 \(lqnasm\(rq, which emulates the syntax of NASM, the Netwide Assembler\&. Another available parser is
143 \(lqgas\(rq, which emulates the syntax of GNU AS\&. To print a list of available parsers to standard output, use
144 \(lqhelp\(rq
145 as
146 \fIparser\fR\&. See
147 \fByasm_parsers\fR(7)
148 for a list of supported parsers\&.
149 .RE
150 .PP
151 \fB\-r \fR\fB\fIpreproc\fR\fR or \fB\-\-preproc=\fR\fB\fIpreproc\fR\fR: Select preprocessor
152 .RS 4
153 Selects the preprocessor to use on the input file before passing it to the parser\&. Preprocessors often provide macro functionality that is not included in the main parser\&. The default preprocessor is
154 \(lqnasm\(rq, which is an imported version of the actual NASM preprocessor\&. A
155 \(lqraw\(rq
156 preprocessor is also available, which simply skips the preprocessing step, passing the input file directly to the parser\&. To print a list of available preprocessors to standard output, use
157 \(lqhelp\(rq
158 as
159 \fIpreproc\fR\&.
160 .RE
161 .PP
162 \fB\-h\fR or \fB\-\-help\fR: Print a summary of options
163 .RS 4
164 Prints a summary of invocation options\&. All other options are ignored, and no output file is generated\&.
165 .RE
166 .PP
167 \fB\-\-version\fR: Get the Yasm version
168 .RS 4
169 This option causes Yasm to prints the version number of Yasm as well as a license summary to standard output\&. All other options are ignored, and no output file is generated\&.
170 .RE
171 .SS "Warning Options"
172 .PP
173 \fB\-W\fR
174 options have two contrary forms:
175 \fB\-W\fR\fB\fIname\fR\fR
176 and
177 \fB\-Wno\-\fR\fB\fIname\fR\fR\&. Only the non\-default forms are shown here\&.
178 .PP
179 The warning options are handled in the order given on the command line, so if
180 \fB\-w\fR
181 is followed by
182 \fB\-Worphan\-labels\fR, all warnings are turned off
183 \fIexcept\fR
184 for orphan\-labels\&.
185 .PP
186 \fB\-w\fR: Inhibit all warning messages
187 .RS 4
188 This option causes Yasm to inhibit all warning messages\&. As discussed above, this option may be followed by other options to re\-enable specified warnings\&.
189 .RE
190 .PP
191 \fB\-Werror\fR: Treat warnings as errors
192 .RS 4
193 This option causes Yasm to treat all warnings as errors\&. Normally warnings do not prevent an object file from being generated and do not result in a failure exit status from
194 \fByasm\fR, whereas errors do\&. This option makes warnings equivalent to errors in terms of this behavior\&.
195 .RE
196 .PP
197 \fB\-Wno\-unrecognized\-char\fR: Do not warn on unrecognized input characters
198 .RS 4
199 Causes Yasm to not warn on unrecognized characters found in the input\&. Normally Yasm will generate a warning for any non\-ASCII character found in the input file\&.
200 .RE
201 .PP
202 \fB\-Worphan\-labels\fR: Warn on labels lacking a trailing option
203 .RS 4
204 When using the NASM\-compatible parser, causes Yasm to warn about labels found alone on a line without a trailing colon\&. While these are legal labels in NASM syntax, they may be unintentional, due to typos or macro definition ordering\&.
205 .RE
206 .PP
207 \fB\-X \fR\fB\fIstyle\fR\fR: Change error/warning reporting style
208 .RS 4
209 Selects a specific output style for error and warning messages\&. The default is
210 \(lqgnu\(rq
211 style, which mimics the output of
212 \fBgcc\fR\&. The
213 \(lqvc\(rq
214 style is also available, which mimics the output of Microsoft\'s Visual C++ compiler\&.
215 .sp
216 This option is available so that Yasm integrates more naturally into IDE environments such as
217 Visual Studio
218 or
219 Emacs, allowing the IDE to correctly recognize the error/warning message as such and link back to the offending line of source code\&.
220 .RE
221 .SS "Preprocessor Options"
222 .PP
223 While these preprocessor options theoretically will affect any preprocessor, the only preprocessor currently in Yasm is the
224 \(lqnasm\(rq
225 preprocessor\&.
226 .PP
227 \fB\-D \fR\fB\fImacro[=value]\fR\fR: Pre\-define a macro
228 .RS 4
229 Pre\-defines a single\-line macro\&. The value is optional (if no value is given, the macro is still defined, but to an empty value)\&.
230 .RE
231 .PP
232 \fB\-e\fR or \fB\-\-preproc\-only\fR: Only preprocess
233 .RS 4
234 Stops assembly after the preprocessing stage; preprocessed output is sent to the specified output name or, if no output name is specified, the standard output\&. No object file is produced\&.
235 .RE
236 .PP
237 \fB\-I \fR\fB\fIpath\fR\fR: Add include file path
238 .RS 4
239 Adds directory
240 \fIpath\fR
241 to the search path for include files\&. The search path defaults to only including the directory in which the source file resides\&.
242 .RE
243 .PP
244 \fB\-P \fR\fB\fIfilename\fR\fR: Pre\-include a file
245 .RS 4
246 Pre\-includes file
247 \fIfilename\fR, making it look as though
248 \fIfilename\fR
249 was prepended to the input\&. Can be useful for prepending multi\-line macros that the
250 \fB\-D\fR
251 can\'t support\&.
252 .RE
253 .PP
254 \fB\-U \fR\fB\fImacro\fR\fR: Undefine a macro
255 .RS 4
256 Undefines a single\-line macro (may be either a built\-in macro or one defined earlier in the command line with
257 \fB\-D\fR\&.
258 .RE
259 .SH "EXAMPLES"
260 .PP
261 To assemble NASM syntax, 32\-bit x86 source
262 source\&.asm
263 into ELF file
264 source\&.o, warning on orphan labels:
265 .sp
266 .if n \{\
267 .RS 4
268 .\}
269 .nf
270 yasm \-f elf32 \-Worphan\-labels source\&.asm
271 .fi
272 .if n \{\
273 .RE
274 .\}
275 .PP
276 To assemble NASM syntax AMD64 source
277 x\&.asm
278 into Win64 file
279 object\&.obj:
280 .sp
281 .if n \{\
282 .RS 4
283 .\}
284 .nf
285 yasm \-f win64 \-o object\&.obj x\&.asm
286 .fi
287 .if n \{\
288 .RE
289 .\}
290 .PP
291 To assemble already preprocessed NASM syntax x86 source
292 y\&.asm
293 into flat binary file
294 y\&.com:
295 .sp
296 .if n \{\
297 .RS 4
298 .\}
299 .nf
300 yasm \-f bin \-r raw \-o y\&.com y\&.asm
301 .fi
302 .if n \{\
303 .RE
304 .\}
305 .SH "DIAGNOSTICS"
306 .PP
307 The
308 \fByasm\fR
309 command exits 0 on success, and nonzero if an error occurs\&.
310 .SH "COMPATIBILITY"
311 .PP
312 Yasm\'s NASM parser and preprocessor, while they strive to be as compatible as possible with NASM, have a few incompatibilities due to YASM\'s different internal structure\&.
313 .PP
314 Yasm\'s GAS parser and preprocessor are missing a number of features present in GNU AS\&.
315 .SH "RESTRICTIONS"
316 .PP
317 As object files are often architecture and machine dependent, not all combinations of object formats, architectures, and machines are legal; trying to use an invalid combination will result in an error\&.
318 .PP
319 There is no support for symbol maps\&.
320 .SH "SEE ALSO"
321 .PP
322 \fByasm_arch\fR(7),
323 \fByasm_dbgfmts\fR(7),
324 \fByasm_objfmts\fR(7),
325 \fByasm_parsers\fR(7)
326 .PP
327 Related tools:
328 \fBas\fR(1),
329 \fBld\fR(1),
330 \fBnasm\fR(1)
331 .SH "BUGS"
332 .PP
333 When using the
334 \(lqx86\(rq
335 architecture, it is overly easy to generate AMD64 code (using the
336 \fBBITS 64\fR
337 directive) and generate a 32\-bit object file (by failing to specify
338 \fB\-m amd64\fR
339 or selecting a 64\-bit object format such as ELF64 on the command line)\&.
340 .SH "AUTHOR"
341 .PP
342 \fBPeter Johnson\fR <\&peter@tortall\&.net\&>
343 .RS 4
344 Author.
345 .RE
346 .SH "COPYRIGHT"
347 .br
348 Copyright \(co 2004, 2005, 2006, 2007 Peter Johnson
349 .br