Generating startup debug symbols

Updated: April 19, 2023

To generate debug symbols for the startup program, you must recompile both the startup library and the board's startup program with debug information.

The general procedure is:

  1. Build the startup library and the target board's startup program with debug information. (Ensure any modifications you require are complete before you build.)
  2. Rebuild the image and symbol file.
  3. Load the symbol file into the hardware debugger program.
  4. Transfer the startup to the board; for example, write the startup into flash memory using a flash writer or JTAG, transfer it over a serial or network connection, or load it from an SD card or other removable media.

To build the startup library with debug information:

# cd bsp_working_dir/src/hardware/startup/lib/target/
# make clean
# make CCOPTS=-g 
# cp libstartup.a bsp_working_dir/board_name/install/processor/lib
# make install

The above steps recompile the startup library (libstartup.a) with debug information and copy this library to the install/processor/lib directory, assuming that the BSP is configured to look for this library first in this directory. The make install is optional, and copies libstartup.a to /processor/usr/lib.

To build the board's startup with debugging information:

# cd bsp_working_dir/board_name/src/hardware/startup/boards/board_name/target/be
# make clean
# make CCOPTS=-g
# make install 

The above steps generate the file startup-board_name with symbol and debug information. The make install is necessary, and copies startup-board_name into the install directory, bsp_working_dir/board_name/install/processor/boot/sys.

Note: You can't load the startup-board_name ELF file into the hardware debugger to obtain the debug symbols, because the mkifs utility adds an offset to the addresses defined in the symbols according to the offset specified in the buildfile.

Modify the buildfile to include the +keeplinked attribute for startup:

# cd bsp_working_dir/board_name/images

Modify the startup line of your buildfile to look like:

[virtual=processor,binary +compress] .bootstrap = {
        [+keeplinked] startup-board_name -vvv -D8250
    PATH=/proc/boot procnto-smp-instr -vv

The +keeplinked option instructs mkifs to generate a symbol file that represents the debug information, positioned by the specified offset in the image filesystem.

To rebuild the image to generate the symbol file:

# cd bsp_working_dir/board_name/images
# make clean

Then, if you're using one of the provided .build files:

# make all


# mkifs -v -r ../install image

These commands create the symbol file, startup-board_name.sym. You can use the objdump utility to view the ELF information.

To view the symbol information contained in the startup-board_name.sym file:

# objdump -t startup-board_name.sym | less

You can now import the startup-board_name.sym file into a hardware debugger to provide the symbol information required for debugging startup. In addition to the startup-board_name.sym file, the hardware debugger needs the source code listings found in the following directories: