CCS News

Getting to Know the .sym File

Tuesday 31 August, 2021

The .sym compiler output file provides a good overview of the build. When you archive your source code and hex file saving the .sym file as well can be helpful. The .sym file has the following information:

RAM allocation
ROM allocation
User memory space allocation (when needed)
Source file list with CRC's
Object signatures
Unit list
Compiler settings that affect compilation
Task scheduling (when needed)
Output file list

RAM allocation
000 @SCRATCH
001 @SCRATCH
001 _RETURN_
002 @SCRATCH
003 @SCRATCH
004-007 main.a
008-00B main.b
00C-00F main.x
010-013 @ADDFF.P1
010 @PRINTF_X_809.P2
010 @delay_ms1.P3

The RAM locations are listed in order with the allocated variable names. Names with an @ before them are compiler generated variables. The main.a notation is used to indicate a local variable x in the function main(). A range indicates multiple bytes for example 004-007 is a four byte variable. For compiler built in functions frequently the .P1, .P2 notation is used for parametter 1 and 2.

Notice there are three variables all sharing location 010. This is because those three functions are never active at the same time so they can use the same memory location.

If there is a out of RAM error, the .sym file is still created and variables that will not fit in memory will have "na" instead of an address.

ROM allocation
000322 USB_CLASS_DESCRIPTORS.call
00032E USB_CLASS_DESCRIPTORS.data
000336 USB_DEVICE_DESC.call
000342 USB_DEVICE_DESC.data
000392 usb_clear_isr_reg
0003A0 usb_cdc_init

Again each area of ROM used is listed with the function or data name. Notice the data areas are shown as .call and .data. The .call address is the function that is called to retrieve data and the actual data is saved at the .data address. The .lst file will show the actual ROM data for each allocated area.

User memory space allocation (when needed)
User Memory space: eeprom
007FFE-007FFE signature
007FFC-007FFC productid
007FF6-007FFA serialnumber

User memory can be anywhere the read/write algorithm and address range are defined in the code. This shows a memory space called "eeprom" and the data areas defined.

Source file list with CRC's
Project Directory:
D:Projects

Project Files:
ex_usb_bootloader.c [05-Jul-18 12:26 CRC=4EE7C16D]
..feex_usb_common.h [26-Jan-17 17:12 CRC=79BAE87A]
..fh24FJ256GB206.h [14-Apr-21 15:34 CRC=A1FBF743]
..feusb_bootloader.h [01-Apr-19 11:57 CRC=A5BB5FCA]
..feusb_cdc.h [01-Apr-19 11:39 CRC=D21D1DD7]

The project files are listed relative to the show project directory. The file date/times are shown along with the file CRC. This can be valuable in comparing builds on different machines to make sure the right source files are being used. This data is one reason to save the .sym files to ensure future builds are done right.

Object signatures
Source signature=0C7E5CD2
Program memory checksum=0000
Hex file CRC=9AF1

More data to compare builds. Note that is you use #rom xxx=checksum then the program memory will be 0 because it saves the checksum itself at location xxx.

Unit list
Units:
project_mcu (main)
D:Projectsmcureport_mcu.o
D:Projectsmcufilter_mcu.o
D:Projectsmcumain_mcu.o

For a single compilation unit program only one file will be listed here, your main program. Above is an example of a three unit program.

Compiler settings that affect compilation
Compiler Settings:
Processor: PIC18F6722
Pointer Size: 16
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: UNSIGNED: 1,8,16
Float,Double: 32,32
ICD Provisions: Yes

This section shows key compiler settings that can affect the compilation. Some lines are only shown if they are different from the compiler default.

Task scheduling (when needed)
Task Info:
Ticks: 100 ns
Cycle: 100 ms

Tasks:
The_first_rtos_task
The_second_rtos_task
The_third_rtos_task

Task Schedule:
100 ms 640:The_second_rtos_task
100 ms 643:The_third_rtos_task
Sync to next 100 ms
100 ms 633:The_first_rtos_task
100 ms 643:The_third_rtos_task
Sync to next 100 ms
100 ms 643:The_third_rtos_task
Sync to next 100 ms
100 ms 643:The_third_rtos_task
Sync to next 100 ms
100 ms 643:The_third_rtos_task
Sync to next 100 ms
100 ms 640:The_second_rtos_task
100 ms 643:The_third_rtos_task
Sync to next 100 ms
100 ms 643:The_third_rtos_task
Sync to next 100 ms
100 ms 643:The_third_rtos_task
Sync to next 100 ms
100 ms 643:The_third_rtos_task
Sync to next 100 ms
100 ms 643:The_third_rtos_task
Sync to next 100 ms

This shows a deterministic RTOS build with a 100ms time slice and timer resolution of 100ns. There are three tasks shown and the schedule of what happens in each 100ms time slice.

Output file list
Output Files:
XREF file: ex_usb_bootloader.xsym
Errors: ex_usb_bootloader.err
Ext Symbols: ex_usb_bootloader.esym
INHX8: ex_usb_bootloader.hex
Symbols: ex_usb_bootloader.sym
List: ex_usb_bootloader.lst
Debug/COFF: ex_usb_bootloader.cof
Project: ex_usb_bootloader.ccspjt
Call Tree: ex_usb_bootloader.tre

Each file created by the compiler is shown again relative to the project directory. Note that the .ccspjt file is both an input and output file. The .xsym and .esym files are only created when compiling in the IDE and those files are only used by the IDE.



Like us on Facebook. Follow us on Twitter.

About CCS:

CCS is a leading worldwide supplier of embedded software development tools that enable companies to develop premium products based on Microchip PIC® MCU and dsPIC® DSC devices. Complete proven tool chains from CCS include a code optimizing C compiler, application specific hardware platforms and software development kits. CCS' products accelerate development of energy saving industrial automation, wireless and wired communication, automotive, medical device and consumer product applications. Established in 1992, CCS is a Microchip Premier 3rd Party Partner. For more information, please visit https://www.ccsinfo.com.

PIC® MCU, MPLAB® IDE, MPLAB® ICD2, MPLAB® ICD3 and dsPIC® are registered trademarks of Microchip Technology Inc. in the U.S. and other countries.