Problem Statement
You are compiling your code with two different options sets, or two different compiler versions, and you want to find the functions which have the largest code size increase between the builds.
Presumptions
- The number and name of all the functions in the two builds is exactly the same
- All function names are unique
- You have some experience with Excel. You know how to sort data, enter basic formulas, etc.
Collect Code Size Data
Collect code size data by using the --func_info option of the Object File Display (OFD) utility. OFD is described in the Assembly Language Tools Guide for your device family. The executable is named something like armofd, ofd6x, or ofd2000.
Here is an example of collecting the code size data on two different builds ...
% armofd --func_info file1.out > size_data1.csv
% armofd --func_info file2.out > size_data2.csv
View Code Size Data with Excel
The output from using --func_info is in CSV format. CSV stands for comma separated values. It is a very simple format. For example ...
C:\dir>ofd6x --func_info file.out | more
"HOSTclose","SHARED/trgdrv.c",0x00004ee0,0x00004f7c,156
"HOSTlseek","SHARED/trgdrv.c",0x000042a0,0x00004374,212
...
Each row represents data for one function. The data is separated by commas. The data on one row is: function name, file name, starting address, ending address, size.
The details of the format don't matter much in this article. Just let Excel deal with that. On a typically configured Windows system, you can "execute" a .csv file to bring it up in Excel ...
C:\dir>size_data1.csv
Compare Code Size Data with Excel
- Bring up both .csv files in Excel
- Delete the file name, starting address, and ending address columns
- Sort both files by function name
- Copy the columns from one file into the other
- Put the name columns next to each other and visually inspect one last time to make sure they are exactly the same
- Delete one name column
- Add a formula to subtract the two size columns, called the delta
- Sort by the delta
The functions with the largest delta are now at the top of the spreadsheet. Here is an example, with column headings added for clarity.
