ziz
ziz

Reputation: 1

dwarf generated file is treating 3 letters variables differently

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.

enter image description here

enter image description here

Thank you.

Upvotes: 0

Views: 30

Answers (1)

Armali
Armali

Reputation: 19375

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, …, does anyone have any idea why i get this.

The OSDev Wiki says:

If most attributes have a fixed size, a few attributes need to have some special handling:

  • DW_FORM_string attributes are a small zero-terminated string (so of variable length)
  • DW_FORM_strp attributes represent the offset inside the .debug_str section of the desired string

Of course you can only get more information (the offset into the .debug_str section) if it is there.

Upvotes: 0

Related Questions