The Object File Cross-Reference Utility

This utility allows you to search for symbols or view the dependencies between two modules by using the object files themselves as a source of information. This utility is based on a similar utility that Borland included in their TURBOC compiler environment for Windows 3.1.

 

One of the main points is showing you which functions in your code aren’t used anywhere. This can be viewed easily with the “Unreferenced publics” list, described below.

The first step when using this utility is to choose the object files that you want to include in the cross-reference.

 

You reach this point by using the ‘Analysis’ option in the main menu, and then choosing  Cross-reference object files: ‘obj’.

To add a file, select it in the list, then press ‘Add’. To eliminate a file,  select it in the list below, then select ‘Eliminate’.

To quickly select all files, select the first file, then simultaneously press the Shift + down arrow keys.

The directory in which the files are located is shown at the bottom left corner of the dialog box.

 

You can change the directory using its corresponding button at the bottom, eliminate object files with the “Ignore” button in the middle. When you are finished, press the ‘OK’ button. The following dialog box will appear. This may take some time, because all of the actions are implemented after you press ‘OK’.

 

 

 

The main point of interest in this dialog box is the left column. It will indicate to you which symbols are exported from a module and not used anywhere else in the program. Either these symbols are used in the same module and should be declared static rather than public, or they are not referenced anywhere and are dead codes that can be eliminated. The latter is the more likely.  Of course, as in the example above, the ‘main’ function is an exception!!

You can choose a module to display using the combo box at the upper left corner. It is possible to find a symbol (press the ‘Find’ button) or display the results in a graphical display. Press the PLOT button.

The plot arranges the object files in a circle, and will indicate the relationships between any two points in the circle with colored lines. Those lines show you what is imported/exported between two modules.

By clicking on a line, you will see what symbols are exported/imported from the two modules. This is similar to the ‘relationships’ utility, but different in that there is no symbolic processing. When two modules share between them a macro definition, for instance, this will not appear here.

Here is an example of the PLOT output.

 

This plot shows six object files. The color codes are shown at the upper left corner. By clicking in the file name ‘exedump.c’, the display changes and two green lines originate at ‘exedump.c’ going to the other modules where there is a relationship. By clicking in those lines, you can display in full all of the symbols that tie those modules together at the object file level.