Skip to content

Unsupported GNU Extensions #785

@crzysdrs

Description

@crzysdrs

examples.tar.gz

Currently running into some failures while parsing some DW_OP values.

 Read(InvalidExpression(DwOp(253)))
 Read(InvalidExpression(DwOp(240)))

These appear to be DW_OP_GNU_uninit, DW_OP_GNU_variable_value. I think these are largely safe to ignore (so long as they are parsed).

Is there any approach to parse these (or other future/unimplemented extensions) without aborting parsing the entire DWARF file?

Ideally we'd be happy to limp along with a partial parse (with corresponding warnings) so long as we got a "best effort" parse (assuming these are as optional as they appear to be).

I did a little digging and got my testcases passing with this proposed workaround:

diff --git a/src/constants.rs b/src/constants.rs
index 1ed8c65..1914e5e 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -1267,6 +1267,7 @@ DwOp(u8) {
 
     // GNU extensions
     DW_OP_GNU_push_tls_address = 0xe0,
+    DW_OP_GNU_uninit = 0xf0,
     DW_OP_GNU_implicit_pointer = 0xf2,
     DW_OP_GNU_entry_value = 0xf3,
     DW_OP_GNU_const_type = 0xf4,
@@ -1277,7 +1278,7 @@ DwOp(u8) {
     DW_OP_GNU_parameter_ref = 0xfa,
     DW_OP_GNU_addr_index = 0xfb,
     DW_OP_GNU_const_index = 0xfc,
+    DW_OP_GNU_variable_value = 0xfd,

     // Wasm extensions
     DW_OP_WASM_location = 0xed,
 });
diff --git a/src/read/op.rs b/src/read/op.rs
index 0f9261a..b1c2d8d 100644
--- a/src/read/op.rs
+++ b/src/read/op.rs
@@ -807,6 +807,12 @@ where
                 }
                 _ => Err(Error::InvalidExpression(name)),
             },
+            constants::DW_OP_GNU_uninit => Ok(Operation::Nop),
+            constants::DW_OP_GNU_variable_value => {
+                // Unsupported
+                let _value = bytes.read_offset(encoding.format)?;
+                Ok(Operation::Nop)
+            }
             _ => Err(Error::InvalidExpression(name)),
         }
     }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions