How to Dig into Firmware Code Size

Hi @ngotes

The puncover tool works on any file that was built with debug information and stored in the ELF file format.

.axf (and .out) files usually use the ELF format so you should just be able to follow the instructions as is.

You can easily check to see if the file is in the ELF format by checking to see if the file starts with the EI_MAG header which is 0x7F followed by ‘E’, ‘L’, ‘F’. For example, here’s an axf file I generated recently using the NXP MCUXpressoIDE:

xxd lpcxpresso55s69_freertos_blinky_s.axf  | head -1
00000000: 7f45 4c46 0101 0100 0000 0000 0000 0000  .ELF............

You can use a tool like readelf to check and see if the ELF was compiled with debug information. If it was there will be debug_* sections in the file, i.e

arm-none-eabi-readelf -S lpcxpresso55s69_freertos_blinky_s.axf | grep debug
  [10] .debug_info       PROGBITS        00000000 02fe60 01dab9 00      0   0  1
  [11] .debug_abbrev     PROGBITS        00000000 04d919 003287 00      0   0  1
  [12] .debug_aranges    PROGBITS        00000000 050ba0 0009d8 00      0   0  1
  [13] .debug_ranges     PROGBITS        00000000 051578 000948 00      0   0  1
  [14] .debug_macro      PROGBITS        00000000 051ec0 01a019 00      0   0  1
  [15] .debug_line       PROGBITS        00000000 06bed9 008c00 00      0   0  1
  [16] .debug_str        PROGBITS        00000000 074ad9 0d42f3 01  MS  0   0  1
  [19] .debug_frame      PROGBITS        00000000 148ef8 002a44 00      0   0  4
  [20] .debug_loc        PROGBITS        00000000 14b93c 0009d1 00      0   0  1