To profile shared libraries, you must set the environment variable SHLIB_FLOW_DATA to the file that receives profile data. Unlike FLOW_DATA, SHLIB_FLOW_DATA has no default output file. If SHLIB_FLOW_DATA is not set, profile data is not collected. This allows you to activate or suspend the profiling of instrumented shared libraries.
Note that you can set SHLIB_FLOW_DATA to flow.data which is the same file as the default setting for FLOW_DATA. But, again, profile data can be collected from shared libraries only if you explicitly set SHLIB_FLOW_DATA to some output file. The following is an example for instrumenting, profiling, and optimizing a shared library:
$ | cc +z +I | //Create |
$ | ld | |
$ | cc main.c mylib.inst.sl | //Create executable a.out file. |
$ | export SHLIB_FLOW_DATA=./flow.data | //Specify output file for profile data |
$ | a.out < input_file | //Run instrumented executable with |
|
| representative input data. |
$ | ld | //Perform PBO. |
| libcode.o |
|
Note that the name used in the database is the output pathname specified when the instrumented library is linked (mylib.inst.sl in the example above), regardless of how the library might be moved or renamed after it is created.
Using PBO with ld
Beginning with the
Briefly, ld
In
$ | cc +I | //Create individual |
$ | ld | //Build relocatable, merged file |
$ | cc +I | //Create instrumented executable file. |
$ | a.out < input_file | //Run instrumented executable |
|
| with representative input data. |
$ | ld |
|
| file1.o file2.o | //Rebuild relocatable file for PBO. |
$ | cc +P | //Perform PBO on the final executable |
|
| file. |
Notice, in the example above, that the +pgm option was necessary because the output file name differs from the instrumented program file name.
NOTE: If you are using
Linker Optimizations 213