
This chapter discusses some of the differences between the Exemplar versions of the assembler (as) and linker (ld) and the standard HP-UX versions on which they are based. Also, this chapter presents some examples of how to use the assembler and linker. See the following for more information:
NOTE: You do not have to invoke the assembler or linker directly; the compiler drivers invoke them for you.
An assembler is a program that converts assembly language
programs into an object file suitable for processing by the
linker ld.
The Exemplar assembler as differs from the HP-UX as in only one way: it supports the .parallel directive. This directive sets the parallel attribute in the header of ESOM object files and is provided so that assembly code that was assembled using /usr/convex/bin/as will assemble under the Exemplar assembler. The Exemplar assembler is the default assembler on SPP1200 and SPP1600 systems and on S2000 and X2000 servers.
Assembler commands have the following form:
% as [options]
[files]
where
is zero or more of the allowed assembler options (see the as(1) man page for information on options)
is a space-delimited list of zero or more files containing
assembly code. If no files are given upon invoking as, source
text is read from standard input
NOTE: The .s files created by compiling with -S are intended to provide
insight into how the compiler is processing your code. These files
may not be suitable as input to the assembler.The first example illustrates how to produce an object file from an assembly-language file named prog.s:
% ls
prog.s
% as prog.s
% ls
prog.o prog.s
The object file (prog.o) is now ready to be processed by the linker to produce an executable file:
% ld prog.o
% ls
a.out prog.o prog.s
By default, the executable is named a.out; the -o filename option to
ld can be used to specify a different name (filename) for the
executable.
A linker is a program that combines separate object files into a single object file or executable program.
The Exemplar linker, ld, is the default linker on SPP1200 and SPP1600 systems and on S2000 and X2000 servers. It differs from the standard HP's ld in that it:
Also, the Exemplar linker is required for using the CXdb debugger and the CXpa profiler.
Some of the options that are specific to the Exemplar linker are:
+parallel
Sets the parallel flag in the ESOM auxiliary header, enabling parallel execution.
+tnode n
Sets the maximum number of threads allocated on each node to n. The maximum number of threads cannot be less than 1. The default for the maximum number of threads per node is 8 for SPP1200 and SPP1600 systems and 16 for S2000 and X2000 servers.
+max n
Sets the maximum number of processors needed for the
parallel program to n. The maximum number of processors
cannot be less than the minimum number of processors. If the
+min is not used, the minimum number of processors is also
set to n.
+over
Sets the oversubscription flag in the executable. Oversubscribing allows the executable to create more than one thread per processor within the subcomplex where the program is running. (See the section "Subcomplexes" on page 71 for information on subcomplexes.) By default this flag is not set.
See the ld(1) man page for more information on these and other Exemplar linker options.
You can specify linker options on the compiler command line by
using the -Wl option. See the cc(1) man page or the f77(1) man
page for more information.
Two kinds of executable files exist on SPP-UX platforms:
The SOM format is used for HP-UX executables. The ESOM format runs only on SPP-UX servers. The ESOM format was derived from the SOM format to support multithreaded processes.
If you link using the Exemplar compiler driver, you will get an
ESOM executable. If you use the linker directly without specifying
the +tm target option, the resulting executable will be in the SOM
format.
Use the file utility or the chatr utility to determine if a program
is in the SOM or ESOM format. See Chapter 6, "System utilities,"
or the file(1) and chatr(1) man pages for more information.
The Exemplar linker, ld, is required if you want to use the CXdb debugger (cxdb) or the CXpa profiler (cxpa). The linker provides support that is needed by both these development tools.
Debugging information is generated by using the -g option to the compiler. Profiling information is generated by using the +pa option. See Chapter 5, "Debugging and profiling," for more information on using these tools.
See the ld(1) man page for the form of linker commands.
The preferred method for accessing the linker is through the C or Fortran 77 compiler driver. If you use a compiler driver, your program is linked with the proper libraries in the right order.
The first example below shows how to combine multiple object files into a single executable file; the executable file is named a.out by default:
% ls
file1.o file2.o file3.o
% ld file1.o file2.o file3.o
% ls
a.out file1.o file2.o file3.o
In the example below, cc compiles main.c to produce the object
file main.o. The compiler then passes control to the linker, which
combines main.o, sub1.o, and sub2.o to produce an executable file.
The file main.o is deleted following a successful link.
Because -o main is specified, the executable file is named main.
% cc -o main main.c sub1.o sub2.o
% ls
main main.c sub1.o sub2.o