From: sagiben Date: Wed, 8 Jul 2020 00:10:07 +0000 (+0300) Subject: for sibling of form ref_addr, only sibling value should be used (#268) X-Git-Tag: v0.27~21 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=575425338fbab134919cb1206509589a174fb81f;p=pyelftools.git for sibling of form ref_addr, only sibling value should be used (#268) * for sibling of form ref_addr, only sibling value should be used * Add ELF testcase for PR #268 --- diff --git a/elftools/dwarf/compileunit.py b/elftools/dwarf/compileunit.py index eb66c57..7357655 100644 --- a/elftools/dwarf/compileunit.py +++ b/elftools/dwarf/compileunit.py @@ -155,7 +155,9 @@ class CompileUnit(object): cur_offset += child.size elif "DW_AT_sibling" in child.attributes: sibling = child.attributes["DW_AT_sibling"] - cur_offset = sibling.value + self.cu_offset + cur_offset = sibling.value + if sibling.form != 'DW_FORM_ref_addr': + cur_offset += self.cu_offset else: # If no DW_AT_sibling attribute is provided by the producer # then the whole child subtree must be parsed to find its next diff --git a/test/testfiles_for_readelf/sibling_ref_addr.elf b/test/testfiles_for_readelf/sibling_ref_addr.elf new file mode 100755 index 0000000..dc0e107 Binary files /dev/null and b/test/testfiles_for_readelf/sibling_ref_addr.elf differ