The Startup File icrt0.o

The icrt0.o startup file uses the atexit system call to register the function that writes out profile data. (For 64-bit mode, the initialization code is in /usr/ccs/lib/pa20_64/fdp_init.0.) That function is called when the application exits.

The atexit system call allows a fixed number of functions to be registered from a user application. Instrumented applications (those linked with -I) have one less atexit call available. One or more instrumented shared libraries use a single additional atexit call. Therefore, an instrumented application that contains any number instrumented shared libraries uses two of the available atexit calls. For details on atexit, see atexit(2).

The -I Linker Option

When invoked with the -Ioption, the linker instruments all the specified object files. Note that the linker instruments regular object files as well as I-SOM files; however, with regular object files, only procedure call instrumentation is added. With I-SOM files, additional instrumentation is done within procedures.

For instance, suppose you have a regular object file named foo.o created by compiling without the +I option, and you compile a source file bar.c with the +I option and specify foo.o on the compile line:

$ cc -c foo.c

$ cc -v -o foobar -O +I bar.c foo.o /opt/langtools/lbin/cpp bar.c /var/tmp/ctm456 /opt/ansic/lbin/ccom /var/tmp/ctm456 bar.o -O2 -I /usr/ccs/bin/ld /opt/langtools/lib/icrt0.o -u main -o foobar \ bar.o foo.o -I -lc

In this case, the linker instruments both bar.o and foo.o. However, since foo.o is not an I-SOM file, only its procedure calls are instrumented; basic blocks within procedures are not instrumented. To instrument foo.c to the same extent, you must compile it with the +I option - for example:

$ cc -v -c +I -O foo.c

/opt/langtools/lbin/cpp foo.c /var/tmp/ctm432 /opt/ansic/lbin/ccom /var/tmp/ctm432 foo.o -O2 -I $ cc -v -o foobar -O +I bar.c foo.o /opt/langtools/lbin/cpp bar.c /var/tmp/ctm456 /opt/ansic/lbin/ccom /var/tmp/ctm456 bar.o -O2 -I /usr/ccs/bin/ld /opt/langtools/lib/icrt0.o -u main -o foobar \ bar.o foo.o -I -lc

A simpler approach is to compile foo.c and bar.c with a single cc command:

$ cc -v +I -O -o foobar bar.c foo.c /opt/langtools/lbin/cpp bar.c /var/tmp/ctm352 /opt/ansic/lbin/ccom /var/tmp/ctm352 bar.o -O2 -I /opt/langtools/lbin/cpp foo.c /var/tmp/ctm456 /opt/ansic/lbin/ccom /var/tmp/ctm456 foo.o -O2 -I /usr/ccs/bin/ld /opt/langtools/lib/icrt0.o -u main -o foobar \ bar.o foo.o -I -lc

Code Generation from I-SOMs

As discussed in Looking "inside" a Compiler , a compiler driver invokes several phases. The last phase before linking is code generation. When using PBO, the compilation process stops at an intermediate code level. The PA-RISC code generation and optimization phase is invoked by the linker. The code generator is /opt/langtools/lbin/ucomp.

NOTE: Since the code generation phase is delayed until link time with PBO, linking can take much longer than usual when using PBO. Compile times are faster than usual, since code generation is not performed.

Linker Optimizations 207