Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to output_code_size to show the size of all compartments and libraries #333

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PhilDay-CT
Copy link
Contributor

Adds a '-a' option that uses the .compartment and .library files alongside the firmware image to get a listing of the size of each compartment and library

@PhilDay-CT
Copy link
Contributor Author

Note this give a slightly different and smaller total that using -f, which itself is different from looking at the Section entries in the .dump file.

For example using the Hugh demo

../../cheriot-rtos/scripts/output_code_size.sh -f build/cheriot/cheriot/release/HughBulb
Size of the full binary: 198.453kB

../../cheriot-rtos/scripts/output_code_size.sh -a build/cheriot/cheriot/release/HughBulb
Size of compartment 'Firewall': 6.84375kB
Size of compartment 'scheduler': 5.25kB
Size of compartment 'MQTT': 11.6797kB
Size of compartment 'NetAPI': 1.33594kB
Size of compartment 'SNTP': 4.46094kB
Size of compartment 'TCPIP': 48.125kB
Size of compartment 'TLS': 59.0234kB
Size of compartment 'allocator': 8.67578kB
Size of compartment 'software_revoker': 0.361328kB
Size of compartment 'hugh': 14.5693kB
Size of library 'atomic1': 0.132812kB
Size of library 'atomic4': 0.09375kB
Size of library 'token_library': 0.119141kB
Size of library 'compartment_helpers': 0.609375kB
Size of library 'crt': 1.58594kB
Size of library 'cxxrt': 0.171875kB
Size of library 'event_group': 1.25kB
Size of library 'freestanding': 0.507812kB
Size of library 'locks': 1.10156kB
Size of library 'message_queue_library': 1.89844kB
Size of library 'stdio': 2.5625kB
Size of library 'string': 0.390625kB
Size of library 'time_helpers': 0.3125kB

Total size of compartments: 160kb
Total size of libraries: 10kb
Total size of image: 171kb

Working from the sections in .dump

Sections:
Idx Name                                                      Size     VMA      Type
  0                                                           00000000 00000000 
  1 .loader_start                                             0000017c 00101000 TEXT
...
 58 .loader_data                                              00000048 00135920 DATA
 59 .library_export_tables                                    000002c0 00135968 DATA
 60 .debug_info                                               0016491a 00000000 DEBUG

(0x135968 + 0x2c0) - 0x101000 = 0x34c28 (211Kb)

@davidchisnall
Copy link
Collaborator

I believe your total is not including space for threads. We also probably want to include the export tables, if we aren’t already, in compartments.

If your cleaning up argument passing, I would like -f to always take the firmware image, -c the compartment name, and -f to be required with other flags just affecting what we do with that output.

@davidchisnall
Copy link
Collaborator

The total image size includes the loader and metadata, which are part of the image, but are erased during loading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants