for sibling of form ref_addr, only sibling value should be used (#268)
authorsagiben <sagiben@users.noreply.github.com>
Wed, 8 Jul 2020 00:10:07 +0000 (03:10 +0300)
committerGitHub <noreply@github.com>
Wed, 8 Jul 2020 00:10:07 +0000 (17:10 -0700)
* for sibling of form ref_addr, only sibling value should be used

* Add ELF testcase for PR #268

elftools/dwarf/compileunit.py
test/testfiles_for_readelf/sibling_ref_addr.elf [new file with mode: 0755]

index eb66c5710f2273abb43217106a4bbf6c8cef0864..7357655151d667418798a44fbe59760f4d48a0b7 100644 (file)
@@ -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 (executable)
index 0000000..dc0e107
Binary files /dev/null and b/test/testfiles_for_readelf/sibling_ref_addr.elf differ