Tool: object-symbols-parser

Intro

When the linker can’t complete as the image size is overrunning the section sizes defined in your linker script, it can be a pain to get the symbol table to find out what is causing the overrun. One solution is to increase the declared resources, link the ELF file and read the object table. This is annoying (to me at least). object-symbols-parser has a few modes to make this somewhat more tolerable.

Directory Crawling For Object Files:

object_symbols_parser.py -f build/CMakeFiles/name_DEBUG.dir/ -o /tmp/out_trim.xlsx  

As the file name is a directory this will crawl through pulling up all the object files and add their symbol tables to the output. This removes the necessity to change the linker script at all as you still get a combined symbols table. Obviously the linker only links in symbols that are being used so this will likely include some entries that will not be in the final binary.

Reading Specific Object Files or Directories

object_symbols_parser.py -f main.o -f library1/library1.o -f library2/ -o /tmp/out_trim.xlsx  

This read the symbol tables of main.o, library1/library1.o, and all the object files under library2/. This is useful for cutting down of the number of entries in case you’re only interested in a specific subset of files.

Reading an ELF/AXF Symbol Table

object_symbols_parser.py -f main.axf -o /tmp/out_trim.xlsx  

Finally in case you want the symbol table of the final binary in a spreadsheet format you can call object_symbols_parser on the ELF or AXF. This is the same output as just calling objdump but puts it in the same spreadsheet format with section and size sorting, allowing one workflow.