eliben / pyelftools

Parsing ELF and DWARF in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

elftools.common.exceptions.ELFParseError: expected 1, found 0

msswamy11 opened this issue · comments

Traceback (most recent call last):
File "/build/zephyr-custom/scripts/footprint/size_report", line 804, in
main()
File "/build/zephyr-custom/scripts/footprint/size_report", line 780, in main
do_simple_name_matching(elf, symbol_dict, processed)
File "/build/zephyr-custom/scripts/footprint/size_report", line 319, in do_simple_name_matching
symbol = match_symbol_address(symlist, die,
File "/build/zephyr-custom/scripts/footprint/size_report", line 114, in match_symbol_address
low, high = get_die_mapped_address(die, parser, dwarfinfo)
File "/build/zephyr-custom/scripts/footprint/size_report", line 84, in get_die_mapped_address
loc = parser.parse_from_attribute(loc_attr, die.cu['version'], die)# die added
File "/home/ssmurala/.local/lib/python3.8/site-packages/elftools/dwarf/locationlists.py", line 322, in parse_from_attribute
return self.location_lists.get_location_list_at_offset(
File "/home/ssmurala/.local/lib/python3.8/site-packages/elftools/dwarf/locationlists.py", line 51, in get_location_list_at_offset
return section.get_location_list_at_offset(offset, die)
File "/home/ssmurala/.local/lib/python3.8/site-packages/elftools/dwarf/locationlists.py", line 100, in get_location_list_at_offset
return self._parse_location_list_from_stream_v5(die.cu) if self.version >= 5 else self._parse_location_list_from_stream()
File "/home/ssmurala/.local/lib/python3.8/site-packages/elftools/dwarf/locationlists.py", line 235, in _parse_location_list_from_stream
loc_expr = [struct_parse(self.structs.Dwarf_uint8(''),
File "/home/ssmurala/.local/lib/python3.8/site-packages/elftools/dwarf/locationlists.py", line 235, in
loc_expr = [struct_parse(self.structs.Dwarf_uint8(''),
File "/home/ssmurala/.local/lib/python3.8/site-packages/elftools/common/utils.py", line 45, in struct_parse
raise ELFParseError(str(e))
elftools.common.exceptions.ELFParseError: expected 1, found 0

That's not nearly enough information to debug. We don't see the binary and we don't see your script. That said, if's fairly obvious that the error happens while parsing a location list from a DIE attribute value. Could be a malformed loclist, but more likely this is a false positive on the "is this a location/loclist" function.

Can you share with us the details of the attribute in question? On size_report:84, what's in the argument of parse_from_attribute?

Also, what's the DWARF version?

OBTW, are you running the released version or the latest master? We had some fixes for similar conditions since.

Hi, Thanks for inputs.
I am closing this issue as this hit after some debug changes, and i will open new one with errors i am facing from beginning.