2.3.6. Specifying output format

By default, source files are compiled and linked into an executable image.

Use the following options to direct the compiler to create unlinked object files, assembly language files, or listing files from C or C++ source files.

-asm

This option writes a listing of the assembly language generated by the compiler to a file. Object code is generated and, unless the -c option is also used, the link step is performed.

If used with -fs, the source code is interleaved with the assembly listing and output to a .txt file.

The output file names depend on the options used:

-asm

inputname.s is used for the resulting listing.

-asm -fs

inputname.txt is used because the resulting interleaved code cannot be input to the assembler. See the -fs option below.

-asm -c -o newname.ext

There are two output files (usually newname.o for object code and newname.s for assembly). If .ext is not .s or .o, newname.ext is the name of the object file and newname.s is the name of the listing file.

-asm -fs -c -o newname.ext

Gives the same output as -asm -c -o newname.ext, except that the listing file has interleaved source code and a .txt extension.

-c

This option compiles but does not perform the link step. The compiler compiles the source program and writes the object files to either the current directory or the file specified by the -o option. This option is different from the uppercase -C option, described in Setting preprocessor options. (The -C option retains comments in preprocessor output.)

-list

This option creates a listing file consisting of lines of source interleaved with error and warning messages. The options -fi, -fj, and -fu can be used to control the contents of this file.

Caution

The -list option does not accept a pathname for the output file. You must rename previous versions of list files if you do not want to overwrite them.

-fi

This option is used with -list to list the lines from any files included with directives of the form #include "file".

-fj

This option is used with -list to list the lines from any files included with directives of the form #include <file>.

-fu

This option is used with -list to list source that was not preprocessed.

By default, if you specify -list, the compiler lists the source text as seen by the compiler after preprocessing. If you specify -fu, the unexpanded source text is listed. For example:

p = NULL; 				/* assume #defined NULL 0 */

If -fu is not specified, this is listed as:

p = 0;

If -fu is specified, it is listed as:


p = NULL;

-o file

This option names the file that holds the final output of the compilation:

  • If file is -, the output is written to the standard output stream and -S is assumed (unless -E is specified).

  • Used with -c, it names the object file.

  • Used with -S, it names the assembly language file.

  • Used with -E, it specifies the output file for preprocessed source.

  • If none of -c, -S, or -E is present, it specifies the output file of the link step. An executable image called file.axf is created.

If you do not specify a -o option, the name of the output file defaults to the name of the input file with the appropriate filename extension. For example, the output from file1.c is named file1.o if the -c option is specified, and file1.s if -S is specified. If none of -c, -S, -E, or -o is present the default linker output name of __image.axf is used.

-MD

This option compiles the source and writes makefile dependency lines to file inputfilename.d. The output file is suitable for use by a make utility.

-depend filename

This option is the same as -MD, but writes makefile dependency lines to the specified file.

-S

This option writes a listing of the assembly language generated by the compiler to a file. However, unlike the -asm option, object modules are not generated. The name of the assembly output file defaults to file.s in the current directory, where file.c is the name of the source file stripped of any leading directory names. The default file name can be overridden with the -o option.

Note

You can use armasm to assemble the output file and produce object code. The compilers add ASSERT directives for command-line options such as ATPCS variants and byte order to ensure that compatible compiler and assembler options are used when reassembling the output. You must specify the same ATPCS settings to both the assembler and the compiler.

-fs

This option, when used with -S or -asm, interleaves C, or C++, source code line by line as comments within the compiler-generated assembler code. The output code is written to file.txt. A text file is output because the resulting interleaved code cannot be input to the assembler.

Note

If you use this option you cannot reassemble the output code listing from -S.

Copyright © 1999-2001 ARM Limited. All rights reserved.ARM DUI 0067D
Non-Confidential