DW_OP_GNU_uninit (#511)
authorSeva Alekseyev <sevaa@yarxi.ru>
Mon, 16 Oct 2023 13:41:03 +0000 (09:41 -0400)
committerGitHub <noreply@github.com>
Mon, 16 Oct 2023 13:41:03 +0000 (06:41 -0700)
* DW_OP_GNU_uninit

* Unit test with an expr blob

elftools/dwarf/dwarf_expr.py
test/test_dwarf_expr.py

index 7d6fc7f0989b76712d26370526da9bd19e3bca21..f05f739bd110f20a7a889e4a159843ebb2c95aae 100644 (file)
@@ -86,6 +86,7 @@ DW_OP_name2opcode = dict(
     DW_OP_lo_user=0xe0,
     DW_OP_GNU_push_tls_address=0xe0,
     DW_OP_WASM_location=0xed,
+    DW_OP_GNU_uninit=0xf0,
     DW_OP_GNU_implicit_pointer=0xf2,
     DW_OP_GNU_entry_value=0xf3,
     DW_OP_GNU_const_type=0xf4,
@@ -238,7 +239,7 @@ def _init_dispatch_table(structs):
                     'DW_OP_gt', 'DW_OP_le', 'DW_OP_lt', 'DW_OP_ne', 'DW_OP_nop',
                     'DW_OP_push_object_address', 'DW_OP_form_tls_address',
                     'DW_OP_call_frame_cfa', 'DW_OP_stack_value',
-                    'DW_OP_GNU_push_tls_address']:
+                    'DW_OP_GNU_push_tls_address', 'DW_OP_GNU_uninit']:
         add(opname, parse_noargs())
 
     for n in range(0, 32):
index 98d8bf53a55a1bd9cd02241aca30e5413b93def1..93dc30f8797d20e86a57fad659b9cba35ac0dfc9 100644 (file)
@@ -107,7 +107,14 @@ class TestParseExpr(unittest.TestCase):
             DWARFExprOp(op=0x34, op_name='DW_OP_lit4', args=[], offset=10),
             DWARFExprOp(op=0x1c, op_name='DW_OP_minus', args=[], offset=11),
             DWARFExprOp(op=0x6,  op_name='DW_OP_deref', args=[], offset=12)])
-
+        
+        # This expression blob came from the test binary in issue 508,
+        # DT_TAG_variable at 0x2a48C, DW_AT_location
+        lst = p.parse_expr([0x5f, 0xf0])
+        self.assertEqual(len(lst), 2)
+        self.assertEqual(lst, [
+            DWARFExprOp(op=0x5f, op_name='DW_OP_reg15', args=[], offset=0),
+            DWARFExprOp(op=0xf0,  op_name='DW_OP_GNU_uninit', args=[], offset=1)])
 
 if __name__ == '__main__':
     unittest.main()