elf_symbols/README.md
Juraj Oravec 06174e66fb
Update README
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
2025-05-24 15:41:48 +02:00

2.4 KiB

Elf-symbols

Extract and expand the symbols based on their type from the ELF files with debug DWARF information

Usability

The symbol table of ELF file only contains the names of the top global variables, which is only useful when the name of the top variable is known. This script provide a way to search for a variable based on its type and the members of the said type (eg. structure members).

In short, search from bottom to top, instead of from top to bottom.

Similar programs

I am sure there are multiple programs which can do the same or similar thing to this script. I simply do not know about them.

Vector CANApe

Similar feature is available in Vector CANApe, which can extract symbols and its children (structure members) and add it to its database which can than be searched.

While this is nice, it has its own limitation, such as:

  • Only ONE instance of CANApe can run at once
  • Editing the database can be tricky and may take a long time
  • Licensing is costly for home use

Usage

main.py [options] [elf_file]

Output

> python main.py ../Playground_C/build/playground_c
0x4030  my_stuff
0x4030  my_stuff.first
0x4030  my_stuff.first.number_1
0x4038  my_stuff.first.number_2
0x403c  my_stuff.first.number_3
0x403e  my_stuff.first.number_4
0x403f  my_stuff.first.number_5
0x4040  my_stuff.second
0x4038  my_little_stuff
0x4038  my_little_stuff.one
0x4038  my_little_stuff.two
0x4040  my_small_stuff
0x4040  my_small_stuff.one
0x4040  my_small_stuff.one[0]
...
0x4057  my_small_stuff.one[23]
0x4040  my_small_stuff.structure
0x4040  my_small_stuff.structure.first
0x4040  my_small_stuff.structure.first.number_1
0x4048  my_small_stuff.structure.first.number_2
0x404c  my_small_stuff.structure.first.number_3
0x404e  my_small_stuff.structure.first.number_4
0x404f  my_small_stuff.structure.first.number_5
0x4050  my_small_stuff.structure.second
0x4060  thing
0x4060  thing.first
0x4060  thing.first.number_1
0x4068  thing.first.number_2
0x406c  thing.first.number_3
0x406e  thing.first.number_4
0x406f  thing.first.number_5
0x4070  thing.second

Licensing

This script is based on dwex DWarf EXplorer by "Seva Alekseyev". The original source code of dwex can be found on GitHub

The code taken from dwex is located in the "dwex" directory together with a LICENSE file.

My code main.py is licensed under GPLv3.