Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trace32 command to read symbol contents from ELF file

Problem scenario: In simple words, do we have a Trace32 command to read symbols (and its contents) from ELF file that was loaded on to target ? We have this special case where application specific debug symbols of the ELF file are made as part of '.noload' section in ELF, which means the symbols/contents are present part of the ELF file (available when read using readelf -a xxxx.elf_file_name) but are not part of the final binary image generated i.e. the '.noload' section in ELF file is stripped away when generating xxx.bin which is flashed to target memory.

  • Debug symbols in '.noload' section are statically assigned values and these values do not change during runtime.
  • When I tried to read the debug symbols part of the '.noload' section (after compiling into binary and loading onto Trace32), I see 'MMU fail' flagged on trace32 popup window which means trace32 is trying to read symbol contents from memory but is not accessible, since symbols part of the '.noload' section was not loaded at all though they have addresses mapped.

Any inputs:
- I need help with a trace32 command that can directly read symbol content from ELF file than from target memory.
- Also not sure if I can use 'readelf ' in practice scripts ? Any help in this direction if we do not have any solution for above query ?

like image 911
Shashaankar Avatar asked Nov 28 '16 03:11

Shashaankar


People also ask

What command do we use to view the symbols in an ELF file?

To find where a symbol is placed in an ELF image file, use the --text -s -v options to view the symbol table and detailed information on each segment and section header, for example: The symbol table identifies the section where the symbol is placed.


1 Answers

Use command

Data.LOAD.Elf myfile.elf [<optional address offset>] /NoCODE

The option /NoCODE instructs TRACE32 to only load the debgug symbols from your ELF but not to load any code to your target. You can than view the symbols with command sYmbol.Browse.

However if you use TRACE32 to load your application to your target, you don't have to create a binary from you ELF first. With TRACE32 you can also load the PROGBITS sections of your ELF directly to your target. In this case you would simply use the Data.LOAD.Elf command without the /NoCODE option (after enabling flash programming).

Since you are using an MMU you might want to activate logical memory space IDs with command SYStem.Option.MMUSPACES ON. Then load your symbols with

Data.LOAD.Elf myfile.elf <space-ID>:<offset> /NoCODE

where 'space-ID' matches with the space-ID used by you MMU for the Task and 'offset' is usually zero.

If you are debugging your application on an embedded Linux than you should use the TRACE32 OS awareness for Linux and the Linux symbol auto-loader to load the symbols to the correct addresses for you.

I don't think there is any reason why you should use 'readelf' from within TRACE32. Anyway you can invoke any command line program with commands OS.Area or OS.Command.

like image 101
Holger Avatar answered Sep 25 '22 13:09

Holger