Assembling and linking with the cc command

The cc command can be used to assemble and link an assembly source program.

The cc command can be used to assemble and link an assembly source program. The following example links object files compiled or assembled with the cc command:

cc pgm.o subs1.o subs2.o

When the cc command is used to link object files, the object files should have the suffix of .o as in the previous example.

When the cc command is used to assemble and link source files, any assembler source files must have the suffix of .s. The cc command invokes the assembler for any files having this suffix. Option flags for the as command can be directed to the assembler through the cc command. The syntax is:

-Wa,Option1,Option2,...
The following example invokes the assembler to assemble the source program using the com assembly mode, and produces an assembler listing and an object file:

cc -c -Wa,-mcom,-l file.s
The cc command invokes the assembler and then continues processing normally. Therefore:

cc -Wa,-l,-oXfile.o file.s

will fail because the object file produced by the assembler is named Xfile.o, but the linkage editor (ld command) invoked by the cc command searches for file.o.

If no option flag is specified on the command line, the cc command uses the compiler, assembler, and link options, as well as the necessary support libraries defined in the xlc.cfg configuration file.

Note: Some option flags defined in the assembler and the linkage editor use the same letters. Therefore, if the xlc.cfg configuration file is used to define the assembler options (asopt) and the link-editor options (ldopt), duplicate letters should not occur in asopt and ldopt because the cc command is unable to distinguish the duplicate letters.

For more information on the option flags passed to the cc command, see the cc command.