I am using a python script which runs OBJDUMP to extract dwarf information from an elf file, this is part of the code:
# Run objdump to extract DWARF information from the ELF file
ps = subprocess.Popen(path + "\\objdump --dwarf=info " + elf_file_name, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
dwarf = ps.communicate()[0]
# Iterate through each line of the decoded DWARF output
for line in dwarf.decode("ascii").split('\n'):
if line.strip().startswith("<"):
.....
.....
the problem is when i iterate through each line of the decoded DWARF output, it will have different ways of extracting variable information, for instance if i have 3 letters variables it will get only the name of the variable but if i have more than 3 letters it will get more information, you can see the photos below, does anyone have any idea why i get this.
Thank you.
objdumpoutput? There are perfectly capable Python native DWARF parsing libraries.pyelftoolsis popular, for example. It resolvesstrpout of the box.