3

–p and –pg

The –pand –pgoptions instruct the compiler to produce code that counts the number of times each routine is called. The profiling is based on a periodic sample taken by the system, rather than by line counters.

Using the -pOption

To generate an execution profile using the –poption:

1.Compile with the –poption.

2.Run a.out, which produces a mon.out executable file.

3.Type prof a.out. The program prints a profile.

Using the -pgOption

To generate an execution profile using the –pgoption:

1.Compile with the –pgoption.

2.Run a.out, which produces a gmon.out executable file, a more sophisticated profiling tool than mon.out.

3.Type gprof a.out. The program prints a profile.

–pic,-Kpic and –PIC,-KPIC

The -picand -PICoptions cause the compiler to generate position- independent code (PIC). One of these options should be used for objects which are then put into shared libraries. With PIC, each reference to a global datum is generated as a dereference of a pointer in the global offset table. Each function call is generated in pc-relative addressing mode through a procedure linkage table.

The size of the global offset table is limited to 8Kbytes with -pic. The -PICoption expands the global offset table to handle 32-bit addresses for those rare cases where there are too many data objects for -pic.

For more information on PIC, see the section on shared libraries in the Solaris documentation.

The Pascal Compiler

39